babylon.module.d.ts 6.2 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410
  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. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27061. /**
  27062. * Base class of materials working in push mode in babylon JS
  27063. * @hidden
  27064. */
  27065. export class PushMaterial extends Material {
  27066. protected _activeEffect: Effect;
  27067. protected _normalMatrix: Matrix;
  27068. /**
  27069. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  27070. * This means that the material can keep using a previous shader while a new one is being compiled.
  27071. * This is mostly used when shader parallel compilation is supported (true by default)
  27072. */
  27073. allowShaderHotSwapping: boolean;
  27074. constructor(name: string, scene: Scene);
  27075. getEffect(): Effect;
  27076. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  27077. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  27078. /**
  27079. * Binds the given world matrix to the active effect
  27080. *
  27081. * @param world the matrix to bind
  27082. */
  27083. bindOnlyWorldMatrix(world: Matrix): void;
  27084. /**
  27085. * Binds the given normal matrix to the active effect
  27086. *
  27087. * @param normalMatrix the matrix to bind
  27088. */
  27089. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  27090. bind(world: Matrix, mesh?: Mesh): void;
  27091. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  27092. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  27093. }
  27094. }
  27095. declare module "babylonjs/Materials/materialFlags" {
  27096. /**
  27097. * This groups all the flags used to control the materials channel.
  27098. */
  27099. export class MaterialFlags {
  27100. private static _DiffuseTextureEnabled;
  27101. /**
  27102. * Are diffuse textures enabled in the application.
  27103. */
  27104. static get DiffuseTextureEnabled(): boolean;
  27105. static set DiffuseTextureEnabled(value: boolean);
  27106. private static _AmbientTextureEnabled;
  27107. /**
  27108. * Are ambient textures enabled in the application.
  27109. */
  27110. static get AmbientTextureEnabled(): boolean;
  27111. static set AmbientTextureEnabled(value: boolean);
  27112. private static _OpacityTextureEnabled;
  27113. /**
  27114. * Are opacity textures enabled in the application.
  27115. */
  27116. static get OpacityTextureEnabled(): boolean;
  27117. static set OpacityTextureEnabled(value: boolean);
  27118. private static _ReflectionTextureEnabled;
  27119. /**
  27120. * Are reflection textures enabled in the application.
  27121. */
  27122. static get ReflectionTextureEnabled(): boolean;
  27123. static set ReflectionTextureEnabled(value: boolean);
  27124. private static _EmissiveTextureEnabled;
  27125. /**
  27126. * Are emissive textures enabled in the application.
  27127. */
  27128. static get EmissiveTextureEnabled(): boolean;
  27129. static set EmissiveTextureEnabled(value: boolean);
  27130. private static _SpecularTextureEnabled;
  27131. /**
  27132. * Are specular textures enabled in the application.
  27133. */
  27134. static get SpecularTextureEnabled(): boolean;
  27135. static set SpecularTextureEnabled(value: boolean);
  27136. private static _BumpTextureEnabled;
  27137. /**
  27138. * Are bump textures enabled in the application.
  27139. */
  27140. static get BumpTextureEnabled(): boolean;
  27141. static set BumpTextureEnabled(value: boolean);
  27142. private static _LightmapTextureEnabled;
  27143. /**
  27144. * Are lightmap textures enabled in the application.
  27145. */
  27146. static get LightmapTextureEnabled(): boolean;
  27147. static set LightmapTextureEnabled(value: boolean);
  27148. private static _RefractionTextureEnabled;
  27149. /**
  27150. * Are refraction textures enabled in the application.
  27151. */
  27152. static get RefractionTextureEnabled(): boolean;
  27153. static set RefractionTextureEnabled(value: boolean);
  27154. private static _ColorGradingTextureEnabled;
  27155. /**
  27156. * Are color grading textures enabled in the application.
  27157. */
  27158. static get ColorGradingTextureEnabled(): boolean;
  27159. static set ColorGradingTextureEnabled(value: boolean);
  27160. private static _FresnelEnabled;
  27161. /**
  27162. * Are fresnels enabled in the application.
  27163. */
  27164. static get FresnelEnabled(): boolean;
  27165. static set FresnelEnabled(value: boolean);
  27166. private static _ClearCoatTextureEnabled;
  27167. /**
  27168. * Are clear coat textures enabled in the application.
  27169. */
  27170. static get ClearCoatTextureEnabled(): boolean;
  27171. static set ClearCoatTextureEnabled(value: boolean);
  27172. private static _ClearCoatBumpTextureEnabled;
  27173. /**
  27174. * Are clear coat bump textures enabled in the application.
  27175. */
  27176. static get ClearCoatBumpTextureEnabled(): boolean;
  27177. static set ClearCoatBumpTextureEnabled(value: boolean);
  27178. private static _ClearCoatTintTextureEnabled;
  27179. /**
  27180. * Are clear coat tint textures enabled in the application.
  27181. */
  27182. static get ClearCoatTintTextureEnabled(): boolean;
  27183. static set ClearCoatTintTextureEnabled(value: boolean);
  27184. private static _SheenTextureEnabled;
  27185. /**
  27186. * Are sheen textures enabled in the application.
  27187. */
  27188. static get SheenTextureEnabled(): boolean;
  27189. static set SheenTextureEnabled(value: boolean);
  27190. private static _AnisotropicTextureEnabled;
  27191. /**
  27192. * Are anisotropic textures enabled in the application.
  27193. */
  27194. static get AnisotropicTextureEnabled(): boolean;
  27195. static set AnisotropicTextureEnabled(value: boolean);
  27196. private static _ThicknessTextureEnabled;
  27197. /**
  27198. * Are thickness textures enabled in the application.
  27199. */
  27200. static get ThicknessTextureEnabled(): boolean;
  27201. static set ThicknessTextureEnabled(value: boolean);
  27202. }
  27203. }
  27204. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  27205. /** @hidden */
  27206. export var defaultFragmentDeclaration: {
  27207. name: string;
  27208. shader: string;
  27209. };
  27210. }
  27211. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  27212. /** @hidden */
  27213. export var defaultUboDeclaration: {
  27214. name: string;
  27215. shader: string;
  27216. };
  27217. }
  27218. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  27219. /** @hidden */
  27220. export var lightFragmentDeclaration: {
  27221. name: string;
  27222. shader: string;
  27223. };
  27224. }
  27225. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  27226. /** @hidden */
  27227. export var lightUboDeclaration: {
  27228. name: string;
  27229. shader: string;
  27230. };
  27231. }
  27232. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  27233. /** @hidden */
  27234. export var lightsFragmentFunctions: {
  27235. name: string;
  27236. shader: string;
  27237. };
  27238. }
  27239. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  27240. /** @hidden */
  27241. export var shadowsFragmentFunctions: {
  27242. name: string;
  27243. shader: string;
  27244. };
  27245. }
  27246. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  27247. /** @hidden */
  27248. export var fresnelFunction: {
  27249. name: string;
  27250. shader: string;
  27251. };
  27252. }
  27253. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  27254. /** @hidden */
  27255. export var reflectionFunction: {
  27256. name: string;
  27257. shader: string;
  27258. };
  27259. }
  27260. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  27261. /** @hidden */
  27262. export var bumpFragmentFunctions: {
  27263. name: string;
  27264. shader: string;
  27265. };
  27266. }
  27267. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  27268. /** @hidden */
  27269. export var logDepthDeclaration: {
  27270. name: string;
  27271. shader: string;
  27272. };
  27273. }
  27274. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  27275. /** @hidden */
  27276. export var bumpFragment: {
  27277. name: string;
  27278. shader: string;
  27279. };
  27280. }
  27281. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  27282. /** @hidden */
  27283. export var depthPrePass: {
  27284. name: string;
  27285. shader: string;
  27286. };
  27287. }
  27288. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  27289. /** @hidden */
  27290. export var lightFragment: {
  27291. name: string;
  27292. shader: string;
  27293. };
  27294. }
  27295. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  27296. /** @hidden */
  27297. export var logDepthFragment: {
  27298. name: string;
  27299. shader: string;
  27300. };
  27301. }
  27302. declare module "babylonjs/Shaders/default.fragment" {
  27303. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  27304. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27305. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27306. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27307. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27308. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  27309. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  27310. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  27311. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  27312. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  27313. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  27314. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  27315. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  27316. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27317. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  27318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  27319. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  27320. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  27321. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  27322. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  27323. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  27324. /** @hidden */
  27325. export var defaultPixelShader: {
  27326. name: string;
  27327. shader: string;
  27328. };
  27329. }
  27330. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  27331. /** @hidden */
  27332. export var defaultVertexDeclaration: {
  27333. name: string;
  27334. shader: string;
  27335. };
  27336. }
  27337. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  27338. /** @hidden */
  27339. export var bumpVertexDeclaration: {
  27340. name: string;
  27341. shader: string;
  27342. };
  27343. }
  27344. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  27345. /** @hidden */
  27346. export var bumpVertex: {
  27347. name: string;
  27348. shader: string;
  27349. };
  27350. }
  27351. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  27352. /** @hidden */
  27353. export var fogVertex: {
  27354. name: string;
  27355. shader: string;
  27356. };
  27357. }
  27358. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  27359. /** @hidden */
  27360. export var shadowsVertex: {
  27361. name: string;
  27362. shader: string;
  27363. };
  27364. }
  27365. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  27366. /** @hidden */
  27367. export var pointCloudVertex: {
  27368. name: string;
  27369. shader: string;
  27370. };
  27371. }
  27372. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  27373. /** @hidden */
  27374. export var logDepthVertex: {
  27375. name: string;
  27376. shader: string;
  27377. };
  27378. }
  27379. declare module "babylonjs/Shaders/default.vertex" {
  27380. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  27381. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  27382. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  27383. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  27384. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  27385. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  27386. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  27387. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  27388. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  27389. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  27390. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  27391. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  27392. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  27393. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  27394. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  27395. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  27396. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  27397. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  27398. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  27399. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  27400. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  27401. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  27402. /** @hidden */
  27403. export var defaultVertexShader: {
  27404. name: string;
  27405. shader: string;
  27406. };
  27407. }
  27408. declare module "babylonjs/Materials/standardMaterial" {
  27409. import { SmartArray } from "babylonjs/Misc/smartArray";
  27410. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27411. import { Nullable } from "babylonjs/types";
  27412. import { Scene } from "babylonjs/scene";
  27413. import { Matrix } from "babylonjs/Maths/math.vector";
  27414. import { Color3 } from "babylonjs/Maths/math.color";
  27415. import { SubMesh } from "babylonjs/Meshes/subMesh";
  27416. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27417. import { Mesh } from "babylonjs/Meshes/mesh";
  27418. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  27419. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  27420. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  27421. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  27422. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  27423. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27424. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27425. import "babylonjs/Shaders/default.fragment";
  27426. import "babylonjs/Shaders/default.vertex";
  27427. /** @hidden */
  27428. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  27429. MAINUV1: boolean;
  27430. MAINUV2: boolean;
  27431. DIFFUSE: boolean;
  27432. DIFFUSEDIRECTUV: number;
  27433. AMBIENT: boolean;
  27434. AMBIENTDIRECTUV: number;
  27435. OPACITY: boolean;
  27436. OPACITYDIRECTUV: number;
  27437. OPACITYRGB: boolean;
  27438. REFLECTION: boolean;
  27439. EMISSIVE: boolean;
  27440. EMISSIVEDIRECTUV: number;
  27441. SPECULAR: boolean;
  27442. SPECULARDIRECTUV: number;
  27443. BUMP: boolean;
  27444. BUMPDIRECTUV: number;
  27445. PARALLAX: boolean;
  27446. PARALLAXOCCLUSION: boolean;
  27447. SPECULAROVERALPHA: boolean;
  27448. CLIPPLANE: boolean;
  27449. CLIPPLANE2: boolean;
  27450. CLIPPLANE3: boolean;
  27451. CLIPPLANE4: boolean;
  27452. CLIPPLANE5: boolean;
  27453. CLIPPLANE6: boolean;
  27454. ALPHATEST: boolean;
  27455. DEPTHPREPASS: boolean;
  27456. ALPHAFROMDIFFUSE: boolean;
  27457. POINTSIZE: boolean;
  27458. FOG: boolean;
  27459. SPECULARTERM: boolean;
  27460. DIFFUSEFRESNEL: boolean;
  27461. OPACITYFRESNEL: boolean;
  27462. REFLECTIONFRESNEL: boolean;
  27463. REFRACTIONFRESNEL: boolean;
  27464. EMISSIVEFRESNEL: boolean;
  27465. FRESNEL: boolean;
  27466. NORMAL: boolean;
  27467. UV1: boolean;
  27468. UV2: boolean;
  27469. VERTEXCOLOR: boolean;
  27470. VERTEXALPHA: boolean;
  27471. NUM_BONE_INFLUENCERS: number;
  27472. BonesPerMesh: number;
  27473. BONETEXTURE: boolean;
  27474. INSTANCES: boolean;
  27475. GLOSSINESS: boolean;
  27476. ROUGHNESS: boolean;
  27477. EMISSIVEASILLUMINATION: boolean;
  27478. LINKEMISSIVEWITHDIFFUSE: boolean;
  27479. REFLECTIONFRESNELFROMSPECULAR: boolean;
  27480. LIGHTMAP: boolean;
  27481. LIGHTMAPDIRECTUV: number;
  27482. OBJECTSPACE_NORMALMAP: boolean;
  27483. USELIGHTMAPASSHADOWMAP: boolean;
  27484. REFLECTIONMAP_3D: boolean;
  27485. REFLECTIONMAP_SPHERICAL: boolean;
  27486. REFLECTIONMAP_PLANAR: boolean;
  27487. REFLECTIONMAP_CUBIC: boolean;
  27488. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  27489. REFLECTIONMAP_PROJECTION: boolean;
  27490. REFLECTIONMAP_SKYBOX: boolean;
  27491. REFLECTIONMAP_EXPLICIT: boolean;
  27492. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  27493. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  27494. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  27495. INVERTCUBICMAP: boolean;
  27496. LOGARITHMICDEPTH: boolean;
  27497. REFRACTION: boolean;
  27498. REFRACTIONMAP_3D: boolean;
  27499. REFLECTIONOVERALPHA: boolean;
  27500. TWOSIDEDLIGHTING: boolean;
  27501. SHADOWFLOAT: boolean;
  27502. MORPHTARGETS: boolean;
  27503. MORPHTARGETS_NORMAL: boolean;
  27504. MORPHTARGETS_TANGENT: boolean;
  27505. MORPHTARGETS_UV: boolean;
  27506. NUM_MORPH_INFLUENCERS: number;
  27507. NONUNIFORMSCALING: boolean;
  27508. PREMULTIPLYALPHA: boolean;
  27509. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  27510. ALPHABLEND: boolean;
  27511. IMAGEPROCESSING: boolean;
  27512. VIGNETTE: boolean;
  27513. VIGNETTEBLENDMODEMULTIPLY: boolean;
  27514. VIGNETTEBLENDMODEOPAQUE: boolean;
  27515. TONEMAPPING: boolean;
  27516. TONEMAPPING_ACES: boolean;
  27517. CONTRAST: boolean;
  27518. COLORCURVES: boolean;
  27519. COLORGRADING: boolean;
  27520. COLORGRADING3D: boolean;
  27521. SAMPLER3DGREENDEPTH: boolean;
  27522. SAMPLER3DBGRMAP: boolean;
  27523. IMAGEPROCESSINGPOSTPROCESS: boolean;
  27524. MULTIVIEW: boolean;
  27525. /**
  27526. * If the reflection texture on this material is in linear color space
  27527. * @hidden
  27528. */
  27529. IS_REFLECTION_LINEAR: boolean;
  27530. /**
  27531. * If the refraction texture on this material is in linear color space
  27532. * @hidden
  27533. */
  27534. IS_REFRACTION_LINEAR: boolean;
  27535. EXPOSURE: boolean;
  27536. constructor();
  27537. setReflectionMode(modeToEnable: string): void;
  27538. }
  27539. /**
  27540. * This is the default material used in Babylon. It is the best trade off between quality
  27541. * and performances.
  27542. * @see http://doc.babylonjs.com/babylon101/materials
  27543. */
  27544. export class StandardMaterial extends PushMaterial {
  27545. private _diffuseTexture;
  27546. /**
  27547. * The basic texture of the material as viewed under a light.
  27548. */
  27549. diffuseTexture: Nullable<BaseTexture>;
  27550. private _ambientTexture;
  27551. /**
  27552. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  27553. */
  27554. ambientTexture: Nullable<BaseTexture>;
  27555. private _opacityTexture;
  27556. /**
  27557. * Define the transparency of the material from a texture.
  27558. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  27559. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  27560. */
  27561. opacityTexture: Nullable<BaseTexture>;
  27562. private _reflectionTexture;
  27563. /**
  27564. * Define the texture used to display the reflection.
  27565. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27566. */
  27567. reflectionTexture: Nullable<BaseTexture>;
  27568. private _emissiveTexture;
  27569. /**
  27570. * Define texture of the material as if self lit.
  27571. * This will be mixed in the final result even in the absence of light.
  27572. */
  27573. emissiveTexture: Nullable<BaseTexture>;
  27574. private _specularTexture;
  27575. /**
  27576. * Define how the color and intensity of the highlight given by the light in the material.
  27577. */
  27578. specularTexture: Nullable<BaseTexture>;
  27579. private _bumpTexture;
  27580. /**
  27581. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  27582. * 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.
  27583. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  27584. */
  27585. bumpTexture: Nullable<BaseTexture>;
  27586. private _lightmapTexture;
  27587. /**
  27588. * Complex lighting can be computationally expensive to compute at runtime.
  27589. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  27590. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  27591. */
  27592. lightmapTexture: Nullable<BaseTexture>;
  27593. private _refractionTexture;
  27594. /**
  27595. * Define the texture used to display the refraction.
  27596. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27597. */
  27598. refractionTexture: Nullable<BaseTexture>;
  27599. /**
  27600. * The color of the material lit by the environmental background lighting.
  27601. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  27602. */
  27603. ambientColor: Color3;
  27604. /**
  27605. * The basic color of the material as viewed under a light.
  27606. */
  27607. diffuseColor: Color3;
  27608. /**
  27609. * Define how the color and intensity of the highlight given by the light in the material.
  27610. */
  27611. specularColor: Color3;
  27612. /**
  27613. * Define the color of the material as if self lit.
  27614. * This will be mixed in the final result even in the absence of light.
  27615. */
  27616. emissiveColor: Color3;
  27617. /**
  27618. * Defines how sharp are the highlights in the material.
  27619. * The bigger the value the sharper giving a more glossy feeling to the result.
  27620. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  27621. */
  27622. specularPower: number;
  27623. private _useAlphaFromDiffuseTexture;
  27624. /**
  27625. * Does the transparency come from the diffuse texture alpha channel.
  27626. */
  27627. useAlphaFromDiffuseTexture: boolean;
  27628. private _useEmissiveAsIllumination;
  27629. /**
  27630. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  27631. */
  27632. useEmissiveAsIllumination: boolean;
  27633. private _linkEmissiveWithDiffuse;
  27634. /**
  27635. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  27636. * the emissive level when the final color is close to one.
  27637. */
  27638. linkEmissiveWithDiffuse: boolean;
  27639. private _useSpecularOverAlpha;
  27640. /**
  27641. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  27642. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  27643. */
  27644. useSpecularOverAlpha: boolean;
  27645. private _useReflectionOverAlpha;
  27646. /**
  27647. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  27648. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  27649. */
  27650. useReflectionOverAlpha: boolean;
  27651. private _disableLighting;
  27652. /**
  27653. * Does lights from the scene impacts this material.
  27654. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  27655. */
  27656. disableLighting: boolean;
  27657. private _useObjectSpaceNormalMap;
  27658. /**
  27659. * Allows using an object space normal map (instead of tangent space).
  27660. */
  27661. useObjectSpaceNormalMap: boolean;
  27662. private _useParallax;
  27663. /**
  27664. * Is parallax enabled or not.
  27665. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27666. */
  27667. useParallax: boolean;
  27668. private _useParallaxOcclusion;
  27669. /**
  27670. * Is parallax occlusion enabled or not.
  27671. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  27672. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  27673. */
  27674. useParallaxOcclusion: boolean;
  27675. /**
  27676. * 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.
  27677. */
  27678. parallaxScaleBias: number;
  27679. private _roughness;
  27680. /**
  27681. * Helps to define how blurry the reflections should appears in the material.
  27682. */
  27683. roughness: number;
  27684. /**
  27685. * In case of refraction, define the value of the index of refraction.
  27686. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27687. */
  27688. indexOfRefraction: number;
  27689. /**
  27690. * Invert the refraction texture alongside the y axis.
  27691. * It can be useful with procedural textures or probe for instance.
  27692. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  27693. */
  27694. invertRefractionY: boolean;
  27695. /**
  27696. * Defines the alpha limits in alpha test mode.
  27697. */
  27698. alphaCutOff: number;
  27699. private _useLightmapAsShadowmap;
  27700. /**
  27701. * In case of light mapping, define whether the map contains light or shadow informations.
  27702. */
  27703. useLightmapAsShadowmap: boolean;
  27704. private _diffuseFresnelParameters;
  27705. /**
  27706. * Define the diffuse fresnel parameters of the material.
  27707. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27708. */
  27709. diffuseFresnelParameters: FresnelParameters;
  27710. private _opacityFresnelParameters;
  27711. /**
  27712. * Define the opacity fresnel parameters of the material.
  27713. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27714. */
  27715. opacityFresnelParameters: FresnelParameters;
  27716. private _reflectionFresnelParameters;
  27717. /**
  27718. * Define the reflection fresnel parameters of the material.
  27719. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27720. */
  27721. reflectionFresnelParameters: FresnelParameters;
  27722. private _refractionFresnelParameters;
  27723. /**
  27724. * Define the refraction fresnel parameters of the material.
  27725. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27726. */
  27727. refractionFresnelParameters: FresnelParameters;
  27728. private _emissiveFresnelParameters;
  27729. /**
  27730. * Define the emissive fresnel parameters of the material.
  27731. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27732. */
  27733. emissiveFresnelParameters: FresnelParameters;
  27734. private _useReflectionFresnelFromSpecular;
  27735. /**
  27736. * If true automatically deducts the fresnels values from the material specularity.
  27737. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  27738. */
  27739. useReflectionFresnelFromSpecular: boolean;
  27740. private _useGlossinessFromSpecularMapAlpha;
  27741. /**
  27742. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  27743. */
  27744. useGlossinessFromSpecularMapAlpha: boolean;
  27745. private _maxSimultaneousLights;
  27746. /**
  27747. * Defines the maximum number of lights that can be used in the material
  27748. */
  27749. maxSimultaneousLights: number;
  27750. private _invertNormalMapX;
  27751. /**
  27752. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  27753. */
  27754. invertNormalMapX: boolean;
  27755. private _invertNormalMapY;
  27756. /**
  27757. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  27758. */
  27759. invertNormalMapY: boolean;
  27760. private _twoSidedLighting;
  27761. /**
  27762. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  27763. */
  27764. twoSidedLighting: boolean;
  27765. /**
  27766. * Default configuration related to image processing available in the standard Material.
  27767. */
  27768. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  27769. /**
  27770. * Gets the image processing configuration used either in this material.
  27771. */
  27772. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  27773. /**
  27774. * Sets the Default image processing configuration used either in the this material.
  27775. *
  27776. * If sets to null, the scene one is in use.
  27777. */
  27778. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  27779. /**
  27780. * Keep track of the image processing observer to allow dispose and replace.
  27781. */
  27782. private _imageProcessingObserver;
  27783. /**
  27784. * Attaches a new image processing configuration to the Standard Material.
  27785. * @param configuration
  27786. */
  27787. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  27788. /**
  27789. * Gets wether the color curves effect is enabled.
  27790. */
  27791. get cameraColorCurvesEnabled(): boolean;
  27792. /**
  27793. * Sets wether the color curves effect is enabled.
  27794. */
  27795. set cameraColorCurvesEnabled(value: boolean);
  27796. /**
  27797. * Gets wether the color grading effect is enabled.
  27798. */
  27799. get cameraColorGradingEnabled(): boolean;
  27800. /**
  27801. * Gets wether the color grading effect is enabled.
  27802. */
  27803. set cameraColorGradingEnabled(value: boolean);
  27804. /**
  27805. * Gets wether tonemapping is enabled or not.
  27806. */
  27807. get cameraToneMappingEnabled(): boolean;
  27808. /**
  27809. * Sets wether tonemapping is enabled or not
  27810. */
  27811. set cameraToneMappingEnabled(value: boolean);
  27812. /**
  27813. * The camera exposure used on this material.
  27814. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27815. * This corresponds to a photographic exposure.
  27816. */
  27817. get cameraExposure(): number;
  27818. /**
  27819. * The camera exposure used on this material.
  27820. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  27821. * This corresponds to a photographic exposure.
  27822. */
  27823. set cameraExposure(value: number);
  27824. /**
  27825. * Gets The camera contrast used on this material.
  27826. */
  27827. get cameraContrast(): number;
  27828. /**
  27829. * Sets The camera contrast used on this material.
  27830. */
  27831. set cameraContrast(value: number);
  27832. /**
  27833. * Gets the Color Grading 2D Lookup Texture.
  27834. */
  27835. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  27836. /**
  27837. * Sets the Color Grading 2D Lookup Texture.
  27838. */
  27839. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  27840. /**
  27841. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27842. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27843. * 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;
  27844. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27845. */
  27846. get cameraColorCurves(): Nullable<ColorCurves>;
  27847. /**
  27848. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  27849. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  27850. * 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;
  27851. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  27852. */
  27853. set cameraColorCurves(value: Nullable<ColorCurves>);
  27854. /**
  27855. * Custom callback helping to override the default shader used in the material.
  27856. */
  27857. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  27858. protected _renderTargets: SmartArray<RenderTargetTexture>;
  27859. protected _worldViewProjectionMatrix: Matrix;
  27860. protected _globalAmbientColor: Color3;
  27861. protected _useLogarithmicDepth: boolean;
  27862. protected _rebuildInParallel: boolean;
  27863. /**
  27864. * Instantiates a new standard material.
  27865. * This is the default material used in Babylon. It is the best trade off between quality
  27866. * and performances.
  27867. * @see http://doc.babylonjs.com/babylon101/materials
  27868. * @param name Define the name of the material in the scene
  27869. * @param scene Define the scene the material belong to
  27870. */
  27871. constructor(name: string, scene: Scene);
  27872. /**
  27873. * Gets a boolean indicating that current material needs to register RTT
  27874. */
  27875. get hasRenderTargetTextures(): boolean;
  27876. /**
  27877. * Gets the current class name of the material e.g. "StandardMaterial"
  27878. * Mainly use in serialization.
  27879. * @returns the class name
  27880. */
  27881. getClassName(): string;
  27882. /**
  27883. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  27884. * You can try switching to logarithmic depth.
  27885. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  27886. */
  27887. get useLogarithmicDepth(): boolean;
  27888. set useLogarithmicDepth(value: boolean);
  27889. /**
  27890. * Specifies if the material will require alpha blending
  27891. * @returns a boolean specifying if alpha blending is needed
  27892. */
  27893. needAlphaBlending(): boolean;
  27894. /**
  27895. * Specifies if this material should be rendered in alpha test mode
  27896. * @returns a boolean specifying if an alpha test is needed.
  27897. */
  27898. needAlphaTesting(): boolean;
  27899. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  27900. /**
  27901. * Get the texture used for alpha test purpose.
  27902. * @returns the diffuse texture in case of the standard material.
  27903. */
  27904. getAlphaTestTexture(): Nullable<BaseTexture>;
  27905. /**
  27906. * Get if the submesh is ready to be used and all its information available.
  27907. * Child classes can use it to update shaders
  27908. * @param mesh defines the mesh to check
  27909. * @param subMesh defines which submesh to check
  27910. * @param useInstances specifies that instances should be used
  27911. * @returns a boolean indicating that the submesh is ready or not
  27912. */
  27913. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  27914. /**
  27915. * Builds the material UBO layouts.
  27916. * Used internally during the effect preparation.
  27917. */
  27918. buildUniformLayout(): void;
  27919. /**
  27920. * Unbinds the material from the mesh
  27921. */
  27922. unbind(): void;
  27923. /**
  27924. * Binds the submesh to this material by preparing the effect and shader to draw
  27925. * @param world defines the world transformation matrix
  27926. * @param mesh defines the mesh containing the submesh
  27927. * @param subMesh defines the submesh to bind the material to
  27928. */
  27929. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  27930. /**
  27931. * Get the list of animatables in the material.
  27932. * @returns the list of animatables object used in the material
  27933. */
  27934. getAnimatables(): IAnimatable[];
  27935. /**
  27936. * Gets the active textures from the material
  27937. * @returns an array of textures
  27938. */
  27939. getActiveTextures(): BaseTexture[];
  27940. /**
  27941. * Specifies if the material uses a texture
  27942. * @param texture defines the texture to check against the material
  27943. * @returns a boolean specifying if the material uses the texture
  27944. */
  27945. hasTexture(texture: BaseTexture): boolean;
  27946. /**
  27947. * Disposes the material
  27948. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  27949. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  27950. */
  27951. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  27952. /**
  27953. * Makes a duplicate of the material, and gives it a new name
  27954. * @param name defines the new name for the duplicated material
  27955. * @returns the cloned material
  27956. */
  27957. clone(name: string): StandardMaterial;
  27958. /**
  27959. * Serializes this material in a JSON representation
  27960. * @returns the serialized material object
  27961. */
  27962. serialize(): any;
  27963. /**
  27964. * Creates a standard material from parsed material data
  27965. * @param source defines the JSON representation of the material
  27966. * @param scene defines the hosting scene
  27967. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  27968. * @returns a new standard material
  27969. */
  27970. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  27971. /**
  27972. * Are diffuse textures enabled in the application.
  27973. */
  27974. static get DiffuseTextureEnabled(): boolean;
  27975. static set DiffuseTextureEnabled(value: boolean);
  27976. /**
  27977. * Are ambient textures enabled in the application.
  27978. */
  27979. static get AmbientTextureEnabled(): boolean;
  27980. static set AmbientTextureEnabled(value: boolean);
  27981. /**
  27982. * Are opacity textures enabled in the application.
  27983. */
  27984. static get OpacityTextureEnabled(): boolean;
  27985. static set OpacityTextureEnabled(value: boolean);
  27986. /**
  27987. * Are reflection textures enabled in the application.
  27988. */
  27989. static get ReflectionTextureEnabled(): boolean;
  27990. static set ReflectionTextureEnabled(value: boolean);
  27991. /**
  27992. * Are emissive textures enabled in the application.
  27993. */
  27994. static get EmissiveTextureEnabled(): boolean;
  27995. static set EmissiveTextureEnabled(value: boolean);
  27996. /**
  27997. * Are specular textures enabled in the application.
  27998. */
  27999. static get SpecularTextureEnabled(): boolean;
  28000. static set SpecularTextureEnabled(value: boolean);
  28001. /**
  28002. * Are bump textures enabled in the application.
  28003. */
  28004. static get BumpTextureEnabled(): boolean;
  28005. static set BumpTextureEnabled(value: boolean);
  28006. /**
  28007. * Are lightmap textures enabled in the application.
  28008. */
  28009. static get LightmapTextureEnabled(): boolean;
  28010. static set LightmapTextureEnabled(value: boolean);
  28011. /**
  28012. * Are refraction textures enabled in the application.
  28013. */
  28014. static get RefractionTextureEnabled(): boolean;
  28015. static set RefractionTextureEnabled(value: boolean);
  28016. /**
  28017. * Are color grading textures enabled in the application.
  28018. */
  28019. static get ColorGradingTextureEnabled(): boolean;
  28020. static set ColorGradingTextureEnabled(value: boolean);
  28021. /**
  28022. * Are fresnels enabled in the application.
  28023. */
  28024. static get FresnelEnabled(): boolean;
  28025. static set FresnelEnabled(value: boolean);
  28026. }
  28027. }
  28028. declare module "babylonjs/Particles/solidParticleSystem" {
  28029. import { Nullable } from "babylonjs/types";
  28030. import { Vector3 } from "babylonjs/Maths/math.vector";
  28031. import { Mesh } from "babylonjs/Meshes/mesh";
  28032. import { Scene, IDisposable } from "babylonjs/scene";
  28033. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  28034. import { Material } from "babylonjs/Materials/material";
  28035. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  28036. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28037. /**
  28038. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  28039. *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.
  28040. * The SPS is also a particle system. It provides some methods to manage the particles.
  28041. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  28042. *
  28043. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  28044. */
  28045. export class SolidParticleSystem implements IDisposable {
  28046. /**
  28047. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  28048. * Example : var p = SPS.particles[i];
  28049. */
  28050. particles: SolidParticle[];
  28051. /**
  28052. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  28053. */
  28054. nbParticles: number;
  28055. /**
  28056. * If the particles must ever face the camera (default false). Useful for planar particles.
  28057. */
  28058. billboard: boolean;
  28059. /**
  28060. * Recompute normals when adding a shape
  28061. */
  28062. recomputeNormals: boolean;
  28063. /**
  28064. * This a counter ofr your own usage. It's not set by any SPS functions.
  28065. */
  28066. counter: number;
  28067. /**
  28068. * The SPS name. This name is also given to the underlying mesh.
  28069. */
  28070. name: string;
  28071. /**
  28072. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  28073. */
  28074. mesh: Mesh;
  28075. /**
  28076. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  28077. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  28078. */
  28079. vars: any;
  28080. /**
  28081. * This array is populated when the SPS is set as 'pickable'.
  28082. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  28083. * Each element of this array is an object `{idx: int, faceId: int}`.
  28084. * `idx` is the picked particle index in the `SPS.particles` array
  28085. * `faceId` is the picked face index counted within this particle.
  28086. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  28087. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  28088. * Use the method SPS.pickedParticle(pickingInfo) instead.
  28089. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28090. */
  28091. pickedParticles: {
  28092. idx: number;
  28093. faceId: number;
  28094. }[];
  28095. /**
  28096. * This array is populated when the SPS is set as 'pickable'
  28097. * Each key of this array is a submesh index.
  28098. * Each element of this array is a second array defined like this :
  28099. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  28100. * Each element of this second array is an object `{idx: int, faceId: int}`.
  28101. * `idx` is the picked particle index in the `SPS.particles` array
  28102. * `faceId` is the picked face index counted within this particle.
  28103. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  28104. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  28105. */
  28106. pickedBySubMesh: {
  28107. idx: number;
  28108. faceId: number;
  28109. }[][];
  28110. /**
  28111. * This array is populated when `enableDepthSort` is set to true.
  28112. * Each element of this array is an instance of the class DepthSortedParticle.
  28113. */
  28114. depthSortedParticles: DepthSortedParticle[];
  28115. /**
  28116. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  28117. * @hidden
  28118. */
  28119. _bSphereOnly: boolean;
  28120. /**
  28121. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  28122. * @hidden
  28123. */
  28124. _bSphereRadiusFactor: number;
  28125. private _scene;
  28126. private _positions;
  28127. private _indices;
  28128. private _normals;
  28129. private _colors;
  28130. private _uvs;
  28131. private _indices32;
  28132. private _positions32;
  28133. private _normals32;
  28134. private _fixedNormal32;
  28135. private _colors32;
  28136. private _uvs32;
  28137. private _index;
  28138. private _updatable;
  28139. private _pickable;
  28140. private _isVisibilityBoxLocked;
  28141. private _alwaysVisible;
  28142. private _depthSort;
  28143. private _expandable;
  28144. private _shapeCounter;
  28145. private _copy;
  28146. private _color;
  28147. private _computeParticleColor;
  28148. private _computeParticleTexture;
  28149. private _computeParticleRotation;
  28150. private _computeParticleVertex;
  28151. private _computeBoundingBox;
  28152. private _depthSortParticles;
  28153. private _camera;
  28154. private _mustUnrotateFixedNormals;
  28155. private _particlesIntersect;
  28156. private _needs32Bits;
  28157. private _isNotBuilt;
  28158. private _lastParticleId;
  28159. private _idxOfId;
  28160. private _multimaterialEnabled;
  28161. private _useModelMaterial;
  28162. private _indicesByMaterial;
  28163. private _materialIndexes;
  28164. private _depthSortFunction;
  28165. private _materialSortFunction;
  28166. private _materials;
  28167. private _multimaterial;
  28168. private _materialIndexesById;
  28169. private _defaultMaterial;
  28170. private _autoUpdateSubMeshes;
  28171. /**
  28172. * Creates a SPS (Solid Particle System) object.
  28173. * @param name (String) is the SPS name, this will be the underlying mesh name.
  28174. * @param scene (Scene) is the scene in which the SPS is added.
  28175. * @param options defines the options of the sps e.g.
  28176. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  28177. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  28178. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  28179. * * 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.
  28180. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  28181. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  28182. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  28183. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  28184. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  28185. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  28186. */
  28187. constructor(name: string, scene: Scene, options?: {
  28188. updatable?: boolean;
  28189. isPickable?: boolean;
  28190. enableDepthSort?: boolean;
  28191. particleIntersection?: boolean;
  28192. boundingSphereOnly?: boolean;
  28193. bSphereRadiusFactor?: number;
  28194. expandable?: boolean;
  28195. useModelMaterial?: boolean;
  28196. enableMultiMaterial?: boolean;
  28197. });
  28198. /**
  28199. * Builds the SPS underlying mesh. Returns a standard Mesh.
  28200. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  28201. * @returns the created mesh
  28202. */
  28203. buildMesh(): Mesh;
  28204. /**
  28205. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  28206. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  28207. * Thus the particles generated from `digest()` have their property `position` set yet.
  28208. * @param mesh ( Mesh ) is the mesh to be digested
  28209. * @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
  28210. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  28211. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  28212. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28213. * @returns the current SPS
  28214. */
  28215. digest(mesh: Mesh, options?: {
  28216. facetNb?: number;
  28217. number?: number;
  28218. delta?: number;
  28219. storage?: [];
  28220. }): SolidParticleSystem;
  28221. /**
  28222. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  28223. * @hidden
  28224. */
  28225. private _unrotateFixedNormals;
  28226. /**
  28227. * Resets the temporary working copy particle
  28228. * @hidden
  28229. */
  28230. private _resetCopy;
  28231. /**
  28232. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  28233. * @param p the current index in the positions array to be updated
  28234. * @param ind the current index in the indices array
  28235. * @param shape a Vector3 array, the shape geometry
  28236. * @param positions the positions array to be updated
  28237. * @param meshInd the shape indices array
  28238. * @param indices the indices array to be updated
  28239. * @param meshUV the shape uv array
  28240. * @param uvs the uv array to be updated
  28241. * @param meshCol the shape color array
  28242. * @param colors the color array to be updated
  28243. * @param meshNor the shape normals array
  28244. * @param normals the normals array to be updated
  28245. * @param idx the particle index
  28246. * @param idxInShape the particle index in its shape
  28247. * @param options the addShape() method passed options
  28248. * @model the particle model
  28249. * @hidden
  28250. */
  28251. private _meshBuilder;
  28252. /**
  28253. * Returns a shape Vector3 array from positions float array
  28254. * @param positions float array
  28255. * @returns a vector3 array
  28256. * @hidden
  28257. */
  28258. private _posToShape;
  28259. /**
  28260. * Returns a shapeUV array from a float uvs (array deep copy)
  28261. * @param uvs as a float array
  28262. * @returns a shapeUV array
  28263. * @hidden
  28264. */
  28265. private _uvsToShapeUV;
  28266. /**
  28267. * Adds a new particle object in the particles array
  28268. * @param idx particle index in particles array
  28269. * @param id particle id
  28270. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  28271. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  28272. * @param model particle ModelShape object
  28273. * @param shapeId model shape identifier
  28274. * @param idxInShape index of the particle in the current model
  28275. * @param bInfo model bounding info object
  28276. * @param storage target storage array, if any
  28277. * @hidden
  28278. */
  28279. private _addParticle;
  28280. /**
  28281. * Adds some particles to the SPS from the model shape. Returns the shape id.
  28282. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  28283. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  28284. * @param nb (positive integer) the number of particles to be created from this model
  28285. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  28286. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  28287. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  28288. * @returns the number of shapes in the system
  28289. */
  28290. addShape(mesh: Mesh, nb: number, options?: {
  28291. positionFunction?: any;
  28292. vertexFunction?: any;
  28293. storage?: [];
  28294. }): number;
  28295. /**
  28296. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  28297. * @hidden
  28298. */
  28299. private _rebuildParticle;
  28300. /**
  28301. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  28302. * @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.
  28303. * @returns the SPS.
  28304. */
  28305. rebuildMesh(reset?: boolean): SolidParticleSystem;
  28306. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  28307. * Returns an array with the removed particles.
  28308. * 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.
  28309. * The SPS can't be empty so at least one particle needs to remain in place.
  28310. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  28311. * @param start index of the first particle to remove
  28312. * @param end index of the last particle to remove (included)
  28313. * @returns an array populated with the removed particles
  28314. */
  28315. removeParticles(start: number, end: number): SolidParticle[];
  28316. /**
  28317. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  28318. * @param solidParticleArray an array populated with Solid Particles objects
  28319. * @returns the SPS
  28320. */
  28321. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  28322. /**
  28323. * Creates a new particle and modifies the SPS mesh geometry :
  28324. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  28325. * - calls _addParticle() to populate the particle array
  28326. * factorized code from addShape() and insertParticlesFromArray()
  28327. * @param idx particle index in the particles array
  28328. * @param i particle index in its shape
  28329. * @param modelShape particle ModelShape object
  28330. * @param shape shape vertex array
  28331. * @param meshInd shape indices array
  28332. * @param meshUV shape uv array
  28333. * @param meshCol shape color array
  28334. * @param meshNor shape normals array
  28335. * @param bbInfo shape bounding info
  28336. * @param storage target particle storage
  28337. * @options addShape() passed options
  28338. * @hidden
  28339. */
  28340. private _insertNewParticle;
  28341. /**
  28342. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  28343. * This method calls `updateParticle()` for each particle of the SPS.
  28344. * For an animated SPS, it is usually called within the render loop.
  28345. * 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.
  28346. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  28347. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  28348. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  28349. * @returns the SPS.
  28350. */
  28351. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  28352. /**
  28353. * Disposes the SPS.
  28354. */
  28355. dispose(): void;
  28356. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  28357. * idx is the particle index in the SPS
  28358. * faceId is the picked face index counted within this particle.
  28359. * Returns null if the pickInfo can't identify a picked particle.
  28360. * @param pickingInfo (PickingInfo object)
  28361. * @returns {idx: number, faceId: number} or null
  28362. */
  28363. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  28364. idx: number;
  28365. faceId: number;
  28366. }>;
  28367. /**
  28368. * Returns a SolidParticle object from its identifier : particle.id
  28369. * @param id (integer) the particle Id
  28370. * @returns the searched particle or null if not found in the SPS.
  28371. */
  28372. getParticleById(id: number): Nullable<SolidParticle>;
  28373. /**
  28374. * Returns a new array populated with the particles having the passed shapeId.
  28375. * @param shapeId (integer) the shape identifier
  28376. * @returns a new solid particle array
  28377. */
  28378. getParticlesByShapeId(shapeId: number): SolidParticle[];
  28379. /**
  28380. * Populates the passed array "ref" with the particles having the passed shapeId.
  28381. * @param shapeId the shape identifier
  28382. * @returns the SPS
  28383. * @param ref
  28384. */
  28385. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  28386. /**
  28387. * Computes the required SubMeshes according the materials assigned to the particles.
  28388. * @returns the solid particle system.
  28389. * Does nothing if called before the SPS mesh is built.
  28390. */
  28391. computeSubMeshes(): SolidParticleSystem;
  28392. /**
  28393. * Sorts the solid particles by material when MultiMaterial is enabled.
  28394. * Updates the indices32 array.
  28395. * Updates the indicesByMaterial array.
  28396. * Updates the mesh indices array.
  28397. * @returns the SPS
  28398. * @hidden
  28399. */
  28400. private _sortParticlesByMaterial;
  28401. /**
  28402. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  28403. * @hidden
  28404. */
  28405. private _setMaterialIndexesById;
  28406. /**
  28407. * Returns an array with unique values of Materials from the passed array
  28408. * @param array the material array to be checked and filtered
  28409. * @hidden
  28410. */
  28411. private _filterUniqueMaterialId;
  28412. /**
  28413. * Sets a new Standard Material as _defaultMaterial if not already set.
  28414. * @hidden
  28415. */
  28416. private _setDefaultMaterial;
  28417. /**
  28418. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  28419. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28420. * @returns the SPS.
  28421. */
  28422. refreshVisibleSize(): SolidParticleSystem;
  28423. /**
  28424. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  28425. * @param size the size (float) of the visibility box
  28426. * note : this doesn't lock the SPS mesh bounding box.
  28427. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28428. */
  28429. setVisibilityBox(size: number): void;
  28430. /**
  28431. * Gets whether the SPS as always visible or not
  28432. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28433. */
  28434. get isAlwaysVisible(): boolean;
  28435. /**
  28436. * Sets the SPS as always visible or not
  28437. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28438. */
  28439. set isAlwaysVisible(val: boolean);
  28440. /**
  28441. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28442. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28443. */
  28444. set isVisibilityBoxLocked(val: boolean);
  28445. /**
  28446. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  28447. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  28448. */
  28449. get isVisibilityBoxLocked(): boolean;
  28450. /**
  28451. * Tells to `setParticles()` to compute the particle rotations or not.
  28452. * Default value : true. The SPS is faster when it's set to false.
  28453. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28454. */
  28455. set computeParticleRotation(val: boolean);
  28456. /**
  28457. * Tells to `setParticles()` to compute the particle colors or not.
  28458. * Default value : true. The SPS is faster when it's set to false.
  28459. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28460. */
  28461. set computeParticleColor(val: boolean);
  28462. set computeParticleTexture(val: boolean);
  28463. /**
  28464. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  28465. * Default value : false. The SPS is faster when it's set to false.
  28466. * Note : the particle custom vertex positions aren't stored values.
  28467. */
  28468. set computeParticleVertex(val: boolean);
  28469. /**
  28470. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  28471. */
  28472. set computeBoundingBox(val: boolean);
  28473. /**
  28474. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  28475. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28476. * Default : `true`
  28477. */
  28478. set depthSortParticles(val: boolean);
  28479. /**
  28480. * Gets if `setParticles()` computes the particle rotations or not.
  28481. * Default value : true. The SPS is faster when it's set to false.
  28482. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  28483. */
  28484. get computeParticleRotation(): boolean;
  28485. /**
  28486. * Gets if `setParticles()` computes the particle colors or not.
  28487. * Default value : true. The SPS is faster when it's set to false.
  28488. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  28489. */
  28490. get computeParticleColor(): boolean;
  28491. /**
  28492. * Gets if `setParticles()` computes the particle textures or not.
  28493. * Default value : true. The SPS is faster when it's set to false.
  28494. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  28495. */
  28496. get computeParticleTexture(): boolean;
  28497. /**
  28498. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  28499. * Default value : false. The SPS is faster when it's set to false.
  28500. * Note : the particle custom vertex positions aren't stored values.
  28501. */
  28502. get computeParticleVertex(): boolean;
  28503. /**
  28504. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  28505. */
  28506. get computeBoundingBox(): boolean;
  28507. /**
  28508. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  28509. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  28510. * Default : `true`
  28511. */
  28512. get depthSortParticles(): boolean;
  28513. /**
  28514. * Gets if the SPS is created as expandable at construction time.
  28515. * Default : `false`
  28516. */
  28517. get expandable(): boolean;
  28518. /**
  28519. * Gets if the SPS supports the Multi Materials
  28520. */
  28521. get multimaterialEnabled(): boolean;
  28522. /**
  28523. * Gets if the SPS uses the model materials for its own multimaterial.
  28524. */
  28525. get useModelMaterial(): boolean;
  28526. /**
  28527. * The SPS used material array.
  28528. */
  28529. get materials(): Material[];
  28530. /**
  28531. * Sets the SPS MultiMaterial from the passed materials.
  28532. * Note : the passed array is internally copied and not used then by reference.
  28533. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  28534. */
  28535. setMultiMaterial(materials: Material[]): void;
  28536. /**
  28537. * The SPS computed multimaterial object
  28538. */
  28539. get multimaterial(): MultiMaterial;
  28540. set multimaterial(mm: MultiMaterial);
  28541. /**
  28542. * If the subMeshes must be updated on the next call to setParticles()
  28543. */
  28544. get autoUpdateSubMeshes(): boolean;
  28545. set autoUpdateSubMeshes(val: boolean);
  28546. /**
  28547. * This function does nothing. It may be overwritten to set all the particle first values.
  28548. * The SPS doesn't call this function, you may have to call it by your own.
  28549. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28550. */
  28551. initParticles(): void;
  28552. /**
  28553. * This function does nothing. It may be overwritten to recycle a particle.
  28554. * The SPS doesn't call this function, you may have to call it by your own.
  28555. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28556. * @param particle The particle to recycle
  28557. * @returns the recycled particle
  28558. */
  28559. recycleParticle(particle: SolidParticle): SolidParticle;
  28560. /**
  28561. * Updates a particle : this function should be overwritten by the user.
  28562. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  28563. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  28564. * @example : just set a particle position or velocity and recycle conditions
  28565. * @param particle The particle to update
  28566. * @returns the updated particle
  28567. */
  28568. updateParticle(particle: SolidParticle): SolidParticle;
  28569. /**
  28570. * Updates a vertex of a particle : it can be overwritten by the user.
  28571. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  28572. * @param particle the current particle
  28573. * @param vertex the current index of the current particle
  28574. * @param pt the index of the current vertex in the particle shape
  28575. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  28576. * @example : just set a vertex particle position
  28577. * @returns the updated vertex
  28578. */
  28579. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  28580. /**
  28581. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  28582. * This does nothing and may be overwritten by the user.
  28583. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28584. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28585. * @param update the boolean update value actually passed to setParticles()
  28586. */
  28587. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28588. /**
  28589. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  28590. * This will be passed three parameters.
  28591. * This does nothing and may be overwritten by the user.
  28592. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28593. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  28594. * @param update the boolean update value actually passed to setParticles()
  28595. */
  28596. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  28597. }
  28598. }
  28599. declare module "babylonjs/Particles/solidParticle" {
  28600. import { Nullable } from "babylonjs/types";
  28601. import { Vector3, Matrix, Quaternion, Vector4 } from "babylonjs/Maths/math.vector";
  28602. import { Color4 } from "babylonjs/Maths/math.color";
  28603. import { Mesh } from "babylonjs/Meshes/mesh";
  28604. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28605. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  28606. import { Plane } from "babylonjs/Maths/math.plane";
  28607. import { Material } from "babylonjs/Materials/material";
  28608. /**
  28609. * Represents one particle of a solid particle system.
  28610. */
  28611. export class SolidParticle {
  28612. /**
  28613. * particle global index
  28614. */
  28615. idx: number;
  28616. /**
  28617. * particle identifier
  28618. */
  28619. id: number;
  28620. /**
  28621. * The color of the particle
  28622. */
  28623. color: Nullable<Color4>;
  28624. /**
  28625. * The world space position of the particle.
  28626. */
  28627. position: Vector3;
  28628. /**
  28629. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  28630. */
  28631. rotation: Vector3;
  28632. /**
  28633. * The world space rotation quaternion of the particle.
  28634. */
  28635. rotationQuaternion: Nullable<Quaternion>;
  28636. /**
  28637. * The scaling of the particle.
  28638. */
  28639. scaling: Vector3;
  28640. /**
  28641. * The uvs of the particle.
  28642. */
  28643. uvs: Vector4;
  28644. /**
  28645. * The current speed of the particle.
  28646. */
  28647. velocity: Vector3;
  28648. /**
  28649. * The pivot point in the particle local space.
  28650. */
  28651. pivot: Vector3;
  28652. /**
  28653. * Must the particle be translated from its pivot point in its local space ?
  28654. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  28655. * Default : false
  28656. */
  28657. translateFromPivot: boolean;
  28658. /**
  28659. * Is the particle active or not ?
  28660. */
  28661. alive: boolean;
  28662. /**
  28663. * Is the particle visible or not ?
  28664. */
  28665. isVisible: boolean;
  28666. /**
  28667. * Index of this particle in the global "positions" array (Internal use)
  28668. * @hidden
  28669. */
  28670. _pos: number;
  28671. /**
  28672. * @hidden Index of this particle in the global "indices" array (Internal use)
  28673. */
  28674. _ind: number;
  28675. /**
  28676. * @hidden ModelShape of this particle (Internal use)
  28677. */
  28678. _model: ModelShape;
  28679. /**
  28680. * ModelShape id of this particle
  28681. */
  28682. shapeId: number;
  28683. /**
  28684. * Index of the particle in its shape id
  28685. */
  28686. idxInShape: number;
  28687. /**
  28688. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  28689. */
  28690. _modelBoundingInfo: BoundingInfo;
  28691. /**
  28692. * @hidden Particle BoundingInfo object (Internal use)
  28693. */
  28694. _boundingInfo: BoundingInfo;
  28695. /**
  28696. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  28697. */
  28698. _sps: SolidParticleSystem;
  28699. /**
  28700. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  28701. */
  28702. _stillInvisible: boolean;
  28703. /**
  28704. * @hidden Last computed particle rotation matrix
  28705. */
  28706. _rotationMatrix: number[];
  28707. /**
  28708. * Parent particle Id, if any.
  28709. * Default null.
  28710. */
  28711. parentId: Nullable<number>;
  28712. /**
  28713. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  28714. */
  28715. materialIndex: Nullable<number>;
  28716. /**
  28717. * Custom object or properties.
  28718. */
  28719. props: Nullable<any>;
  28720. /**
  28721. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  28722. * The possible values are :
  28723. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  28724. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28725. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  28726. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  28727. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  28728. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  28729. * */
  28730. cullingStrategy: number;
  28731. /**
  28732. * @hidden Internal global position in the SPS.
  28733. */
  28734. _globalPosition: Vector3;
  28735. /**
  28736. * Creates a Solid Particle object.
  28737. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  28738. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  28739. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  28740. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  28741. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  28742. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  28743. * @param shapeId (integer) is the model shape identifier in the SPS.
  28744. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  28745. * @param sps defines the sps it is associated to
  28746. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  28747. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  28748. */
  28749. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  28750. /**
  28751. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  28752. * @param target the particle target
  28753. * @returns the current particle
  28754. */
  28755. copyToRef(target: SolidParticle): SolidParticle;
  28756. /**
  28757. * Legacy support, changed scale to scaling
  28758. */
  28759. get scale(): Vector3;
  28760. /**
  28761. * Legacy support, changed scale to scaling
  28762. */
  28763. set scale(scale: Vector3);
  28764. /**
  28765. * Legacy support, changed quaternion to rotationQuaternion
  28766. */
  28767. get quaternion(): Nullable<Quaternion>;
  28768. /**
  28769. * Legacy support, changed quaternion to rotationQuaternion
  28770. */
  28771. set quaternion(q: Nullable<Quaternion>);
  28772. /**
  28773. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  28774. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  28775. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  28776. * @returns true if it intersects
  28777. */
  28778. intersectsMesh(target: Mesh | SolidParticle): boolean;
  28779. /**
  28780. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  28781. * A particle is in the frustum if its bounding box intersects the frustum
  28782. * @param frustumPlanes defines the frustum to test
  28783. * @returns true if the particle is in the frustum planes
  28784. */
  28785. isInFrustum(frustumPlanes: Plane[]): boolean;
  28786. /**
  28787. * get the rotation matrix of the particle
  28788. * @hidden
  28789. */
  28790. getRotationMatrix(m: Matrix): void;
  28791. }
  28792. /**
  28793. * Represents the shape of the model used by one particle of a solid particle system.
  28794. * SPS internal tool, don't use it manually.
  28795. */
  28796. export class ModelShape {
  28797. /**
  28798. * The shape id
  28799. * @hidden
  28800. */
  28801. shapeID: number;
  28802. /**
  28803. * flat array of model positions (internal use)
  28804. * @hidden
  28805. */
  28806. _shape: Vector3[];
  28807. /**
  28808. * flat array of model UVs (internal use)
  28809. * @hidden
  28810. */
  28811. _shapeUV: number[];
  28812. /**
  28813. * color array of the model
  28814. * @hidden
  28815. */
  28816. _shapeColors: number[];
  28817. /**
  28818. * indices array of the model
  28819. * @hidden
  28820. */
  28821. _indices: number[];
  28822. /**
  28823. * normals array of the model
  28824. * @hidden
  28825. */
  28826. _normals: number[];
  28827. /**
  28828. * length of the shape in the model indices array (internal use)
  28829. * @hidden
  28830. */
  28831. _indicesLength: number;
  28832. /**
  28833. * Custom position function (internal use)
  28834. * @hidden
  28835. */
  28836. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  28837. /**
  28838. * Custom vertex function (internal use)
  28839. * @hidden
  28840. */
  28841. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  28842. /**
  28843. * Model material (internal use)
  28844. * @hidden
  28845. */
  28846. _material: Nullable<Material>;
  28847. /**
  28848. * 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.
  28849. * SPS internal tool, don't use it manually.
  28850. * @hidden
  28851. */
  28852. 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>);
  28853. }
  28854. /**
  28855. * Represents a Depth Sorted Particle in the solid particle system.
  28856. * @hidden
  28857. */
  28858. export class DepthSortedParticle {
  28859. /**
  28860. * Particle index
  28861. */
  28862. idx: number;
  28863. /**
  28864. * Index of the particle in the "indices" array
  28865. */
  28866. ind: number;
  28867. /**
  28868. * Length of the particle shape in the "indices" array
  28869. */
  28870. indicesLength: number;
  28871. /**
  28872. * Squared distance from the particle to the camera
  28873. */
  28874. sqDistance: number;
  28875. /**
  28876. * Material index when used with MultiMaterials
  28877. */
  28878. materialIndex: number;
  28879. /**
  28880. * Creates a new sorted particle
  28881. * @param materialIndex
  28882. */
  28883. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  28884. }
  28885. }
  28886. declare module "babylonjs/Collisions/meshCollisionData" {
  28887. import { Collider } from "babylonjs/Collisions/collider";
  28888. import { Vector3 } from "babylonjs/Maths/math.vector";
  28889. import { Nullable } from "babylonjs/types";
  28890. import { Observer } from "babylonjs/Misc/observable";
  28891. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28892. /**
  28893. * @hidden
  28894. */
  28895. export class _MeshCollisionData {
  28896. _checkCollisions: boolean;
  28897. _collisionMask: number;
  28898. _collisionGroup: number;
  28899. _surroundingMeshes: Nullable<AbstractMesh[]>;
  28900. _collider: Nullable<Collider>;
  28901. _oldPositionForCollisions: Vector3;
  28902. _diffPositionForCollisions: Vector3;
  28903. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  28904. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  28905. }
  28906. }
  28907. declare module "babylonjs/Meshes/abstractMesh" {
  28908. import { Observable } from "babylonjs/Misc/observable";
  28909. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  28910. import { Camera } from "babylonjs/Cameras/camera";
  28911. import { Scene, IDisposable } from "babylonjs/scene";
  28912. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  28913. import { Node } from "babylonjs/node";
  28914. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  28915. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28916. import { SubMesh } from "babylonjs/Meshes/subMesh";
  28917. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  28918. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28919. import { Material } from "babylonjs/Materials/material";
  28920. import { Light } from "babylonjs/Lights/light";
  28921. import { Skeleton } from "babylonjs/Bones/skeleton";
  28922. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  28923. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  28924. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  28925. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  28926. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  28927. import { Plane } from "babylonjs/Maths/math.plane";
  28928. import { Ray } from "babylonjs/Culling/ray";
  28929. import { Collider } from "babylonjs/Collisions/collider";
  28930. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  28931. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  28932. /** @hidden */
  28933. class _FacetDataStorage {
  28934. facetPositions: Vector3[];
  28935. facetNormals: Vector3[];
  28936. facetPartitioning: number[][];
  28937. facetNb: number;
  28938. partitioningSubdivisions: number;
  28939. partitioningBBoxRatio: number;
  28940. facetDataEnabled: boolean;
  28941. facetParameters: any;
  28942. bbSize: Vector3;
  28943. subDiv: {
  28944. max: number;
  28945. X: number;
  28946. Y: number;
  28947. Z: number;
  28948. };
  28949. facetDepthSort: boolean;
  28950. facetDepthSortEnabled: boolean;
  28951. depthSortedIndices: IndicesArray;
  28952. depthSortedFacets: {
  28953. ind: number;
  28954. sqDistance: number;
  28955. }[];
  28956. facetDepthSortFunction: (f1: {
  28957. ind: number;
  28958. sqDistance: number;
  28959. }, f2: {
  28960. ind: number;
  28961. sqDistance: number;
  28962. }) => number;
  28963. facetDepthSortFrom: Vector3;
  28964. facetDepthSortOrigin: Vector3;
  28965. invertedMatrix: Matrix;
  28966. }
  28967. /**
  28968. * @hidden
  28969. **/
  28970. class _InternalAbstractMeshDataInfo {
  28971. _hasVertexAlpha: boolean;
  28972. _useVertexColors: boolean;
  28973. _numBoneInfluencers: number;
  28974. _applyFog: boolean;
  28975. _receiveShadows: boolean;
  28976. _facetData: _FacetDataStorage;
  28977. _visibility: number;
  28978. _skeleton: Nullable<Skeleton>;
  28979. _layerMask: number;
  28980. _computeBonesUsingShaders: boolean;
  28981. _isActive: boolean;
  28982. _onlyForInstances: boolean;
  28983. _isActiveIntermediate: boolean;
  28984. _onlyForInstancesIntermediate: boolean;
  28985. _actAsRegularMesh: boolean;
  28986. }
  28987. /**
  28988. * Class used to store all common mesh properties
  28989. */
  28990. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  28991. /** No occlusion */
  28992. static OCCLUSION_TYPE_NONE: number;
  28993. /** Occlusion set to optimisitic */
  28994. static OCCLUSION_TYPE_OPTIMISTIC: number;
  28995. /** Occlusion set to strict */
  28996. static OCCLUSION_TYPE_STRICT: number;
  28997. /** Use an accurante occlusion algorithm */
  28998. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  28999. /** Use a conservative occlusion algorithm */
  29000. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  29001. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  29002. * Test order :
  29003. * Is the bounding sphere outside the frustum ?
  29004. * If not, are the bounding box vertices outside the frustum ?
  29005. * It not, then the cullable object is in the frustum.
  29006. */
  29007. static readonly CULLINGSTRATEGY_STANDARD: number;
  29008. /** Culling strategy : Bounding Sphere Only.
  29009. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  29010. * It's also less accurate than the standard because some not visible objects can still be selected.
  29011. * Test : is the bounding sphere outside the frustum ?
  29012. * If not, then the cullable object is in the frustum.
  29013. */
  29014. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  29015. /** Culling strategy : Optimistic Inclusion.
  29016. * This in an inclusion test first, then the standard exclusion test.
  29017. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  29018. * 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.
  29019. * Anyway, it's as accurate as the standard strategy.
  29020. * Test :
  29021. * Is the cullable object bounding sphere center in the frustum ?
  29022. * If not, apply the default culling strategy.
  29023. */
  29024. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  29025. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  29026. * This in an inclusion test first, then the bounding sphere only exclusion test.
  29027. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  29028. * 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.
  29029. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  29030. * Test :
  29031. * Is the cullable object bounding sphere center in the frustum ?
  29032. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  29033. */
  29034. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  29035. /**
  29036. * No billboard
  29037. */
  29038. static get BILLBOARDMODE_NONE(): number;
  29039. /** Billboard on X axis */
  29040. static get BILLBOARDMODE_X(): number;
  29041. /** Billboard on Y axis */
  29042. static get BILLBOARDMODE_Y(): number;
  29043. /** Billboard on Z axis */
  29044. static get BILLBOARDMODE_Z(): number;
  29045. /** Billboard on all axes */
  29046. static get BILLBOARDMODE_ALL(): number;
  29047. /** Billboard on using position instead of orientation */
  29048. static get BILLBOARDMODE_USE_POSITION(): number;
  29049. /** @hidden */
  29050. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  29051. /**
  29052. * The culling strategy to use to check whether the mesh must be rendered or not.
  29053. * This value can be changed at any time and will be used on the next render mesh selection.
  29054. * The possible values are :
  29055. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  29056. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  29057. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  29058. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  29059. * Please read each static variable documentation to get details about the culling process.
  29060. * */
  29061. cullingStrategy: number;
  29062. /**
  29063. * Gets the number of facets in the mesh
  29064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29065. */
  29066. get facetNb(): number;
  29067. /**
  29068. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  29069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29070. */
  29071. get partitioningSubdivisions(): number;
  29072. set partitioningSubdivisions(nb: number);
  29073. /**
  29074. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  29075. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  29076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  29077. */
  29078. get partitioningBBoxRatio(): number;
  29079. set partitioningBBoxRatio(ratio: number);
  29080. /**
  29081. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  29082. * Works only for updatable meshes.
  29083. * Doesn't work with multi-materials
  29084. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29085. */
  29086. get mustDepthSortFacets(): boolean;
  29087. set mustDepthSortFacets(sort: boolean);
  29088. /**
  29089. * The location (Vector3) where the facet depth sort must be computed from.
  29090. * By default, the active camera position.
  29091. * Used only when facet depth sort is enabled
  29092. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  29093. */
  29094. get facetDepthSortFrom(): Vector3;
  29095. set facetDepthSortFrom(location: Vector3);
  29096. /**
  29097. * gets a boolean indicating if facetData is enabled
  29098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  29099. */
  29100. get isFacetDataEnabled(): boolean;
  29101. /** @hidden */
  29102. _updateNonUniformScalingState(value: boolean): boolean;
  29103. /**
  29104. * An event triggered when this mesh collides with another one
  29105. */
  29106. onCollideObservable: Observable<AbstractMesh>;
  29107. /** Set a function to call when this mesh collides with another one */
  29108. set onCollide(callback: () => void);
  29109. /**
  29110. * An event triggered when the collision's position changes
  29111. */
  29112. onCollisionPositionChangeObservable: Observable<Vector3>;
  29113. /** Set a function to call when the collision's position changes */
  29114. set onCollisionPositionChange(callback: () => void);
  29115. /**
  29116. * An event triggered when material is changed
  29117. */
  29118. onMaterialChangedObservable: Observable<AbstractMesh>;
  29119. /**
  29120. * Gets or sets the orientation for POV movement & rotation
  29121. */
  29122. definedFacingForward: boolean;
  29123. /** @hidden */
  29124. _occlusionQuery: Nullable<WebGLQuery>;
  29125. /** @hidden */
  29126. _renderingGroup: Nullable<RenderingGroup>;
  29127. /**
  29128. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29129. */
  29130. get visibility(): number;
  29131. /**
  29132. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  29133. */
  29134. set visibility(value: number);
  29135. /** Gets or sets the alpha index used to sort transparent meshes
  29136. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  29137. */
  29138. alphaIndex: number;
  29139. /**
  29140. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  29141. */
  29142. isVisible: boolean;
  29143. /**
  29144. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  29145. */
  29146. isPickable: boolean;
  29147. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  29148. showSubMeshesBoundingBox: boolean;
  29149. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  29150. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  29151. */
  29152. isBlocker: boolean;
  29153. /**
  29154. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  29155. */
  29156. enablePointerMoveEvents: boolean;
  29157. /**
  29158. * Specifies the rendering group id for this mesh (0 by default)
  29159. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  29160. */
  29161. renderingGroupId: number;
  29162. private _material;
  29163. /** Gets or sets current material */
  29164. get material(): Nullable<Material>;
  29165. set material(value: Nullable<Material>);
  29166. /**
  29167. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  29168. * @see http://doc.babylonjs.com/babylon101/shadows
  29169. */
  29170. get receiveShadows(): boolean;
  29171. set receiveShadows(value: boolean);
  29172. /** Defines color to use when rendering outline */
  29173. outlineColor: Color3;
  29174. /** Define width to use when rendering outline */
  29175. outlineWidth: number;
  29176. /** Defines color to use when rendering overlay */
  29177. overlayColor: Color3;
  29178. /** Defines alpha to use when rendering overlay */
  29179. overlayAlpha: number;
  29180. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  29181. get hasVertexAlpha(): boolean;
  29182. set hasVertexAlpha(value: boolean);
  29183. /** 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) */
  29184. get useVertexColors(): boolean;
  29185. set useVertexColors(value: boolean);
  29186. /**
  29187. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  29188. */
  29189. get computeBonesUsingShaders(): boolean;
  29190. set computeBonesUsingShaders(value: boolean);
  29191. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  29192. get numBoneInfluencers(): number;
  29193. set numBoneInfluencers(value: number);
  29194. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  29195. get applyFog(): boolean;
  29196. set applyFog(value: boolean);
  29197. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  29198. useOctreeForRenderingSelection: boolean;
  29199. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  29200. useOctreeForPicking: boolean;
  29201. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  29202. useOctreeForCollisions: boolean;
  29203. /**
  29204. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  29205. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  29206. */
  29207. get layerMask(): number;
  29208. set layerMask(value: number);
  29209. /**
  29210. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  29211. */
  29212. alwaysSelectAsActiveMesh: boolean;
  29213. /**
  29214. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  29215. */
  29216. doNotSyncBoundingInfo: boolean;
  29217. /**
  29218. * Gets or sets the current action manager
  29219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29220. */
  29221. actionManager: Nullable<AbstractActionManager>;
  29222. private _meshCollisionData;
  29223. /**
  29224. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  29225. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29226. */
  29227. ellipsoid: Vector3;
  29228. /**
  29229. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  29230. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29231. */
  29232. ellipsoidOffset: Vector3;
  29233. /**
  29234. * Gets or sets a collision mask used to mask collisions (default is -1).
  29235. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29236. */
  29237. get collisionMask(): number;
  29238. set collisionMask(mask: number);
  29239. /**
  29240. * Gets or sets the current collision group mask (-1 by default).
  29241. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  29242. */
  29243. get collisionGroup(): number;
  29244. set collisionGroup(mask: number);
  29245. /**
  29246. * Gets or sets current surrounding meshes (null by default).
  29247. *
  29248. * By default collision detection is tested against every mesh in the scene.
  29249. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  29250. * meshes will be tested for the collision.
  29251. *
  29252. * Note: if set to an empty array no collision will happen when this mesh is moved.
  29253. */
  29254. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  29255. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  29256. /**
  29257. * Defines edge width used when edgesRenderer is enabled
  29258. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29259. */
  29260. edgesWidth: number;
  29261. /**
  29262. * Defines edge color used when edgesRenderer is enabled
  29263. * @see https://www.babylonjs-playground.com/#10OJSG#13
  29264. */
  29265. edgesColor: Color4;
  29266. /** @hidden */
  29267. _edgesRenderer: Nullable<IEdgesRenderer>;
  29268. /** @hidden */
  29269. _masterMesh: Nullable<AbstractMesh>;
  29270. /** @hidden */
  29271. _boundingInfo: Nullable<BoundingInfo>;
  29272. /** @hidden */
  29273. _renderId: number;
  29274. /**
  29275. * Gets or sets the list of subMeshes
  29276. * @see http://doc.babylonjs.com/how_to/multi_materials
  29277. */
  29278. subMeshes: SubMesh[];
  29279. /** @hidden */
  29280. _intersectionsInProgress: AbstractMesh[];
  29281. /** @hidden */
  29282. _unIndexed: boolean;
  29283. /** @hidden */
  29284. _lightSources: Light[];
  29285. /** Gets the list of lights affecting that mesh */
  29286. get lightSources(): Light[];
  29287. /** @hidden */
  29288. get _positions(): Nullable<Vector3[]>;
  29289. /** @hidden */
  29290. _waitingData: {
  29291. lods: Nullable<any>;
  29292. actions: Nullable<any>;
  29293. freezeWorldMatrix: Nullable<boolean>;
  29294. };
  29295. /** @hidden */
  29296. _bonesTransformMatrices: Nullable<Float32Array>;
  29297. /** @hidden */
  29298. _transformMatrixTexture: Nullable<RawTexture>;
  29299. /**
  29300. * Gets or sets a skeleton to apply skining transformations
  29301. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  29302. */
  29303. set skeleton(value: Nullable<Skeleton>);
  29304. get skeleton(): Nullable<Skeleton>;
  29305. /**
  29306. * An event triggered when the mesh is rebuilt.
  29307. */
  29308. onRebuildObservable: Observable<AbstractMesh>;
  29309. /**
  29310. * Creates a new AbstractMesh
  29311. * @param name defines the name of the mesh
  29312. * @param scene defines the hosting scene
  29313. */
  29314. constructor(name: string, scene?: Nullable<Scene>);
  29315. /**
  29316. * Returns the string "AbstractMesh"
  29317. * @returns "AbstractMesh"
  29318. */
  29319. getClassName(): string;
  29320. /**
  29321. * Gets a string representation of the current mesh
  29322. * @param fullDetails defines a boolean indicating if full details must be included
  29323. * @returns a string representation of the current mesh
  29324. */
  29325. toString(fullDetails?: boolean): string;
  29326. /**
  29327. * @hidden
  29328. */
  29329. protected _getEffectiveParent(): Nullable<Node>;
  29330. /** @hidden */
  29331. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  29332. /** @hidden */
  29333. _rebuild(): void;
  29334. /** @hidden */
  29335. _resyncLightSources(): void;
  29336. /** @hidden */
  29337. _resyncLightSource(light: Light): void;
  29338. /** @hidden */
  29339. _unBindEffect(): void;
  29340. /** @hidden */
  29341. _removeLightSource(light: Light, dispose: boolean): void;
  29342. private _markSubMeshesAsDirty;
  29343. /** @hidden */
  29344. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  29345. /** @hidden */
  29346. _markSubMeshesAsAttributesDirty(): void;
  29347. /** @hidden */
  29348. _markSubMeshesAsMiscDirty(): void;
  29349. /**
  29350. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  29351. */
  29352. get scaling(): Vector3;
  29353. set scaling(newScaling: Vector3);
  29354. /**
  29355. * Returns true if the mesh is blocked. Implemented by child classes
  29356. */
  29357. get isBlocked(): boolean;
  29358. /**
  29359. * Returns the mesh itself by default. Implemented by child classes
  29360. * @param camera defines the camera to use to pick the right LOD level
  29361. * @returns the currentAbstractMesh
  29362. */
  29363. getLOD(camera: Camera): Nullable<AbstractMesh>;
  29364. /**
  29365. * Returns 0 by default. Implemented by child classes
  29366. * @returns an integer
  29367. */
  29368. getTotalVertices(): number;
  29369. /**
  29370. * Returns a positive integer : the total number of indices in this mesh geometry.
  29371. * @returns the numner of indices or zero if the mesh has no geometry.
  29372. */
  29373. getTotalIndices(): number;
  29374. /**
  29375. * Returns null by default. Implemented by child classes
  29376. * @returns null
  29377. */
  29378. getIndices(): Nullable<IndicesArray>;
  29379. /**
  29380. * Returns the array of the requested vertex data kind. Implemented by child classes
  29381. * @param kind defines the vertex data kind to use
  29382. * @returns null
  29383. */
  29384. getVerticesData(kind: string): Nullable<FloatArray>;
  29385. /**
  29386. * Sets the vertex data of the mesh geometry for the requested `kind`.
  29387. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  29388. * Note that a new underlying VertexBuffer object is created each call.
  29389. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  29390. * @param kind defines vertex data kind:
  29391. * * VertexBuffer.PositionKind
  29392. * * VertexBuffer.UVKind
  29393. * * VertexBuffer.UV2Kind
  29394. * * VertexBuffer.UV3Kind
  29395. * * VertexBuffer.UV4Kind
  29396. * * VertexBuffer.UV5Kind
  29397. * * VertexBuffer.UV6Kind
  29398. * * VertexBuffer.ColorKind
  29399. * * VertexBuffer.MatricesIndicesKind
  29400. * * VertexBuffer.MatricesIndicesExtraKind
  29401. * * VertexBuffer.MatricesWeightsKind
  29402. * * VertexBuffer.MatricesWeightsExtraKind
  29403. * @param data defines the data source
  29404. * @param updatable defines if the data must be flagged as updatable (or static)
  29405. * @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
  29406. * @returns the current mesh
  29407. */
  29408. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29409. /**
  29410. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  29411. * If the mesh has no geometry, it is simply returned as it is.
  29412. * @param kind defines vertex data kind:
  29413. * * VertexBuffer.PositionKind
  29414. * * VertexBuffer.UVKind
  29415. * * VertexBuffer.UV2Kind
  29416. * * VertexBuffer.UV3Kind
  29417. * * VertexBuffer.UV4Kind
  29418. * * VertexBuffer.UV5Kind
  29419. * * VertexBuffer.UV6Kind
  29420. * * VertexBuffer.ColorKind
  29421. * * VertexBuffer.MatricesIndicesKind
  29422. * * VertexBuffer.MatricesIndicesExtraKind
  29423. * * VertexBuffer.MatricesWeightsKind
  29424. * * VertexBuffer.MatricesWeightsExtraKind
  29425. * @param data defines the data source
  29426. * @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
  29427. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  29428. * @returns the current mesh
  29429. */
  29430. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29431. /**
  29432. * Sets the mesh indices,
  29433. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  29434. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  29435. * @param totalVertices Defines the total number of vertices
  29436. * @returns the current mesh
  29437. */
  29438. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  29439. /**
  29440. * Gets a boolean indicating if specific vertex data is present
  29441. * @param kind defines the vertex data kind to use
  29442. * @returns true is data kind is present
  29443. */
  29444. isVerticesDataPresent(kind: string): boolean;
  29445. /**
  29446. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  29447. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  29448. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  29449. * @returns a BoundingInfo
  29450. */
  29451. getBoundingInfo(): BoundingInfo;
  29452. /**
  29453. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  29454. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  29455. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  29456. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  29457. * @returns the current mesh
  29458. */
  29459. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  29460. /**
  29461. * Overwrite the current bounding info
  29462. * @param boundingInfo defines the new bounding info
  29463. * @returns the current mesh
  29464. */
  29465. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  29466. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  29467. get useBones(): boolean;
  29468. /** @hidden */
  29469. _preActivate(): void;
  29470. /** @hidden */
  29471. _preActivateForIntermediateRendering(renderId: number): void;
  29472. /** @hidden */
  29473. _activate(renderId: number, intermediateRendering: boolean): boolean;
  29474. /** @hidden */
  29475. _postActivate(): void;
  29476. /** @hidden */
  29477. _freeze(): void;
  29478. /** @hidden */
  29479. _unFreeze(): void;
  29480. /**
  29481. * Gets the current world matrix
  29482. * @returns a Matrix
  29483. */
  29484. getWorldMatrix(): Matrix;
  29485. /** @hidden */
  29486. _getWorldMatrixDeterminant(): number;
  29487. /**
  29488. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  29489. */
  29490. get isAnInstance(): boolean;
  29491. /**
  29492. * Gets a boolean indicating if this mesh has instances
  29493. */
  29494. get hasInstances(): boolean;
  29495. /**
  29496. * Perform relative position change from the point of view of behind the front of the mesh.
  29497. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29498. * Supports definition of mesh facing forward or backward
  29499. * @param amountRight defines the distance on the right axis
  29500. * @param amountUp defines the distance on the up axis
  29501. * @param amountForward defines the distance on the forward axis
  29502. * @returns the current mesh
  29503. */
  29504. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  29505. /**
  29506. * Calculate relative position change from the point of view of behind the front of the mesh.
  29507. * This is performed taking into account the meshes current rotation, so you do not have to care.
  29508. * Supports definition of mesh facing forward or backward
  29509. * @param amountRight defines the distance on the right axis
  29510. * @param amountUp defines the distance on the up axis
  29511. * @param amountForward defines the distance on the forward axis
  29512. * @returns the new displacement vector
  29513. */
  29514. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  29515. /**
  29516. * Perform relative rotation change from the point of view of behind the front of the mesh.
  29517. * Supports definition of mesh facing forward or backward
  29518. * @param flipBack defines the flip
  29519. * @param twirlClockwise defines the twirl
  29520. * @param tiltRight defines the tilt
  29521. * @returns the current mesh
  29522. */
  29523. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  29524. /**
  29525. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  29526. * Supports definition of mesh facing forward or backward.
  29527. * @param flipBack defines the flip
  29528. * @param twirlClockwise defines the twirl
  29529. * @param tiltRight defines the tilt
  29530. * @returns the new rotation vector
  29531. */
  29532. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  29533. /**
  29534. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29535. * This means the mesh underlying bounding box and sphere are recomputed.
  29536. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29537. * @returns the current mesh
  29538. */
  29539. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  29540. /** @hidden */
  29541. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  29542. /** @hidden */
  29543. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  29544. /** @hidden */
  29545. _updateBoundingInfo(): AbstractMesh;
  29546. /** @hidden */
  29547. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  29548. /** @hidden */
  29549. protected _afterComputeWorldMatrix(): void;
  29550. /** @hidden */
  29551. get _effectiveMesh(): AbstractMesh;
  29552. /**
  29553. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29554. * A mesh is in the frustum if its bounding box intersects the frustum
  29555. * @param frustumPlanes defines the frustum to test
  29556. * @returns true if the mesh is in the frustum planes
  29557. */
  29558. isInFrustum(frustumPlanes: Plane[]): boolean;
  29559. /**
  29560. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  29561. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  29562. * @param frustumPlanes defines the frustum to test
  29563. * @returns true if the mesh is completely in the frustum planes
  29564. */
  29565. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  29566. /**
  29567. * True if the mesh intersects another mesh or a SolidParticle object
  29568. * @param mesh defines a target mesh or SolidParticle to test
  29569. * @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)
  29570. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  29571. * @returns true if there is an intersection
  29572. */
  29573. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  29574. /**
  29575. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  29576. * @param point defines the point to test
  29577. * @returns true if there is an intersection
  29578. */
  29579. intersectsPoint(point: Vector3): boolean;
  29580. /**
  29581. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  29582. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29583. */
  29584. get checkCollisions(): boolean;
  29585. set checkCollisions(collisionEnabled: boolean);
  29586. /**
  29587. * Gets Collider object used to compute collisions (not physics)
  29588. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29589. */
  29590. get collider(): Nullable<Collider>;
  29591. /**
  29592. * Move the mesh using collision engine
  29593. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  29594. * @param displacement defines the requested displacement vector
  29595. * @returns the current mesh
  29596. */
  29597. moveWithCollisions(displacement: Vector3): AbstractMesh;
  29598. private _onCollisionPositionChange;
  29599. /** @hidden */
  29600. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  29601. /** @hidden */
  29602. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  29603. /** @hidden */
  29604. _checkCollision(collider: Collider): AbstractMesh;
  29605. /** @hidden */
  29606. _generatePointsArray(): boolean;
  29607. /**
  29608. * Checks if the passed Ray intersects with the mesh
  29609. * @param ray defines the ray to use
  29610. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  29611. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  29612. * @returns the picking info
  29613. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  29614. */
  29615. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  29616. /**
  29617. * Clones the current mesh
  29618. * @param name defines the mesh name
  29619. * @param newParent defines the new mesh parent
  29620. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  29621. * @returns the new mesh
  29622. */
  29623. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  29624. /**
  29625. * Disposes all the submeshes of the current meshnp
  29626. * @returns the current mesh
  29627. */
  29628. releaseSubMeshes(): AbstractMesh;
  29629. /**
  29630. * Releases resources associated with this abstract mesh.
  29631. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29632. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29633. */
  29634. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29635. /**
  29636. * Adds the passed mesh as a child to the current mesh
  29637. * @param mesh defines the child mesh
  29638. * @returns the current mesh
  29639. */
  29640. addChild(mesh: AbstractMesh): AbstractMesh;
  29641. /**
  29642. * Removes the passed mesh from the current mesh children list
  29643. * @param mesh defines the child mesh
  29644. * @returns the current mesh
  29645. */
  29646. removeChild(mesh: AbstractMesh): AbstractMesh;
  29647. /** @hidden */
  29648. private _initFacetData;
  29649. /**
  29650. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  29651. * This method can be called within the render loop.
  29652. * 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
  29653. * @returns the current mesh
  29654. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29655. */
  29656. updateFacetData(): AbstractMesh;
  29657. /**
  29658. * Returns the facetLocalNormals array.
  29659. * The normals are expressed in the mesh local spac
  29660. * @returns an array of Vector3
  29661. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29662. */
  29663. getFacetLocalNormals(): Vector3[];
  29664. /**
  29665. * Returns the facetLocalPositions array.
  29666. * The facet positions are expressed in the mesh local space
  29667. * @returns an array of Vector3
  29668. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29669. */
  29670. getFacetLocalPositions(): Vector3[];
  29671. /**
  29672. * Returns the facetLocalPartioning array
  29673. * @returns an array of array of numbers
  29674. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29675. */
  29676. getFacetLocalPartitioning(): number[][];
  29677. /**
  29678. * Returns the i-th facet position in the world system.
  29679. * This method allocates a new Vector3 per call
  29680. * @param i defines the facet index
  29681. * @returns a new Vector3
  29682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29683. */
  29684. getFacetPosition(i: number): Vector3;
  29685. /**
  29686. * Sets the reference Vector3 with the i-th facet position in the world system
  29687. * @param i defines the facet index
  29688. * @param ref defines the target vector
  29689. * @returns the current mesh
  29690. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29691. */
  29692. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  29693. /**
  29694. * Returns the i-th facet normal in the world system.
  29695. * This method allocates a new Vector3 per call
  29696. * @param i defines the facet index
  29697. * @returns a new Vector3
  29698. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29699. */
  29700. getFacetNormal(i: number): Vector3;
  29701. /**
  29702. * Sets the reference Vector3 with the i-th facet normal in the world system
  29703. * @param i defines the facet index
  29704. * @param ref defines the target vector
  29705. * @returns the current mesh
  29706. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29707. */
  29708. getFacetNormalToRef(i: number, ref: Vector3): this;
  29709. /**
  29710. * 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)
  29711. * @param x defines x coordinate
  29712. * @param y defines y coordinate
  29713. * @param z defines z coordinate
  29714. * @returns the array of facet indexes
  29715. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29716. */
  29717. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  29718. /**
  29719. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  29720. * @param projected sets as the (x,y,z) world projection on the facet
  29721. * @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
  29722. * @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
  29723. * @param x defines x coordinate
  29724. * @param y defines y coordinate
  29725. * @param z defines z coordinate
  29726. * @returns the face index if found (or null instead)
  29727. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29728. */
  29729. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29730. /**
  29731. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  29732. * @param projected sets as the (x,y,z) local projection on the facet
  29733. * @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
  29734. * @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
  29735. * @param x defines x coordinate
  29736. * @param y defines y coordinate
  29737. * @param z defines z coordinate
  29738. * @returns the face index if found (or null instead)
  29739. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29740. */
  29741. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  29742. /**
  29743. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  29744. * @returns the parameters
  29745. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29746. */
  29747. getFacetDataParameters(): any;
  29748. /**
  29749. * Disables the feature FacetData and frees the related memory
  29750. * @returns the current mesh
  29751. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  29752. */
  29753. disableFacetData(): AbstractMesh;
  29754. /**
  29755. * Updates the AbstractMesh indices array
  29756. * @param indices defines the data source
  29757. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29758. * @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)
  29759. * @returns the current mesh
  29760. */
  29761. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29762. /**
  29763. * Creates new normals data for the mesh
  29764. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  29765. * @returns the current mesh
  29766. */
  29767. createNormals(updatable: boolean): AbstractMesh;
  29768. /**
  29769. * Align the mesh with a normal
  29770. * @param normal defines the normal to use
  29771. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  29772. * @returns the current mesh
  29773. */
  29774. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  29775. /** @hidden */
  29776. _checkOcclusionQuery(): boolean;
  29777. /**
  29778. * Disables the mesh edge rendering mode
  29779. * @returns the currentAbstractMesh
  29780. */
  29781. disableEdgesRendering(): AbstractMesh;
  29782. /**
  29783. * Enables the edge rendering mode on the mesh.
  29784. * This mode makes the mesh edges visible
  29785. * @param epsilon defines the maximal distance between two angles to detect a face
  29786. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  29787. * @returns the currentAbstractMesh
  29788. * @see https://www.babylonjs-playground.com/#19O9TU#0
  29789. */
  29790. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  29791. }
  29792. }
  29793. declare module "babylonjs/Actions/actionEvent" {
  29794. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29795. import { Nullable } from "babylonjs/types";
  29796. import { Sprite } from "babylonjs/Sprites/sprite";
  29797. import { Scene } from "babylonjs/scene";
  29798. import { Vector2 } from "babylonjs/Maths/math.vector";
  29799. /**
  29800. * Interface used to define ActionEvent
  29801. */
  29802. export interface IActionEvent {
  29803. /** The mesh or sprite that triggered the action */
  29804. source: any;
  29805. /** The X mouse cursor position at the time of the event */
  29806. pointerX: number;
  29807. /** The Y mouse cursor position at the time of the event */
  29808. pointerY: number;
  29809. /** The mesh that is currently pointed at (can be null) */
  29810. meshUnderPointer: Nullable<AbstractMesh>;
  29811. /** the original (browser) event that triggered the ActionEvent */
  29812. sourceEvent?: any;
  29813. /** additional data for the event */
  29814. additionalData?: any;
  29815. }
  29816. /**
  29817. * ActionEvent is the event being sent when an action is triggered.
  29818. */
  29819. export class ActionEvent implements IActionEvent {
  29820. /** The mesh or sprite that triggered the action */
  29821. source: any;
  29822. /** The X mouse cursor position at the time of the event */
  29823. pointerX: number;
  29824. /** The Y mouse cursor position at the time of the event */
  29825. pointerY: number;
  29826. /** The mesh that is currently pointed at (can be null) */
  29827. meshUnderPointer: Nullable<AbstractMesh>;
  29828. /** the original (browser) event that triggered the ActionEvent */
  29829. sourceEvent?: any;
  29830. /** additional data for the event */
  29831. additionalData?: any;
  29832. /**
  29833. * Creates a new ActionEvent
  29834. * @param source The mesh or sprite that triggered the action
  29835. * @param pointerX The X mouse cursor position at the time of the event
  29836. * @param pointerY The Y mouse cursor position at the time of the event
  29837. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  29838. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  29839. * @param additionalData additional data for the event
  29840. */
  29841. constructor(
  29842. /** The mesh or sprite that triggered the action */
  29843. source: any,
  29844. /** The X mouse cursor position at the time of the event */
  29845. pointerX: number,
  29846. /** The Y mouse cursor position at the time of the event */
  29847. pointerY: number,
  29848. /** The mesh that is currently pointed at (can be null) */
  29849. meshUnderPointer: Nullable<AbstractMesh>,
  29850. /** the original (browser) event that triggered the ActionEvent */
  29851. sourceEvent?: any,
  29852. /** additional data for the event */
  29853. additionalData?: any);
  29854. /**
  29855. * Helper function to auto-create an ActionEvent from a source mesh.
  29856. * @param source The source mesh that triggered the event
  29857. * @param evt The original (browser) event
  29858. * @param additionalData additional data for the event
  29859. * @returns the new ActionEvent
  29860. */
  29861. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  29862. /**
  29863. * Helper function to auto-create an ActionEvent from a source sprite
  29864. * @param source The source sprite that triggered the event
  29865. * @param scene Scene associated with the sprite
  29866. * @param evt The original (browser) event
  29867. * @param additionalData additional data for the event
  29868. * @returns the new ActionEvent
  29869. */
  29870. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  29871. /**
  29872. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  29873. * @param scene the scene where the event occurred
  29874. * @param evt The original (browser) event
  29875. * @returns the new ActionEvent
  29876. */
  29877. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  29878. /**
  29879. * Helper function to auto-create an ActionEvent from a primitive
  29880. * @param prim defines the target primitive
  29881. * @param pointerPos defines the pointer position
  29882. * @param evt The original (browser) event
  29883. * @param additionalData additional data for the event
  29884. * @returns the new ActionEvent
  29885. */
  29886. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  29887. }
  29888. }
  29889. declare module "babylonjs/Actions/abstractActionManager" {
  29890. import { IDisposable } from "babylonjs/scene";
  29891. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  29892. import { IAction } from "babylonjs/Actions/action";
  29893. import { Nullable } from "babylonjs/types";
  29894. /**
  29895. * Abstract class used to decouple action Manager from scene and meshes.
  29896. * Do not instantiate.
  29897. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  29898. */
  29899. export abstract class AbstractActionManager implements IDisposable {
  29900. /** Gets the list of active triggers */
  29901. static Triggers: {
  29902. [key: string]: number;
  29903. };
  29904. /** Gets the cursor to use when hovering items */
  29905. hoverCursor: string;
  29906. /** Gets the list of actions */
  29907. actions: IAction[];
  29908. /**
  29909. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  29910. */
  29911. isRecursive: boolean;
  29912. /**
  29913. * Releases all associated resources
  29914. */
  29915. abstract dispose(): void;
  29916. /**
  29917. * Does this action manager has pointer triggers
  29918. */
  29919. abstract get hasPointerTriggers(): boolean;
  29920. /**
  29921. * Does this action manager has pick triggers
  29922. */
  29923. abstract get hasPickTriggers(): boolean;
  29924. /**
  29925. * Process a specific trigger
  29926. * @param trigger defines the trigger to process
  29927. * @param evt defines the event details to be processed
  29928. */
  29929. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  29930. /**
  29931. * Does this action manager handles actions of any of the given triggers
  29932. * @param triggers defines the triggers to be tested
  29933. * @return a boolean indicating whether one (or more) of the triggers is handled
  29934. */
  29935. abstract hasSpecificTriggers(triggers: number[]): boolean;
  29936. /**
  29937. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  29938. * speed.
  29939. * @param triggerA defines the trigger to be tested
  29940. * @param triggerB defines the trigger to be tested
  29941. * @return a boolean indicating whether one (or more) of the triggers is handled
  29942. */
  29943. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  29944. /**
  29945. * Does this action manager handles actions of a given trigger
  29946. * @param trigger defines the trigger to be tested
  29947. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  29948. * @return whether the trigger is handled
  29949. */
  29950. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  29951. /**
  29952. * Serialize this manager to a JSON object
  29953. * @param name defines the property name to store this manager
  29954. * @returns a JSON representation of this manager
  29955. */
  29956. abstract serialize(name: string): any;
  29957. /**
  29958. * Registers an action to this action manager
  29959. * @param action defines the action to be registered
  29960. * @return the action amended (prepared) after registration
  29961. */
  29962. abstract registerAction(action: IAction): Nullable<IAction>;
  29963. /**
  29964. * Unregisters an action to this action manager
  29965. * @param action defines the action to be unregistered
  29966. * @return a boolean indicating whether the action has been unregistered
  29967. */
  29968. abstract unregisterAction(action: IAction): Boolean;
  29969. /**
  29970. * Does exist one action manager with at least one trigger
  29971. **/
  29972. static get HasTriggers(): boolean;
  29973. /**
  29974. * Does exist one action manager with at least one pick trigger
  29975. **/
  29976. static get HasPickTriggers(): boolean;
  29977. /**
  29978. * Does exist one action manager that handles actions of a given trigger
  29979. * @param trigger defines the trigger to be tested
  29980. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  29981. **/
  29982. static HasSpecificTrigger(trigger: number): boolean;
  29983. }
  29984. }
  29985. declare module "babylonjs/node" {
  29986. import { Scene } from "babylonjs/scene";
  29987. import { Nullable } from "babylonjs/types";
  29988. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  29989. import { Engine } from "babylonjs/Engines/engine";
  29990. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  29991. import { Observable } from "babylonjs/Misc/observable";
  29992. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  29993. import { IInspectable } from "babylonjs/Misc/iInspectable";
  29994. import { Animatable } from "babylonjs/Animations/animatable";
  29995. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  29996. import { Animation } from "babylonjs/Animations/animation";
  29997. import { AnimationRange } from "babylonjs/Animations/animationRange";
  29998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29999. /**
  30000. * Defines how a node can be built from a string name.
  30001. */
  30002. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  30003. /**
  30004. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  30005. */
  30006. export class Node implements IBehaviorAware<Node> {
  30007. /** @hidden */
  30008. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  30009. private static _NodeConstructors;
  30010. /**
  30011. * Add a new node constructor
  30012. * @param type defines the type name of the node to construct
  30013. * @param constructorFunc defines the constructor function
  30014. */
  30015. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  30016. /**
  30017. * Returns a node constructor based on type name
  30018. * @param type defines the type name
  30019. * @param name defines the new node name
  30020. * @param scene defines the hosting scene
  30021. * @param options defines optional options to transmit to constructors
  30022. * @returns the new constructor or null
  30023. */
  30024. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  30025. /**
  30026. * Gets or sets the name of the node
  30027. */
  30028. name: string;
  30029. /**
  30030. * Gets or sets the id of the node
  30031. */
  30032. id: string;
  30033. /**
  30034. * Gets or sets the unique id of the node
  30035. */
  30036. uniqueId: number;
  30037. /**
  30038. * Gets or sets a string used to store user defined state for the node
  30039. */
  30040. state: string;
  30041. /**
  30042. * Gets or sets an object used to store user defined information for the node
  30043. */
  30044. metadata: any;
  30045. /**
  30046. * For internal use only. Please do not use.
  30047. */
  30048. reservedDataStore: any;
  30049. /**
  30050. * List of inspectable custom properties (used by the Inspector)
  30051. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  30052. */
  30053. inspectableCustomProperties: IInspectable[];
  30054. private _doNotSerialize;
  30055. /**
  30056. * Gets or sets a boolean used to define if the node must be serialized
  30057. */
  30058. get doNotSerialize(): boolean;
  30059. set doNotSerialize(value: boolean);
  30060. /** @hidden */
  30061. _isDisposed: boolean;
  30062. /**
  30063. * Gets a list of Animations associated with the node
  30064. */
  30065. animations: import("babylonjs/Animations/animation").Animation[];
  30066. protected _ranges: {
  30067. [name: string]: Nullable<AnimationRange>;
  30068. };
  30069. /**
  30070. * Callback raised when the node is ready to be used
  30071. */
  30072. onReady: Nullable<(node: Node) => void>;
  30073. private _isEnabled;
  30074. private _isParentEnabled;
  30075. private _isReady;
  30076. /** @hidden */
  30077. _currentRenderId: number;
  30078. private _parentUpdateId;
  30079. /** @hidden */
  30080. _childUpdateId: number;
  30081. /** @hidden */
  30082. _waitingParentId: Nullable<string>;
  30083. /** @hidden */
  30084. _scene: Scene;
  30085. /** @hidden */
  30086. _cache: any;
  30087. private _parentNode;
  30088. private _children;
  30089. /** @hidden */
  30090. _worldMatrix: Matrix;
  30091. /** @hidden */
  30092. _worldMatrixDeterminant: number;
  30093. /** @hidden */
  30094. _worldMatrixDeterminantIsDirty: boolean;
  30095. /** @hidden */
  30096. private _sceneRootNodesIndex;
  30097. /**
  30098. * Gets a boolean indicating if the node has been disposed
  30099. * @returns true if the node was disposed
  30100. */
  30101. isDisposed(): boolean;
  30102. /**
  30103. * Gets or sets the parent of the node (without keeping the current position in the scene)
  30104. * @see https://doc.babylonjs.com/how_to/parenting
  30105. */
  30106. set parent(parent: Nullable<Node>);
  30107. get parent(): Nullable<Node>;
  30108. /** @hidden */
  30109. _addToSceneRootNodes(): void;
  30110. /** @hidden */
  30111. _removeFromSceneRootNodes(): void;
  30112. private _animationPropertiesOverride;
  30113. /**
  30114. * Gets or sets the animation properties override
  30115. */
  30116. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  30117. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  30118. /**
  30119. * Gets a string idenfifying the name of the class
  30120. * @returns "Node" string
  30121. */
  30122. getClassName(): string;
  30123. /** @hidden */
  30124. readonly _isNode: boolean;
  30125. /**
  30126. * An event triggered when the mesh is disposed
  30127. */
  30128. onDisposeObservable: Observable<Node>;
  30129. private _onDisposeObserver;
  30130. /**
  30131. * Sets a callback that will be raised when the node will be disposed
  30132. */
  30133. set onDispose(callback: () => void);
  30134. /**
  30135. * Creates a new Node
  30136. * @param name the name and id to be given to this node
  30137. * @param scene the scene this node will be added to
  30138. */
  30139. constructor(name: string, scene?: Nullable<Scene>);
  30140. /**
  30141. * Gets the scene of the node
  30142. * @returns a scene
  30143. */
  30144. getScene(): Scene;
  30145. /**
  30146. * Gets the engine of the node
  30147. * @returns a Engine
  30148. */
  30149. getEngine(): Engine;
  30150. private _behaviors;
  30151. /**
  30152. * Attach a behavior to the node
  30153. * @see http://doc.babylonjs.com/features/behaviour
  30154. * @param behavior defines the behavior to attach
  30155. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  30156. * @returns the current Node
  30157. */
  30158. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  30159. /**
  30160. * Remove an attached behavior
  30161. * @see http://doc.babylonjs.com/features/behaviour
  30162. * @param behavior defines the behavior to attach
  30163. * @returns the current Node
  30164. */
  30165. removeBehavior(behavior: Behavior<Node>): Node;
  30166. /**
  30167. * Gets the list of attached behaviors
  30168. * @see http://doc.babylonjs.com/features/behaviour
  30169. */
  30170. get behaviors(): Behavior<Node>[];
  30171. /**
  30172. * Gets an attached behavior by name
  30173. * @param name defines the name of the behavior to look for
  30174. * @see http://doc.babylonjs.com/features/behaviour
  30175. * @returns null if behavior was not found else the requested behavior
  30176. */
  30177. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  30178. /**
  30179. * Returns the latest update of the World matrix
  30180. * @returns a Matrix
  30181. */
  30182. getWorldMatrix(): Matrix;
  30183. /** @hidden */
  30184. _getWorldMatrixDeterminant(): number;
  30185. /**
  30186. * Returns directly the latest state of the mesh World matrix.
  30187. * A Matrix is returned.
  30188. */
  30189. get worldMatrixFromCache(): Matrix;
  30190. /** @hidden */
  30191. _initCache(): void;
  30192. /** @hidden */
  30193. updateCache(force?: boolean): void;
  30194. /** @hidden */
  30195. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  30196. /** @hidden */
  30197. _updateCache(ignoreParentClass?: boolean): void;
  30198. /** @hidden */
  30199. _isSynchronized(): boolean;
  30200. /** @hidden */
  30201. _markSyncedWithParent(): void;
  30202. /** @hidden */
  30203. isSynchronizedWithParent(): boolean;
  30204. /** @hidden */
  30205. isSynchronized(): boolean;
  30206. /**
  30207. * Is this node ready to be used/rendered
  30208. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  30209. * @return true if the node is ready
  30210. */
  30211. isReady(completeCheck?: boolean): boolean;
  30212. /**
  30213. * Is this node enabled?
  30214. * 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
  30215. * @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
  30216. * @return whether this node (and its parent) is enabled
  30217. */
  30218. isEnabled(checkAncestors?: boolean): boolean;
  30219. /** @hidden */
  30220. protected _syncParentEnabledState(): void;
  30221. /**
  30222. * Set the enabled state of this node
  30223. * @param value defines the new enabled state
  30224. */
  30225. setEnabled(value: boolean): void;
  30226. /**
  30227. * Is this node a descendant of the given node?
  30228. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  30229. * @param ancestor defines the parent node to inspect
  30230. * @returns a boolean indicating if this node is a descendant of the given node
  30231. */
  30232. isDescendantOf(ancestor: Node): boolean;
  30233. /** @hidden */
  30234. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  30235. /**
  30236. * Will return all nodes that have this node as ascendant
  30237. * @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
  30238. * @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
  30239. * @return all children nodes of all types
  30240. */
  30241. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  30242. /**
  30243. * Get all child-meshes of this node
  30244. * @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)
  30245. * @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
  30246. * @returns an array of AbstractMesh
  30247. */
  30248. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  30249. /**
  30250. * Get all direct children of this node
  30251. * @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
  30252. * @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)
  30253. * @returns an array of Node
  30254. */
  30255. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  30256. /** @hidden */
  30257. _setReady(state: boolean): void;
  30258. /**
  30259. * Get an animation by name
  30260. * @param name defines the name of the animation to look for
  30261. * @returns null if not found else the requested animation
  30262. */
  30263. getAnimationByName(name: string): Nullable<Animation>;
  30264. /**
  30265. * Creates an animation range for this node
  30266. * @param name defines the name of the range
  30267. * @param from defines the starting key
  30268. * @param to defines the end key
  30269. */
  30270. createAnimationRange(name: string, from: number, to: number): void;
  30271. /**
  30272. * Delete a specific animation range
  30273. * @param name defines the name of the range to delete
  30274. * @param deleteFrames defines if animation frames from the range must be deleted as well
  30275. */
  30276. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  30277. /**
  30278. * Get an animation range by name
  30279. * @param name defines the name of the animation range to look for
  30280. * @returns null if not found else the requested animation range
  30281. */
  30282. getAnimationRange(name: string): Nullable<AnimationRange>;
  30283. /**
  30284. * Gets the list of all animation ranges defined on this node
  30285. * @returns an array
  30286. */
  30287. getAnimationRanges(): Nullable<AnimationRange>[];
  30288. /**
  30289. * Will start the animation sequence
  30290. * @param name defines the range frames for animation sequence
  30291. * @param loop defines if the animation should loop (false by default)
  30292. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  30293. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  30294. * @returns the object created for this animation. If range does not exist, it will return null
  30295. */
  30296. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  30297. /**
  30298. * Serialize animation ranges into a JSON compatible object
  30299. * @returns serialization object
  30300. */
  30301. serializeAnimationRanges(): any;
  30302. /**
  30303. * Computes the world matrix of the node
  30304. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  30305. * @returns the world matrix
  30306. */
  30307. computeWorldMatrix(force?: boolean): Matrix;
  30308. /**
  30309. * Releases resources associated with this node.
  30310. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30311. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30312. */
  30313. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30314. /**
  30315. * Parse animation range data from a serialization object and store them into a given node
  30316. * @param node defines where to store the animation ranges
  30317. * @param parsedNode defines the serialization object to read data from
  30318. * @param scene defines the hosting scene
  30319. */
  30320. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  30321. /**
  30322. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  30323. * @param includeDescendants Include bounding info from descendants as well (true by default)
  30324. * @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
  30325. * @returns the new bounding vectors
  30326. */
  30327. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  30328. min: Vector3;
  30329. max: Vector3;
  30330. };
  30331. }
  30332. }
  30333. declare module "babylonjs/Animations/animation" {
  30334. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  30335. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  30336. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  30337. import { Nullable } from "babylonjs/types";
  30338. import { Scene } from "babylonjs/scene";
  30339. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  30340. import { AnimationRange } from "babylonjs/Animations/animationRange";
  30341. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  30342. import { Node } from "babylonjs/node";
  30343. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30344. import { Size } from "babylonjs/Maths/math.size";
  30345. import { Animatable } from "babylonjs/Animations/animatable";
  30346. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  30347. /**
  30348. * @hidden
  30349. */
  30350. export class _IAnimationState {
  30351. key: number;
  30352. repeatCount: number;
  30353. workValue?: any;
  30354. loopMode?: number;
  30355. offsetValue?: any;
  30356. highLimitValue?: any;
  30357. }
  30358. /**
  30359. * Class used to store any kind of animation
  30360. */
  30361. export class Animation {
  30362. /**Name of the animation */
  30363. name: string;
  30364. /**Property to animate */
  30365. targetProperty: string;
  30366. /**The frames per second of the animation */
  30367. framePerSecond: number;
  30368. /**The data type of the animation */
  30369. dataType: number;
  30370. /**The loop mode of the animation */
  30371. loopMode?: number | undefined;
  30372. /**Specifies if blending should be enabled */
  30373. enableBlending?: boolean | undefined;
  30374. /**
  30375. * Use matrix interpolation instead of using direct key value when animating matrices
  30376. */
  30377. static AllowMatricesInterpolation: boolean;
  30378. /**
  30379. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  30380. */
  30381. static AllowMatrixDecomposeForInterpolation: boolean;
  30382. /**
  30383. * Stores the key frames of the animation
  30384. */
  30385. private _keys;
  30386. /**
  30387. * Stores the easing function of the animation
  30388. */
  30389. private _easingFunction;
  30390. /**
  30391. * @hidden Internal use only
  30392. */
  30393. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  30394. /**
  30395. * The set of event that will be linked to this animation
  30396. */
  30397. private _events;
  30398. /**
  30399. * Stores an array of target property paths
  30400. */
  30401. targetPropertyPath: string[];
  30402. /**
  30403. * Stores the blending speed of the animation
  30404. */
  30405. blendingSpeed: number;
  30406. /**
  30407. * Stores the animation ranges for the animation
  30408. */
  30409. private _ranges;
  30410. /**
  30411. * @hidden Internal use
  30412. */
  30413. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  30414. /**
  30415. * Sets up an animation
  30416. * @param property The property to animate
  30417. * @param animationType The animation type to apply
  30418. * @param framePerSecond The frames per second of the animation
  30419. * @param easingFunction The easing function used in the animation
  30420. * @returns The created animation
  30421. */
  30422. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  30423. /**
  30424. * Create and start an animation on a node
  30425. * @param name defines the name of the global animation that will be run on all nodes
  30426. * @param node defines the root node where the animation will take place
  30427. * @param targetProperty defines property to animate
  30428. * @param framePerSecond defines the number of frame per second yo use
  30429. * @param totalFrame defines the number of frames in total
  30430. * @param from defines the initial value
  30431. * @param to defines the final value
  30432. * @param loopMode defines which loop mode you want to use (off by default)
  30433. * @param easingFunction defines the easing function to use (linear by default)
  30434. * @param onAnimationEnd defines the callback to call when animation end
  30435. * @returns the animatable created for this animation
  30436. */
  30437. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30438. /**
  30439. * Create and start an animation on a node and its descendants
  30440. * @param name defines the name of the global animation that will be run on all nodes
  30441. * @param node defines the root node where the animation will take place
  30442. * @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
  30443. * @param targetProperty defines property to animate
  30444. * @param framePerSecond defines the number of frame per second to use
  30445. * @param totalFrame defines the number of frames in total
  30446. * @param from defines the initial value
  30447. * @param to defines the final value
  30448. * @param loopMode defines which loop mode you want to use (off by default)
  30449. * @param easingFunction defines the easing function to use (linear by default)
  30450. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  30451. * @returns the list of animatables created for all nodes
  30452. * @example https://www.babylonjs-playground.com/#MH0VLI
  30453. */
  30454. 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[]>;
  30455. /**
  30456. * Creates a new animation, merges it with the existing animations and starts it
  30457. * @param name Name of the animation
  30458. * @param node Node which contains the scene that begins the animations
  30459. * @param targetProperty Specifies which property to animate
  30460. * @param framePerSecond The frames per second of the animation
  30461. * @param totalFrame The total number of frames
  30462. * @param from The frame at the beginning of the animation
  30463. * @param to The frame at the end of the animation
  30464. * @param loopMode Specifies the loop mode of the animation
  30465. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  30466. * @param onAnimationEnd Callback to run once the animation is complete
  30467. * @returns Nullable animation
  30468. */
  30469. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  30470. /**
  30471. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  30472. * @param sourceAnimation defines the Animation containing keyframes to convert
  30473. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  30474. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  30475. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  30476. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  30477. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  30478. */
  30479. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  30480. /**
  30481. * Transition property of an host to the target Value
  30482. * @param property The property to transition
  30483. * @param targetValue The target Value of the property
  30484. * @param host The object where the property to animate belongs
  30485. * @param scene Scene used to run the animation
  30486. * @param frameRate Framerate (in frame/s) to use
  30487. * @param transition The transition type we want to use
  30488. * @param duration The duration of the animation, in milliseconds
  30489. * @param onAnimationEnd Callback trigger at the end of the animation
  30490. * @returns Nullable animation
  30491. */
  30492. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  30493. /**
  30494. * Return the array of runtime animations currently using this animation
  30495. */
  30496. get runtimeAnimations(): RuntimeAnimation[];
  30497. /**
  30498. * Specifies if any of the runtime animations are currently running
  30499. */
  30500. get hasRunningRuntimeAnimations(): boolean;
  30501. /**
  30502. * Initializes the animation
  30503. * @param name Name of the animation
  30504. * @param targetProperty Property to animate
  30505. * @param framePerSecond The frames per second of the animation
  30506. * @param dataType The data type of the animation
  30507. * @param loopMode The loop mode of the animation
  30508. * @param enableBlending Specifies if blending should be enabled
  30509. */
  30510. constructor(
  30511. /**Name of the animation */
  30512. name: string,
  30513. /**Property to animate */
  30514. targetProperty: string,
  30515. /**The frames per second of the animation */
  30516. framePerSecond: number,
  30517. /**The data type of the animation */
  30518. dataType: number,
  30519. /**The loop mode of the animation */
  30520. loopMode?: number | undefined,
  30521. /**Specifies if blending should be enabled */
  30522. enableBlending?: boolean | undefined);
  30523. /**
  30524. * Converts the animation to a string
  30525. * @param fullDetails support for multiple levels of logging within scene loading
  30526. * @returns String form of the animation
  30527. */
  30528. toString(fullDetails?: boolean): string;
  30529. /**
  30530. * Add an event to this animation
  30531. * @param event Event to add
  30532. */
  30533. addEvent(event: AnimationEvent): void;
  30534. /**
  30535. * Remove all events found at the given frame
  30536. * @param frame The frame to remove events from
  30537. */
  30538. removeEvents(frame: number): void;
  30539. /**
  30540. * Retrieves all the events from the animation
  30541. * @returns Events from the animation
  30542. */
  30543. getEvents(): AnimationEvent[];
  30544. /**
  30545. * Creates an animation range
  30546. * @param name Name of the animation range
  30547. * @param from Starting frame of the animation range
  30548. * @param to Ending frame of the animation
  30549. */
  30550. createRange(name: string, from: number, to: number): void;
  30551. /**
  30552. * Deletes an animation range by name
  30553. * @param name Name of the animation range to delete
  30554. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  30555. */
  30556. deleteRange(name: string, deleteFrames?: boolean): void;
  30557. /**
  30558. * Gets the animation range by name, or null if not defined
  30559. * @param name Name of the animation range
  30560. * @returns Nullable animation range
  30561. */
  30562. getRange(name: string): Nullable<AnimationRange>;
  30563. /**
  30564. * Gets the key frames from the animation
  30565. * @returns The key frames of the animation
  30566. */
  30567. getKeys(): Array<IAnimationKey>;
  30568. /**
  30569. * Gets the highest frame rate of the animation
  30570. * @returns Highest frame rate of the animation
  30571. */
  30572. getHighestFrame(): number;
  30573. /**
  30574. * Gets the easing function of the animation
  30575. * @returns Easing function of the animation
  30576. */
  30577. getEasingFunction(): IEasingFunction;
  30578. /**
  30579. * Sets the easing function of the animation
  30580. * @param easingFunction A custom mathematical formula for animation
  30581. */
  30582. setEasingFunction(easingFunction: EasingFunction): void;
  30583. /**
  30584. * Interpolates a scalar linearly
  30585. * @param startValue Start value of the animation curve
  30586. * @param endValue End value of the animation curve
  30587. * @param gradient Scalar amount to interpolate
  30588. * @returns Interpolated scalar value
  30589. */
  30590. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  30591. /**
  30592. * Interpolates a scalar cubically
  30593. * @param startValue Start value of the animation curve
  30594. * @param outTangent End tangent of the animation
  30595. * @param endValue End value of the animation curve
  30596. * @param inTangent Start tangent of the animation curve
  30597. * @param gradient Scalar amount to interpolate
  30598. * @returns Interpolated scalar value
  30599. */
  30600. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  30601. /**
  30602. * Interpolates a quaternion using a spherical linear interpolation
  30603. * @param startValue Start value of the animation curve
  30604. * @param endValue End value of the animation curve
  30605. * @param gradient Scalar amount to interpolate
  30606. * @returns Interpolated quaternion value
  30607. */
  30608. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  30609. /**
  30610. * Interpolates a quaternion cubically
  30611. * @param startValue Start value of the animation curve
  30612. * @param outTangent End tangent of the animation curve
  30613. * @param endValue End value of the animation curve
  30614. * @param inTangent Start tangent of the animation curve
  30615. * @param gradient Scalar amount to interpolate
  30616. * @returns Interpolated quaternion value
  30617. */
  30618. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  30619. /**
  30620. * Interpolates a Vector3 linearl
  30621. * @param startValue Start value of the animation curve
  30622. * @param endValue End value of the animation curve
  30623. * @param gradient Scalar amount to interpolate
  30624. * @returns Interpolated scalar value
  30625. */
  30626. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  30627. /**
  30628. * Interpolates a Vector3 cubically
  30629. * @param startValue Start value of the animation curve
  30630. * @param outTangent End tangent of the animation
  30631. * @param endValue End value of the animation curve
  30632. * @param inTangent Start tangent of the animation curve
  30633. * @param gradient Scalar amount to interpolate
  30634. * @returns InterpolatedVector3 value
  30635. */
  30636. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  30637. /**
  30638. * Interpolates a Vector2 linearly
  30639. * @param startValue Start value of the animation curve
  30640. * @param endValue End value of the animation curve
  30641. * @param gradient Scalar amount to interpolate
  30642. * @returns Interpolated Vector2 value
  30643. */
  30644. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  30645. /**
  30646. * Interpolates a Vector2 cubically
  30647. * @param startValue Start value of the animation curve
  30648. * @param outTangent End tangent of the animation
  30649. * @param endValue End value of the animation curve
  30650. * @param inTangent Start tangent of the animation curve
  30651. * @param gradient Scalar amount to interpolate
  30652. * @returns Interpolated Vector2 value
  30653. */
  30654. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  30655. /**
  30656. * Interpolates a size linearly
  30657. * @param startValue Start value of the animation curve
  30658. * @param endValue End value of the animation curve
  30659. * @param gradient Scalar amount to interpolate
  30660. * @returns Interpolated Size value
  30661. */
  30662. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  30663. /**
  30664. * Interpolates a Color3 linearly
  30665. * @param startValue Start value of the animation curve
  30666. * @param endValue End value of the animation curve
  30667. * @param gradient Scalar amount to interpolate
  30668. * @returns Interpolated Color3 value
  30669. */
  30670. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  30671. /**
  30672. * Interpolates a Color4 linearly
  30673. * @param startValue Start value of the animation curve
  30674. * @param endValue End value of the animation curve
  30675. * @param gradient Scalar amount to interpolate
  30676. * @returns Interpolated Color3 value
  30677. */
  30678. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  30679. /**
  30680. * @hidden Internal use only
  30681. */
  30682. _getKeyValue(value: any): any;
  30683. /**
  30684. * @hidden Internal use only
  30685. */
  30686. _interpolate(currentFrame: number, state: _IAnimationState): any;
  30687. /**
  30688. * Defines the function to use to interpolate matrices
  30689. * @param startValue defines the start matrix
  30690. * @param endValue defines the end matrix
  30691. * @param gradient defines the gradient between both matrices
  30692. * @param result defines an optional target matrix where to store the interpolation
  30693. * @returns the interpolated matrix
  30694. */
  30695. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  30696. /**
  30697. * Makes a copy of the animation
  30698. * @returns Cloned animation
  30699. */
  30700. clone(): Animation;
  30701. /**
  30702. * Sets the key frames of the animation
  30703. * @param values The animation key frames to set
  30704. */
  30705. setKeys(values: Array<IAnimationKey>): void;
  30706. /**
  30707. * Serializes the animation to an object
  30708. * @returns Serialized object
  30709. */
  30710. serialize(): any;
  30711. /**
  30712. * Float animation type
  30713. */
  30714. static readonly ANIMATIONTYPE_FLOAT: number;
  30715. /**
  30716. * Vector3 animation type
  30717. */
  30718. static readonly ANIMATIONTYPE_VECTOR3: number;
  30719. /**
  30720. * Quaternion animation type
  30721. */
  30722. static readonly ANIMATIONTYPE_QUATERNION: number;
  30723. /**
  30724. * Matrix animation type
  30725. */
  30726. static readonly ANIMATIONTYPE_MATRIX: number;
  30727. /**
  30728. * Color3 animation type
  30729. */
  30730. static readonly ANIMATIONTYPE_COLOR3: number;
  30731. /**
  30732. * Color3 animation type
  30733. */
  30734. static readonly ANIMATIONTYPE_COLOR4: number;
  30735. /**
  30736. * Vector2 animation type
  30737. */
  30738. static readonly ANIMATIONTYPE_VECTOR2: number;
  30739. /**
  30740. * Size animation type
  30741. */
  30742. static readonly ANIMATIONTYPE_SIZE: number;
  30743. /**
  30744. * Relative Loop Mode
  30745. */
  30746. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  30747. /**
  30748. * Cycle Loop Mode
  30749. */
  30750. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  30751. /**
  30752. * Constant Loop Mode
  30753. */
  30754. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  30755. /** @hidden */
  30756. static _UniversalLerp(left: any, right: any, amount: number): any;
  30757. /**
  30758. * Parses an animation object and creates an animation
  30759. * @param parsedAnimation Parsed animation object
  30760. * @returns Animation object
  30761. */
  30762. static Parse(parsedAnimation: any): Animation;
  30763. /**
  30764. * Appends the serialized animations from the source animations
  30765. * @param source Source containing the animations
  30766. * @param destination Target to store the animations
  30767. */
  30768. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30769. }
  30770. }
  30771. declare module "babylonjs/Animations/animatable.interface" {
  30772. import { Nullable } from "babylonjs/types";
  30773. import { Animation } from "babylonjs/Animations/animation";
  30774. /**
  30775. * Interface containing an array of animations
  30776. */
  30777. export interface IAnimatable {
  30778. /**
  30779. * Array of animations
  30780. */
  30781. animations: Nullable<Array<Animation>>;
  30782. }
  30783. }
  30784. declare module "babylonjs/Misc/decorators" {
  30785. import { Nullable } from "babylonjs/types";
  30786. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30787. import { Scene } from "babylonjs/scene";
  30788. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30789. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30790. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30791. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30792. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30793. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30794. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30795. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30796. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30797. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30798. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30799. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30800. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30801. /**
  30802. * Decorator used to define property that can be serialized as reference to a camera
  30803. * @param sourceName defines the name of the property to decorate
  30804. */
  30805. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30806. /**
  30807. * Class used to help serialization objects
  30808. */
  30809. export class SerializationHelper {
  30810. /** @hidden */
  30811. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30812. /** @hidden */
  30813. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30814. /** @hidden */
  30815. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30816. /** @hidden */
  30817. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30818. /**
  30819. * Appends the serialized animations from the source animations
  30820. * @param source Source containing the animations
  30821. * @param destination Target to store the animations
  30822. */
  30823. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30824. /**
  30825. * Static function used to serialized a specific entity
  30826. * @param entity defines the entity to serialize
  30827. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30828. * @returns a JSON compatible object representing the serialization of the entity
  30829. */
  30830. static Serialize<T>(entity: T, serializationObject?: any): any;
  30831. /**
  30832. * Creates a new entity from a serialization data object
  30833. * @param creationFunction defines a function used to instanciated the new entity
  30834. * @param source defines the source serialization data
  30835. * @param scene defines the hosting scene
  30836. * @param rootUrl defines the root url for resources
  30837. * @returns a new entity
  30838. */
  30839. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30840. /**
  30841. * Clones an object
  30842. * @param creationFunction defines the function used to instanciate the new object
  30843. * @param source defines the source object
  30844. * @returns the cloned object
  30845. */
  30846. static Clone<T>(creationFunction: () => T, source: T): T;
  30847. /**
  30848. * Instanciates a new object based on a source one (some data will be shared between both object)
  30849. * @param creationFunction defines the function used to instanciate the new object
  30850. * @param source defines the source object
  30851. * @returns the new object
  30852. */
  30853. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30854. }
  30855. }
  30856. declare module "babylonjs/Misc/guid" {
  30857. /**
  30858. * Class used to manipulate GUIDs
  30859. */
  30860. export class GUID {
  30861. /**
  30862. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  30863. * Be aware Math.random() could cause collisions, but:
  30864. * "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"
  30865. * @returns a pseudo random id
  30866. */
  30867. static RandomId(): string;
  30868. }
  30869. }
  30870. declare module "babylonjs/Materials/Textures/baseTexture" {
  30871. import { Observable } from "babylonjs/Misc/observable";
  30872. import { Nullable } from "babylonjs/types";
  30873. import { Scene } from "babylonjs/scene";
  30874. import { Matrix } from "babylonjs/Maths/math.vector";
  30875. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  30876. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  30877. import { ISize } from "babylonjs/Maths/math.size";
  30878. import "babylonjs/Misc/fileTools";
  30879. /**
  30880. * Base class of all the textures in babylon.
  30881. * It groups all the common properties the materials, post process, lights... might need
  30882. * in order to make a correct use of the texture.
  30883. */
  30884. export class BaseTexture implements IAnimatable {
  30885. /**
  30886. * Default anisotropic filtering level for the application.
  30887. * It is set to 4 as a good tradeoff between perf and quality.
  30888. */
  30889. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  30890. /**
  30891. * Gets or sets the unique id of the texture
  30892. */
  30893. uniqueId: number;
  30894. /**
  30895. * Define the name of the texture.
  30896. */
  30897. name: string;
  30898. /**
  30899. * Gets or sets an object used to store user defined information.
  30900. */
  30901. metadata: any;
  30902. /**
  30903. * For internal use only. Please do not use.
  30904. */
  30905. reservedDataStore: any;
  30906. private _hasAlpha;
  30907. /**
  30908. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  30909. */
  30910. set hasAlpha(value: boolean);
  30911. get hasAlpha(): boolean;
  30912. /**
  30913. * Defines if the alpha value should be determined via the rgb values.
  30914. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  30915. */
  30916. getAlphaFromRGB: boolean;
  30917. /**
  30918. * Intensity or strength of the texture.
  30919. * It is commonly used by materials to fine tune the intensity of the texture
  30920. */
  30921. level: number;
  30922. /**
  30923. * Define the UV chanel to use starting from 0 and defaulting to 0.
  30924. * This is part of the texture as textures usually maps to one uv set.
  30925. */
  30926. coordinatesIndex: number;
  30927. private _coordinatesMode;
  30928. /**
  30929. * How a texture is mapped.
  30930. *
  30931. * | Value | Type | Description |
  30932. * | ----- | ----------------------------------- | ----------- |
  30933. * | 0 | EXPLICIT_MODE | |
  30934. * | 1 | SPHERICAL_MODE | |
  30935. * | 2 | PLANAR_MODE | |
  30936. * | 3 | CUBIC_MODE | |
  30937. * | 4 | PROJECTION_MODE | |
  30938. * | 5 | SKYBOX_MODE | |
  30939. * | 6 | INVCUBIC_MODE | |
  30940. * | 7 | EQUIRECTANGULAR_MODE | |
  30941. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  30942. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  30943. */
  30944. set coordinatesMode(value: number);
  30945. get coordinatesMode(): number;
  30946. /**
  30947. * | Value | Type | Description |
  30948. * | ----- | ------------------ | ----------- |
  30949. * | 0 | CLAMP_ADDRESSMODE | |
  30950. * | 1 | WRAP_ADDRESSMODE | |
  30951. * | 2 | MIRROR_ADDRESSMODE | |
  30952. */
  30953. wrapU: number;
  30954. /**
  30955. * | Value | Type | Description |
  30956. * | ----- | ------------------ | ----------- |
  30957. * | 0 | CLAMP_ADDRESSMODE | |
  30958. * | 1 | WRAP_ADDRESSMODE | |
  30959. * | 2 | MIRROR_ADDRESSMODE | |
  30960. */
  30961. wrapV: number;
  30962. /**
  30963. * | Value | Type | Description |
  30964. * | ----- | ------------------ | ----------- |
  30965. * | 0 | CLAMP_ADDRESSMODE | |
  30966. * | 1 | WRAP_ADDRESSMODE | |
  30967. * | 2 | MIRROR_ADDRESSMODE | |
  30968. */
  30969. wrapR: number;
  30970. /**
  30971. * With compliant hardware and browser (supporting anisotropic filtering)
  30972. * this defines the level of anisotropic filtering in the texture.
  30973. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  30974. */
  30975. anisotropicFilteringLevel: number;
  30976. /**
  30977. * Define if the texture is a cube texture or if false a 2d texture.
  30978. */
  30979. get isCube(): boolean;
  30980. set isCube(value: boolean);
  30981. /**
  30982. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  30983. */
  30984. get is3D(): boolean;
  30985. set is3D(value: boolean);
  30986. /**
  30987. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  30988. */
  30989. get is2DArray(): boolean;
  30990. set is2DArray(value: boolean);
  30991. /**
  30992. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  30993. * HDR texture are usually stored in linear space.
  30994. * This only impacts the PBR and Background materials
  30995. */
  30996. gammaSpace: boolean;
  30997. /**
  30998. * Gets or sets whether or not the texture contains RGBD data.
  30999. */
  31000. get isRGBD(): boolean;
  31001. set isRGBD(value: boolean);
  31002. /**
  31003. * Is Z inverted in the texture (useful in a cube texture).
  31004. */
  31005. invertZ: boolean;
  31006. /**
  31007. * Are mip maps generated for this texture or not.
  31008. */
  31009. get noMipmap(): boolean;
  31010. /**
  31011. * @hidden
  31012. */
  31013. lodLevelInAlpha: boolean;
  31014. /**
  31015. * With prefiltered texture, defined the offset used during the prefiltering steps.
  31016. */
  31017. get lodGenerationOffset(): number;
  31018. set lodGenerationOffset(value: number);
  31019. /**
  31020. * With prefiltered texture, defined the scale used during the prefiltering steps.
  31021. */
  31022. get lodGenerationScale(): number;
  31023. set lodGenerationScale(value: number);
  31024. /**
  31025. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  31026. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  31027. * average roughness values.
  31028. */
  31029. get linearSpecularLOD(): boolean;
  31030. set linearSpecularLOD(value: boolean);
  31031. /**
  31032. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  31033. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  31034. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  31035. */
  31036. get irradianceTexture(): Nullable<BaseTexture>;
  31037. set irradianceTexture(value: Nullable<BaseTexture>);
  31038. /**
  31039. * Define if the texture is a render target.
  31040. */
  31041. isRenderTarget: boolean;
  31042. /**
  31043. * Define the unique id of the texture in the scene.
  31044. */
  31045. get uid(): string;
  31046. /**
  31047. * Return a string representation of the texture.
  31048. * @returns the texture as a string
  31049. */
  31050. toString(): string;
  31051. /**
  31052. * Get the class name of the texture.
  31053. * @returns "BaseTexture"
  31054. */
  31055. getClassName(): string;
  31056. /**
  31057. * Define the list of animation attached to the texture.
  31058. */
  31059. animations: import("babylonjs/Animations/animation").Animation[];
  31060. /**
  31061. * An event triggered when the texture is disposed.
  31062. */
  31063. onDisposeObservable: Observable<BaseTexture>;
  31064. private _onDisposeObserver;
  31065. /**
  31066. * Callback triggered when the texture has been disposed.
  31067. * Kept for back compatibility, you can use the onDisposeObservable instead.
  31068. */
  31069. set onDispose(callback: () => void);
  31070. /**
  31071. * Define the current state of the loading sequence when in delayed load mode.
  31072. */
  31073. delayLoadState: number;
  31074. private _scene;
  31075. /** @hidden */
  31076. _texture: Nullable<InternalTexture>;
  31077. private _uid;
  31078. /**
  31079. * Define if the texture is preventinga material to render or not.
  31080. * If not and the texture is not ready, the engine will use a default black texture instead.
  31081. */
  31082. get isBlocking(): boolean;
  31083. /**
  31084. * Instantiates a new BaseTexture.
  31085. * Base class of all the textures in babylon.
  31086. * It groups all the common properties the materials, post process, lights... might need
  31087. * in order to make a correct use of the texture.
  31088. * @param scene Define the scene the texture blongs to
  31089. */
  31090. constructor(scene: Nullable<Scene>);
  31091. /**
  31092. * Get the scene the texture belongs to.
  31093. * @returns the scene or null if undefined
  31094. */
  31095. getScene(): Nullable<Scene>;
  31096. /**
  31097. * Get the texture transform matrix used to offset tile the texture for istance.
  31098. * @returns the transformation matrix
  31099. */
  31100. getTextureMatrix(): Matrix;
  31101. /**
  31102. * Get the texture reflection matrix used to rotate/transform the reflection.
  31103. * @returns the reflection matrix
  31104. */
  31105. getReflectionTextureMatrix(): Matrix;
  31106. /**
  31107. * Get the underlying lower level texture from Babylon.
  31108. * @returns the insternal texture
  31109. */
  31110. getInternalTexture(): Nullable<InternalTexture>;
  31111. /**
  31112. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  31113. * @returns true if ready or not blocking
  31114. */
  31115. isReadyOrNotBlocking(): boolean;
  31116. /**
  31117. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  31118. * @returns true if fully ready
  31119. */
  31120. isReady(): boolean;
  31121. private _cachedSize;
  31122. /**
  31123. * Get the size of the texture.
  31124. * @returns the texture size.
  31125. */
  31126. getSize(): ISize;
  31127. /**
  31128. * Get the base size of the texture.
  31129. * It can be different from the size if the texture has been resized for POT for instance
  31130. * @returns the base size
  31131. */
  31132. getBaseSize(): ISize;
  31133. /**
  31134. * Update the sampling mode of the texture.
  31135. * Default is Trilinear mode.
  31136. *
  31137. * | Value | Type | Description |
  31138. * | ----- | ------------------ | ----------- |
  31139. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  31140. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  31141. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  31142. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  31143. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  31144. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  31145. * | 7 | NEAREST_LINEAR | |
  31146. * | 8 | NEAREST_NEAREST | |
  31147. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  31148. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  31149. * | 11 | LINEAR_LINEAR | |
  31150. * | 12 | LINEAR_NEAREST | |
  31151. *
  31152. * > _mag_: magnification filter (close to the viewer)
  31153. * > _min_: minification filter (far from the viewer)
  31154. * > _mip_: filter used between mip map levels
  31155. *@param samplingMode Define the new sampling mode of the texture
  31156. */
  31157. updateSamplingMode(samplingMode: number): void;
  31158. /**
  31159. * Scales the texture if is `canRescale()`
  31160. * @param ratio the resize factor we want to use to rescale
  31161. */
  31162. scale(ratio: number): void;
  31163. /**
  31164. * Get if the texture can rescale.
  31165. */
  31166. get canRescale(): boolean;
  31167. /** @hidden */
  31168. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  31169. /** @hidden */
  31170. _rebuild(): void;
  31171. /**
  31172. * Triggers the load sequence in delayed load mode.
  31173. */
  31174. delayLoad(): void;
  31175. /**
  31176. * Clones the texture.
  31177. * @returns the cloned texture
  31178. */
  31179. clone(): Nullable<BaseTexture>;
  31180. /**
  31181. * Get the texture underlying type (INT, FLOAT...)
  31182. */
  31183. get textureType(): number;
  31184. /**
  31185. * Get the texture underlying format (RGB, RGBA...)
  31186. */
  31187. get textureFormat(): number;
  31188. /**
  31189. * Indicates that textures need to be re-calculated for all materials
  31190. */
  31191. protected _markAllSubMeshesAsTexturesDirty(): void;
  31192. /**
  31193. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  31194. * This will returns an RGBA array buffer containing either in values (0-255) or
  31195. * float values (0-1) depending of the underlying buffer type.
  31196. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  31197. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  31198. * @param buffer defines a user defined buffer to fill with data (can be null)
  31199. * @returns The Array buffer containing the pixels data.
  31200. */
  31201. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  31202. /**
  31203. * Release and destroy the underlying lower level texture aka internalTexture.
  31204. */
  31205. releaseInternalTexture(): void;
  31206. /** @hidden */
  31207. get _lodTextureHigh(): Nullable<BaseTexture>;
  31208. /** @hidden */
  31209. get _lodTextureMid(): Nullable<BaseTexture>;
  31210. /** @hidden */
  31211. get _lodTextureLow(): Nullable<BaseTexture>;
  31212. /**
  31213. * Dispose the texture and release its associated resources.
  31214. */
  31215. dispose(): void;
  31216. /**
  31217. * Serialize the texture into a JSON representation that can be parsed later on.
  31218. * @returns the JSON representation of the texture
  31219. */
  31220. serialize(): any;
  31221. /**
  31222. * Helper function to be called back once a list of texture contains only ready textures.
  31223. * @param textures Define the list of textures to wait for
  31224. * @param callback Define the callback triggered once the entire list will be ready
  31225. */
  31226. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  31227. }
  31228. }
  31229. declare module "babylonjs/Materials/effect" {
  31230. import { Observable } from "babylonjs/Misc/observable";
  31231. import { Nullable } from "babylonjs/types";
  31232. import { IDisposable } from "babylonjs/scene";
  31233. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  31234. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  31235. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  31236. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  31237. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  31238. import { Engine } from "babylonjs/Engines/engine";
  31239. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  31240. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31241. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31242. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  31243. /**
  31244. * Options to be used when creating an effect.
  31245. */
  31246. export interface IEffectCreationOptions {
  31247. /**
  31248. * Atrributes that will be used in the shader.
  31249. */
  31250. attributes: string[];
  31251. /**
  31252. * Uniform varible names that will be set in the shader.
  31253. */
  31254. uniformsNames: string[];
  31255. /**
  31256. * Uniform buffer variable names that will be set in the shader.
  31257. */
  31258. uniformBuffersNames: string[];
  31259. /**
  31260. * Sampler texture variable names that will be set in the shader.
  31261. */
  31262. samplers: string[];
  31263. /**
  31264. * Define statements that will be set in the shader.
  31265. */
  31266. defines: any;
  31267. /**
  31268. * Possible fallbacks for this effect to improve performance when needed.
  31269. */
  31270. fallbacks: Nullable<IEffectFallbacks>;
  31271. /**
  31272. * Callback that will be called when the shader is compiled.
  31273. */
  31274. onCompiled: Nullable<(effect: Effect) => void>;
  31275. /**
  31276. * Callback that will be called if an error occurs during shader compilation.
  31277. */
  31278. onError: Nullable<(effect: Effect, errors: string) => void>;
  31279. /**
  31280. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31281. */
  31282. indexParameters?: any;
  31283. /**
  31284. * Max number of lights that can be used in the shader.
  31285. */
  31286. maxSimultaneousLights?: number;
  31287. /**
  31288. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  31289. */
  31290. transformFeedbackVaryings?: Nullable<string[]>;
  31291. }
  31292. /**
  31293. * Effect containing vertex and fragment shader that can be executed on an object.
  31294. */
  31295. export class Effect implements IDisposable {
  31296. /**
  31297. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  31298. */
  31299. static ShadersRepository: string;
  31300. /**
  31301. * Enable logging of the shader code when a compilation error occurs
  31302. */
  31303. static LogShaderCodeOnCompilationError: boolean;
  31304. /**
  31305. * Name of the effect.
  31306. */
  31307. name: any;
  31308. /**
  31309. * String container all the define statements that should be set on the shader.
  31310. */
  31311. defines: string;
  31312. /**
  31313. * Callback that will be called when the shader is compiled.
  31314. */
  31315. onCompiled: Nullable<(effect: Effect) => void>;
  31316. /**
  31317. * Callback that will be called if an error occurs during shader compilation.
  31318. */
  31319. onError: Nullable<(effect: Effect, errors: string) => void>;
  31320. /**
  31321. * Callback that will be called when effect is bound.
  31322. */
  31323. onBind: Nullable<(effect: Effect) => void>;
  31324. /**
  31325. * Unique ID of the effect.
  31326. */
  31327. uniqueId: number;
  31328. /**
  31329. * Observable that will be called when the shader is compiled.
  31330. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  31331. */
  31332. onCompileObservable: Observable<Effect>;
  31333. /**
  31334. * Observable that will be called if an error occurs during shader compilation.
  31335. */
  31336. onErrorObservable: Observable<Effect>;
  31337. /** @hidden */
  31338. _onBindObservable: Nullable<Observable<Effect>>;
  31339. /**
  31340. * @hidden
  31341. * Specifies if the effect was previously ready
  31342. */
  31343. _wasPreviouslyReady: boolean;
  31344. /**
  31345. * Observable that will be called when effect is bound.
  31346. */
  31347. get onBindObservable(): Observable<Effect>;
  31348. /** @hidden */
  31349. _bonesComputationForcedToCPU: boolean;
  31350. private static _uniqueIdSeed;
  31351. private _engine;
  31352. private _uniformBuffersNames;
  31353. private _uniformsNames;
  31354. private _samplerList;
  31355. private _samplers;
  31356. private _isReady;
  31357. private _compilationError;
  31358. private _allFallbacksProcessed;
  31359. private _attributesNames;
  31360. private _attributes;
  31361. private _attributeLocationByName;
  31362. private _uniforms;
  31363. /**
  31364. * Key for the effect.
  31365. * @hidden
  31366. */
  31367. _key: string;
  31368. private _indexParameters;
  31369. private _fallbacks;
  31370. private _vertexSourceCode;
  31371. private _fragmentSourceCode;
  31372. private _vertexSourceCodeOverride;
  31373. private _fragmentSourceCodeOverride;
  31374. private _transformFeedbackVaryings;
  31375. /**
  31376. * Compiled shader to webGL program.
  31377. * @hidden
  31378. */
  31379. _pipelineContext: Nullable<IPipelineContext>;
  31380. private _valueCache;
  31381. private static _baseCache;
  31382. /**
  31383. * Instantiates an effect.
  31384. * An effect can be used to create/manage/execute vertex and fragment shaders.
  31385. * @param baseName Name of the effect.
  31386. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  31387. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  31388. * @param samplers List of sampler variables that will be passed to the shader.
  31389. * @param engine Engine to be used to render the effect
  31390. * @param defines Define statements to be added to the shader.
  31391. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  31392. * @param onCompiled Callback that will be called when the shader is compiled.
  31393. * @param onError Callback that will be called if an error occurs during shader compilation.
  31394. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  31395. */
  31396. 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);
  31397. private _useFinalCode;
  31398. /**
  31399. * Unique key for this effect
  31400. */
  31401. get key(): string;
  31402. /**
  31403. * If the effect has been compiled and prepared.
  31404. * @returns if the effect is compiled and prepared.
  31405. */
  31406. isReady(): boolean;
  31407. private _isReadyInternal;
  31408. /**
  31409. * The engine the effect was initialized with.
  31410. * @returns the engine.
  31411. */
  31412. getEngine(): Engine;
  31413. /**
  31414. * The pipeline context for this effect
  31415. * @returns the associated pipeline context
  31416. */
  31417. getPipelineContext(): Nullable<IPipelineContext>;
  31418. /**
  31419. * The set of names of attribute variables for the shader.
  31420. * @returns An array of attribute names.
  31421. */
  31422. getAttributesNames(): string[];
  31423. /**
  31424. * Returns the attribute at the given index.
  31425. * @param index The index of the attribute.
  31426. * @returns The location of the attribute.
  31427. */
  31428. getAttributeLocation(index: number): number;
  31429. /**
  31430. * Returns the attribute based on the name of the variable.
  31431. * @param name of the attribute to look up.
  31432. * @returns the attribute location.
  31433. */
  31434. getAttributeLocationByName(name: string): number;
  31435. /**
  31436. * The number of attributes.
  31437. * @returns the numnber of attributes.
  31438. */
  31439. getAttributesCount(): number;
  31440. /**
  31441. * Gets the index of a uniform variable.
  31442. * @param uniformName of the uniform to look up.
  31443. * @returns the index.
  31444. */
  31445. getUniformIndex(uniformName: string): number;
  31446. /**
  31447. * Returns the attribute based on the name of the variable.
  31448. * @param uniformName of the uniform to look up.
  31449. * @returns the location of the uniform.
  31450. */
  31451. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  31452. /**
  31453. * Returns an array of sampler variable names
  31454. * @returns The array of sampler variable neames.
  31455. */
  31456. getSamplers(): string[];
  31457. /**
  31458. * The error from the last compilation.
  31459. * @returns the error string.
  31460. */
  31461. getCompilationError(): string;
  31462. /**
  31463. * Gets a boolean indicating that all fallbacks were used during compilation
  31464. * @returns true if all fallbacks were used
  31465. */
  31466. allFallbacksProcessed(): boolean;
  31467. /**
  31468. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  31469. * @param func The callback to be used.
  31470. */
  31471. executeWhenCompiled(func: (effect: Effect) => void): void;
  31472. private _checkIsReady;
  31473. private _loadShader;
  31474. /**
  31475. * Recompiles the webGL program
  31476. * @param vertexSourceCode The source code for the vertex shader.
  31477. * @param fragmentSourceCode The source code for the fragment shader.
  31478. * @param onCompiled Callback called when completed.
  31479. * @param onError Callback called on error.
  31480. * @hidden
  31481. */
  31482. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  31483. /**
  31484. * Prepares the effect
  31485. * @hidden
  31486. */
  31487. _prepareEffect(): void;
  31488. private _getShaderCodeAndErrorLine;
  31489. private _processCompilationErrors;
  31490. /**
  31491. * Checks if the effect is supported. (Must be called after compilation)
  31492. */
  31493. get isSupported(): boolean;
  31494. /**
  31495. * Binds a texture to the engine to be used as output of the shader.
  31496. * @param channel Name of the output variable.
  31497. * @param texture Texture to bind.
  31498. * @hidden
  31499. */
  31500. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  31501. /**
  31502. * Sets a texture on the engine to be used in the shader.
  31503. * @param channel Name of the sampler variable.
  31504. * @param texture Texture to set.
  31505. */
  31506. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  31507. /**
  31508. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  31509. * @param channel Name of the sampler variable.
  31510. * @param texture Texture to set.
  31511. */
  31512. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  31513. /**
  31514. * Sets an array of textures on the engine to be used in the shader.
  31515. * @param channel Name of the variable.
  31516. * @param textures Textures to set.
  31517. */
  31518. setTextureArray(channel: string, textures: BaseTexture[]): void;
  31519. /**
  31520. * 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)
  31521. * @param channel Name of the sampler variable.
  31522. * @param postProcess Post process to get the input texture from.
  31523. */
  31524. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  31525. /**
  31526. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  31527. * 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)
  31528. * @param channel Name of the sampler variable.
  31529. * @param postProcess Post process to get the output texture from.
  31530. */
  31531. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  31532. /** @hidden */
  31533. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  31534. /** @hidden */
  31535. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  31536. /** @hidden */
  31537. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  31538. /** @hidden */
  31539. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  31540. /**
  31541. * Binds a buffer to a uniform.
  31542. * @param buffer Buffer to bind.
  31543. * @param name Name of the uniform variable to bind to.
  31544. */
  31545. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  31546. /**
  31547. * Binds block to a uniform.
  31548. * @param blockName Name of the block to bind.
  31549. * @param index Index to bind.
  31550. */
  31551. bindUniformBlock(blockName: string, index: number): void;
  31552. /**
  31553. * Sets an interger value on a uniform variable.
  31554. * @param uniformName Name of the variable.
  31555. * @param value Value to be set.
  31556. * @returns this effect.
  31557. */
  31558. setInt(uniformName: string, value: number): Effect;
  31559. /**
  31560. * Sets an int array on a uniform variable.
  31561. * @param uniformName Name of the variable.
  31562. * @param array array to be set.
  31563. * @returns this effect.
  31564. */
  31565. setIntArray(uniformName: string, array: Int32Array): Effect;
  31566. /**
  31567. * 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)
  31568. * @param uniformName Name of the variable.
  31569. * @param array array to be set.
  31570. * @returns this effect.
  31571. */
  31572. setIntArray2(uniformName: string, array: Int32Array): Effect;
  31573. /**
  31574. * 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)
  31575. * @param uniformName Name of the variable.
  31576. * @param array array to be set.
  31577. * @returns this effect.
  31578. */
  31579. setIntArray3(uniformName: string, array: Int32Array): Effect;
  31580. /**
  31581. * 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)
  31582. * @param uniformName Name of the variable.
  31583. * @param array array to be set.
  31584. * @returns this effect.
  31585. */
  31586. setIntArray4(uniformName: string, array: Int32Array): Effect;
  31587. /**
  31588. * Sets an float array on a uniform variable.
  31589. * @param uniformName Name of the variable.
  31590. * @param array array to be set.
  31591. * @returns this effect.
  31592. */
  31593. setFloatArray(uniformName: string, array: Float32Array): Effect;
  31594. /**
  31595. * 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)
  31596. * @param uniformName Name of the variable.
  31597. * @param array array to be set.
  31598. * @returns this effect.
  31599. */
  31600. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  31601. /**
  31602. * 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)
  31603. * @param uniformName Name of the variable.
  31604. * @param array array to be set.
  31605. * @returns this effect.
  31606. */
  31607. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  31608. /**
  31609. * 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)
  31610. * @param uniformName Name of the variable.
  31611. * @param array array to be set.
  31612. * @returns this effect.
  31613. */
  31614. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  31615. /**
  31616. * Sets an array on a uniform variable.
  31617. * @param uniformName Name of the variable.
  31618. * @param array array to be set.
  31619. * @returns this effect.
  31620. */
  31621. setArray(uniformName: string, array: number[]): Effect;
  31622. /**
  31623. * 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)
  31624. * @param uniformName Name of the variable.
  31625. * @param array array to be set.
  31626. * @returns this effect.
  31627. */
  31628. setArray2(uniformName: string, array: number[]): Effect;
  31629. /**
  31630. * 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)
  31631. * @param uniformName Name of the variable.
  31632. * @param array array to be set.
  31633. * @returns this effect.
  31634. */
  31635. setArray3(uniformName: string, array: number[]): Effect;
  31636. /**
  31637. * 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)
  31638. * @param uniformName Name of the variable.
  31639. * @param array array to be set.
  31640. * @returns this effect.
  31641. */
  31642. setArray4(uniformName: string, array: number[]): Effect;
  31643. /**
  31644. * Sets matrices on a uniform variable.
  31645. * @param uniformName Name of the variable.
  31646. * @param matrices matrices to be set.
  31647. * @returns this effect.
  31648. */
  31649. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  31650. /**
  31651. * Sets matrix on a uniform variable.
  31652. * @param uniformName Name of the variable.
  31653. * @param matrix matrix to be set.
  31654. * @returns this effect.
  31655. */
  31656. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  31657. /**
  31658. * 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)
  31659. * @param uniformName Name of the variable.
  31660. * @param matrix matrix to be set.
  31661. * @returns this effect.
  31662. */
  31663. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  31664. /**
  31665. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  31666. * @param uniformName Name of the variable.
  31667. * @param matrix matrix to be set.
  31668. * @returns this effect.
  31669. */
  31670. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  31671. /**
  31672. * Sets a float on a uniform variable.
  31673. * @param uniformName Name of the variable.
  31674. * @param value value to be set.
  31675. * @returns this effect.
  31676. */
  31677. setFloat(uniformName: string, value: number): Effect;
  31678. /**
  31679. * Sets a boolean on a uniform variable.
  31680. * @param uniformName Name of the variable.
  31681. * @param bool value to be set.
  31682. * @returns this effect.
  31683. */
  31684. setBool(uniformName: string, bool: boolean): Effect;
  31685. /**
  31686. * Sets a Vector2 on a uniform variable.
  31687. * @param uniformName Name of the variable.
  31688. * @param vector2 vector2 to be set.
  31689. * @returns this effect.
  31690. */
  31691. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  31692. /**
  31693. * Sets a float2 on a uniform variable.
  31694. * @param uniformName Name of the variable.
  31695. * @param x First float in float2.
  31696. * @param y Second float in float2.
  31697. * @returns this effect.
  31698. */
  31699. setFloat2(uniformName: string, x: number, y: number): Effect;
  31700. /**
  31701. * Sets a Vector3 on a uniform variable.
  31702. * @param uniformName Name of the variable.
  31703. * @param vector3 Value to be set.
  31704. * @returns this effect.
  31705. */
  31706. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  31707. /**
  31708. * Sets a float3 on a uniform variable.
  31709. * @param uniformName Name of the variable.
  31710. * @param x First float in float3.
  31711. * @param y Second float in float3.
  31712. * @param z Third float in float3.
  31713. * @returns this effect.
  31714. */
  31715. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  31716. /**
  31717. * Sets a Vector4 on a uniform variable.
  31718. * @param uniformName Name of the variable.
  31719. * @param vector4 Value to be set.
  31720. * @returns this effect.
  31721. */
  31722. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  31723. /**
  31724. * Sets a float4 on a uniform variable.
  31725. * @param uniformName Name of the variable.
  31726. * @param x First float in float4.
  31727. * @param y Second float in float4.
  31728. * @param z Third float in float4.
  31729. * @param w Fourth float in float4.
  31730. * @returns this effect.
  31731. */
  31732. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  31733. /**
  31734. * Sets a Color3 on a uniform variable.
  31735. * @param uniformName Name of the variable.
  31736. * @param color3 Value to be set.
  31737. * @returns this effect.
  31738. */
  31739. setColor3(uniformName: string, color3: IColor3Like): Effect;
  31740. /**
  31741. * Sets a Color4 on a uniform variable.
  31742. * @param uniformName Name of the variable.
  31743. * @param color3 Value to be set.
  31744. * @param alpha Alpha value to be set.
  31745. * @returns this effect.
  31746. */
  31747. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  31748. /**
  31749. * Sets a Color4 on a uniform variable
  31750. * @param uniformName defines the name of the variable
  31751. * @param color4 defines the value to be set
  31752. * @returns this effect.
  31753. */
  31754. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  31755. /** Release all associated resources */
  31756. dispose(): void;
  31757. /**
  31758. * This function will add a new shader to the shader store
  31759. * @param name the name of the shader
  31760. * @param pixelShader optional pixel shader content
  31761. * @param vertexShader optional vertex shader content
  31762. */
  31763. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  31764. /**
  31765. * Store of each shader (The can be looked up using effect.key)
  31766. */
  31767. static ShadersStore: {
  31768. [key: string]: string;
  31769. };
  31770. /**
  31771. * Store of each included file for a shader (The can be looked up using effect.key)
  31772. */
  31773. static IncludesShadersStore: {
  31774. [key: string]: string;
  31775. };
  31776. /**
  31777. * Resets the cache of effects.
  31778. */
  31779. static ResetCache(): void;
  31780. }
  31781. }
  31782. declare module "babylonjs/Engines/engineCapabilities" {
  31783. /**
  31784. * Interface used to describe the capabilities of the engine relatively to the current browser
  31785. */
  31786. export interface EngineCapabilities {
  31787. /** Maximum textures units per fragment shader */
  31788. maxTexturesImageUnits: number;
  31789. /** Maximum texture units per vertex shader */
  31790. maxVertexTextureImageUnits: number;
  31791. /** Maximum textures units in the entire pipeline */
  31792. maxCombinedTexturesImageUnits: number;
  31793. /** Maximum texture size */
  31794. maxTextureSize: number;
  31795. /** Maximum texture samples */
  31796. maxSamples?: number;
  31797. /** Maximum cube texture size */
  31798. maxCubemapTextureSize: number;
  31799. /** Maximum render texture size */
  31800. maxRenderTextureSize: number;
  31801. /** Maximum number of vertex attributes */
  31802. maxVertexAttribs: number;
  31803. /** Maximum number of varyings */
  31804. maxVaryingVectors: number;
  31805. /** Maximum number of uniforms per vertex shader */
  31806. maxVertexUniformVectors: number;
  31807. /** Maximum number of uniforms per fragment shader */
  31808. maxFragmentUniformVectors: number;
  31809. /** Defines if standard derivates (dx/dy) are supported */
  31810. standardDerivatives: boolean;
  31811. /** Defines if s3tc texture compression is supported */
  31812. s3tc?: WEBGL_compressed_texture_s3tc;
  31813. /** Defines if pvrtc texture compression is supported */
  31814. pvrtc: any;
  31815. /** Defines if etc1 texture compression is supported */
  31816. etc1: any;
  31817. /** Defines if etc2 texture compression is supported */
  31818. etc2: any;
  31819. /** Defines if astc texture compression is supported */
  31820. astc: any;
  31821. /** Defines if float textures are supported */
  31822. textureFloat: boolean;
  31823. /** Defines if vertex array objects are supported */
  31824. vertexArrayObject: boolean;
  31825. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  31826. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  31827. /** Gets the maximum level of anisotropy supported */
  31828. maxAnisotropy: number;
  31829. /** Defines if instancing is supported */
  31830. instancedArrays: boolean;
  31831. /** Defines if 32 bits indices are supported */
  31832. uintIndices: boolean;
  31833. /** Defines if high precision shaders are supported */
  31834. highPrecisionShaderSupported: boolean;
  31835. /** Defines if depth reading in the fragment shader is supported */
  31836. fragmentDepthSupported: boolean;
  31837. /** Defines if float texture linear filtering is supported*/
  31838. textureFloatLinearFiltering: boolean;
  31839. /** Defines if rendering to float textures is supported */
  31840. textureFloatRender: boolean;
  31841. /** Defines if half float textures are supported*/
  31842. textureHalfFloat: boolean;
  31843. /** Defines if half float texture linear filtering is supported*/
  31844. textureHalfFloatLinearFiltering: boolean;
  31845. /** Defines if rendering to half float textures is supported */
  31846. textureHalfFloatRender: boolean;
  31847. /** Defines if textureLOD shader command is supported */
  31848. textureLOD: boolean;
  31849. /** Defines if draw buffers extension is supported */
  31850. drawBuffersExtension: boolean;
  31851. /** Defines if depth textures are supported */
  31852. depthTextureExtension: boolean;
  31853. /** Defines if float color buffer are supported */
  31854. colorBufferFloat: boolean;
  31855. /** Gets disjoint timer query extension (null if not supported) */
  31856. timerQuery?: EXT_disjoint_timer_query;
  31857. /** Defines if timestamp can be used with timer query */
  31858. canUseTimestampForTimerQuery: boolean;
  31859. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  31860. multiview?: any;
  31861. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  31862. oculusMultiview?: any;
  31863. /** Function used to let the system compiles shaders in background */
  31864. parallelShaderCompile?: {
  31865. COMPLETION_STATUS_KHR: number;
  31866. };
  31867. /** Max number of texture samples for MSAA */
  31868. maxMSAASamples: number;
  31869. /** Defines if the blend min max extension is supported */
  31870. blendMinMax: boolean;
  31871. }
  31872. }
  31873. declare module "babylonjs/States/depthCullingState" {
  31874. import { Nullable } from "babylonjs/types";
  31875. /**
  31876. * @hidden
  31877. **/
  31878. export class DepthCullingState {
  31879. private _isDepthTestDirty;
  31880. private _isDepthMaskDirty;
  31881. private _isDepthFuncDirty;
  31882. private _isCullFaceDirty;
  31883. private _isCullDirty;
  31884. private _isZOffsetDirty;
  31885. private _isFrontFaceDirty;
  31886. private _depthTest;
  31887. private _depthMask;
  31888. private _depthFunc;
  31889. private _cull;
  31890. private _cullFace;
  31891. private _zOffset;
  31892. private _frontFace;
  31893. /**
  31894. * Initializes the state.
  31895. */
  31896. constructor();
  31897. get isDirty(): boolean;
  31898. get zOffset(): number;
  31899. set zOffset(value: number);
  31900. get cullFace(): Nullable<number>;
  31901. set cullFace(value: Nullable<number>);
  31902. get cull(): Nullable<boolean>;
  31903. set cull(value: Nullable<boolean>);
  31904. get depthFunc(): Nullable<number>;
  31905. set depthFunc(value: Nullable<number>);
  31906. get depthMask(): boolean;
  31907. set depthMask(value: boolean);
  31908. get depthTest(): boolean;
  31909. set depthTest(value: boolean);
  31910. get frontFace(): Nullable<number>;
  31911. set frontFace(value: Nullable<number>);
  31912. reset(): void;
  31913. apply(gl: WebGLRenderingContext): void;
  31914. }
  31915. }
  31916. declare module "babylonjs/States/stencilState" {
  31917. /**
  31918. * @hidden
  31919. **/
  31920. export class StencilState {
  31921. /** 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 */
  31922. static readonly ALWAYS: number;
  31923. /** Passed to stencilOperation to specify that stencil value must be kept */
  31924. static readonly KEEP: number;
  31925. /** Passed to stencilOperation to specify that stencil value must be replaced */
  31926. static readonly REPLACE: number;
  31927. private _isStencilTestDirty;
  31928. private _isStencilMaskDirty;
  31929. private _isStencilFuncDirty;
  31930. private _isStencilOpDirty;
  31931. private _stencilTest;
  31932. private _stencilMask;
  31933. private _stencilFunc;
  31934. private _stencilFuncRef;
  31935. private _stencilFuncMask;
  31936. private _stencilOpStencilFail;
  31937. private _stencilOpDepthFail;
  31938. private _stencilOpStencilDepthPass;
  31939. get isDirty(): boolean;
  31940. get stencilFunc(): number;
  31941. set stencilFunc(value: number);
  31942. get stencilFuncRef(): number;
  31943. set stencilFuncRef(value: number);
  31944. get stencilFuncMask(): number;
  31945. set stencilFuncMask(value: number);
  31946. get stencilOpStencilFail(): number;
  31947. set stencilOpStencilFail(value: number);
  31948. get stencilOpDepthFail(): number;
  31949. set stencilOpDepthFail(value: number);
  31950. get stencilOpStencilDepthPass(): number;
  31951. set stencilOpStencilDepthPass(value: number);
  31952. get stencilMask(): number;
  31953. set stencilMask(value: number);
  31954. get stencilTest(): boolean;
  31955. set stencilTest(value: boolean);
  31956. constructor();
  31957. reset(): void;
  31958. apply(gl: WebGLRenderingContext): void;
  31959. }
  31960. }
  31961. declare module "babylonjs/States/alphaCullingState" {
  31962. /**
  31963. * @hidden
  31964. **/
  31965. export class AlphaState {
  31966. private _isAlphaBlendDirty;
  31967. private _isBlendFunctionParametersDirty;
  31968. private _isBlendEquationParametersDirty;
  31969. private _isBlendConstantsDirty;
  31970. private _alphaBlend;
  31971. private _blendFunctionParameters;
  31972. private _blendEquationParameters;
  31973. private _blendConstants;
  31974. /**
  31975. * Initializes the state.
  31976. */
  31977. constructor();
  31978. get isDirty(): boolean;
  31979. get alphaBlend(): boolean;
  31980. set alphaBlend(value: boolean);
  31981. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  31982. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  31983. setAlphaEquationParameters(rgb: number, alpha: number): void;
  31984. reset(): void;
  31985. apply(gl: WebGLRenderingContext): void;
  31986. }
  31987. }
  31988. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  31989. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  31990. /** @hidden */
  31991. export class WebGL2ShaderProcessor implements IShaderProcessor {
  31992. attributeProcessor(attribute: string): string;
  31993. varyingProcessor(varying: string, isFragment: boolean): string;
  31994. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  31995. }
  31996. }
  31997. declare module "babylonjs/Engines/instancingAttributeInfo" {
  31998. /**
  31999. * Interface for attribute information associated with buffer instanciation
  32000. */
  32001. export interface InstancingAttributeInfo {
  32002. /**
  32003. * Name of the GLSL attribute
  32004. * if attribute index is not specified, this is used to retrieve the index from the effect
  32005. */
  32006. attributeName: string;
  32007. /**
  32008. * Index/offset of the attribute in the vertex shader
  32009. * if not specified, this will be computes from the name.
  32010. */
  32011. index?: number;
  32012. /**
  32013. * size of the attribute, 1, 2, 3 or 4
  32014. */
  32015. attributeSize: number;
  32016. /**
  32017. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  32018. */
  32019. offset: number;
  32020. /**
  32021. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  32022. * default to 1
  32023. */
  32024. divisor?: number;
  32025. /**
  32026. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  32027. * default is FLOAT
  32028. */
  32029. attributeType?: number;
  32030. /**
  32031. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  32032. */
  32033. normalized?: boolean;
  32034. }
  32035. }
  32036. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  32037. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32038. import { Nullable } from "babylonjs/types";
  32039. module "babylonjs/Engines/thinEngine" {
  32040. interface ThinEngine {
  32041. /**
  32042. * Update a video texture
  32043. * @param texture defines the texture to update
  32044. * @param video defines the video element to use
  32045. * @param invertY defines if data must be stored with Y axis inverted
  32046. */
  32047. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  32048. }
  32049. }
  32050. }
  32051. declare module "babylonjs/Materials/Textures/videoTexture" {
  32052. import { Observable } from "babylonjs/Misc/observable";
  32053. import { Nullable } from "babylonjs/types";
  32054. import { Scene } from "babylonjs/scene";
  32055. import { Texture } from "babylonjs/Materials/Textures/texture";
  32056. import "babylonjs/Engines/Extensions/engine.videoTexture";
  32057. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  32058. /**
  32059. * Settings for finer control over video usage
  32060. */
  32061. export interface VideoTextureSettings {
  32062. /**
  32063. * Applies `autoplay` to video, if specified
  32064. */
  32065. autoPlay?: boolean;
  32066. /**
  32067. * Applies `loop` to video, if specified
  32068. */
  32069. loop?: boolean;
  32070. /**
  32071. * Automatically updates internal texture from video at every frame in the render loop
  32072. */
  32073. autoUpdateTexture: boolean;
  32074. /**
  32075. * Image src displayed during the video loading or until the user interacts with the video.
  32076. */
  32077. poster?: string;
  32078. }
  32079. /**
  32080. * If you want to display a video in your scene, this is the special texture for that.
  32081. * This special texture works similar to other textures, with the exception of a few parameters.
  32082. * @see https://doc.babylonjs.com/how_to/video_texture
  32083. */
  32084. export class VideoTexture extends Texture {
  32085. /**
  32086. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  32087. */
  32088. readonly autoUpdateTexture: boolean;
  32089. /**
  32090. * The video instance used by the texture internally
  32091. */
  32092. readonly video: HTMLVideoElement;
  32093. private _onUserActionRequestedObservable;
  32094. /**
  32095. * Event triggerd when a dom action is required by the user to play the video.
  32096. * This happens due to recent changes in browser policies preventing video to auto start.
  32097. */
  32098. get onUserActionRequestedObservable(): Observable<Texture>;
  32099. private _generateMipMaps;
  32100. private _engine;
  32101. private _stillImageCaptured;
  32102. private _displayingPosterTexture;
  32103. private _settings;
  32104. private _createInternalTextureOnEvent;
  32105. private _frameId;
  32106. private _currentSrc;
  32107. /**
  32108. * Creates a video texture.
  32109. * If you want to display a video in your scene, this is the special texture for that.
  32110. * This special texture works similar to other textures, with the exception of a few parameters.
  32111. * @see https://doc.babylonjs.com/how_to/video_texture
  32112. * @param name optional name, will detect from video source, if not defined
  32113. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  32114. * @param scene is obviously the current scene.
  32115. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  32116. * @param invertY is false by default but can be used to invert video on Y axis
  32117. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  32118. * @param settings allows finer control over video usage
  32119. */
  32120. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  32121. private _getName;
  32122. private _getVideo;
  32123. private _createInternalTexture;
  32124. private reset;
  32125. /**
  32126. * @hidden Internal method to initiate `update`.
  32127. */
  32128. _rebuild(): void;
  32129. /**
  32130. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  32131. */
  32132. update(): void;
  32133. /**
  32134. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  32135. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  32136. */
  32137. updateTexture(isVisible: boolean): void;
  32138. protected _updateInternalTexture: () => void;
  32139. /**
  32140. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  32141. * @param url New url.
  32142. */
  32143. updateURL(url: string): void;
  32144. /**
  32145. * Clones the texture.
  32146. * @returns the cloned texture
  32147. */
  32148. clone(): VideoTexture;
  32149. /**
  32150. * Dispose the texture and release its associated resources.
  32151. */
  32152. dispose(): void;
  32153. /**
  32154. * Creates a video texture straight from a stream.
  32155. * @param scene Define the scene the texture should be created in
  32156. * @param stream Define the stream the texture should be created from
  32157. * @returns The created video texture as a promise
  32158. */
  32159. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  32160. /**
  32161. * Creates a video texture straight from your WebCam video feed.
  32162. * @param scene Define the scene the texture should be created in
  32163. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32164. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32165. * @returns The created video texture as a promise
  32166. */
  32167. static CreateFromWebCamAsync(scene: Scene, constraints: {
  32168. minWidth: number;
  32169. maxWidth: number;
  32170. minHeight: number;
  32171. maxHeight: number;
  32172. deviceId: string;
  32173. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  32174. /**
  32175. * Creates a video texture straight from your WebCam video feed.
  32176. * @param scene Define the scene the texture should be created in
  32177. * @param onReady Define a callback to triggered once the texture will be ready
  32178. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  32179. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  32180. */
  32181. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  32182. minWidth: number;
  32183. maxWidth: number;
  32184. minHeight: number;
  32185. maxHeight: number;
  32186. deviceId: string;
  32187. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  32188. }
  32189. }
  32190. declare module "babylonjs/Engines/thinEngine" {
  32191. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  32192. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  32193. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  32194. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32195. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  32196. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  32197. import { Observable } from "babylonjs/Misc/observable";
  32198. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  32199. import { StencilState } from "babylonjs/States/stencilState";
  32200. import { AlphaState } from "babylonjs/States/alphaCullingState";
  32201. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  32202. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  32203. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  32204. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  32205. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  32206. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  32207. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  32208. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  32209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32210. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32211. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  32212. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  32213. import { WebRequest } from "babylonjs/Misc/webRequest";
  32214. import { LoadFileError } from "babylonjs/Misc/fileTools";
  32215. /**
  32216. * Defines the interface used by objects working like Scene
  32217. * @hidden
  32218. */
  32219. export interface ISceneLike {
  32220. _addPendingData(data: any): void;
  32221. _removePendingData(data: any): void;
  32222. offlineProvider: IOfflineProvider;
  32223. }
  32224. /** Interface defining initialization parameters for Engine class */
  32225. export interface EngineOptions extends WebGLContextAttributes {
  32226. /**
  32227. * Defines if the engine should no exceed a specified device ratio
  32228. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  32229. */
  32230. limitDeviceRatio?: number;
  32231. /**
  32232. * Defines if webvr should be enabled automatically
  32233. * @see http://doc.babylonjs.com/how_to/webvr_camera
  32234. */
  32235. autoEnableWebVR?: boolean;
  32236. /**
  32237. * Defines if webgl2 should be turned off even if supported
  32238. * @see http://doc.babylonjs.com/features/webgl2
  32239. */
  32240. disableWebGL2Support?: boolean;
  32241. /**
  32242. * Defines if webaudio should be initialized as well
  32243. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  32244. */
  32245. audioEngine?: boolean;
  32246. /**
  32247. * Defines if animations should run using a deterministic lock step
  32248. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32249. */
  32250. deterministicLockstep?: boolean;
  32251. /** Defines the maximum steps to use with deterministic lock step mode */
  32252. lockstepMaxSteps?: number;
  32253. /** Defines the seconds between each deterministic lock step */
  32254. timeStep?: number;
  32255. /**
  32256. * Defines that engine should ignore context lost events
  32257. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  32258. */
  32259. doNotHandleContextLost?: boolean;
  32260. /**
  32261. * Defines that engine should ignore modifying touch action attribute and style
  32262. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  32263. */
  32264. doNotHandleTouchAction?: boolean;
  32265. /**
  32266. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  32267. */
  32268. useHighPrecisionFloats?: boolean;
  32269. }
  32270. /**
  32271. * The base engine class (root of all engines)
  32272. */
  32273. export class ThinEngine {
  32274. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  32275. static ExceptionList: ({
  32276. key: string;
  32277. capture: string;
  32278. captureConstraint: number;
  32279. targets: string[];
  32280. } | {
  32281. key: string;
  32282. capture: null;
  32283. captureConstraint: null;
  32284. targets: string[];
  32285. })[];
  32286. /** @hidden */
  32287. static _TextureLoaders: IInternalTextureLoader[];
  32288. /**
  32289. * Returns the current npm package of the sdk
  32290. */
  32291. static get NpmPackage(): string;
  32292. /**
  32293. * Returns the current version of the framework
  32294. */
  32295. static get Version(): string;
  32296. /**
  32297. * Returns a string describing the current engine
  32298. */
  32299. get description(): string;
  32300. /**
  32301. * Gets or sets the epsilon value used by collision engine
  32302. */
  32303. static CollisionsEpsilon: number;
  32304. /**
  32305. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  32306. */
  32307. static get ShadersRepository(): string;
  32308. static set ShadersRepository(value: string);
  32309. /** @hidden */
  32310. _shaderProcessor: IShaderProcessor;
  32311. /**
  32312. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  32313. */
  32314. forcePOTTextures: boolean;
  32315. /**
  32316. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  32317. */
  32318. isFullscreen: boolean;
  32319. /**
  32320. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  32321. */
  32322. cullBackFaces: boolean;
  32323. /**
  32324. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  32325. */
  32326. renderEvenInBackground: boolean;
  32327. /**
  32328. * Gets or sets a boolean indicating that cache can be kept between frames
  32329. */
  32330. preventCacheWipeBetweenFrames: boolean;
  32331. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  32332. validateShaderPrograms: boolean;
  32333. /**
  32334. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  32335. * This can provide greater z depth for distant objects.
  32336. */
  32337. useReverseDepthBuffer: boolean;
  32338. /**
  32339. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  32340. */
  32341. disableUniformBuffers: boolean;
  32342. /** @hidden */
  32343. _uniformBuffers: UniformBuffer[];
  32344. /**
  32345. * Gets a boolean indicating that the engine supports uniform buffers
  32346. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  32347. */
  32348. get supportsUniformBuffers(): boolean;
  32349. /** @hidden */
  32350. _gl: WebGLRenderingContext;
  32351. /** @hidden */
  32352. _webGLVersion: number;
  32353. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  32354. protected _windowIsBackground: boolean;
  32355. protected _creationOptions: EngineOptions;
  32356. protected _highPrecisionShadersAllowed: boolean;
  32357. /** @hidden */
  32358. get _shouldUseHighPrecisionShader(): boolean;
  32359. /**
  32360. * Gets a boolean indicating that only power of 2 textures are supported
  32361. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  32362. */
  32363. get needPOTTextures(): boolean;
  32364. /** @hidden */
  32365. _badOS: boolean;
  32366. /** @hidden */
  32367. _badDesktopOS: boolean;
  32368. private _hardwareScalingLevel;
  32369. /** @hidden */
  32370. _caps: EngineCapabilities;
  32371. private _isStencilEnable;
  32372. private _glVersion;
  32373. private _glRenderer;
  32374. private _glVendor;
  32375. /** @hidden */
  32376. _videoTextureSupported: boolean;
  32377. protected _renderingQueueLaunched: boolean;
  32378. protected _activeRenderLoops: (() => void)[];
  32379. /**
  32380. * Observable signaled when a context lost event is raised
  32381. */
  32382. onContextLostObservable: Observable<ThinEngine>;
  32383. /**
  32384. * Observable signaled when a context restored event is raised
  32385. */
  32386. onContextRestoredObservable: Observable<ThinEngine>;
  32387. private _onContextLost;
  32388. private _onContextRestored;
  32389. protected _contextWasLost: boolean;
  32390. /** @hidden */
  32391. _doNotHandleContextLost: boolean;
  32392. /**
  32393. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  32394. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  32395. */
  32396. get doNotHandleContextLost(): boolean;
  32397. set doNotHandleContextLost(value: boolean);
  32398. /**
  32399. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  32400. */
  32401. disableVertexArrayObjects: boolean;
  32402. /** @hidden */
  32403. protected _colorWrite: boolean;
  32404. /** @hidden */
  32405. protected _colorWriteChanged: boolean;
  32406. /** @hidden */
  32407. protected _depthCullingState: DepthCullingState;
  32408. /** @hidden */
  32409. protected _stencilState: StencilState;
  32410. /** @hidden */
  32411. _alphaState: AlphaState;
  32412. /** @hidden */
  32413. _alphaMode: number;
  32414. /** @hidden */
  32415. _alphaEquation: number;
  32416. /** @hidden */
  32417. _internalTexturesCache: InternalTexture[];
  32418. /** @hidden */
  32419. protected _activeChannel: number;
  32420. private _currentTextureChannel;
  32421. /** @hidden */
  32422. protected _boundTexturesCache: {
  32423. [key: string]: Nullable<InternalTexture>;
  32424. };
  32425. /** @hidden */
  32426. protected _currentEffect: Nullable<Effect>;
  32427. /** @hidden */
  32428. protected _currentProgram: Nullable<WebGLProgram>;
  32429. private _compiledEffects;
  32430. private _vertexAttribArraysEnabled;
  32431. /** @hidden */
  32432. protected _cachedViewport: Nullable<IViewportLike>;
  32433. private _cachedVertexArrayObject;
  32434. /** @hidden */
  32435. protected _cachedVertexBuffers: any;
  32436. /** @hidden */
  32437. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  32438. /** @hidden */
  32439. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  32440. /** @hidden */
  32441. _currentRenderTarget: Nullable<InternalTexture>;
  32442. private _uintIndicesCurrentlySet;
  32443. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  32444. /** @hidden */
  32445. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  32446. private _currentBufferPointers;
  32447. private _currentInstanceLocations;
  32448. private _currentInstanceBuffers;
  32449. private _textureUnits;
  32450. /** @hidden */
  32451. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  32452. /** @hidden */
  32453. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  32454. /** @hidden */
  32455. _boundRenderFunction: any;
  32456. private _vaoRecordInProgress;
  32457. private _mustWipeVertexAttributes;
  32458. private _emptyTexture;
  32459. private _emptyCubeTexture;
  32460. private _emptyTexture3D;
  32461. private _emptyTexture2DArray;
  32462. /** @hidden */
  32463. _frameHandler: number;
  32464. private _nextFreeTextureSlots;
  32465. private _maxSimultaneousTextures;
  32466. private _activeRequests;
  32467. /** @hidden */
  32468. _transformTextureUrl: Nullable<(url: string) => string>;
  32469. protected get _supportsHardwareTextureRescaling(): boolean;
  32470. private _framebufferDimensionsObject;
  32471. /**
  32472. * sets the object from which width and height will be taken from when getting render width and height
  32473. * Will fallback to the gl object
  32474. * @param dimensions the framebuffer width and height that will be used.
  32475. */
  32476. set framebufferDimensionsObject(dimensions: Nullable<{
  32477. framebufferWidth: number;
  32478. framebufferHeight: number;
  32479. }>);
  32480. /**
  32481. * Gets the current viewport
  32482. */
  32483. get currentViewport(): Nullable<IViewportLike>;
  32484. /**
  32485. * Gets the default empty texture
  32486. */
  32487. get emptyTexture(): InternalTexture;
  32488. /**
  32489. * Gets the default empty 3D texture
  32490. */
  32491. get emptyTexture3D(): InternalTexture;
  32492. /**
  32493. * Gets the default empty 2D array texture
  32494. */
  32495. get emptyTexture2DArray(): InternalTexture;
  32496. /**
  32497. * Gets the default empty cube texture
  32498. */
  32499. get emptyCubeTexture(): InternalTexture;
  32500. /**
  32501. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  32502. */
  32503. readonly premultipliedAlpha: boolean;
  32504. /**
  32505. * Observable event triggered before each texture is initialized
  32506. */
  32507. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  32508. /**
  32509. * Creates a new engine
  32510. * @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
  32511. * @param antialias defines enable antialiasing (default: false)
  32512. * @param options defines further options to be sent to the getContext() function
  32513. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  32514. */
  32515. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  32516. private _rebuildInternalTextures;
  32517. private _rebuildEffects;
  32518. /**
  32519. * Gets a boolean indicating if all created effects are ready
  32520. * @returns true if all effects are ready
  32521. */
  32522. areAllEffectsReady(): boolean;
  32523. protected _rebuildBuffers(): void;
  32524. protected _initGLContext(): void;
  32525. /**
  32526. * Gets version of the current webGL context
  32527. */
  32528. get webGLVersion(): number;
  32529. /**
  32530. * Gets a string idenfifying the name of the class
  32531. * @returns "Engine" string
  32532. */
  32533. getClassName(): string;
  32534. /**
  32535. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  32536. */
  32537. get isStencilEnable(): boolean;
  32538. /** @hidden */
  32539. _prepareWorkingCanvas(): void;
  32540. /**
  32541. * Reset the texture cache to empty state
  32542. */
  32543. resetTextureCache(): void;
  32544. /**
  32545. * Gets an object containing information about the current webGL context
  32546. * @returns an object containing the vender, the renderer and the version of the current webGL context
  32547. */
  32548. getGlInfo(): {
  32549. vendor: string;
  32550. renderer: string;
  32551. version: string;
  32552. };
  32553. /**
  32554. * Defines the hardware scaling level.
  32555. * By default the hardware scaling level is computed from the window device ratio.
  32556. * 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.
  32557. * @param level defines the level to use
  32558. */
  32559. setHardwareScalingLevel(level: number): void;
  32560. /**
  32561. * Gets the current hardware scaling level.
  32562. * By default the hardware scaling level is computed from the window device ratio.
  32563. * 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.
  32564. * @returns a number indicating the current hardware scaling level
  32565. */
  32566. getHardwareScalingLevel(): number;
  32567. /**
  32568. * Gets the list of loaded textures
  32569. * @returns an array containing all loaded textures
  32570. */
  32571. getLoadedTexturesCache(): InternalTexture[];
  32572. /**
  32573. * Gets the object containing all engine capabilities
  32574. * @returns the EngineCapabilities object
  32575. */
  32576. getCaps(): EngineCapabilities;
  32577. /**
  32578. * stop executing a render loop function and remove it from the execution array
  32579. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  32580. */
  32581. stopRenderLoop(renderFunction?: () => void): void;
  32582. /** @hidden */
  32583. _renderLoop(): void;
  32584. /**
  32585. * Gets the HTML canvas attached with the current webGL context
  32586. * @returns a HTML canvas
  32587. */
  32588. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  32589. /**
  32590. * Gets host window
  32591. * @returns the host window object
  32592. */
  32593. getHostWindow(): Nullable<Window>;
  32594. /**
  32595. * Gets the current render width
  32596. * @param useScreen defines if screen size must be used (or the current render target if any)
  32597. * @returns a number defining the current render width
  32598. */
  32599. getRenderWidth(useScreen?: boolean): number;
  32600. /**
  32601. * Gets the current render height
  32602. * @param useScreen defines if screen size must be used (or the current render target if any)
  32603. * @returns a number defining the current render height
  32604. */
  32605. getRenderHeight(useScreen?: boolean): number;
  32606. /**
  32607. * Can be used to override the current requestAnimationFrame requester.
  32608. * @hidden
  32609. */
  32610. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  32611. /**
  32612. * Register and execute a render loop. The engine can have more than one render function
  32613. * @param renderFunction defines the function to continuously execute
  32614. */
  32615. runRenderLoop(renderFunction: () => void): void;
  32616. /**
  32617. * Clear the current render buffer or the current render target (if any is set up)
  32618. * @param color defines the color to use
  32619. * @param backBuffer defines if the back buffer must be cleared
  32620. * @param depth defines if the depth buffer must be cleared
  32621. * @param stencil defines if the stencil buffer must be cleared
  32622. */
  32623. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  32624. private _viewportCached;
  32625. /** @hidden */
  32626. _viewport(x: number, y: number, width: number, height: number): void;
  32627. /**
  32628. * Set the WebGL's viewport
  32629. * @param viewport defines the viewport element to be used
  32630. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  32631. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  32632. */
  32633. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  32634. /**
  32635. * Begin a new frame
  32636. */
  32637. beginFrame(): void;
  32638. /**
  32639. * Enf the current frame
  32640. */
  32641. endFrame(): void;
  32642. /**
  32643. * Resize the view according to the canvas' size
  32644. */
  32645. resize(): void;
  32646. /**
  32647. * Force a specific size of the canvas
  32648. * @param width defines the new canvas' width
  32649. * @param height defines the new canvas' height
  32650. */
  32651. setSize(width: number, height: number): void;
  32652. /**
  32653. * Binds the frame buffer to the specified texture.
  32654. * @param texture The texture to render to or null for the default canvas
  32655. * @param faceIndex The face of the texture to render to in case of cube texture
  32656. * @param requiredWidth The width of the target to render to
  32657. * @param requiredHeight The height of the target to render to
  32658. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  32659. * @param lodLevel defines the lod level to bind to the frame buffer
  32660. * @param layer defines the 2d array index to bind to frame buffer to
  32661. */
  32662. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  32663. /** @hidden */
  32664. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  32665. /**
  32666. * Unbind the current render target texture from the webGL context
  32667. * @param texture defines the render target texture to unbind
  32668. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  32669. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  32670. */
  32671. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  32672. /**
  32673. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  32674. */
  32675. flushFramebuffer(): void;
  32676. /**
  32677. * Unbind the current render target and bind the default framebuffer
  32678. */
  32679. restoreDefaultFramebuffer(): void;
  32680. /** @hidden */
  32681. protected _resetVertexBufferBinding(): void;
  32682. /**
  32683. * Creates a vertex buffer
  32684. * @param data the data for the vertex buffer
  32685. * @returns the new WebGL static buffer
  32686. */
  32687. createVertexBuffer(data: DataArray): DataBuffer;
  32688. private _createVertexBuffer;
  32689. /**
  32690. * Creates a dynamic vertex buffer
  32691. * @param data the data for the dynamic vertex buffer
  32692. * @returns the new WebGL dynamic buffer
  32693. */
  32694. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  32695. protected _resetIndexBufferBinding(): void;
  32696. /**
  32697. * Creates a new index buffer
  32698. * @param indices defines the content of the index buffer
  32699. * @param updatable defines if the index buffer must be updatable
  32700. * @returns a new webGL buffer
  32701. */
  32702. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  32703. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  32704. /**
  32705. * Bind a webGL buffer to the webGL context
  32706. * @param buffer defines the buffer to bind
  32707. */
  32708. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  32709. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  32710. private bindBuffer;
  32711. /**
  32712. * update the bound buffer with the given data
  32713. * @param data defines the data to update
  32714. */
  32715. updateArrayBuffer(data: Float32Array): void;
  32716. private _vertexAttribPointer;
  32717. /** @hidden */
  32718. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  32719. private _bindVertexBuffersAttributes;
  32720. /**
  32721. * Records a vertex array object
  32722. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32723. * @param vertexBuffers defines the list of vertex buffers to store
  32724. * @param indexBuffer defines the index buffer to store
  32725. * @param effect defines the effect to store
  32726. * @returns the new vertex array object
  32727. */
  32728. recordVertexArrayObject(vertexBuffers: {
  32729. [key: string]: VertexBuffer;
  32730. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  32731. /**
  32732. * Bind a specific vertex array object
  32733. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  32734. * @param vertexArrayObject defines the vertex array object to bind
  32735. * @param indexBuffer defines the index buffer to bind
  32736. */
  32737. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  32738. /**
  32739. * Bind webGl buffers directly to the webGL context
  32740. * @param vertexBuffer defines the vertex buffer to bind
  32741. * @param indexBuffer defines the index buffer to bind
  32742. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  32743. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  32744. * @param effect defines the effect associated with the vertex buffer
  32745. */
  32746. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  32747. private _unbindVertexArrayObject;
  32748. /**
  32749. * Bind a list of vertex buffers to the webGL context
  32750. * @param vertexBuffers defines the list of vertex buffers to bind
  32751. * @param indexBuffer defines the index buffer to bind
  32752. * @param effect defines the effect associated with the vertex buffers
  32753. */
  32754. bindBuffers(vertexBuffers: {
  32755. [key: string]: Nullable<VertexBuffer>;
  32756. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  32757. /**
  32758. * Unbind all instance attributes
  32759. */
  32760. unbindInstanceAttributes(): void;
  32761. /**
  32762. * Release and free the memory of a vertex array object
  32763. * @param vao defines the vertex array object to delete
  32764. */
  32765. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  32766. /** @hidden */
  32767. _releaseBuffer(buffer: DataBuffer): boolean;
  32768. protected _deleteBuffer(buffer: DataBuffer): void;
  32769. /**
  32770. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  32771. * @param instancesBuffer defines the webGL buffer to update and bind
  32772. * @param data defines the data to store in the buffer
  32773. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  32774. */
  32775. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  32776. /**
  32777. * Bind the content of a webGL buffer used with instantiation
  32778. * @param instancesBuffer defines the webGL buffer to bind
  32779. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  32780. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  32781. */
  32782. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  32783. /**
  32784. * Disable the instance attribute corresponding to the name in parameter
  32785. * @param name defines the name of the attribute to disable
  32786. */
  32787. disableInstanceAttributeByName(name: string): void;
  32788. /**
  32789. * Disable the instance attribute corresponding to the location in parameter
  32790. * @param attributeLocation defines the attribute location of the attribute to disable
  32791. */
  32792. disableInstanceAttribute(attributeLocation: number): void;
  32793. /**
  32794. * Disable the attribute corresponding to the location in parameter
  32795. * @param attributeLocation defines the attribute location of the attribute to disable
  32796. */
  32797. disableAttributeByIndex(attributeLocation: number): void;
  32798. /**
  32799. * Send a draw order
  32800. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32801. * @param indexStart defines the starting index
  32802. * @param indexCount defines the number of index to draw
  32803. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32804. */
  32805. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  32806. /**
  32807. * Draw a list of points
  32808. * @param verticesStart defines the index of first vertex to draw
  32809. * @param verticesCount defines the count of vertices to draw
  32810. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32811. */
  32812. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32813. /**
  32814. * Draw a list of unindexed primitives
  32815. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  32816. * @param verticesStart defines the index of first vertex to draw
  32817. * @param verticesCount defines the count of vertices to draw
  32818. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32819. */
  32820. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32821. /**
  32822. * Draw a list of indexed primitives
  32823. * @param fillMode defines the primitive to use
  32824. * @param indexStart defines the starting index
  32825. * @param indexCount defines the number of index to draw
  32826. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32827. */
  32828. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  32829. /**
  32830. * Draw a list of unindexed primitives
  32831. * @param fillMode defines the primitive to use
  32832. * @param verticesStart defines the index of first vertex to draw
  32833. * @param verticesCount defines the count of vertices to draw
  32834. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  32835. */
  32836. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  32837. private _drawMode;
  32838. /** @hidden */
  32839. protected _reportDrawCall(): void;
  32840. /** @hidden */
  32841. _releaseEffect(effect: Effect): void;
  32842. /** @hidden */
  32843. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  32844. /**
  32845. * Create a new effect (used to store vertex/fragment shaders)
  32846. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  32847. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  32848. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  32849. * @param samplers defines an array of string used to represent textures
  32850. * @param defines defines the string containing the defines to use to compile the shaders
  32851. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  32852. * @param onCompiled defines a function to call when the effect creation is successful
  32853. * @param onError defines a function to call when the effect creation has failed
  32854. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  32855. * @returns the new Effect
  32856. */
  32857. 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;
  32858. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  32859. private _compileShader;
  32860. private _compileRawShader;
  32861. /** @hidden */
  32862. _getShaderSource(shader: WebGLShader): Nullable<string>;
  32863. /**
  32864. * Directly creates a webGL program
  32865. * @param pipelineContext defines the pipeline context to attach to
  32866. * @param vertexCode defines the vertex shader code to use
  32867. * @param fragmentCode defines the fragment shader code to use
  32868. * @param context defines the webGL context to use (if not set, the current one will be used)
  32869. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32870. * @returns the new webGL program
  32871. */
  32872. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32873. /**
  32874. * Creates a webGL program
  32875. * @param pipelineContext defines the pipeline context to attach to
  32876. * @param vertexCode defines the vertex shader code to use
  32877. * @param fragmentCode defines the fragment shader code to use
  32878. * @param defines defines the string containing the defines to use to compile the shaders
  32879. * @param context defines the webGL context to use (if not set, the current one will be used)
  32880. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  32881. * @returns the new webGL program
  32882. */
  32883. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32884. /**
  32885. * Creates a new pipeline context
  32886. * @returns the new pipeline
  32887. */
  32888. createPipelineContext(): IPipelineContext;
  32889. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  32890. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  32891. /** @hidden */
  32892. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  32893. /** @hidden */
  32894. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  32895. /** @hidden */
  32896. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  32897. /**
  32898. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  32899. * @param pipelineContext defines the pipeline context to use
  32900. * @param uniformsNames defines the list of uniform names
  32901. * @returns an array of webGL uniform locations
  32902. */
  32903. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  32904. /**
  32905. * Gets the lsit of active attributes for a given webGL program
  32906. * @param pipelineContext defines the pipeline context to use
  32907. * @param attributesNames defines the list of attribute names to get
  32908. * @returns an array of indices indicating the offset of each attribute
  32909. */
  32910. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  32911. /**
  32912. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  32913. * @param effect defines the effect to activate
  32914. */
  32915. enableEffect(effect: Nullable<Effect>): void;
  32916. /**
  32917. * Set the value of an uniform to a number (int)
  32918. * @param uniform defines the webGL uniform location where to store the value
  32919. * @param value defines the int number to store
  32920. */
  32921. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32922. /**
  32923. * Set the value of an uniform to an array of int32
  32924. * @param uniform defines the webGL uniform location where to store the value
  32925. * @param array defines the array of int32 to store
  32926. */
  32927. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32928. /**
  32929. * Set the value of an uniform to an array of int32 (stored as vec2)
  32930. * @param uniform defines the webGL uniform location where to store the value
  32931. * @param array defines the array of int32 to store
  32932. */
  32933. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32934. /**
  32935. * Set the value of an uniform to an array of int32 (stored as vec3)
  32936. * @param uniform defines the webGL uniform location where to store the value
  32937. * @param array defines the array of int32 to store
  32938. */
  32939. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32940. /**
  32941. * Set the value of an uniform to an array of int32 (stored as vec4)
  32942. * @param uniform defines the webGL uniform location where to store the value
  32943. * @param array defines the array of int32 to store
  32944. */
  32945. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  32946. /**
  32947. * Set the value of an uniform to an array of number
  32948. * @param uniform defines the webGL uniform location where to store the value
  32949. * @param array defines the array of number to store
  32950. */
  32951. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32952. /**
  32953. * Set the value of an uniform to an array of number (stored as vec2)
  32954. * @param uniform defines the webGL uniform location where to store the value
  32955. * @param array defines the array of number to store
  32956. */
  32957. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32958. /**
  32959. * Set the value of an uniform to an array of number (stored as vec3)
  32960. * @param uniform defines the webGL uniform location where to store the value
  32961. * @param array defines the array of number to store
  32962. */
  32963. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32964. /**
  32965. * Set the value of an uniform to an array of number (stored as vec4)
  32966. * @param uniform defines the webGL uniform location where to store the value
  32967. * @param array defines the array of number to store
  32968. */
  32969. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  32970. /**
  32971. * Set the value of an uniform to an array of float32 (stored as matrices)
  32972. * @param uniform defines the webGL uniform location where to store the value
  32973. * @param matrices defines the array of float32 to store
  32974. */
  32975. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  32976. /**
  32977. * Set the value of an uniform to a matrix (3x3)
  32978. * @param uniform defines the webGL uniform location where to store the value
  32979. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  32980. */
  32981. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32982. /**
  32983. * Set the value of an uniform to a matrix (2x2)
  32984. * @param uniform defines the webGL uniform location where to store the value
  32985. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  32986. */
  32987. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  32988. /**
  32989. * Set the value of an uniform to a number (float)
  32990. * @param uniform defines the webGL uniform location where to store the value
  32991. * @param value defines the float number to store
  32992. */
  32993. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  32994. /**
  32995. * Set the value of an uniform to a vec2
  32996. * @param uniform defines the webGL uniform location where to store the value
  32997. * @param x defines the 1st component of the value
  32998. * @param y defines the 2nd component of the value
  32999. */
  33000. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  33001. /**
  33002. * Set the value of an uniform to a vec3
  33003. * @param uniform defines the webGL uniform location where to store the value
  33004. * @param x defines the 1st component of the value
  33005. * @param y defines the 2nd component of the value
  33006. * @param z defines the 3rd component of the value
  33007. */
  33008. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  33009. /**
  33010. * Set the value of an uniform to a vec4
  33011. * @param uniform defines the webGL uniform location where to store the value
  33012. * @param x defines the 1st component of the value
  33013. * @param y defines the 2nd component of the value
  33014. * @param z defines the 3rd component of the value
  33015. * @param w defines the 4th component of the value
  33016. */
  33017. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  33018. /**
  33019. * Apply all cached states (depth, culling, stencil and alpha)
  33020. */
  33021. applyStates(): void;
  33022. /**
  33023. * Enable or disable color writing
  33024. * @param enable defines the state to set
  33025. */
  33026. setColorWrite(enable: boolean): void;
  33027. /**
  33028. * Gets a boolean indicating if color writing is enabled
  33029. * @returns the current color writing state
  33030. */
  33031. getColorWrite(): boolean;
  33032. /**
  33033. * Gets the depth culling state manager
  33034. */
  33035. get depthCullingState(): DepthCullingState;
  33036. /**
  33037. * Gets the alpha state manager
  33038. */
  33039. get alphaState(): AlphaState;
  33040. /**
  33041. * Gets the stencil state manager
  33042. */
  33043. get stencilState(): StencilState;
  33044. /**
  33045. * Clears the list of texture accessible through engine.
  33046. * This can help preventing texture load conflict due to name collision.
  33047. */
  33048. clearInternalTexturesCache(): void;
  33049. /**
  33050. * Force the entire cache to be cleared
  33051. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  33052. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  33053. */
  33054. wipeCaches(bruteForce?: boolean): void;
  33055. /** @hidden */
  33056. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  33057. min: number;
  33058. mag: number;
  33059. };
  33060. /** @hidden */
  33061. _createTexture(): WebGLTexture;
  33062. /**
  33063. * Usually called from Texture.ts.
  33064. * Passed information to create a WebGLTexture
  33065. * @param url defines a value which contains one of the following:
  33066. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  33067. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  33068. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  33069. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  33070. * @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)
  33071. * @param scene needed for loading to the correct scene
  33072. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  33073. * @param onLoad optional callback to be called upon successful completion
  33074. * @param onError optional callback to be called upon failure
  33075. * @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
  33076. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  33077. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  33078. * @param forcedExtension defines the extension to use to pick the right loader
  33079. * @param mimeType defines an optional mime type
  33080. * @returns a InternalTexture for assignment back into BABYLON.Texture
  33081. */
  33082. 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;
  33083. /**
  33084. * Loads an image as an HTMLImageElement.
  33085. * @param input url string, ArrayBuffer, or Blob to load
  33086. * @param onLoad callback called when the image successfully loads
  33087. * @param onError callback called when the image fails to load
  33088. * @param offlineProvider offline provider for caching
  33089. * @param mimeType optional mime type
  33090. * @returns the HTMLImageElement of the loaded image
  33091. * @hidden
  33092. */
  33093. 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>;
  33094. /**
  33095. * @hidden
  33096. */
  33097. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  33098. /**
  33099. * Creates a raw texture
  33100. * @param data defines the data to store in the texture
  33101. * @param width defines the width of the texture
  33102. * @param height defines the height of the texture
  33103. * @param format defines the format of the data
  33104. * @param generateMipMaps defines if the engine should generate the mip levels
  33105. * @param invertY defines if data must be stored with Y axis inverted
  33106. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  33107. * @param compression defines the compression used (null by default)
  33108. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  33109. * @returns the raw texture inside an InternalTexture
  33110. */
  33111. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  33112. /**
  33113. * Creates a new raw cube texture
  33114. * @param data defines the array of data to use to create each face
  33115. * @param size defines the size of the textures
  33116. * @param format defines the format of the data
  33117. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  33118. * @param generateMipMaps defines if the engine should generate the mip levels
  33119. * @param invertY defines if data must be stored with Y axis inverted
  33120. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33121. * @param compression defines the compression used (null by default)
  33122. * @returns the cube texture as an InternalTexture
  33123. */
  33124. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  33125. /**
  33126. * Creates a new raw 3D texture
  33127. * @param data defines the data used to create the texture
  33128. * @param width defines the width of the texture
  33129. * @param height defines the height of the texture
  33130. * @param depth defines the depth of the texture
  33131. * @param format defines the format of the texture
  33132. * @param generateMipMaps defines if the engine must generate mip levels
  33133. * @param invertY defines if data must be stored with Y axis inverted
  33134. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33135. * @param compression defines the compressed used (can be null)
  33136. * @param textureType defines the compressed used (can be null)
  33137. * @returns a new raw 3D texture (stored in an InternalTexture)
  33138. */
  33139. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33140. /**
  33141. * Creates a new raw 2D array texture
  33142. * @param data defines the data used to create the texture
  33143. * @param width defines the width of the texture
  33144. * @param height defines the height of the texture
  33145. * @param depth defines the number of layers of the texture
  33146. * @param format defines the format of the texture
  33147. * @param generateMipMaps defines if the engine must generate mip levels
  33148. * @param invertY defines if data must be stored with Y axis inverted
  33149. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  33150. * @param compression defines the compressed used (can be null)
  33151. * @param textureType defines the compressed used (can be null)
  33152. * @returns a new raw 2D array texture (stored in an InternalTexture)
  33153. */
  33154. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  33155. private _unpackFlipYCached;
  33156. /**
  33157. * In case you are sharing the context with other applications, it might
  33158. * be interested to not cache the unpack flip y state to ensure a consistent
  33159. * value would be set.
  33160. */
  33161. enableUnpackFlipYCached: boolean;
  33162. /** @hidden */
  33163. _unpackFlipY(value: boolean): void;
  33164. /** @hidden */
  33165. _getUnpackAlignement(): number;
  33166. private _getTextureTarget;
  33167. /**
  33168. * Update the sampling mode of a given texture
  33169. * @param samplingMode defines the required sampling mode
  33170. * @param texture defines the texture to update
  33171. * @param generateMipMaps defines whether to generate mipmaps for the texture
  33172. */
  33173. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  33174. /**
  33175. * Update the sampling mode of a given texture
  33176. * @param texture defines the texture to update
  33177. * @param wrapU defines the texture wrap mode of the u coordinates
  33178. * @param wrapV defines the texture wrap mode of the v coordinates
  33179. * @param wrapR defines the texture wrap mode of the r coordinates
  33180. */
  33181. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  33182. /** @hidden */
  33183. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  33184. width: number;
  33185. height: number;
  33186. layers?: number;
  33187. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  33188. /** @hidden */
  33189. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33190. /** @hidden */
  33191. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  33192. /**
  33193. * Update a portion of an internal texture
  33194. * @param texture defines the texture to update
  33195. * @param imageData defines the data to store into the texture
  33196. * @param xOffset defines the x coordinates of the update rectangle
  33197. * @param yOffset defines the y coordinates of the update rectangle
  33198. * @param width defines the width of the update rectangle
  33199. * @param height defines the height of the update rectangle
  33200. * @param faceIndex defines the face index if texture is a cube (0 by default)
  33201. * @param lod defines the lod level to update (0 by default)
  33202. */
  33203. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  33204. /** @hidden */
  33205. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  33206. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  33207. private _prepareWebGLTexture;
  33208. /** @hidden */
  33209. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  33210. private _getDepthStencilBuffer;
  33211. /** @hidden */
  33212. _releaseFramebufferObjects(texture: InternalTexture): void;
  33213. /** @hidden */
  33214. _releaseTexture(texture: InternalTexture): void;
  33215. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  33216. protected _setProgram(program: WebGLProgram): void;
  33217. protected _boundUniforms: {
  33218. [key: number]: WebGLUniformLocation;
  33219. };
  33220. /**
  33221. * Binds an effect to the webGL context
  33222. * @param effect defines the effect to bind
  33223. */
  33224. bindSamplers(effect: Effect): void;
  33225. private _activateCurrentTexture;
  33226. /** @hidden */
  33227. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  33228. /** @hidden */
  33229. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  33230. /**
  33231. * Unbind all textures from the webGL context
  33232. */
  33233. unbindAllTextures(): void;
  33234. /**
  33235. * Sets a texture to the according uniform.
  33236. * @param channel The texture channel
  33237. * @param uniform The uniform to set
  33238. * @param texture The texture to apply
  33239. */
  33240. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  33241. private _bindSamplerUniformToChannel;
  33242. private _getTextureWrapMode;
  33243. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  33244. /**
  33245. * Sets an array of texture to the webGL context
  33246. * @param channel defines the channel where the texture array must be set
  33247. * @param uniform defines the associated uniform location
  33248. * @param textures defines the array of textures to bind
  33249. */
  33250. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  33251. /** @hidden */
  33252. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  33253. private _setTextureParameterFloat;
  33254. private _setTextureParameterInteger;
  33255. /**
  33256. * Unbind all vertex attributes from the webGL context
  33257. */
  33258. unbindAllAttributes(): void;
  33259. /**
  33260. * 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
  33261. */
  33262. releaseEffects(): void;
  33263. /**
  33264. * Dispose and release all associated resources
  33265. */
  33266. dispose(): void;
  33267. /**
  33268. * Attach a new callback raised when context lost event is fired
  33269. * @param callback defines the callback to call
  33270. */
  33271. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33272. /**
  33273. * Attach a new callback raised when context restored event is fired
  33274. * @param callback defines the callback to call
  33275. */
  33276. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  33277. /**
  33278. * Get the current error code of the webGL context
  33279. * @returns the error code
  33280. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33281. */
  33282. getError(): number;
  33283. private _canRenderToFloatFramebuffer;
  33284. private _canRenderToHalfFloatFramebuffer;
  33285. private _canRenderToFramebuffer;
  33286. /** @hidden */
  33287. _getWebGLTextureType(type: number): number;
  33288. /** @hidden */
  33289. _getInternalFormat(format: number): number;
  33290. /** @hidden */
  33291. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  33292. /** @hidden */
  33293. _getRGBAMultiSampleBufferFormat(type: number): number;
  33294. /** @hidden */
  33295. _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;
  33296. /**
  33297. * Loads a file from a url
  33298. * @param url url to load
  33299. * @param onSuccess callback called when the file successfully loads
  33300. * @param onProgress callback called while file is loading (if the server supports this mode)
  33301. * @param offlineProvider defines the offline provider for caching
  33302. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  33303. * @param onError callback called when the file fails to load
  33304. * @returns a file request object
  33305. * @hidden
  33306. */
  33307. 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;
  33308. /**
  33309. * Reads pixels from the current frame buffer. Please note that this function can be slow
  33310. * @param x defines the x coordinate of the rectangle where pixels must be read
  33311. * @param y defines the y coordinate of the rectangle where pixels must be read
  33312. * @param width defines the width of the rectangle where pixels must be read
  33313. * @param height defines the height of the rectangle where pixels must be read
  33314. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  33315. * @returns a Uint8Array containing RGBA colors
  33316. */
  33317. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  33318. private static _isSupported;
  33319. /**
  33320. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33321. * @returns true if the engine can be created
  33322. * @ignorenaming
  33323. */
  33324. static isSupported(): boolean;
  33325. /**
  33326. * Find the next highest power of two.
  33327. * @param x Number to start search from.
  33328. * @return Next highest power of two.
  33329. */
  33330. static CeilingPOT(x: number): number;
  33331. /**
  33332. * Find the next lowest power of two.
  33333. * @param x Number to start search from.
  33334. * @return Next lowest power of two.
  33335. */
  33336. static FloorPOT(x: number): number;
  33337. /**
  33338. * Find the nearest power of two.
  33339. * @param x Number to start search from.
  33340. * @return Next nearest power of two.
  33341. */
  33342. static NearestPOT(x: number): number;
  33343. /**
  33344. * Get the closest exponent of two
  33345. * @param value defines the value to approximate
  33346. * @param max defines the maximum value to return
  33347. * @param mode defines how to define the closest value
  33348. * @returns closest exponent of two of the given value
  33349. */
  33350. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  33351. /**
  33352. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  33353. * @param func - the function to be called
  33354. * @param requester - the object that will request the next frame. Falls back to window.
  33355. * @returns frame number
  33356. */
  33357. static QueueNewFrame(func: () => void, requester?: any): number;
  33358. /**
  33359. * Gets host document
  33360. * @returns the host document object
  33361. */
  33362. getHostDocument(): Nullable<Document>;
  33363. }
  33364. }
  33365. declare module "babylonjs/Maths/sphericalPolynomial" {
  33366. import { Vector3 } from "babylonjs/Maths/math.vector";
  33367. import { Color3 } from "babylonjs/Maths/math.color";
  33368. /**
  33369. * Class representing spherical harmonics coefficients to the 3rd degree
  33370. */
  33371. export class SphericalHarmonics {
  33372. /**
  33373. * Defines whether or not the harmonics have been prescaled for rendering.
  33374. */
  33375. preScaled: boolean;
  33376. /**
  33377. * The l0,0 coefficients of the spherical harmonics
  33378. */
  33379. l00: Vector3;
  33380. /**
  33381. * The l1,-1 coefficients of the spherical harmonics
  33382. */
  33383. l1_1: Vector3;
  33384. /**
  33385. * The l1,0 coefficients of the spherical harmonics
  33386. */
  33387. l10: Vector3;
  33388. /**
  33389. * The l1,1 coefficients of the spherical harmonics
  33390. */
  33391. l11: Vector3;
  33392. /**
  33393. * The l2,-2 coefficients of the spherical harmonics
  33394. */
  33395. l2_2: Vector3;
  33396. /**
  33397. * The l2,-1 coefficients of the spherical harmonics
  33398. */
  33399. l2_1: Vector3;
  33400. /**
  33401. * The l2,0 coefficients of the spherical harmonics
  33402. */
  33403. l20: Vector3;
  33404. /**
  33405. * The l2,1 coefficients of the spherical harmonics
  33406. */
  33407. l21: Vector3;
  33408. /**
  33409. * The l2,2 coefficients of the spherical harmonics
  33410. */
  33411. l22: Vector3;
  33412. /**
  33413. * Adds a light to the spherical harmonics
  33414. * @param direction the direction of the light
  33415. * @param color the color of the light
  33416. * @param deltaSolidAngle the delta solid angle of the light
  33417. */
  33418. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  33419. /**
  33420. * Scales the spherical harmonics by the given amount
  33421. * @param scale the amount to scale
  33422. */
  33423. scaleInPlace(scale: number): void;
  33424. /**
  33425. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  33426. *
  33427. * ```
  33428. * E_lm = A_l * L_lm
  33429. * ```
  33430. *
  33431. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  33432. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  33433. * the scaling factors are given in equation 9.
  33434. */
  33435. convertIncidentRadianceToIrradiance(): void;
  33436. /**
  33437. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  33438. *
  33439. * ```
  33440. * L = (1/pi) * E * rho
  33441. * ```
  33442. *
  33443. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  33444. */
  33445. convertIrradianceToLambertianRadiance(): void;
  33446. /**
  33447. * Integrates the reconstruction coefficients directly in to the SH preventing further
  33448. * required operations at run time.
  33449. *
  33450. * This is simply done by scaling back the SH with Ylm constants parameter.
  33451. * The trigonometric part being applied by the shader at run time.
  33452. */
  33453. preScaleForRendering(): void;
  33454. /**
  33455. * Constructs a spherical harmonics from an array.
  33456. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  33457. * @returns the spherical harmonics
  33458. */
  33459. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  33460. /**
  33461. * Gets the spherical harmonics from polynomial
  33462. * @param polynomial the spherical polynomial
  33463. * @returns the spherical harmonics
  33464. */
  33465. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  33466. }
  33467. /**
  33468. * Class representing spherical polynomial coefficients to the 3rd degree
  33469. */
  33470. export class SphericalPolynomial {
  33471. private _harmonics;
  33472. /**
  33473. * The spherical harmonics used to create the polynomials.
  33474. */
  33475. get preScaledHarmonics(): SphericalHarmonics;
  33476. /**
  33477. * The x coefficients of the spherical polynomial
  33478. */
  33479. x: Vector3;
  33480. /**
  33481. * The y coefficients of the spherical polynomial
  33482. */
  33483. y: Vector3;
  33484. /**
  33485. * The z coefficients of the spherical polynomial
  33486. */
  33487. z: Vector3;
  33488. /**
  33489. * The xx coefficients of the spherical polynomial
  33490. */
  33491. xx: Vector3;
  33492. /**
  33493. * The yy coefficients of the spherical polynomial
  33494. */
  33495. yy: Vector3;
  33496. /**
  33497. * The zz coefficients of the spherical polynomial
  33498. */
  33499. zz: Vector3;
  33500. /**
  33501. * The xy coefficients of the spherical polynomial
  33502. */
  33503. xy: Vector3;
  33504. /**
  33505. * The yz coefficients of the spherical polynomial
  33506. */
  33507. yz: Vector3;
  33508. /**
  33509. * The zx coefficients of the spherical polynomial
  33510. */
  33511. zx: Vector3;
  33512. /**
  33513. * Adds an ambient color to the spherical polynomial
  33514. * @param color the color to add
  33515. */
  33516. addAmbient(color: Color3): void;
  33517. /**
  33518. * Scales the spherical polynomial by the given amount
  33519. * @param scale the amount to scale
  33520. */
  33521. scaleInPlace(scale: number): void;
  33522. /**
  33523. * Gets the spherical polynomial from harmonics
  33524. * @param harmonics the spherical harmonics
  33525. * @returns the spherical polynomial
  33526. */
  33527. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  33528. /**
  33529. * Constructs a spherical polynomial from an array.
  33530. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  33531. * @returns the spherical polynomial
  33532. */
  33533. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  33534. }
  33535. }
  33536. declare module "babylonjs/Materials/Textures/internalTexture" {
  33537. import { Observable } from "babylonjs/Misc/observable";
  33538. import { Nullable, int } from "babylonjs/types";
  33539. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  33540. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  33541. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  33542. /**
  33543. * Defines the source of the internal texture
  33544. */
  33545. export enum InternalTextureSource {
  33546. /**
  33547. * The source of the texture data is unknown
  33548. */
  33549. Unknown = 0,
  33550. /**
  33551. * Texture data comes from an URL
  33552. */
  33553. Url = 1,
  33554. /**
  33555. * Texture data is only used for temporary storage
  33556. */
  33557. Temp = 2,
  33558. /**
  33559. * Texture data comes from raw data (ArrayBuffer)
  33560. */
  33561. Raw = 3,
  33562. /**
  33563. * Texture content is dynamic (video or dynamic texture)
  33564. */
  33565. Dynamic = 4,
  33566. /**
  33567. * Texture content is generated by rendering to it
  33568. */
  33569. RenderTarget = 5,
  33570. /**
  33571. * Texture content is part of a multi render target process
  33572. */
  33573. MultiRenderTarget = 6,
  33574. /**
  33575. * Texture data comes from a cube data file
  33576. */
  33577. Cube = 7,
  33578. /**
  33579. * Texture data comes from a raw cube data
  33580. */
  33581. CubeRaw = 8,
  33582. /**
  33583. * Texture data come from a prefiltered cube data file
  33584. */
  33585. CubePrefiltered = 9,
  33586. /**
  33587. * Texture content is raw 3D data
  33588. */
  33589. Raw3D = 10,
  33590. /**
  33591. * Texture content is raw 2D array data
  33592. */
  33593. Raw2DArray = 11,
  33594. /**
  33595. * Texture content is a depth texture
  33596. */
  33597. Depth = 12,
  33598. /**
  33599. * Texture data comes from a raw cube data encoded with RGBD
  33600. */
  33601. CubeRawRGBD = 13
  33602. }
  33603. /**
  33604. * Class used to store data associated with WebGL texture data for the engine
  33605. * This class should not be used directly
  33606. */
  33607. export class InternalTexture {
  33608. /** @hidden */
  33609. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<import("babylonjs/Maths/sphericalPolynomial").SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  33610. /**
  33611. * Defines if the texture is ready
  33612. */
  33613. isReady: boolean;
  33614. /**
  33615. * Defines if the texture is a cube texture
  33616. */
  33617. isCube: boolean;
  33618. /**
  33619. * Defines if the texture contains 3D data
  33620. */
  33621. is3D: boolean;
  33622. /**
  33623. * Defines if the texture contains 2D array data
  33624. */
  33625. is2DArray: boolean;
  33626. /**
  33627. * Defines if the texture contains multiview data
  33628. */
  33629. isMultiview: boolean;
  33630. /**
  33631. * Gets the URL used to load this texture
  33632. */
  33633. url: string;
  33634. /**
  33635. * Gets the sampling mode of the texture
  33636. */
  33637. samplingMode: number;
  33638. /**
  33639. * Gets a boolean indicating if the texture needs mipmaps generation
  33640. */
  33641. generateMipMaps: boolean;
  33642. /**
  33643. * Gets the number of samples used by the texture (WebGL2+ only)
  33644. */
  33645. samples: number;
  33646. /**
  33647. * Gets the type of the texture (int, float...)
  33648. */
  33649. type: number;
  33650. /**
  33651. * Gets the format of the texture (RGB, RGBA...)
  33652. */
  33653. format: number;
  33654. /**
  33655. * Observable called when the texture is loaded
  33656. */
  33657. onLoadedObservable: Observable<InternalTexture>;
  33658. /**
  33659. * Gets the width of the texture
  33660. */
  33661. width: number;
  33662. /**
  33663. * Gets the height of the texture
  33664. */
  33665. height: number;
  33666. /**
  33667. * Gets the depth of the texture
  33668. */
  33669. depth: number;
  33670. /**
  33671. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  33672. */
  33673. baseWidth: number;
  33674. /**
  33675. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  33676. */
  33677. baseHeight: number;
  33678. /**
  33679. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  33680. */
  33681. baseDepth: number;
  33682. /**
  33683. * Gets a boolean indicating if the texture is inverted on Y axis
  33684. */
  33685. invertY: boolean;
  33686. /** @hidden */
  33687. _invertVScale: boolean;
  33688. /** @hidden */
  33689. _associatedChannel: number;
  33690. /** @hidden */
  33691. _source: InternalTextureSource;
  33692. /** @hidden */
  33693. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  33694. /** @hidden */
  33695. _bufferView: Nullable<ArrayBufferView>;
  33696. /** @hidden */
  33697. _bufferViewArray: Nullable<ArrayBufferView[]>;
  33698. /** @hidden */
  33699. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  33700. /** @hidden */
  33701. _size: number;
  33702. /** @hidden */
  33703. _extension: string;
  33704. /** @hidden */
  33705. _files: Nullable<string[]>;
  33706. /** @hidden */
  33707. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  33708. /** @hidden */
  33709. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  33710. /** @hidden */
  33711. _framebuffer: Nullable<WebGLFramebuffer>;
  33712. /** @hidden */
  33713. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  33714. /** @hidden */
  33715. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  33716. /** @hidden */
  33717. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  33718. /** @hidden */
  33719. _attachments: Nullable<number[]>;
  33720. /** @hidden */
  33721. _cachedCoordinatesMode: Nullable<number>;
  33722. /** @hidden */
  33723. _cachedWrapU: Nullable<number>;
  33724. /** @hidden */
  33725. _cachedWrapV: Nullable<number>;
  33726. /** @hidden */
  33727. _cachedWrapR: Nullable<number>;
  33728. /** @hidden */
  33729. _cachedAnisotropicFilteringLevel: Nullable<number>;
  33730. /** @hidden */
  33731. _isDisabled: boolean;
  33732. /** @hidden */
  33733. _compression: Nullable<string>;
  33734. /** @hidden */
  33735. _generateStencilBuffer: boolean;
  33736. /** @hidden */
  33737. _generateDepthBuffer: boolean;
  33738. /** @hidden */
  33739. _comparisonFunction: number;
  33740. /** @hidden */
  33741. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  33742. /** @hidden */
  33743. _lodGenerationScale: number;
  33744. /** @hidden */
  33745. _lodGenerationOffset: number;
  33746. /** @hidden */
  33747. _depthStencilTexture: Nullable<InternalTexture>;
  33748. /** @hidden */
  33749. _colorTextureArray: Nullable<WebGLTexture>;
  33750. /** @hidden */
  33751. _depthStencilTextureArray: Nullable<WebGLTexture>;
  33752. /** @hidden */
  33753. _lodTextureHigh: Nullable<BaseTexture>;
  33754. /** @hidden */
  33755. _lodTextureMid: Nullable<BaseTexture>;
  33756. /** @hidden */
  33757. _lodTextureLow: Nullable<BaseTexture>;
  33758. /** @hidden */
  33759. _isRGBD: boolean;
  33760. /** @hidden */
  33761. _linearSpecularLOD: boolean;
  33762. /** @hidden */
  33763. _irradianceTexture: Nullable<BaseTexture>;
  33764. /** @hidden */
  33765. _webGLTexture: Nullable<WebGLTexture>;
  33766. /** @hidden */
  33767. _references: number;
  33768. private _engine;
  33769. /**
  33770. * Gets the Engine the texture belongs to.
  33771. * @returns The babylon engine
  33772. */
  33773. getEngine(): ThinEngine;
  33774. /**
  33775. * Gets the data source type of the texture
  33776. */
  33777. get source(): InternalTextureSource;
  33778. /**
  33779. * Creates a new InternalTexture
  33780. * @param engine defines the engine to use
  33781. * @param source defines the type of data that will be used
  33782. * @param delayAllocation if the texture allocation should be delayed (default: false)
  33783. */
  33784. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  33785. /**
  33786. * Increments the number of references (ie. the number of Texture that point to it)
  33787. */
  33788. incrementReferences(): void;
  33789. /**
  33790. * Change the size of the texture (not the size of the content)
  33791. * @param width defines the new width
  33792. * @param height defines the new height
  33793. * @param depth defines the new depth (1 by default)
  33794. */
  33795. updateSize(width: int, height: int, depth?: int): void;
  33796. /** @hidden */
  33797. _rebuild(): void;
  33798. /** @hidden */
  33799. _swapAndDie(target: InternalTexture): void;
  33800. /**
  33801. * Dispose the current allocated resources
  33802. */
  33803. dispose(): void;
  33804. }
  33805. }
  33806. declare module "babylonjs/Audio/analyser" {
  33807. import { Scene } from "babylonjs/scene";
  33808. /**
  33809. * Class used to work with sound analyzer using fast fourier transform (FFT)
  33810. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33811. */
  33812. export class Analyser {
  33813. /**
  33814. * Gets or sets the smoothing
  33815. * @ignorenaming
  33816. */
  33817. SMOOTHING: number;
  33818. /**
  33819. * Gets or sets the FFT table size
  33820. * @ignorenaming
  33821. */
  33822. FFT_SIZE: number;
  33823. /**
  33824. * Gets or sets the bar graph amplitude
  33825. * @ignorenaming
  33826. */
  33827. BARGRAPHAMPLITUDE: number;
  33828. /**
  33829. * Gets or sets the position of the debug canvas
  33830. * @ignorenaming
  33831. */
  33832. DEBUGCANVASPOS: {
  33833. x: number;
  33834. y: number;
  33835. };
  33836. /**
  33837. * Gets or sets the debug canvas size
  33838. * @ignorenaming
  33839. */
  33840. DEBUGCANVASSIZE: {
  33841. width: number;
  33842. height: number;
  33843. };
  33844. private _byteFreqs;
  33845. private _byteTime;
  33846. private _floatFreqs;
  33847. private _webAudioAnalyser;
  33848. private _debugCanvas;
  33849. private _debugCanvasContext;
  33850. private _scene;
  33851. private _registerFunc;
  33852. private _audioEngine;
  33853. /**
  33854. * Creates a new analyser
  33855. * @param scene defines hosting scene
  33856. */
  33857. constructor(scene: Scene);
  33858. /**
  33859. * Get the number of data values you will have to play with for the visualization
  33860. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  33861. * @returns a number
  33862. */
  33863. getFrequencyBinCount(): number;
  33864. /**
  33865. * Gets the current frequency data as a byte array
  33866. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33867. * @returns a Uint8Array
  33868. */
  33869. getByteFrequencyData(): Uint8Array;
  33870. /**
  33871. * Gets the current waveform as a byte array
  33872. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  33873. * @returns a Uint8Array
  33874. */
  33875. getByteTimeDomainData(): Uint8Array;
  33876. /**
  33877. * Gets the current frequency data as a float array
  33878. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  33879. * @returns a Float32Array
  33880. */
  33881. getFloatFrequencyData(): Float32Array;
  33882. /**
  33883. * Renders the debug canvas
  33884. */
  33885. drawDebugCanvas(): void;
  33886. /**
  33887. * Stops rendering the debug canvas and removes it
  33888. */
  33889. stopDebugCanvas(): void;
  33890. /**
  33891. * Connects two audio nodes
  33892. * @param inputAudioNode defines first node to connect
  33893. * @param outputAudioNode defines second node to connect
  33894. */
  33895. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  33896. /**
  33897. * Releases all associated resources
  33898. */
  33899. dispose(): void;
  33900. }
  33901. }
  33902. declare module "babylonjs/Audio/audioEngine" {
  33903. import { IDisposable } from "babylonjs/scene";
  33904. import { Analyser } from "babylonjs/Audio/analyser";
  33905. import { Nullable } from "babylonjs/types";
  33906. import { Observable } from "babylonjs/Misc/observable";
  33907. /**
  33908. * This represents an audio engine and it is responsible
  33909. * to play, synchronize and analyse sounds throughout the application.
  33910. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33911. */
  33912. export interface IAudioEngine extends IDisposable {
  33913. /**
  33914. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33915. */
  33916. readonly canUseWebAudio: boolean;
  33917. /**
  33918. * Gets the current AudioContext if available.
  33919. */
  33920. readonly audioContext: Nullable<AudioContext>;
  33921. /**
  33922. * The master gain node defines the global audio volume of your audio engine.
  33923. */
  33924. readonly masterGain: GainNode;
  33925. /**
  33926. * Gets whether or not mp3 are supported by your browser.
  33927. */
  33928. readonly isMP3supported: boolean;
  33929. /**
  33930. * Gets whether or not ogg are supported by your browser.
  33931. */
  33932. readonly isOGGsupported: boolean;
  33933. /**
  33934. * Defines if Babylon should emit a warning if WebAudio is not supported.
  33935. * @ignoreNaming
  33936. */
  33937. WarnedWebAudioUnsupported: boolean;
  33938. /**
  33939. * Defines if the audio engine relies on a custom unlocked button.
  33940. * In this case, the embedded button will not be displayed.
  33941. */
  33942. useCustomUnlockedButton: boolean;
  33943. /**
  33944. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  33945. */
  33946. readonly unlocked: boolean;
  33947. /**
  33948. * Event raised when audio has been unlocked on the browser.
  33949. */
  33950. onAudioUnlockedObservable: Observable<AudioEngine>;
  33951. /**
  33952. * Event raised when audio has been locked on the browser.
  33953. */
  33954. onAudioLockedObservable: Observable<AudioEngine>;
  33955. /**
  33956. * Flags the audio engine in Locked state.
  33957. * This happens due to new browser policies preventing audio to autoplay.
  33958. */
  33959. lock(): void;
  33960. /**
  33961. * Unlocks the audio engine once a user action has been done on the dom.
  33962. * This is helpful to resume play once browser policies have been satisfied.
  33963. */
  33964. unlock(): void;
  33965. /**
  33966. * Gets the global volume sets on the master gain.
  33967. * @returns the global volume if set or -1 otherwise
  33968. */
  33969. getGlobalVolume(): number;
  33970. /**
  33971. * Sets the global volume of your experience (sets on the master gain).
  33972. * @param newVolume Defines the new global volume of the application
  33973. */
  33974. setGlobalVolume(newVolume: number): void;
  33975. /**
  33976. * Connect the audio engine to an audio analyser allowing some amazing
  33977. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  33978. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  33979. * @param analyser The analyser to connect to the engine
  33980. */
  33981. connectToAnalyser(analyser: Analyser): void;
  33982. }
  33983. /**
  33984. * This represents the default audio engine used in babylon.
  33985. * It is responsible to play, synchronize and analyse sounds throughout the application.
  33986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  33987. */
  33988. export class AudioEngine implements IAudioEngine {
  33989. private _audioContext;
  33990. private _audioContextInitialized;
  33991. private _muteButton;
  33992. private _hostElement;
  33993. /**
  33994. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  33995. */
  33996. canUseWebAudio: boolean;
  33997. /**
  33998. * The master gain node defines the global audio volume of your audio engine.
  33999. */
  34000. masterGain: GainNode;
  34001. /**
  34002. * Defines if Babylon should emit a warning if WebAudio is not supported.
  34003. * @ignoreNaming
  34004. */
  34005. WarnedWebAudioUnsupported: boolean;
  34006. /**
  34007. * Gets whether or not mp3 are supported by your browser.
  34008. */
  34009. isMP3supported: boolean;
  34010. /**
  34011. * Gets whether or not ogg are supported by your browser.
  34012. */
  34013. isOGGsupported: boolean;
  34014. /**
  34015. * Gets whether audio has been unlocked on the device.
  34016. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  34017. * a user interaction has happened.
  34018. */
  34019. unlocked: boolean;
  34020. /**
  34021. * Defines if the audio engine relies on a custom unlocked button.
  34022. * In this case, the embedded button will not be displayed.
  34023. */
  34024. useCustomUnlockedButton: boolean;
  34025. /**
  34026. * Event raised when audio has been unlocked on the browser.
  34027. */
  34028. onAudioUnlockedObservable: Observable<AudioEngine>;
  34029. /**
  34030. * Event raised when audio has been locked on the browser.
  34031. */
  34032. onAudioLockedObservable: Observable<AudioEngine>;
  34033. /**
  34034. * Gets the current AudioContext if available.
  34035. */
  34036. get audioContext(): Nullable<AudioContext>;
  34037. private _connectedAnalyser;
  34038. /**
  34039. * Instantiates a new audio engine.
  34040. *
  34041. * There should be only one per page as some browsers restrict the number
  34042. * of audio contexts you can create.
  34043. * @param hostElement defines the host element where to display the mute icon if necessary
  34044. */
  34045. constructor(hostElement?: Nullable<HTMLElement>);
  34046. /**
  34047. * Flags the audio engine in Locked state.
  34048. * This happens due to new browser policies preventing audio to autoplay.
  34049. */
  34050. lock(): void;
  34051. /**
  34052. * Unlocks the audio engine once a user action has been done on the dom.
  34053. * This is helpful to resume play once browser policies have been satisfied.
  34054. */
  34055. unlock(): void;
  34056. private _resumeAudioContext;
  34057. private _initializeAudioContext;
  34058. private _tryToRun;
  34059. private _triggerRunningState;
  34060. private _triggerSuspendedState;
  34061. private _displayMuteButton;
  34062. private _moveButtonToTopLeft;
  34063. private _onResize;
  34064. private _hideMuteButton;
  34065. /**
  34066. * Destroy and release the resources associated with the audio ccontext.
  34067. */
  34068. dispose(): void;
  34069. /**
  34070. * Gets the global volume sets on the master gain.
  34071. * @returns the global volume if set or -1 otherwise
  34072. */
  34073. getGlobalVolume(): number;
  34074. /**
  34075. * Sets the global volume of your experience (sets on the master gain).
  34076. * @param newVolume Defines the new global volume of the application
  34077. */
  34078. setGlobalVolume(newVolume: number): void;
  34079. /**
  34080. * Connect the audio engine to an audio analyser allowing some amazing
  34081. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  34082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  34083. * @param analyser The analyser to connect to the engine
  34084. */
  34085. connectToAnalyser(analyser: Analyser): void;
  34086. }
  34087. }
  34088. declare module "babylonjs/Loading/loadingScreen" {
  34089. /**
  34090. * Interface used to present a loading screen while loading a scene
  34091. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34092. */
  34093. export interface ILoadingScreen {
  34094. /**
  34095. * Function called to display the loading screen
  34096. */
  34097. displayLoadingUI: () => void;
  34098. /**
  34099. * Function called to hide the loading screen
  34100. */
  34101. hideLoadingUI: () => void;
  34102. /**
  34103. * Gets or sets the color to use for the background
  34104. */
  34105. loadingUIBackgroundColor: string;
  34106. /**
  34107. * Gets or sets the text to display while loading
  34108. */
  34109. loadingUIText: string;
  34110. }
  34111. /**
  34112. * Class used for the default loading screen
  34113. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  34114. */
  34115. export class DefaultLoadingScreen implements ILoadingScreen {
  34116. private _renderingCanvas;
  34117. private _loadingText;
  34118. private _loadingDivBackgroundColor;
  34119. private _loadingDiv;
  34120. private _loadingTextDiv;
  34121. /** Gets or sets the logo url to use for the default loading screen */
  34122. static DefaultLogoUrl: string;
  34123. /** Gets or sets the spinner url to use for the default loading screen */
  34124. static DefaultSpinnerUrl: string;
  34125. /**
  34126. * Creates a new default loading screen
  34127. * @param _renderingCanvas defines the canvas used to render the scene
  34128. * @param _loadingText defines the default text to display
  34129. * @param _loadingDivBackgroundColor defines the default background color
  34130. */
  34131. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  34132. /**
  34133. * Function called to display the loading screen
  34134. */
  34135. displayLoadingUI(): void;
  34136. /**
  34137. * Function called to hide the loading screen
  34138. */
  34139. hideLoadingUI(): void;
  34140. /**
  34141. * Gets or sets the text to display while loading
  34142. */
  34143. set loadingUIText(text: string);
  34144. get loadingUIText(): string;
  34145. /**
  34146. * Gets or sets the color to use for the background
  34147. */
  34148. get loadingUIBackgroundColor(): string;
  34149. set loadingUIBackgroundColor(color: string);
  34150. private _resizeLoadingUI;
  34151. }
  34152. }
  34153. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  34154. /**
  34155. * Interface for any object that can request an animation frame
  34156. */
  34157. export interface ICustomAnimationFrameRequester {
  34158. /**
  34159. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  34160. */
  34161. renderFunction?: Function;
  34162. /**
  34163. * Called to request the next frame to render to
  34164. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  34165. */
  34166. requestAnimationFrame: Function;
  34167. /**
  34168. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  34169. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  34170. */
  34171. requestID?: number;
  34172. }
  34173. }
  34174. declare module "babylonjs/Misc/performanceMonitor" {
  34175. /**
  34176. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  34177. */
  34178. export class PerformanceMonitor {
  34179. private _enabled;
  34180. private _rollingFrameTime;
  34181. private _lastFrameTimeMs;
  34182. /**
  34183. * constructor
  34184. * @param frameSampleSize The number of samples required to saturate the sliding window
  34185. */
  34186. constructor(frameSampleSize?: number);
  34187. /**
  34188. * Samples current frame
  34189. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  34190. */
  34191. sampleFrame(timeMs?: number): void;
  34192. /**
  34193. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34194. */
  34195. get averageFrameTime(): number;
  34196. /**
  34197. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  34198. */
  34199. get averageFrameTimeVariance(): number;
  34200. /**
  34201. * Returns the frame time of the most recent frame
  34202. */
  34203. get instantaneousFrameTime(): number;
  34204. /**
  34205. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  34206. */
  34207. get averageFPS(): number;
  34208. /**
  34209. * Returns the average framerate in frames per second using the most recent frame time
  34210. */
  34211. get instantaneousFPS(): number;
  34212. /**
  34213. * Returns true if enough samples have been taken to completely fill the sliding window
  34214. */
  34215. get isSaturated(): boolean;
  34216. /**
  34217. * Enables contributions to the sliding window sample set
  34218. */
  34219. enable(): void;
  34220. /**
  34221. * Disables contributions to the sliding window sample set
  34222. * Samples will not be interpolated over the disabled period
  34223. */
  34224. disable(): void;
  34225. /**
  34226. * Returns true if sampling is enabled
  34227. */
  34228. get isEnabled(): boolean;
  34229. /**
  34230. * Resets performance monitor
  34231. */
  34232. reset(): void;
  34233. }
  34234. /**
  34235. * RollingAverage
  34236. *
  34237. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  34238. */
  34239. export class RollingAverage {
  34240. /**
  34241. * Current average
  34242. */
  34243. average: number;
  34244. /**
  34245. * Current variance
  34246. */
  34247. variance: number;
  34248. protected _samples: Array<number>;
  34249. protected _sampleCount: number;
  34250. protected _pos: number;
  34251. protected _m2: number;
  34252. /**
  34253. * constructor
  34254. * @param length The number of samples required to saturate the sliding window
  34255. */
  34256. constructor(length: number);
  34257. /**
  34258. * Adds a sample to the sample set
  34259. * @param v The sample value
  34260. */
  34261. add(v: number): void;
  34262. /**
  34263. * Returns previously added values or null if outside of history or outside the sliding window domain
  34264. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  34265. * @return Value previously recorded with add() or null if outside of range
  34266. */
  34267. history(i: number): number;
  34268. /**
  34269. * Returns true if enough samples have been taken to completely fill the sliding window
  34270. * @return true if sample-set saturated
  34271. */
  34272. isSaturated(): boolean;
  34273. /**
  34274. * Resets the rolling average (equivalent to 0 samples taken so far)
  34275. */
  34276. reset(): void;
  34277. /**
  34278. * Wraps a value around the sample range boundaries
  34279. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  34280. * @return Wrapped position in sample range
  34281. */
  34282. protected _wrapPosition(i: number): number;
  34283. }
  34284. }
  34285. declare module "babylonjs/Misc/perfCounter" {
  34286. /**
  34287. * This class is used to track a performance counter which is number based.
  34288. * The user has access to many properties which give statistics of different nature.
  34289. *
  34290. * The implementer can track two kinds of Performance Counter: time and count.
  34291. * 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.
  34292. * 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.
  34293. */
  34294. export class PerfCounter {
  34295. /**
  34296. * Gets or sets a global boolean to turn on and off all the counters
  34297. */
  34298. static Enabled: boolean;
  34299. /**
  34300. * Returns the smallest value ever
  34301. */
  34302. get min(): number;
  34303. /**
  34304. * Returns the biggest value ever
  34305. */
  34306. get max(): number;
  34307. /**
  34308. * Returns the average value since the performance counter is running
  34309. */
  34310. get average(): number;
  34311. /**
  34312. * Returns the average value of the last second the counter was monitored
  34313. */
  34314. get lastSecAverage(): number;
  34315. /**
  34316. * Returns the current value
  34317. */
  34318. get current(): number;
  34319. /**
  34320. * Gets the accumulated total
  34321. */
  34322. get total(): number;
  34323. /**
  34324. * Gets the total value count
  34325. */
  34326. get count(): number;
  34327. /**
  34328. * Creates a new counter
  34329. */
  34330. constructor();
  34331. /**
  34332. * Call this method to start monitoring a new frame.
  34333. * 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.
  34334. */
  34335. fetchNewFrame(): void;
  34336. /**
  34337. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  34338. * @param newCount the count value to add to the monitored count
  34339. * @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.
  34340. */
  34341. addCount(newCount: number, fetchResult: boolean): void;
  34342. /**
  34343. * Start monitoring this performance counter
  34344. */
  34345. beginMonitoring(): void;
  34346. /**
  34347. * Compute the time lapsed since the previous beginMonitoring() call.
  34348. * @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
  34349. */
  34350. endMonitoring(newFrame?: boolean): void;
  34351. private _fetchResult;
  34352. private _startMonitoringTime;
  34353. private _min;
  34354. private _max;
  34355. private _average;
  34356. private _current;
  34357. private _totalValueCount;
  34358. private _totalAccumulated;
  34359. private _lastSecAverage;
  34360. private _lastSecAccumulated;
  34361. private _lastSecTime;
  34362. private _lastSecValueCount;
  34363. }
  34364. }
  34365. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  34366. module "babylonjs/Engines/thinEngine" {
  34367. interface ThinEngine {
  34368. /**
  34369. * Sets alpha constants used by some alpha blending modes
  34370. * @param r defines the red component
  34371. * @param g defines the green component
  34372. * @param b defines the blue component
  34373. * @param a defines the alpha component
  34374. */
  34375. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  34376. /**
  34377. * Sets the current alpha mode
  34378. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  34379. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  34380. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34381. */
  34382. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  34383. /**
  34384. * Gets the current alpha mode
  34385. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  34386. * @returns the current alpha mode
  34387. */
  34388. getAlphaMode(): number;
  34389. /**
  34390. * Sets the current alpha equation
  34391. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  34392. */
  34393. setAlphaEquation(equation: number): void;
  34394. /**
  34395. * Gets the current alpha equation.
  34396. * @returns the current alpha equation
  34397. */
  34398. getAlphaEquation(): number;
  34399. }
  34400. }
  34401. }
  34402. declare module "babylonjs/Engines/engine" {
  34403. import { Observable } from "babylonjs/Misc/observable";
  34404. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  34405. import { Scene } from "babylonjs/scene";
  34406. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  34407. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  34408. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  34409. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  34410. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  34411. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  34412. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  34413. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  34414. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  34415. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  34416. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  34417. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  34418. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  34419. import "babylonjs/Engines/Extensions/engine.alpha";
  34420. import { Material } from "babylonjs/Materials/material";
  34421. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  34422. /**
  34423. * Defines the interface used by display changed events
  34424. */
  34425. export interface IDisplayChangedEventArgs {
  34426. /** Gets the vrDisplay object (if any) */
  34427. vrDisplay: Nullable<any>;
  34428. /** Gets a boolean indicating if webVR is supported */
  34429. vrSupported: boolean;
  34430. }
  34431. /**
  34432. * Defines the interface used by objects containing a viewport (like a camera)
  34433. */
  34434. interface IViewportOwnerLike {
  34435. /**
  34436. * Gets or sets the viewport
  34437. */
  34438. viewport: IViewportLike;
  34439. }
  34440. /**
  34441. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  34442. */
  34443. export class Engine extends ThinEngine {
  34444. /** Defines that alpha blending is disabled */
  34445. static readonly ALPHA_DISABLE: number;
  34446. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  34447. static readonly ALPHA_ADD: number;
  34448. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  34449. static readonly ALPHA_COMBINE: number;
  34450. /** Defines that alpha blending to DEST - SRC * DEST */
  34451. static readonly ALPHA_SUBTRACT: number;
  34452. /** Defines that alpha blending to SRC * DEST */
  34453. static readonly ALPHA_MULTIPLY: number;
  34454. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  34455. static readonly ALPHA_MAXIMIZED: number;
  34456. /** Defines that alpha blending to SRC + DEST */
  34457. static readonly ALPHA_ONEONE: number;
  34458. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  34459. static readonly ALPHA_PREMULTIPLIED: number;
  34460. /**
  34461. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  34462. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  34463. */
  34464. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  34465. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  34466. static readonly ALPHA_INTERPOLATE: number;
  34467. /**
  34468. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  34469. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  34470. */
  34471. static readonly ALPHA_SCREENMODE: number;
  34472. /** Defines that the ressource is not delayed*/
  34473. static readonly DELAYLOADSTATE_NONE: number;
  34474. /** Defines that the ressource was successfully delay loaded */
  34475. static readonly DELAYLOADSTATE_LOADED: number;
  34476. /** Defines that the ressource is currently delay loading */
  34477. static readonly DELAYLOADSTATE_LOADING: number;
  34478. /** Defines that the ressource is delayed and has not started loading */
  34479. static readonly DELAYLOADSTATE_NOTLOADED: number;
  34480. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  34481. static readonly NEVER: number;
  34482. /** 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 */
  34483. static readonly ALWAYS: number;
  34484. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  34485. static readonly LESS: number;
  34486. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  34487. static readonly EQUAL: number;
  34488. /** 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 */
  34489. static readonly LEQUAL: number;
  34490. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  34491. static readonly GREATER: number;
  34492. /** 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 */
  34493. static readonly GEQUAL: number;
  34494. /** 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 */
  34495. static readonly NOTEQUAL: number;
  34496. /** Passed to stencilOperation to specify that stencil value must be kept */
  34497. static readonly KEEP: number;
  34498. /** Passed to stencilOperation to specify that stencil value must be replaced */
  34499. static readonly REPLACE: number;
  34500. /** Passed to stencilOperation to specify that stencil value must be incremented */
  34501. static readonly INCR: number;
  34502. /** Passed to stencilOperation to specify that stencil value must be decremented */
  34503. static readonly DECR: number;
  34504. /** Passed to stencilOperation to specify that stencil value must be inverted */
  34505. static readonly INVERT: number;
  34506. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  34507. static readonly INCR_WRAP: number;
  34508. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  34509. static readonly DECR_WRAP: number;
  34510. /** Texture is not repeating outside of 0..1 UVs */
  34511. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  34512. /** Texture is repeating outside of 0..1 UVs */
  34513. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  34514. /** Texture is repeating and mirrored */
  34515. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  34516. /** ALPHA */
  34517. static readonly TEXTUREFORMAT_ALPHA: number;
  34518. /** LUMINANCE */
  34519. static readonly TEXTUREFORMAT_LUMINANCE: number;
  34520. /** LUMINANCE_ALPHA */
  34521. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  34522. /** RGB */
  34523. static readonly TEXTUREFORMAT_RGB: number;
  34524. /** RGBA */
  34525. static readonly TEXTUREFORMAT_RGBA: number;
  34526. /** RED */
  34527. static readonly TEXTUREFORMAT_RED: number;
  34528. /** RED (2nd reference) */
  34529. static readonly TEXTUREFORMAT_R: number;
  34530. /** RG */
  34531. static readonly TEXTUREFORMAT_RG: number;
  34532. /** RED_INTEGER */
  34533. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  34534. /** RED_INTEGER (2nd reference) */
  34535. static readonly TEXTUREFORMAT_R_INTEGER: number;
  34536. /** RG_INTEGER */
  34537. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  34538. /** RGB_INTEGER */
  34539. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  34540. /** RGBA_INTEGER */
  34541. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  34542. /** UNSIGNED_BYTE */
  34543. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  34544. /** UNSIGNED_BYTE (2nd reference) */
  34545. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  34546. /** FLOAT */
  34547. static readonly TEXTURETYPE_FLOAT: number;
  34548. /** HALF_FLOAT */
  34549. static readonly TEXTURETYPE_HALF_FLOAT: number;
  34550. /** BYTE */
  34551. static readonly TEXTURETYPE_BYTE: number;
  34552. /** SHORT */
  34553. static readonly TEXTURETYPE_SHORT: number;
  34554. /** UNSIGNED_SHORT */
  34555. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  34556. /** INT */
  34557. static readonly TEXTURETYPE_INT: number;
  34558. /** UNSIGNED_INT */
  34559. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  34560. /** UNSIGNED_SHORT_4_4_4_4 */
  34561. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  34562. /** UNSIGNED_SHORT_5_5_5_1 */
  34563. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  34564. /** UNSIGNED_SHORT_5_6_5 */
  34565. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  34566. /** UNSIGNED_INT_2_10_10_10_REV */
  34567. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  34568. /** UNSIGNED_INT_24_8 */
  34569. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  34570. /** UNSIGNED_INT_10F_11F_11F_REV */
  34571. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  34572. /** UNSIGNED_INT_5_9_9_9_REV */
  34573. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  34574. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  34575. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  34576. /** nearest is mag = nearest and min = nearest and mip = linear */
  34577. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  34578. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34579. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  34580. /** Trilinear is mag = linear and min = linear and mip = linear */
  34581. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  34582. /** nearest is mag = nearest and min = nearest and mip = linear */
  34583. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  34584. /** Bilinear is mag = linear and min = linear and mip = nearest */
  34585. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  34586. /** Trilinear is mag = linear and min = linear and mip = linear */
  34587. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  34588. /** mag = nearest and min = nearest and mip = nearest */
  34589. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  34590. /** mag = nearest and min = linear and mip = nearest */
  34591. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  34592. /** mag = nearest and min = linear and mip = linear */
  34593. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  34594. /** mag = nearest and min = linear and mip = none */
  34595. static readonly TEXTURE_NEAREST_LINEAR: number;
  34596. /** mag = nearest and min = nearest and mip = none */
  34597. static readonly TEXTURE_NEAREST_NEAREST: number;
  34598. /** mag = linear and min = nearest and mip = nearest */
  34599. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  34600. /** mag = linear and min = nearest and mip = linear */
  34601. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  34602. /** mag = linear and min = linear and mip = none */
  34603. static readonly TEXTURE_LINEAR_LINEAR: number;
  34604. /** mag = linear and min = nearest and mip = none */
  34605. static readonly TEXTURE_LINEAR_NEAREST: number;
  34606. /** Explicit coordinates mode */
  34607. static readonly TEXTURE_EXPLICIT_MODE: number;
  34608. /** Spherical coordinates mode */
  34609. static readonly TEXTURE_SPHERICAL_MODE: number;
  34610. /** Planar coordinates mode */
  34611. static readonly TEXTURE_PLANAR_MODE: number;
  34612. /** Cubic coordinates mode */
  34613. static readonly TEXTURE_CUBIC_MODE: number;
  34614. /** Projection coordinates mode */
  34615. static readonly TEXTURE_PROJECTION_MODE: number;
  34616. /** Skybox coordinates mode */
  34617. static readonly TEXTURE_SKYBOX_MODE: number;
  34618. /** Inverse Cubic coordinates mode */
  34619. static readonly TEXTURE_INVCUBIC_MODE: number;
  34620. /** Equirectangular coordinates mode */
  34621. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  34622. /** Equirectangular Fixed coordinates mode */
  34623. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  34624. /** Equirectangular Fixed Mirrored coordinates mode */
  34625. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  34626. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  34627. static readonly SCALEMODE_FLOOR: number;
  34628. /** Defines that texture rescaling will look for the nearest power of 2 size */
  34629. static readonly SCALEMODE_NEAREST: number;
  34630. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  34631. static readonly SCALEMODE_CEILING: number;
  34632. /**
  34633. * Returns the current npm package of the sdk
  34634. */
  34635. static get NpmPackage(): string;
  34636. /**
  34637. * Returns the current version of the framework
  34638. */
  34639. static get Version(): string;
  34640. /** Gets the list of created engines */
  34641. static get Instances(): Engine[];
  34642. /**
  34643. * Gets the latest created engine
  34644. */
  34645. static get LastCreatedEngine(): Nullable<Engine>;
  34646. /**
  34647. * Gets the latest created scene
  34648. */
  34649. static get LastCreatedScene(): Nullable<Scene>;
  34650. /**
  34651. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  34652. * @param flag defines which part of the materials must be marked as dirty
  34653. * @param predicate defines a predicate used to filter which materials should be affected
  34654. */
  34655. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34656. /**
  34657. * Method called to create the default loading screen.
  34658. * This can be overriden in your own app.
  34659. * @param canvas The rendering canvas element
  34660. * @returns The loading screen
  34661. */
  34662. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  34663. /**
  34664. * Method called to create the default rescale post process on each engine.
  34665. */
  34666. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  34667. /**
  34668. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  34669. **/
  34670. enableOfflineSupport: boolean;
  34671. /**
  34672. * 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)
  34673. **/
  34674. disableManifestCheck: boolean;
  34675. /**
  34676. * Gets the list of created scenes
  34677. */
  34678. scenes: Scene[];
  34679. /**
  34680. * Event raised when a new scene is created
  34681. */
  34682. onNewSceneAddedObservable: Observable<Scene>;
  34683. /**
  34684. * Gets the list of created postprocesses
  34685. */
  34686. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  34687. /**
  34688. * Gets a boolean indicating if the pointer is currently locked
  34689. */
  34690. isPointerLock: boolean;
  34691. /**
  34692. * Observable event triggered each time the rendering canvas is resized
  34693. */
  34694. onResizeObservable: Observable<Engine>;
  34695. /**
  34696. * Observable event triggered each time the canvas loses focus
  34697. */
  34698. onCanvasBlurObservable: Observable<Engine>;
  34699. /**
  34700. * Observable event triggered each time the canvas gains focus
  34701. */
  34702. onCanvasFocusObservable: Observable<Engine>;
  34703. /**
  34704. * Observable event triggered each time the canvas receives pointerout event
  34705. */
  34706. onCanvasPointerOutObservable: Observable<PointerEvent>;
  34707. /**
  34708. * Observable raised when the engine begins a new frame
  34709. */
  34710. onBeginFrameObservable: Observable<Engine>;
  34711. /**
  34712. * If set, will be used to request the next animation frame for the render loop
  34713. */
  34714. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  34715. /**
  34716. * Observable raised when the engine ends the current frame
  34717. */
  34718. onEndFrameObservable: Observable<Engine>;
  34719. /**
  34720. * Observable raised when the engine is about to compile a shader
  34721. */
  34722. onBeforeShaderCompilationObservable: Observable<Engine>;
  34723. /**
  34724. * Observable raised when the engine has jsut compiled a shader
  34725. */
  34726. onAfterShaderCompilationObservable: Observable<Engine>;
  34727. /**
  34728. * Gets the audio engine
  34729. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34730. * @ignorenaming
  34731. */
  34732. static audioEngine: IAudioEngine;
  34733. /**
  34734. * Default AudioEngine factory responsible of creating the Audio Engine.
  34735. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  34736. */
  34737. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  34738. /**
  34739. * Default offline support factory responsible of creating a tool used to store data locally.
  34740. * By default, this will create a Database object if the workload has been embedded.
  34741. */
  34742. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  34743. private _loadingScreen;
  34744. private _pointerLockRequested;
  34745. private _dummyFramebuffer;
  34746. private _rescalePostProcess;
  34747. private _deterministicLockstep;
  34748. private _lockstepMaxSteps;
  34749. private _timeStep;
  34750. protected get _supportsHardwareTextureRescaling(): boolean;
  34751. private _fps;
  34752. private _deltaTime;
  34753. /** @hidden */
  34754. _drawCalls: PerfCounter;
  34755. /** 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 */
  34756. canvasTabIndex: number;
  34757. /**
  34758. * Turn this value on if you want to pause FPS computation when in background
  34759. */
  34760. disablePerformanceMonitorInBackground: boolean;
  34761. private _performanceMonitor;
  34762. /**
  34763. * Gets the performance monitor attached to this engine
  34764. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  34765. */
  34766. get performanceMonitor(): PerformanceMonitor;
  34767. private _onFocus;
  34768. private _onBlur;
  34769. private _onCanvasPointerOut;
  34770. private _onCanvasBlur;
  34771. private _onCanvasFocus;
  34772. private _onFullscreenChange;
  34773. private _onPointerLockChange;
  34774. /**
  34775. * Gets the HTML element used to attach event listeners
  34776. * @returns a HTML element
  34777. */
  34778. getInputElement(): Nullable<HTMLElement>;
  34779. /**
  34780. * Creates a new engine
  34781. * @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
  34782. * @param antialias defines enable antialiasing (default: false)
  34783. * @param options defines further options to be sent to the getContext() function
  34784. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  34785. */
  34786. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  34787. /**
  34788. * Gets current aspect ratio
  34789. * @param viewportOwner defines the camera to use to get the aspect ratio
  34790. * @param useScreen defines if screen size must be used (or the current render target if any)
  34791. * @returns a number defining the aspect ratio
  34792. */
  34793. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  34794. /**
  34795. * Gets current screen aspect ratio
  34796. * @returns a number defining the aspect ratio
  34797. */
  34798. getScreenAspectRatio(): number;
  34799. /**
  34800. * Gets the client rect of the HTML canvas attached with the current webGL context
  34801. * @returns a client rectanglee
  34802. */
  34803. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  34804. /**
  34805. * Gets the client rect of the HTML element used for events
  34806. * @returns a client rectanglee
  34807. */
  34808. getInputElementClientRect(): Nullable<ClientRect>;
  34809. /**
  34810. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  34811. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34812. * @returns true if engine is in deterministic lock step mode
  34813. */
  34814. isDeterministicLockStep(): boolean;
  34815. /**
  34816. * Gets the max steps when engine is running in deterministic lock step
  34817. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  34818. * @returns the max steps
  34819. */
  34820. getLockstepMaxSteps(): number;
  34821. /**
  34822. * Returns the time in ms between steps when using deterministic lock step.
  34823. * @returns time step in (ms)
  34824. */
  34825. getTimeStep(): number;
  34826. /**
  34827. * Force the mipmap generation for the given render target texture
  34828. * @param texture defines the render target texture to use
  34829. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  34830. */
  34831. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  34832. /** States */
  34833. /**
  34834. * Set various states to the webGL context
  34835. * @param culling defines backface culling state
  34836. * @param zOffset defines the value to apply to zOffset (0 by default)
  34837. * @param force defines if states must be applied even if cache is up to date
  34838. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  34839. */
  34840. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  34841. /**
  34842. * Set the z offset to apply to current rendering
  34843. * @param value defines the offset to apply
  34844. */
  34845. setZOffset(value: number): void;
  34846. /**
  34847. * Gets the current value of the zOffset
  34848. * @returns the current zOffset state
  34849. */
  34850. getZOffset(): number;
  34851. /**
  34852. * Enable or disable depth buffering
  34853. * @param enable defines the state to set
  34854. */
  34855. setDepthBuffer(enable: boolean): void;
  34856. /**
  34857. * Gets a boolean indicating if depth writing is enabled
  34858. * @returns the current depth writing state
  34859. */
  34860. getDepthWrite(): boolean;
  34861. /**
  34862. * Enable or disable depth writing
  34863. * @param enable defines the state to set
  34864. */
  34865. setDepthWrite(enable: boolean): void;
  34866. /**
  34867. * Gets a boolean indicating if stencil buffer is enabled
  34868. * @returns the current stencil buffer state
  34869. */
  34870. getStencilBuffer(): boolean;
  34871. /**
  34872. * Enable or disable the stencil buffer
  34873. * @param enable defines if the stencil buffer must be enabled or disabled
  34874. */
  34875. setStencilBuffer(enable: boolean): void;
  34876. /**
  34877. * Gets the current stencil mask
  34878. * @returns a number defining the new stencil mask to use
  34879. */
  34880. getStencilMask(): number;
  34881. /**
  34882. * Sets the current stencil mask
  34883. * @param mask defines the new stencil mask to use
  34884. */
  34885. setStencilMask(mask: number): void;
  34886. /**
  34887. * Gets the current stencil function
  34888. * @returns a number defining the stencil function to use
  34889. */
  34890. getStencilFunction(): number;
  34891. /**
  34892. * Gets the current stencil reference value
  34893. * @returns a number defining the stencil reference value to use
  34894. */
  34895. getStencilFunctionReference(): number;
  34896. /**
  34897. * Gets the current stencil mask
  34898. * @returns a number defining the stencil mask to use
  34899. */
  34900. getStencilFunctionMask(): number;
  34901. /**
  34902. * Sets the current stencil function
  34903. * @param stencilFunc defines the new stencil function to use
  34904. */
  34905. setStencilFunction(stencilFunc: number): void;
  34906. /**
  34907. * Sets the current stencil reference
  34908. * @param reference defines the new stencil reference to use
  34909. */
  34910. setStencilFunctionReference(reference: number): void;
  34911. /**
  34912. * Sets the current stencil mask
  34913. * @param mask defines the new stencil mask to use
  34914. */
  34915. setStencilFunctionMask(mask: number): void;
  34916. /**
  34917. * Gets the current stencil operation when stencil fails
  34918. * @returns a number defining stencil operation to use when stencil fails
  34919. */
  34920. getStencilOperationFail(): number;
  34921. /**
  34922. * Gets the current stencil operation when depth fails
  34923. * @returns a number defining stencil operation to use when depth fails
  34924. */
  34925. getStencilOperationDepthFail(): number;
  34926. /**
  34927. * Gets the current stencil operation when stencil passes
  34928. * @returns a number defining stencil operation to use when stencil passes
  34929. */
  34930. getStencilOperationPass(): number;
  34931. /**
  34932. * Sets the stencil operation to use when stencil fails
  34933. * @param operation defines the stencil operation to use when stencil fails
  34934. */
  34935. setStencilOperationFail(operation: number): void;
  34936. /**
  34937. * Sets the stencil operation to use when depth fails
  34938. * @param operation defines the stencil operation to use when depth fails
  34939. */
  34940. setStencilOperationDepthFail(operation: number): void;
  34941. /**
  34942. * Sets the stencil operation to use when stencil passes
  34943. * @param operation defines the stencil operation to use when stencil passes
  34944. */
  34945. setStencilOperationPass(operation: number): void;
  34946. /**
  34947. * Sets a boolean indicating if the dithering state is enabled or disabled
  34948. * @param value defines the dithering state
  34949. */
  34950. setDitheringState(value: boolean): void;
  34951. /**
  34952. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  34953. * @param value defines the rasterizer state
  34954. */
  34955. setRasterizerState(value: boolean): void;
  34956. /**
  34957. * Gets the current depth function
  34958. * @returns a number defining the depth function
  34959. */
  34960. getDepthFunction(): Nullable<number>;
  34961. /**
  34962. * Sets the current depth function
  34963. * @param depthFunc defines the function to use
  34964. */
  34965. setDepthFunction(depthFunc: number): void;
  34966. /**
  34967. * Sets the current depth function to GREATER
  34968. */
  34969. setDepthFunctionToGreater(): void;
  34970. /**
  34971. * Sets the current depth function to GEQUAL
  34972. */
  34973. setDepthFunctionToGreaterOrEqual(): void;
  34974. /**
  34975. * Sets the current depth function to LESS
  34976. */
  34977. setDepthFunctionToLess(): void;
  34978. /**
  34979. * Sets the current depth function to LEQUAL
  34980. */
  34981. setDepthFunctionToLessOrEqual(): void;
  34982. private _cachedStencilBuffer;
  34983. private _cachedStencilFunction;
  34984. private _cachedStencilMask;
  34985. private _cachedStencilOperationPass;
  34986. private _cachedStencilOperationFail;
  34987. private _cachedStencilOperationDepthFail;
  34988. private _cachedStencilReference;
  34989. /**
  34990. * Caches the the state of the stencil buffer
  34991. */
  34992. cacheStencilState(): void;
  34993. /**
  34994. * Restores the state of the stencil buffer
  34995. */
  34996. restoreStencilState(): void;
  34997. /**
  34998. * Directly set the WebGL Viewport
  34999. * @param x defines the x coordinate of the viewport (in screen space)
  35000. * @param y defines the y coordinate of the viewport (in screen space)
  35001. * @param width defines the width of the viewport (in screen space)
  35002. * @param height defines the height of the viewport (in screen space)
  35003. * @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
  35004. */
  35005. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  35006. /**
  35007. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  35008. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35009. * @param y defines the y-coordinate of the corner of the clear rectangle
  35010. * @param width defines the width of the clear rectangle
  35011. * @param height defines the height of the clear rectangle
  35012. * @param clearColor defines the clear color
  35013. */
  35014. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  35015. /**
  35016. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  35017. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  35018. * @param y defines the y-coordinate of the corner of the clear rectangle
  35019. * @param width defines the width of the clear rectangle
  35020. * @param height defines the height of the clear rectangle
  35021. */
  35022. enableScissor(x: number, y: number, width: number, height: number): void;
  35023. /**
  35024. * Disable previously set scissor test rectangle
  35025. */
  35026. disableScissor(): void;
  35027. protected _reportDrawCall(): void;
  35028. /**
  35029. * Initializes a webVR display and starts listening to display change events
  35030. * The onVRDisplayChangedObservable will be notified upon these changes
  35031. * @returns The onVRDisplayChangedObservable
  35032. */
  35033. initWebVR(): Observable<IDisplayChangedEventArgs>;
  35034. /** @hidden */
  35035. _prepareVRComponent(): void;
  35036. /** @hidden */
  35037. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  35038. /** @hidden */
  35039. _submitVRFrame(): void;
  35040. /**
  35041. * Call this function to leave webVR mode
  35042. * Will do nothing if webVR is not supported or if there is no webVR device
  35043. * @see http://doc.babylonjs.com/how_to/webvr_camera
  35044. */
  35045. disableVR(): void;
  35046. /**
  35047. * Gets a boolean indicating that the system is in VR mode and is presenting
  35048. * @returns true if VR mode is engaged
  35049. */
  35050. isVRPresenting(): boolean;
  35051. /** @hidden */
  35052. _requestVRFrame(): void;
  35053. /** @hidden */
  35054. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  35055. /**
  35056. * Gets the source code of the vertex shader associated with a specific webGL program
  35057. * @param program defines the program to use
  35058. * @returns a string containing the source code of the vertex shader associated with the program
  35059. */
  35060. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  35061. /**
  35062. * Gets the source code of the fragment shader associated with a specific webGL program
  35063. * @param program defines the program to use
  35064. * @returns a string containing the source code of the fragment shader associated with the program
  35065. */
  35066. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  35067. /**
  35068. * Sets a depth stencil texture from a render target to the according uniform.
  35069. * @param channel The texture channel
  35070. * @param uniform The uniform to set
  35071. * @param texture The render target texture containing the depth stencil texture to apply
  35072. */
  35073. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  35074. /**
  35075. * Sets a texture to the webGL context from a postprocess
  35076. * @param channel defines the channel to use
  35077. * @param postProcess defines the source postprocess
  35078. */
  35079. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  35080. /**
  35081. * Binds the output of the passed in post process to the texture channel specified
  35082. * @param channel The channel the texture should be bound to
  35083. * @param postProcess The post process which's output should be bound
  35084. */
  35085. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  35086. /** @hidden */
  35087. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  35088. protected _rebuildBuffers(): void;
  35089. /** @hidden */
  35090. _renderFrame(): void;
  35091. _renderLoop(): void;
  35092. /** @hidden */
  35093. _renderViews(): boolean;
  35094. /**
  35095. * Toggle full screen mode
  35096. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35097. */
  35098. switchFullscreen(requestPointerLock: boolean): void;
  35099. /**
  35100. * Enters full screen mode
  35101. * @param requestPointerLock defines if a pointer lock should be requested from the user
  35102. */
  35103. enterFullscreen(requestPointerLock: boolean): void;
  35104. /**
  35105. * Exits full screen mode
  35106. */
  35107. exitFullscreen(): void;
  35108. /**
  35109. * Enters Pointerlock mode
  35110. */
  35111. enterPointerlock(): void;
  35112. /**
  35113. * Exits Pointerlock mode
  35114. */
  35115. exitPointerlock(): void;
  35116. /**
  35117. * Begin a new frame
  35118. */
  35119. beginFrame(): void;
  35120. /**
  35121. * Enf the current frame
  35122. */
  35123. endFrame(): void;
  35124. resize(): void;
  35125. /**
  35126. * Force a specific size of the canvas
  35127. * @param width defines the new canvas' width
  35128. * @param height defines the new canvas' height
  35129. */
  35130. setSize(width: number, height: number): void;
  35131. /**
  35132. * Updates a dynamic vertex buffer.
  35133. * @param vertexBuffer the vertex buffer to update
  35134. * @param data the data used to update the vertex buffer
  35135. * @param byteOffset the byte offset of the data
  35136. * @param byteLength the byte length of the data
  35137. */
  35138. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  35139. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  35140. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35141. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  35142. _releaseTexture(texture: InternalTexture): void;
  35143. /**
  35144. * @hidden
  35145. * Rescales a texture
  35146. * @param source input texutre
  35147. * @param destination destination texture
  35148. * @param scene scene to use to render the resize
  35149. * @param internalFormat format to use when resizing
  35150. * @param onComplete callback to be called when resize has completed
  35151. */
  35152. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  35153. /**
  35154. * Gets the current framerate
  35155. * @returns a number representing the framerate
  35156. */
  35157. getFps(): number;
  35158. /**
  35159. * Gets the time spent between current and previous frame
  35160. * @returns a number representing the delta time in ms
  35161. */
  35162. getDeltaTime(): number;
  35163. private _measureFps;
  35164. /** @hidden */
  35165. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  35166. /**
  35167. * Update a dynamic index buffer
  35168. * @param indexBuffer defines the target index buffer
  35169. * @param indices defines the data to update
  35170. * @param offset defines the offset in the target index buffer where update should start
  35171. */
  35172. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  35173. /**
  35174. * Updates the sample count of a render target texture
  35175. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  35176. * @param texture defines the texture to update
  35177. * @param samples defines the sample count to set
  35178. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  35179. */
  35180. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  35181. /**
  35182. * Updates a depth texture Comparison Mode and Function.
  35183. * If the comparison Function is equal to 0, the mode will be set to none.
  35184. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  35185. * @param texture The texture to set the comparison function for
  35186. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  35187. */
  35188. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  35189. /**
  35190. * Creates a webGL buffer to use with instanciation
  35191. * @param capacity defines the size of the buffer
  35192. * @returns the webGL buffer
  35193. */
  35194. createInstancesBuffer(capacity: number): DataBuffer;
  35195. /**
  35196. * Delete a webGL buffer used with instanciation
  35197. * @param buffer defines the webGL buffer to delete
  35198. */
  35199. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  35200. private _clientWaitAsync;
  35201. /** @hidden */
  35202. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  35203. /** @hidden */
  35204. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  35205. dispose(): void;
  35206. private _disableTouchAction;
  35207. /**
  35208. * Display the loading screen
  35209. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35210. */
  35211. displayLoadingUI(): void;
  35212. /**
  35213. * Hide the loading screen
  35214. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35215. */
  35216. hideLoadingUI(): void;
  35217. /**
  35218. * Gets the current loading screen object
  35219. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35220. */
  35221. get loadingScreen(): ILoadingScreen;
  35222. /**
  35223. * Sets the current loading screen object
  35224. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35225. */
  35226. set loadingScreen(loadingScreen: ILoadingScreen);
  35227. /**
  35228. * Sets the current loading screen text
  35229. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35230. */
  35231. set loadingUIText(text: string);
  35232. /**
  35233. * Sets the current loading screen background color
  35234. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  35235. */
  35236. set loadingUIBackgroundColor(color: string);
  35237. /** Pointerlock and fullscreen */
  35238. /**
  35239. * Ask the browser to promote the current element to pointerlock mode
  35240. * @param element defines the DOM element to promote
  35241. */
  35242. static _RequestPointerlock(element: HTMLElement): void;
  35243. /**
  35244. * Asks the browser to exit pointerlock mode
  35245. */
  35246. static _ExitPointerlock(): void;
  35247. /**
  35248. * Ask the browser to promote the current element to fullscreen rendering mode
  35249. * @param element defines the DOM element to promote
  35250. */
  35251. static _RequestFullscreen(element: HTMLElement): void;
  35252. /**
  35253. * Asks the browser to exit fullscreen mode
  35254. */
  35255. static _ExitFullscreen(): void;
  35256. }
  35257. }
  35258. declare module "babylonjs/Engines/engineStore" {
  35259. import { Nullable } from "babylonjs/types";
  35260. import { Engine } from "babylonjs/Engines/engine";
  35261. import { Scene } from "babylonjs/scene";
  35262. /**
  35263. * The engine store class is responsible to hold all the instances of Engine and Scene created
  35264. * during the life time of the application.
  35265. */
  35266. export class EngineStore {
  35267. /** Gets the list of created engines */
  35268. static Instances: import("babylonjs/Engines/engine").Engine[];
  35269. /** @hidden */
  35270. static _LastCreatedScene: Nullable<Scene>;
  35271. /**
  35272. * Gets the latest created engine
  35273. */
  35274. static get LastCreatedEngine(): Nullable<Engine>;
  35275. /**
  35276. * Gets the latest created scene
  35277. */
  35278. static get LastCreatedScene(): Nullable<Scene>;
  35279. /**
  35280. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35281. * @ignorenaming
  35282. */
  35283. static UseFallbackTexture: boolean;
  35284. /**
  35285. * Texture content used if a texture cannot loaded
  35286. * @ignorenaming
  35287. */
  35288. static FallbackTexture: string;
  35289. }
  35290. }
  35291. declare module "babylonjs/Misc/promise" {
  35292. /**
  35293. * Helper class that provides a small promise polyfill
  35294. */
  35295. export class PromisePolyfill {
  35296. /**
  35297. * Static function used to check if the polyfill is required
  35298. * If this is the case then the function will inject the polyfill to window.Promise
  35299. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  35300. */
  35301. static Apply(force?: boolean): void;
  35302. }
  35303. }
  35304. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  35305. /**
  35306. * Interface for screenshot methods with describe argument called `size` as object with options
  35307. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  35308. */
  35309. export interface IScreenshotSize {
  35310. /**
  35311. * number in pixels for canvas height
  35312. */
  35313. height?: number;
  35314. /**
  35315. * multiplier allowing render at a higher or lower resolution
  35316. * If value is defined then height and width will be ignored and taken from camera
  35317. */
  35318. precision?: number;
  35319. /**
  35320. * number in pixels for canvas width
  35321. */
  35322. width?: number;
  35323. }
  35324. }
  35325. declare module "babylonjs/Misc/tools" {
  35326. import { Nullable, float } from "babylonjs/types";
  35327. import { DomManagement } from "babylonjs/Misc/domManagement";
  35328. import { WebRequest } from "babylonjs/Misc/webRequest";
  35329. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  35330. import { ReadFileError } from "babylonjs/Misc/fileTools";
  35331. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  35332. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  35333. import { Camera } from "babylonjs/Cameras/camera";
  35334. import { Engine } from "babylonjs/Engines/engine";
  35335. interface IColor4Like {
  35336. r: float;
  35337. g: float;
  35338. b: float;
  35339. a: float;
  35340. }
  35341. /**
  35342. * Class containing a set of static utilities functions
  35343. */
  35344. export class Tools {
  35345. /**
  35346. * Gets or sets the base URL to use to load assets
  35347. */
  35348. static get BaseUrl(): string;
  35349. static set BaseUrl(value: string);
  35350. /**
  35351. * Enable/Disable Custom HTTP Request Headers globally.
  35352. * default = false
  35353. * @see CustomRequestHeaders
  35354. */
  35355. static UseCustomRequestHeaders: boolean;
  35356. /**
  35357. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  35358. * i.e. when loading files, where the server/service expects an Authorization header
  35359. */
  35360. static CustomRequestHeaders: {
  35361. [key: string]: string;
  35362. };
  35363. /**
  35364. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  35365. */
  35366. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  35367. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  35368. /**
  35369. * Default behaviour for cors in the application.
  35370. * It can be a string if the expected behavior is identical in the entire app.
  35371. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  35372. */
  35373. static get CorsBehavior(): string | ((url: string | string[]) => string);
  35374. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  35375. /**
  35376. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  35377. * @ignorenaming
  35378. */
  35379. static get UseFallbackTexture(): boolean;
  35380. static set UseFallbackTexture(value: boolean);
  35381. /**
  35382. * Use this object to register external classes like custom textures or material
  35383. * to allow the laoders to instantiate them
  35384. */
  35385. static get RegisteredExternalClasses(): {
  35386. [key: string]: Object;
  35387. };
  35388. static set RegisteredExternalClasses(classes: {
  35389. [key: string]: Object;
  35390. });
  35391. /**
  35392. * Texture content used if a texture cannot loaded
  35393. * @ignorenaming
  35394. */
  35395. static get fallbackTexture(): string;
  35396. static set fallbackTexture(value: string);
  35397. /**
  35398. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  35399. * @param u defines the coordinate on X axis
  35400. * @param v defines the coordinate on Y axis
  35401. * @param width defines the width of the source data
  35402. * @param height defines the height of the source data
  35403. * @param pixels defines the source byte array
  35404. * @param color defines the output color
  35405. */
  35406. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  35407. /**
  35408. * Interpolates between a and b via alpha
  35409. * @param a The lower value (returned when alpha = 0)
  35410. * @param b The upper value (returned when alpha = 1)
  35411. * @param alpha The interpolation-factor
  35412. * @return The mixed value
  35413. */
  35414. static Mix(a: number, b: number, alpha: number): number;
  35415. /**
  35416. * Tries to instantiate a new object from a given class name
  35417. * @param className defines the class name to instantiate
  35418. * @returns the new object or null if the system was not able to do the instantiation
  35419. */
  35420. static Instantiate(className: string): any;
  35421. /**
  35422. * Provides a slice function that will work even on IE
  35423. * @param data defines the array to slice
  35424. * @param start defines the start of the data (optional)
  35425. * @param end defines the end of the data (optional)
  35426. * @returns the new sliced array
  35427. */
  35428. static Slice<T>(data: T, start?: number, end?: number): T;
  35429. /**
  35430. * Polyfill for setImmediate
  35431. * @param action defines the action to execute after the current execution block
  35432. */
  35433. static SetImmediate(action: () => void): void;
  35434. /**
  35435. * Function indicating if a number is an exponent of 2
  35436. * @param value defines the value to test
  35437. * @returns true if the value is an exponent of 2
  35438. */
  35439. static IsExponentOfTwo(value: number): boolean;
  35440. private static _tmpFloatArray;
  35441. /**
  35442. * Returns the nearest 32-bit single precision float representation of a Number
  35443. * @param value A Number. If the parameter is of a different type, it will get converted
  35444. * to a number or to NaN if it cannot be converted
  35445. * @returns number
  35446. */
  35447. static FloatRound(value: number): number;
  35448. /**
  35449. * Extracts the filename from a path
  35450. * @param path defines the path to use
  35451. * @returns the filename
  35452. */
  35453. static GetFilename(path: string): string;
  35454. /**
  35455. * Extracts the "folder" part of a path (everything before the filename).
  35456. * @param uri The URI to extract the info from
  35457. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  35458. * @returns The "folder" part of the path
  35459. */
  35460. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  35461. /**
  35462. * Extracts text content from a DOM element hierarchy
  35463. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  35464. */
  35465. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  35466. /**
  35467. * Convert an angle in radians to degrees
  35468. * @param angle defines the angle to convert
  35469. * @returns the angle in degrees
  35470. */
  35471. static ToDegrees(angle: number): number;
  35472. /**
  35473. * Convert an angle in degrees to radians
  35474. * @param angle defines the angle to convert
  35475. * @returns the angle in radians
  35476. */
  35477. static ToRadians(angle: number): number;
  35478. /**
  35479. * Returns an array if obj is not an array
  35480. * @param obj defines the object to evaluate as an array
  35481. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  35482. * @returns either obj directly if obj is an array or a new array containing obj
  35483. */
  35484. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  35485. /**
  35486. * Gets the pointer prefix to use
  35487. * @returns "pointer" if touch is enabled. Else returns "mouse"
  35488. */
  35489. static GetPointerPrefix(): string;
  35490. /**
  35491. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  35492. * @param url define the url we are trying
  35493. * @param element define the dom element where to configure the cors policy
  35494. */
  35495. static SetCorsBehavior(url: string | string[], element: {
  35496. crossOrigin: string | null;
  35497. }): void;
  35498. /**
  35499. * Removes unwanted characters from an url
  35500. * @param url defines the url to clean
  35501. * @returns the cleaned url
  35502. */
  35503. static CleanUrl(url: string): string;
  35504. /**
  35505. * Gets or sets a function used to pre-process url before using them to load assets
  35506. */
  35507. static get PreprocessUrl(): (url: string) => string;
  35508. static set PreprocessUrl(processor: (url: string) => string);
  35509. /**
  35510. * Loads an image as an HTMLImageElement.
  35511. * @param input url string, ArrayBuffer, or Blob to load
  35512. * @param onLoad callback called when the image successfully loads
  35513. * @param onError callback called when the image fails to load
  35514. * @param offlineProvider offline provider for caching
  35515. * @param mimeType optional mime type
  35516. * @returns the HTMLImageElement of the loaded image
  35517. */
  35518. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  35519. /**
  35520. * Loads a file from a url
  35521. * @param url url string, ArrayBuffer, or Blob to load
  35522. * @param onSuccess callback called when the file successfully loads
  35523. * @param onProgress callback called while file is loading (if the server supports this mode)
  35524. * @param offlineProvider defines the offline provider for caching
  35525. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35526. * @param onError callback called when the file fails to load
  35527. * @returns a file request object
  35528. */
  35529. 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;
  35530. /**
  35531. * Loads a file from a url
  35532. * @param url the file url to load
  35533. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  35534. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  35535. */
  35536. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  35537. /**
  35538. * Load a script (identified by an url). When the url returns, the
  35539. * content of this file is added into a new script element, attached to the DOM (body element)
  35540. * @param scriptUrl defines the url of the script to laod
  35541. * @param onSuccess defines the callback called when the script is loaded
  35542. * @param onError defines the callback to call if an error occurs
  35543. * @param scriptId defines the id of the script element
  35544. */
  35545. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  35546. /**
  35547. * Load an asynchronous script (identified by an url). When the url returns, the
  35548. * content of this file is added into a new script element, attached to the DOM (body element)
  35549. * @param scriptUrl defines the url of the script to laod
  35550. * @param scriptId defines the id of the script element
  35551. * @returns a promise request object
  35552. */
  35553. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  35554. /**
  35555. * Loads a file from a blob
  35556. * @param fileToLoad defines the blob to use
  35557. * @param callback defines the callback to call when data is loaded
  35558. * @param progressCallback defines the callback to call during loading process
  35559. * @returns a file request object
  35560. */
  35561. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  35562. /**
  35563. * Reads a file from a File object
  35564. * @param file defines the file to load
  35565. * @param onSuccess defines the callback to call when data is loaded
  35566. * @param onProgress defines the callback to call during loading process
  35567. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  35568. * @param onError defines the callback to call when an error occurs
  35569. * @returns a file request object
  35570. */
  35571. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  35572. /**
  35573. * Creates a data url from a given string content
  35574. * @param content defines the content to convert
  35575. * @returns the new data url link
  35576. */
  35577. static FileAsURL(content: string): string;
  35578. /**
  35579. * Format the given number to a specific decimal format
  35580. * @param value defines the number to format
  35581. * @param decimals defines the number of decimals to use
  35582. * @returns the formatted string
  35583. */
  35584. static Format(value: number, decimals?: number): string;
  35585. /**
  35586. * Tries to copy an object by duplicating every property
  35587. * @param source defines the source object
  35588. * @param destination defines the target object
  35589. * @param doNotCopyList defines a list of properties to avoid
  35590. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  35591. */
  35592. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  35593. /**
  35594. * Gets a boolean indicating if the given object has no own property
  35595. * @param obj defines the object to test
  35596. * @returns true if object has no own property
  35597. */
  35598. static IsEmpty(obj: any): boolean;
  35599. /**
  35600. * Function used to register events at window level
  35601. * @param windowElement defines the Window object to use
  35602. * @param events defines the events to register
  35603. */
  35604. static RegisterTopRootEvents(windowElement: Window, events: {
  35605. name: string;
  35606. handler: Nullable<(e: FocusEvent) => any>;
  35607. }[]): void;
  35608. /**
  35609. * Function used to unregister events from window level
  35610. * @param windowElement defines the Window object to use
  35611. * @param events defines the events to unregister
  35612. */
  35613. static UnregisterTopRootEvents(windowElement: Window, events: {
  35614. name: string;
  35615. handler: Nullable<(e: FocusEvent) => any>;
  35616. }[]): void;
  35617. /**
  35618. * @ignore
  35619. */
  35620. static _ScreenshotCanvas: HTMLCanvasElement;
  35621. /**
  35622. * Dumps the current bound framebuffer
  35623. * @param width defines the rendering width
  35624. * @param height defines the rendering height
  35625. * @param engine defines the hosting engine
  35626. * @param successCallback defines the callback triggered once the data are available
  35627. * @param mimeType defines the mime type of the result
  35628. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  35629. */
  35630. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35631. /**
  35632. * Converts the canvas data to blob.
  35633. * This acts as a polyfill for browsers not supporting the to blob function.
  35634. * @param canvas Defines the canvas to extract the data from
  35635. * @param successCallback Defines the callback triggered once the data are available
  35636. * @param mimeType Defines the mime type of the result
  35637. */
  35638. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  35639. /**
  35640. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  35641. * @param successCallback defines the callback triggered once the data are available
  35642. * @param mimeType defines the mime type of the result
  35643. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  35644. */
  35645. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  35646. /**
  35647. * Downloads a blob in the browser
  35648. * @param blob defines the blob to download
  35649. * @param fileName defines the name of the downloaded file
  35650. */
  35651. static Download(blob: Blob, fileName: string): void;
  35652. /**
  35653. * Captures a screenshot of the current rendering
  35654. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35655. * @param engine defines the rendering engine
  35656. * @param camera defines the source camera
  35657. * @param size This parameter can be set to a single number or to an object with the
  35658. * following (optional) properties: precision, width, height. If a single number is passed,
  35659. * it will be used for both width and height. If an object is passed, the screenshot size
  35660. * will be derived from the parameters. The precision property is a multiplier allowing
  35661. * rendering at a higher or lower resolution
  35662. * @param successCallback defines the callback receives a single parameter which contains the
  35663. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35664. * src parameter of an <img> to display it
  35665. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35666. * Check your browser for supported MIME types
  35667. */
  35668. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  35669. /**
  35670. * Captures a screenshot of the current rendering
  35671. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35672. * @param engine defines the rendering engine
  35673. * @param camera defines the source camera
  35674. * @param size This parameter can be set to a single number or to an object with the
  35675. * following (optional) properties: precision, width, height. If a single number is passed,
  35676. * it will be used for both width and height. If an object is passed, the screenshot size
  35677. * will be derived from the parameters. The precision property is a multiplier allowing
  35678. * rendering at a higher or lower resolution
  35679. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  35680. * Check your browser for supported MIME types
  35681. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35682. * to the src parameter of an <img> to display it
  35683. */
  35684. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  35685. /**
  35686. * Generates an image screenshot from the specified camera.
  35687. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35688. * @param engine The engine to use for rendering
  35689. * @param camera The camera to use for rendering
  35690. * @param size This parameter can be set to a single number or to an object with the
  35691. * following (optional) properties: precision, width, height. If a single number is passed,
  35692. * it will be used for both width and height. If an object is passed, the screenshot size
  35693. * will be derived from the parameters. The precision property is a multiplier allowing
  35694. * rendering at a higher or lower resolution
  35695. * @param successCallback The callback receives a single parameter which contains the
  35696. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  35697. * src parameter of an <img> to display it
  35698. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35699. * Check your browser for supported MIME types
  35700. * @param samples Texture samples (default: 1)
  35701. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35702. * @param fileName A name for for the downloaded file.
  35703. */
  35704. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  35705. /**
  35706. * Generates an image screenshot from the specified camera.
  35707. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  35708. * @param engine The engine to use for rendering
  35709. * @param camera The camera to use for rendering
  35710. * @param size This parameter can be set to a single number or to an object with the
  35711. * following (optional) properties: precision, width, height. If a single number is passed,
  35712. * it will be used for both width and height. If an object is passed, the screenshot size
  35713. * will be derived from the parameters. The precision property is a multiplier allowing
  35714. * rendering at a higher or lower resolution
  35715. * @param mimeType The MIME type of the screenshot image (default: image/png).
  35716. * Check your browser for supported MIME types
  35717. * @param samples Texture samples (default: 1)
  35718. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  35719. * @param fileName A name for for the downloaded file.
  35720. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  35721. * to the src parameter of an <img> to display it
  35722. */
  35723. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  35724. /**
  35725. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  35726. * Be aware Math.random() could cause collisions, but:
  35727. * "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"
  35728. * @returns a pseudo random id
  35729. */
  35730. static RandomId(): string;
  35731. /**
  35732. * Test if the given uri is a base64 string
  35733. * @param uri The uri to test
  35734. * @return True if the uri is a base64 string or false otherwise
  35735. */
  35736. static IsBase64(uri: string): boolean;
  35737. /**
  35738. * Decode the given base64 uri.
  35739. * @param uri The uri to decode
  35740. * @return The decoded base64 data.
  35741. */
  35742. static DecodeBase64(uri: string): ArrayBuffer;
  35743. /**
  35744. * Gets the absolute url.
  35745. * @param url the input url
  35746. * @return the absolute url
  35747. */
  35748. static GetAbsoluteUrl(url: string): string;
  35749. /**
  35750. * No log
  35751. */
  35752. static readonly NoneLogLevel: number;
  35753. /**
  35754. * Only message logs
  35755. */
  35756. static readonly MessageLogLevel: number;
  35757. /**
  35758. * Only warning logs
  35759. */
  35760. static readonly WarningLogLevel: number;
  35761. /**
  35762. * Only error logs
  35763. */
  35764. static readonly ErrorLogLevel: number;
  35765. /**
  35766. * All logs
  35767. */
  35768. static readonly AllLogLevel: number;
  35769. /**
  35770. * Gets a value indicating the number of loading errors
  35771. * @ignorenaming
  35772. */
  35773. static get errorsCount(): number;
  35774. /**
  35775. * Callback called when a new log is added
  35776. */
  35777. static OnNewCacheEntry: (entry: string) => void;
  35778. /**
  35779. * Log a message to the console
  35780. * @param message defines the message to log
  35781. */
  35782. static Log(message: string): void;
  35783. /**
  35784. * Write a warning message to the console
  35785. * @param message defines the message to log
  35786. */
  35787. static Warn(message: string): void;
  35788. /**
  35789. * Write an error message to the console
  35790. * @param message defines the message to log
  35791. */
  35792. static Error(message: string): void;
  35793. /**
  35794. * Gets current log cache (list of logs)
  35795. */
  35796. static get LogCache(): string;
  35797. /**
  35798. * Clears the log cache
  35799. */
  35800. static ClearLogCache(): void;
  35801. /**
  35802. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  35803. */
  35804. static set LogLevels(level: number);
  35805. /**
  35806. * Checks if the window object exists
  35807. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  35808. */
  35809. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  35810. /**
  35811. * No performance log
  35812. */
  35813. static readonly PerformanceNoneLogLevel: number;
  35814. /**
  35815. * Use user marks to log performance
  35816. */
  35817. static readonly PerformanceUserMarkLogLevel: number;
  35818. /**
  35819. * Log performance to the console
  35820. */
  35821. static readonly PerformanceConsoleLogLevel: number;
  35822. private static _performance;
  35823. /**
  35824. * Sets the current performance log level
  35825. */
  35826. static set PerformanceLogLevel(level: number);
  35827. private static _StartPerformanceCounterDisabled;
  35828. private static _EndPerformanceCounterDisabled;
  35829. private static _StartUserMark;
  35830. private static _EndUserMark;
  35831. private static _StartPerformanceConsole;
  35832. private static _EndPerformanceConsole;
  35833. /**
  35834. * Starts a performance counter
  35835. */
  35836. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35837. /**
  35838. * Ends a specific performance coutner
  35839. */
  35840. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  35841. /**
  35842. * Gets either window.performance.now() if supported or Date.now() else
  35843. */
  35844. static get Now(): number;
  35845. /**
  35846. * This method will return the name of the class used to create the instance of the given object.
  35847. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  35848. * @param object the object to get the class name from
  35849. * @param isType defines if the object is actually a type
  35850. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  35851. */
  35852. static GetClassName(object: any, isType?: boolean): string;
  35853. /**
  35854. * Gets the first element of an array satisfying a given predicate
  35855. * @param array defines the array to browse
  35856. * @param predicate defines the predicate to use
  35857. * @returns null if not found or the element
  35858. */
  35859. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  35860. /**
  35861. * This method will return the name of the full name of the class, including its owning module (if any).
  35862. * 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).
  35863. * @param object the object to get the class name from
  35864. * @param isType defines if the object is actually a type
  35865. * @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.
  35866. * @ignorenaming
  35867. */
  35868. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  35869. /**
  35870. * Returns a promise that resolves after the given amount of time.
  35871. * @param delay Number of milliseconds to delay
  35872. * @returns Promise that resolves after the given amount of time
  35873. */
  35874. static DelayAsync(delay: number): Promise<void>;
  35875. /**
  35876. * Utility function to detect if the current user agent is Safari
  35877. * @returns whether or not the current user agent is safari
  35878. */
  35879. static IsSafari(): boolean;
  35880. }
  35881. /**
  35882. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  35883. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  35884. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  35885. * @param name The name of the class, case should be preserved
  35886. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  35887. */
  35888. export function className(name: string, module?: string): (target: Object) => void;
  35889. /**
  35890. * An implementation of a loop for asynchronous functions.
  35891. */
  35892. export class AsyncLoop {
  35893. /**
  35894. * Defines the number of iterations for the loop
  35895. */
  35896. iterations: number;
  35897. /**
  35898. * Defines the current index of the loop.
  35899. */
  35900. index: number;
  35901. private _done;
  35902. private _fn;
  35903. private _successCallback;
  35904. /**
  35905. * Constructor.
  35906. * @param iterations the number of iterations.
  35907. * @param func the function to run each iteration
  35908. * @param successCallback the callback that will be called upon succesful execution
  35909. * @param offset starting offset.
  35910. */
  35911. constructor(
  35912. /**
  35913. * Defines the number of iterations for the loop
  35914. */
  35915. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  35916. /**
  35917. * Execute the next iteration. Must be called after the last iteration was finished.
  35918. */
  35919. executeNext(): void;
  35920. /**
  35921. * Break the loop and run the success callback.
  35922. */
  35923. breakLoop(): void;
  35924. /**
  35925. * Create and run an async loop.
  35926. * @param iterations the number of iterations.
  35927. * @param fn the function to run each iteration
  35928. * @param successCallback the callback that will be called upon succesful execution
  35929. * @param offset starting offset.
  35930. * @returns the created async loop object
  35931. */
  35932. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  35933. /**
  35934. * A for-loop that will run a given number of iterations synchronous and the rest async.
  35935. * @param iterations total number of iterations
  35936. * @param syncedIterations number of synchronous iterations in each async iteration.
  35937. * @param fn the function to call each iteration.
  35938. * @param callback a success call back that will be called when iterating stops.
  35939. * @param breakFunction a break condition (optional)
  35940. * @param timeout timeout settings for the setTimeout function. default - 0.
  35941. * @returns the created async loop object
  35942. */
  35943. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  35944. }
  35945. }
  35946. declare module "babylonjs/Misc/stringDictionary" {
  35947. import { Nullable } from "babylonjs/types";
  35948. /**
  35949. * This class implement a typical dictionary using a string as key and the generic type T as value.
  35950. * The underlying implementation relies on an associative array to ensure the best performances.
  35951. * The value can be anything including 'null' but except 'undefined'
  35952. */
  35953. export class StringDictionary<T> {
  35954. /**
  35955. * This will clear this dictionary and copy the content from the 'source' one.
  35956. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  35957. * @param source the dictionary to take the content from and copy to this dictionary
  35958. */
  35959. copyFrom(source: StringDictionary<T>): void;
  35960. /**
  35961. * Get a value based from its key
  35962. * @param key the given key to get the matching value from
  35963. * @return the value if found, otherwise undefined is returned
  35964. */
  35965. get(key: string): T | undefined;
  35966. /**
  35967. * Get a value from its key or add it if it doesn't exist.
  35968. * This method will ensure you that a given key/data will be present in the dictionary.
  35969. * @param key the given key to get the matching value from
  35970. * @param factory the factory that will create the value if the key is not present in the dictionary.
  35971. * The factory will only be invoked if there's no data for the given key.
  35972. * @return the value corresponding to the key.
  35973. */
  35974. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  35975. /**
  35976. * Get a value from its key if present in the dictionary otherwise add it
  35977. * @param key the key to get the value from
  35978. * @param val if there's no such key/value pair in the dictionary add it with this value
  35979. * @return the value corresponding to the key
  35980. */
  35981. getOrAdd(key: string, val: T): T;
  35982. /**
  35983. * Check if there's a given key in the dictionary
  35984. * @param key the key to check for
  35985. * @return true if the key is present, false otherwise
  35986. */
  35987. contains(key: string): boolean;
  35988. /**
  35989. * Add a new key and its corresponding value
  35990. * @param key the key to add
  35991. * @param value the value corresponding to the key
  35992. * @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
  35993. */
  35994. add(key: string, value: T): boolean;
  35995. /**
  35996. * Update a specific value associated to a key
  35997. * @param key defines the key to use
  35998. * @param value defines the value to store
  35999. * @returns true if the value was updated (or false if the key was not found)
  36000. */
  36001. set(key: string, value: T): boolean;
  36002. /**
  36003. * Get the element of the given key and remove it from the dictionary
  36004. * @param key defines the key to search
  36005. * @returns the value associated with the key or null if not found
  36006. */
  36007. getAndRemove(key: string): Nullable<T>;
  36008. /**
  36009. * Remove a key/value from the dictionary.
  36010. * @param key the key to remove
  36011. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  36012. */
  36013. remove(key: string): boolean;
  36014. /**
  36015. * Clear the whole content of the dictionary
  36016. */
  36017. clear(): void;
  36018. /**
  36019. * Gets the current count
  36020. */
  36021. get count(): number;
  36022. /**
  36023. * Execute a callback on each key/val of the dictionary.
  36024. * Note that you can remove any element in this dictionary in the callback implementation
  36025. * @param callback the callback to execute on a given key/value pair
  36026. */
  36027. forEach(callback: (key: string, val: T) => void): void;
  36028. /**
  36029. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  36030. * If the callback returns null or undefined the method will iterate to the next key/value pair
  36031. * Note that you can remove any element in this dictionary in the callback implementation
  36032. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  36033. * @returns the first item
  36034. */
  36035. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  36036. private _count;
  36037. private _data;
  36038. }
  36039. }
  36040. declare module "babylonjs/Collisions/collisionCoordinator" {
  36041. import { Nullable } from "babylonjs/types";
  36042. import { Scene } from "babylonjs/scene";
  36043. import { Vector3 } from "babylonjs/Maths/math.vector";
  36044. import { Collider } from "babylonjs/Collisions/collider";
  36045. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36046. /** @hidden */
  36047. export interface ICollisionCoordinator {
  36048. createCollider(): Collider;
  36049. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36050. init(scene: Scene): void;
  36051. }
  36052. /** @hidden */
  36053. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  36054. private _scene;
  36055. private _scaledPosition;
  36056. private _scaledVelocity;
  36057. private _finalPosition;
  36058. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  36059. createCollider(): Collider;
  36060. init(scene: Scene): void;
  36061. private _collideWithWorld;
  36062. }
  36063. }
  36064. declare module "babylonjs/Inputs/scene.inputManager" {
  36065. import { Nullable } from "babylonjs/types";
  36066. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36067. import { Vector2 } from "babylonjs/Maths/math.vector";
  36068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36069. import { Scene } from "babylonjs/scene";
  36070. /**
  36071. * Class used to manage all inputs for the scene.
  36072. */
  36073. export class InputManager {
  36074. /** The distance in pixel that you have to move to prevent some events */
  36075. static DragMovementThreshold: number;
  36076. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  36077. static LongPressDelay: number;
  36078. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  36079. static DoubleClickDelay: number;
  36080. /** If you need to check double click without raising a single click at first click, enable this flag */
  36081. static ExclusiveDoubleClickMode: boolean;
  36082. private _wheelEventName;
  36083. private _onPointerMove;
  36084. private _onPointerDown;
  36085. private _onPointerUp;
  36086. private _initClickEvent;
  36087. private _initActionManager;
  36088. private _delayedSimpleClick;
  36089. private _delayedSimpleClickTimeout;
  36090. private _previousDelayedSimpleClickTimeout;
  36091. private _meshPickProceed;
  36092. private _previousButtonPressed;
  36093. private _currentPickResult;
  36094. private _previousPickResult;
  36095. private _totalPointersPressed;
  36096. private _doubleClickOccured;
  36097. private _pointerOverMesh;
  36098. private _pickedDownMesh;
  36099. private _pickedUpMesh;
  36100. private _pointerX;
  36101. private _pointerY;
  36102. private _unTranslatedPointerX;
  36103. private _unTranslatedPointerY;
  36104. private _startingPointerPosition;
  36105. private _previousStartingPointerPosition;
  36106. private _startingPointerTime;
  36107. private _previousStartingPointerTime;
  36108. private _pointerCaptures;
  36109. private _onKeyDown;
  36110. private _onKeyUp;
  36111. private _onCanvasFocusObserver;
  36112. private _onCanvasBlurObserver;
  36113. private _scene;
  36114. /**
  36115. * Creates a new InputManager
  36116. * @param scene defines the hosting scene
  36117. */
  36118. constructor(scene: Scene);
  36119. /**
  36120. * Gets the mesh that is currently under the pointer
  36121. */
  36122. get meshUnderPointer(): Nullable<AbstractMesh>;
  36123. /**
  36124. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  36125. */
  36126. get unTranslatedPointer(): Vector2;
  36127. /**
  36128. * Gets or sets the current on-screen X position of the pointer
  36129. */
  36130. get pointerX(): number;
  36131. set pointerX(value: number);
  36132. /**
  36133. * Gets or sets the current on-screen Y position of the pointer
  36134. */
  36135. get pointerY(): number;
  36136. set pointerY(value: number);
  36137. private _updatePointerPosition;
  36138. private _processPointerMove;
  36139. private _setRayOnPointerInfo;
  36140. private _checkPrePointerObservable;
  36141. /**
  36142. * Use this method to simulate a pointer move on a mesh
  36143. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36144. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36145. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36146. */
  36147. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36148. /**
  36149. * Use this method to simulate a pointer down on a mesh
  36150. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36151. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36152. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36153. */
  36154. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  36155. private _processPointerDown;
  36156. /** @hidden */
  36157. _isPointerSwiping(): boolean;
  36158. /**
  36159. * Use this method to simulate a pointer up on a mesh
  36160. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  36161. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  36162. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  36163. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  36164. */
  36165. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  36166. private _processPointerUp;
  36167. /**
  36168. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  36169. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  36170. * @returns true if the pointer was captured
  36171. */
  36172. isPointerCaptured(pointerId?: number): boolean;
  36173. /**
  36174. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  36175. * @param attachUp defines if you want to attach events to pointerup
  36176. * @param attachDown defines if you want to attach events to pointerdown
  36177. * @param attachMove defines if you want to attach events to pointermove
  36178. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  36179. */
  36180. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  36181. /**
  36182. * Detaches all event handlers
  36183. */
  36184. detachControl(): void;
  36185. /**
  36186. * Force the value of meshUnderPointer
  36187. * @param mesh defines the mesh to use
  36188. */
  36189. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  36190. /**
  36191. * Gets the mesh under the pointer
  36192. * @returns a Mesh or null if no mesh is under the pointer
  36193. */
  36194. getPointerOverMesh(): Nullable<AbstractMesh>;
  36195. }
  36196. }
  36197. declare module "babylonjs/Misc/uniqueIdGenerator" {
  36198. /**
  36199. * Helper class used to generate session unique ID
  36200. */
  36201. export class UniqueIdGenerator {
  36202. private static _UniqueIdCounter;
  36203. /**
  36204. * Gets an unique (relatively to the current scene) Id
  36205. */
  36206. static get UniqueId(): number;
  36207. }
  36208. }
  36209. declare module "babylonjs/Animations/animationGroup" {
  36210. import { Animatable } from "babylonjs/Animations/animatable";
  36211. import { Animation } from "babylonjs/Animations/animation";
  36212. import { Scene, IDisposable } from "babylonjs/scene";
  36213. import { Observable } from "babylonjs/Misc/observable";
  36214. import { Nullable } from "babylonjs/types";
  36215. import "babylonjs/Animations/animatable";
  36216. /**
  36217. * This class defines the direct association between an animation and a target
  36218. */
  36219. export class TargetedAnimation {
  36220. /**
  36221. * Animation to perform
  36222. */
  36223. animation: Animation;
  36224. /**
  36225. * Target to animate
  36226. */
  36227. target: any;
  36228. /**
  36229. * Serialize the object
  36230. * @returns the JSON object representing the current entity
  36231. */
  36232. serialize(): any;
  36233. }
  36234. /**
  36235. * Use this class to create coordinated animations on multiple targets
  36236. */
  36237. export class AnimationGroup implements IDisposable {
  36238. /** The name of the animation group */
  36239. name: string;
  36240. private _scene;
  36241. private _targetedAnimations;
  36242. private _animatables;
  36243. private _from;
  36244. private _to;
  36245. private _isStarted;
  36246. private _isPaused;
  36247. private _speedRatio;
  36248. private _loopAnimation;
  36249. private _isAdditive;
  36250. /**
  36251. * Gets or sets the unique id of the node
  36252. */
  36253. uniqueId: number;
  36254. /**
  36255. * This observable will notify when one animation have ended
  36256. */
  36257. onAnimationEndObservable: Observable<TargetedAnimation>;
  36258. /**
  36259. * Observer raised when one animation loops
  36260. */
  36261. onAnimationLoopObservable: Observable<TargetedAnimation>;
  36262. /**
  36263. * Observer raised when all animations have looped
  36264. */
  36265. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  36266. /**
  36267. * This observable will notify when all animations have ended.
  36268. */
  36269. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  36270. /**
  36271. * This observable will notify when all animations have paused.
  36272. */
  36273. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  36274. /**
  36275. * This observable will notify when all animations are playing.
  36276. */
  36277. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  36278. /**
  36279. * Gets the first frame
  36280. */
  36281. get from(): number;
  36282. /**
  36283. * Gets the last frame
  36284. */
  36285. get to(): number;
  36286. /**
  36287. * Define if the animations are started
  36288. */
  36289. get isStarted(): boolean;
  36290. /**
  36291. * Gets a value indicating that the current group is playing
  36292. */
  36293. get isPlaying(): boolean;
  36294. /**
  36295. * Gets or sets the speed ratio to use for all animations
  36296. */
  36297. get speedRatio(): number;
  36298. /**
  36299. * Gets or sets the speed ratio to use for all animations
  36300. */
  36301. set speedRatio(value: number);
  36302. /**
  36303. * Gets or sets if all animations should loop or not
  36304. */
  36305. get loopAnimation(): boolean;
  36306. set loopAnimation(value: boolean);
  36307. /**
  36308. * Gets or sets if all animations should be evaluated additively
  36309. */
  36310. get isAdditive(): boolean;
  36311. set isAdditive(value: boolean);
  36312. /**
  36313. * Gets the targeted animations for this animation group
  36314. */
  36315. get targetedAnimations(): Array<TargetedAnimation>;
  36316. /**
  36317. * returning the list of animatables controlled by this animation group.
  36318. */
  36319. get animatables(): Array<Animatable>;
  36320. /**
  36321. * Instantiates a new Animation Group.
  36322. * This helps managing several animations at once.
  36323. * @see http://doc.babylonjs.com/how_to/group
  36324. * @param name Defines the name of the group
  36325. * @param scene Defines the scene the group belongs to
  36326. */
  36327. constructor(
  36328. /** The name of the animation group */
  36329. name: string, scene?: Nullable<Scene>);
  36330. /**
  36331. * Add an animation (with its target) in the group
  36332. * @param animation defines the animation we want to add
  36333. * @param target defines the target of the animation
  36334. * @returns the TargetedAnimation object
  36335. */
  36336. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  36337. /**
  36338. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  36339. * It can add constant keys at begin or end
  36340. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  36341. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  36342. * @returns the animation group
  36343. */
  36344. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  36345. private _animationLoopCount;
  36346. private _animationLoopFlags;
  36347. private _processLoop;
  36348. /**
  36349. * Start all animations on given targets
  36350. * @param loop defines if animations must loop
  36351. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  36352. * @param from defines the from key (optional)
  36353. * @param to defines the to key (optional)
  36354. * @param isAdditive defines the additive state for the resulting animatables (optional)
  36355. * @returns the current animation group
  36356. */
  36357. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  36358. /**
  36359. * Pause all animations
  36360. * @returns the animation group
  36361. */
  36362. pause(): AnimationGroup;
  36363. /**
  36364. * Play all animations to initial state
  36365. * This function will start() the animations if they were not started or will restart() them if they were paused
  36366. * @param loop defines if animations must loop
  36367. * @returns the animation group
  36368. */
  36369. play(loop?: boolean): AnimationGroup;
  36370. /**
  36371. * Reset all animations to initial state
  36372. * @returns the animation group
  36373. */
  36374. reset(): AnimationGroup;
  36375. /**
  36376. * Restart animations from key 0
  36377. * @returns the animation group
  36378. */
  36379. restart(): AnimationGroup;
  36380. /**
  36381. * Stop all animations
  36382. * @returns the animation group
  36383. */
  36384. stop(): AnimationGroup;
  36385. /**
  36386. * Set animation weight for all animatables
  36387. * @param weight defines the weight to use
  36388. * @return the animationGroup
  36389. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36390. */
  36391. setWeightForAllAnimatables(weight: number): AnimationGroup;
  36392. /**
  36393. * Synchronize and normalize all animatables with a source animatable
  36394. * @param root defines the root animatable to synchronize with
  36395. * @return the animationGroup
  36396. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  36397. */
  36398. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  36399. /**
  36400. * Goes to a specific frame in this animation group
  36401. * @param frame the frame number to go to
  36402. * @return the animationGroup
  36403. */
  36404. goToFrame(frame: number): AnimationGroup;
  36405. /**
  36406. * Dispose all associated resources
  36407. */
  36408. dispose(): void;
  36409. private _checkAnimationGroupEnded;
  36410. /**
  36411. * Clone the current animation group and returns a copy
  36412. * @param newName defines the name of the new group
  36413. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  36414. * @returns the new aniamtion group
  36415. */
  36416. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  36417. /**
  36418. * Serializes the animationGroup to an object
  36419. * @returns Serialized object
  36420. */
  36421. serialize(): any;
  36422. /**
  36423. * Returns a new AnimationGroup object parsed from the source provided.
  36424. * @param parsedAnimationGroup defines the source
  36425. * @param scene defines the scene that will receive the animationGroup
  36426. * @returns a new AnimationGroup
  36427. */
  36428. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  36429. /**
  36430. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  36431. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  36432. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  36433. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  36434. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  36435. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  36436. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  36437. */
  36438. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  36439. /**
  36440. * Returns the string "AnimationGroup"
  36441. * @returns "AnimationGroup"
  36442. */
  36443. getClassName(): string;
  36444. /**
  36445. * Creates a detailled string about the object
  36446. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  36447. * @returns a string representing the object
  36448. */
  36449. toString(fullDetails?: boolean): string;
  36450. }
  36451. }
  36452. declare module "babylonjs/scene" {
  36453. import { Nullable } from "babylonjs/types";
  36454. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  36455. import { Observable } from "babylonjs/Misc/observable";
  36456. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  36457. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  36458. import { Geometry } from "babylonjs/Meshes/geometry";
  36459. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36460. import { SubMesh } from "babylonjs/Meshes/subMesh";
  36461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36462. import { Mesh } from "babylonjs/Meshes/mesh";
  36463. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  36464. import { Bone } from "babylonjs/Bones/bone";
  36465. import { Skeleton } from "babylonjs/Bones/skeleton";
  36466. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  36467. import { Camera } from "babylonjs/Cameras/camera";
  36468. import { AbstractScene } from "babylonjs/abstractScene";
  36469. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36470. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  36471. import { Material } from "babylonjs/Materials/material";
  36472. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  36473. import { Effect } from "babylonjs/Materials/effect";
  36474. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36475. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  36476. import { Light } from "babylonjs/Lights/light";
  36477. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  36478. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  36479. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  36480. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  36481. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  36482. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  36483. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36484. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  36485. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  36486. import { Engine } from "babylonjs/Engines/engine";
  36487. import { Node } from "babylonjs/node";
  36488. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  36489. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  36490. import { WebRequest } from "babylonjs/Misc/webRequest";
  36491. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  36492. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  36493. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36494. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  36495. import { Plane } from "babylonjs/Maths/math.plane";
  36496. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  36497. import { Ray } from "babylonjs/Culling/ray";
  36498. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  36499. import { Animation } from "babylonjs/Animations/animation";
  36500. import { Animatable } from "babylonjs/Animations/animatable";
  36501. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  36502. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  36503. import { Collider } from "babylonjs/Collisions/collider";
  36504. /**
  36505. * Define an interface for all classes that will hold resources
  36506. */
  36507. export interface IDisposable {
  36508. /**
  36509. * Releases all held resources
  36510. */
  36511. dispose(): void;
  36512. }
  36513. /** Interface defining initialization parameters for Scene class */
  36514. export interface SceneOptions {
  36515. /**
  36516. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  36517. * It will improve performance when the number of geometries becomes important.
  36518. */
  36519. useGeometryUniqueIdsMap?: boolean;
  36520. /**
  36521. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  36522. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36523. */
  36524. useMaterialMeshMap?: boolean;
  36525. /**
  36526. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  36527. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  36528. */
  36529. useClonedMeshMap?: boolean;
  36530. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  36531. virtual?: boolean;
  36532. }
  36533. /**
  36534. * Represents a scene to be rendered by the engine.
  36535. * @see http://doc.babylonjs.com/features/scene
  36536. */
  36537. export class Scene extends AbstractScene implements IAnimatable {
  36538. /** The fog is deactivated */
  36539. static readonly FOGMODE_NONE: number;
  36540. /** The fog density is following an exponential function */
  36541. static readonly FOGMODE_EXP: number;
  36542. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  36543. static readonly FOGMODE_EXP2: number;
  36544. /** The fog density is following a linear function. */
  36545. static readonly FOGMODE_LINEAR: number;
  36546. /**
  36547. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  36548. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36549. */
  36550. static MinDeltaTime: number;
  36551. /**
  36552. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  36553. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36554. */
  36555. static MaxDeltaTime: number;
  36556. /**
  36557. * Factory used to create the default material.
  36558. * @param name The name of the material to create
  36559. * @param scene The scene to create the material for
  36560. * @returns The default material
  36561. */
  36562. static DefaultMaterialFactory(scene: Scene): Material;
  36563. /**
  36564. * Factory used to create the a collision coordinator.
  36565. * @returns The collision coordinator
  36566. */
  36567. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  36568. /** @hidden */
  36569. _inputManager: InputManager;
  36570. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  36571. cameraToUseForPointers: Nullable<Camera>;
  36572. /** @hidden */
  36573. readonly _isScene: boolean;
  36574. /** @hidden */
  36575. _blockEntityCollection: boolean;
  36576. /**
  36577. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  36578. */
  36579. autoClear: boolean;
  36580. /**
  36581. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  36582. */
  36583. autoClearDepthAndStencil: boolean;
  36584. /**
  36585. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  36586. */
  36587. clearColor: Color4;
  36588. /**
  36589. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  36590. */
  36591. ambientColor: Color3;
  36592. /**
  36593. * This is use to store the default BRDF lookup for PBR materials in your scene.
  36594. * It should only be one of the following (if not the default embedded one):
  36595. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  36596. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  36597. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  36598. * The material properties need to be setup according to the type of texture in use.
  36599. */
  36600. environmentBRDFTexture: BaseTexture;
  36601. /** @hidden */
  36602. protected _environmentTexture: Nullable<BaseTexture>;
  36603. /**
  36604. * Texture used in all pbr material as the reflection texture.
  36605. * As in the majority of the scene they are the same (exception for multi room and so on),
  36606. * this is easier to reference from here than from all the materials.
  36607. */
  36608. get environmentTexture(): Nullable<BaseTexture>;
  36609. /**
  36610. * Texture used in all pbr material as the reflection texture.
  36611. * As in the majority of the scene they are the same (exception for multi room and so on),
  36612. * this is easier to set here than in all the materials.
  36613. */
  36614. set environmentTexture(value: Nullable<BaseTexture>);
  36615. /** @hidden */
  36616. protected _environmentIntensity: number;
  36617. /**
  36618. * Intensity of the environment in all pbr material.
  36619. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36620. * As in the majority of the scene they are the same (exception for multi room and so on),
  36621. * this is easier to reference from here than from all the materials.
  36622. */
  36623. get environmentIntensity(): number;
  36624. /**
  36625. * Intensity of the environment in all pbr material.
  36626. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  36627. * As in the majority of the scene they are the same (exception for multi room and so on),
  36628. * this is easier to set here than in all the materials.
  36629. */
  36630. set environmentIntensity(value: number);
  36631. /** @hidden */
  36632. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  36633. /**
  36634. * Default image processing configuration used either in the rendering
  36635. * Forward main pass or through the imageProcessingPostProcess if present.
  36636. * As in the majority of the scene they are the same (exception for multi camera),
  36637. * this is easier to reference from here than from all the materials and post process.
  36638. *
  36639. * No setter as we it is a shared configuration, you can set the values instead.
  36640. */
  36641. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  36642. private _forceWireframe;
  36643. /**
  36644. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  36645. */
  36646. set forceWireframe(value: boolean);
  36647. get forceWireframe(): boolean;
  36648. private _skipFrustumClipping;
  36649. /**
  36650. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  36651. */
  36652. set skipFrustumClipping(value: boolean);
  36653. get skipFrustumClipping(): boolean;
  36654. private _forcePointsCloud;
  36655. /**
  36656. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  36657. */
  36658. set forcePointsCloud(value: boolean);
  36659. get forcePointsCloud(): boolean;
  36660. /**
  36661. * Gets or sets the active clipplane 1
  36662. */
  36663. clipPlane: Nullable<Plane>;
  36664. /**
  36665. * Gets or sets the active clipplane 2
  36666. */
  36667. clipPlane2: Nullable<Plane>;
  36668. /**
  36669. * Gets or sets the active clipplane 3
  36670. */
  36671. clipPlane3: Nullable<Plane>;
  36672. /**
  36673. * Gets or sets the active clipplane 4
  36674. */
  36675. clipPlane4: Nullable<Plane>;
  36676. /**
  36677. * Gets or sets the active clipplane 5
  36678. */
  36679. clipPlane5: Nullable<Plane>;
  36680. /**
  36681. * Gets or sets the active clipplane 6
  36682. */
  36683. clipPlane6: Nullable<Plane>;
  36684. /**
  36685. * Gets or sets a boolean indicating if animations are enabled
  36686. */
  36687. animationsEnabled: boolean;
  36688. private _animationPropertiesOverride;
  36689. /**
  36690. * Gets or sets the animation properties override
  36691. */
  36692. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  36693. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  36694. /**
  36695. * Gets or sets a boolean indicating if a constant deltatime has to be used
  36696. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  36697. */
  36698. useConstantAnimationDeltaTime: boolean;
  36699. /**
  36700. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  36701. * Please note that it requires to run a ray cast through the scene on every frame
  36702. */
  36703. constantlyUpdateMeshUnderPointer: boolean;
  36704. /**
  36705. * Defines the HTML cursor to use when hovering over interactive elements
  36706. */
  36707. hoverCursor: string;
  36708. /**
  36709. * Defines the HTML default cursor to use (empty by default)
  36710. */
  36711. defaultCursor: string;
  36712. /**
  36713. * Defines whether cursors are handled by the scene.
  36714. */
  36715. doNotHandleCursors: boolean;
  36716. /**
  36717. * This is used to call preventDefault() on pointer down
  36718. * in order to block unwanted artifacts like system double clicks
  36719. */
  36720. preventDefaultOnPointerDown: boolean;
  36721. /**
  36722. * This is used to call preventDefault() on pointer up
  36723. * in order to block unwanted artifacts like system double clicks
  36724. */
  36725. preventDefaultOnPointerUp: boolean;
  36726. /**
  36727. * Gets or sets user defined metadata
  36728. */
  36729. metadata: any;
  36730. /**
  36731. * For internal use only. Please do not use.
  36732. */
  36733. reservedDataStore: any;
  36734. /**
  36735. * Gets the name of the plugin used to load this scene (null by default)
  36736. */
  36737. loadingPluginName: string;
  36738. /**
  36739. * Use this array to add regular expressions used to disable offline support for specific urls
  36740. */
  36741. disableOfflineSupportExceptionRules: RegExp[];
  36742. /**
  36743. * An event triggered when the scene is disposed.
  36744. */
  36745. onDisposeObservable: Observable<Scene>;
  36746. private _onDisposeObserver;
  36747. /** Sets a function to be executed when this scene is disposed. */
  36748. set onDispose(callback: () => void);
  36749. /**
  36750. * An event triggered before rendering the scene (right after animations and physics)
  36751. */
  36752. onBeforeRenderObservable: Observable<Scene>;
  36753. private _onBeforeRenderObserver;
  36754. /** Sets a function to be executed before rendering this scene */
  36755. set beforeRender(callback: Nullable<() => void>);
  36756. /**
  36757. * An event triggered after rendering the scene
  36758. */
  36759. onAfterRenderObservable: Observable<Scene>;
  36760. /**
  36761. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  36762. */
  36763. onAfterRenderCameraObservable: Observable<Camera>;
  36764. private _onAfterRenderObserver;
  36765. /** Sets a function to be executed after rendering this scene */
  36766. set afterRender(callback: Nullable<() => void>);
  36767. /**
  36768. * An event triggered before animating the scene
  36769. */
  36770. onBeforeAnimationsObservable: Observable<Scene>;
  36771. /**
  36772. * An event triggered after animations processing
  36773. */
  36774. onAfterAnimationsObservable: Observable<Scene>;
  36775. /**
  36776. * An event triggered before draw calls are ready to be sent
  36777. */
  36778. onBeforeDrawPhaseObservable: Observable<Scene>;
  36779. /**
  36780. * An event triggered after draw calls have been sent
  36781. */
  36782. onAfterDrawPhaseObservable: Observable<Scene>;
  36783. /**
  36784. * An event triggered when the scene is ready
  36785. */
  36786. onReadyObservable: Observable<Scene>;
  36787. /**
  36788. * An event triggered before rendering a camera
  36789. */
  36790. onBeforeCameraRenderObservable: Observable<Camera>;
  36791. private _onBeforeCameraRenderObserver;
  36792. /** Sets a function to be executed before rendering a camera*/
  36793. set beforeCameraRender(callback: () => void);
  36794. /**
  36795. * An event triggered after rendering a camera
  36796. */
  36797. onAfterCameraRenderObservable: Observable<Camera>;
  36798. private _onAfterCameraRenderObserver;
  36799. /** Sets a function to be executed after rendering a camera*/
  36800. set afterCameraRender(callback: () => void);
  36801. /**
  36802. * An event triggered when active meshes evaluation is about to start
  36803. */
  36804. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  36805. /**
  36806. * An event triggered when active meshes evaluation is done
  36807. */
  36808. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  36809. /**
  36810. * An event triggered when particles rendering is about to start
  36811. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36812. */
  36813. onBeforeParticlesRenderingObservable: Observable<Scene>;
  36814. /**
  36815. * An event triggered when particles rendering is done
  36816. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  36817. */
  36818. onAfterParticlesRenderingObservable: Observable<Scene>;
  36819. /**
  36820. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  36821. */
  36822. onDataLoadedObservable: Observable<Scene>;
  36823. /**
  36824. * An event triggered when a camera is created
  36825. */
  36826. onNewCameraAddedObservable: Observable<Camera>;
  36827. /**
  36828. * An event triggered when a camera is removed
  36829. */
  36830. onCameraRemovedObservable: Observable<Camera>;
  36831. /**
  36832. * An event triggered when a light is created
  36833. */
  36834. onNewLightAddedObservable: Observable<Light>;
  36835. /**
  36836. * An event triggered when a light is removed
  36837. */
  36838. onLightRemovedObservable: Observable<Light>;
  36839. /**
  36840. * An event triggered when a geometry is created
  36841. */
  36842. onNewGeometryAddedObservable: Observable<Geometry>;
  36843. /**
  36844. * An event triggered when a geometry is removed
  36845. */
  36846. onGeometryRemovedObservable: Observable<Geometry>;
  36847. /**
  36848. * An event triggered when a transform node is created
  36849. */
  36850. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  36851. /**
  36852. * An event triggered when a transform node is removed
  36853. */
  36854. onTransformNodeRemovedObservable: Observable<TransformNode>;
  36855. /**
  36856. * An event triggered when a mesh is created
  36857. */
  36858. onNewMeshAddedObservable: Observable<AbstractMesh>;
  36859. /**
  36860. * An event triggered when a mesh is removed
  36861. */
  36862. onMeshRemovedObservable: Observable<AbstractMesh>;
  36863. /**
  36864. * An event triggered when a skeleton is created
  36865. */
  36866. onNewSkeletonAddedObservable: Observable<Skeleton>;
  36867. /**
  36868. * An event triggered when a skeleton is removed
  36869. */
  36870. onSkeletonRemovedObservable: Observable<Skeleton>;
  36871. /**
  36872. * An event triggered when a material is created
  36873. */
  36874. onNewMaterialAddedObservable: Observable<Material>;
  36875. /**
  36876. * An event triggered when a material is removed
  36877. */
  36878. onMaterialRemovedObservable: Observable<Material>;
  36879. /**
  36880. * An event triggered when a texture is created
  36881. */
  36882. onNewTextureAddedObservable: Observable<BaseTexture>;
  36883. /**
  36884. * An event triggered when a texture is removed
  36885. */
  36886. onTextureRemovedObservable: Observable<BaseTexture>;
  36887. /**
  36888. * An event triggered when render targets are about to be rendered
  36889. * Can happen multiple times per frame.
  36890. */
  36891. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  36892. /**
  36893. * An event triggered when render targets were rendered.
  36894. * Can happen multiple times per frame.
  36895. */
  36896. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  36897. /**
  36898. * An event triggered before calculating deterministic simulation step
  36899. */
  36900. onBeforeStepObservable: Observable<Scene>;
  36901. /**
  36902. * An event triggered after calculating deterministic simulation step
  36903. */
  36904. onAfterStepObservable: Observable<Scene>;
  36905. /**
  36906. * An event triggered when the activeCamera property is updated
  36907. */
  36908. onActiveCameraChanged: Observable<Scene>;
  36909. /**
  36910. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  36911. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36912. * 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)
  36913. */
  36914. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36915. /**
  36916. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  36917. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  36918. * 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)
  36919. */
  36920. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  36921. /**
  36922. * This Observable will when a mesh has been imported into the scene.
  36923. */
  36924. onMeshImportedObservable: Observable<AbstractMesh>;
  36925. /**
  36926. * This Observable will when an animation file has been imported into the scene.
  36927. */
  36928. onAnimationFileImportedObservable: Observable<Scene>;
  36929. /**
  36930. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  36931. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  36932. */
  36933. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  36934. /** @hidden */
  36935. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  36936. /**
  36937. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  36938. */
  36939. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  36940. /**
  36941. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  36942. */
  36943. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  36944. /**
  36945. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  36946. */
  36947. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  36948. /** Callback called when a pointer move is detected */
  36949. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36950. /** Callback called when a pointer down is detected */
  36951. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  36952. /** Callback called when a pointer up is detected */
  36953. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  36954. /** Callback called when a pointer pick is detected */
  36955. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  36956. /**
  36957. * 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).
  36958. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  36959. */
  36960. onPrePointerObservable: Observable<PointerInfoPre>;
  36961. /**
  36962. * Observable event triggered each time an input event is received from the rendering canvas
  36963. */
  36964. onPointerObservable: Observable<PointerInfo>;
  36965. /**
  36966. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  36967. */
  36968. get unTranslatedPointer(): Vector2;
  36969. /**
  36970. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  36971. */
  36972. static get DragMovementThreshold(): number;
  36973. static set DragMovementThreshold(value: number);
  36974. /**
  36975. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  36976. */
  36977. static get LongPressDelay(): number;
  36978. static set LongPressDelay(value: number);
  36979. /**
  36980. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  36981. */
  36982. static get DoubleClickDelay(): number;
  36983. static set DoubleClickDelay(value: number);
  36984. /** If you need to check double click without raising a single click at first click, enable this flag */
  36985. static get ExclusiveDoubleClickMode(): boolean;
  36986. static set ExclusiveDoubleClickMode(value: boolean);
  36987. /** @hidden */
  36988. _mirroredCameraPosition: Nullable<Vector3>;
  36989. /**
  36990. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  36991. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  36992. */
  36993. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  36994. /**
  36995. * Observable event triggered each time an keyboard event is received from the hosting window
  36996. */
  36997. onKeyboardObservable: Observable<KeyboardInfo>;
  36998. private _useRightHandedSystem;
  36999. /**
  37000. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  37001. */
  37002. set useRightHandedSystem(value: boolean);
  37003. get useRightHandedSystem(): boolean;
  37004. private _timeAccumulator;
  37005. private _currentStepId;
  37006. private _currentInternalStep;
  37007. /**
  37008. * Sets the step Id used by deterministic lock step
  37009. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37010. * @param newStepId defines the step Id
  37011. */
  37012. setStepId(newStepId: number): void;
  37013. /**
  37014. * Gets the step Id used by deterministic lock step
  37015. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37016. * @returns the step Id
  37017. */
  37018. getStepId(): number;
  37019. /**
  37020. * Gets the internal step used by deterministic lock step
  37021. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  37022. * @returns the internal step
  37023. */
  37024. getInternalStep(): number;
  37025. private _fogEnabled;
  37026. /**
  37027. * Gets or sets a boolean indicating if fog is enabled on this scene
  37028. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37029. * (Default is true)
  37030. */
  37031. set fogEnabled(value: boolean);
  37032. get fogEnabled(): boolean;
  37033. private _fogMode;
  37034. /**
  37035. * Gets or sets the fog mode to use
  37036. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37037. * | mode | value |
  37038. * | --- | --- |
  37039. * | FOGMODE_NONE | 0 |
  37040. * | FOGMODE_EXP | 1 |
  37041. * | FOGMODE_EXP2 | 2 |
  37042. * | FOGMODE_LINEAR | 3 |
  37043. */
  37044. set fogMode(value: number);
  37045. get fogMode(): number;
  37046. /**
  37047. * Gets or sets the fog color to use
  37048. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37049. * (Default is Color3(0.2, 0.2, 0.3))
  37050. */
  37051. fogColor: Color3;
  37052. /**
  37053. * Gets or sets the fog density to use
  37054. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37055. * (Default is 0.1)
  37056. */
  37057. fogDensity: number;
  37058. /**
  37059. * Gets or sets the fog start distance to use
  37060. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37061. * (Default is 0)
  37062. */
  37063. fogStart: number;
  37064. /**
  37065. * Gets or sets the fog end distance to use
  37066. * @see http://doc.babylonjs.com/babylon101/environment#fog
  37067. * (Default is 1000)
  37068. */
  37069. fogEnd: number;
  37070. private _shadowsEnabled;
  37071. /**
  37072. * Gets or sets a boolean indicating if shadows are enabled on this scene
  37073. */
  37074. set shadowsEnabled(value: boolean);
  37075. get shadowsEnabled(): boolean;
  37076. private _lightsEnabled;
  37077. /**
  37078. * Gets or sets a boolean indicating if lights are enabled on this scene
  37079. */
  37080. set lightsEnabled(value: boolean);
  37081. get lightsEnabled(): boolean;
  37082. /** All of the active cameras added to this scene. */
  37083. activeCameras: Camera[];
  37084. /** @hidden */
  37085. _activeCamera: Nullable<Camera>;
  37086. /** Gets or sets the current active camera */
  37087. get activeCamera(): Nullable<Camera>;
  37088. set activeCamera(value: Nullable<Camera>);
  37089. private _defaultMaterial;
  37090. /** The default material used on meshes when no material is affected */
  37091. get defaultMaterial(): Material;
  37092. /** The default material used on meshes when no material is affected */
  37093. set defaultMaterial(value: Material);
  37094. private _texturesEnabled;
  37095. /**
  37096. * Gets or sets a boolean indicating if textures are enabled on this scene
  37097. */
  37098. set texturesEnabled(value: boolean);
  37099. get texturesEnabled(): boolean;
  37100. /**
  37101. * Gets or sets a boolean indicating if particles are enabled on this scene
  37102. */
  37103. particlesEnabled: boolean;
  37104. /**
  37105. * Gets or sets a boolean indicating if sprites are enabled on this scene
  37106. */
  37107. spritesEnabled: boolean;
  37108. private _skeletonsEnabled;
  37109. /**
  37110. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  37111. */
  37112. set skeletonsEnabled(value: boolean);
  37113. get skeletonsEnabled(): boolean;
  37114. /**
  37115. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  37116. */
  37117. lensFlaresEnabled: boolean;
  37118. /**
  37119. * Gets or sets a boolean indicating if collisions are enabled on this scene
  37120. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37121. */
  37122. collisionsEnabled: boolean;
  37123. private _collisionCoordinator;
  37124. /** @hidden */
  37125. get collisionCoordinator(): ICollisionCoordinator;
  37126. /**
  37127. * Defines the gravity applied to this scene (used only for collisions)
  37128. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  37129. */
  37130. gravity: Vector3;
  37131. /**
  37132. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  37133. */
  37134. postProcessesEnabled: boolean;
  37135. /**
  37136. * The list of postprocesses added to the scene
  37137. */
  37138. postProcesses: PostProcess[];
  37139. /**
  37140. * Gets the current postprocess manager
  37141. */
  37142. postProcessManager: PostProcessManager;
  37143. /**
  37144. * Gets or sets a boolean indicating if render targets are enabled on this scene
  37145. */
  37146. renderTargetsEnabled: boolean;
  37147. /**
  37148. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  37149. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  37150. */
  37151. dumpNextRenderTargets: boolean;
  37152. /**
  37153. * The list of user defined render targets added to the scene
  37154. */
  37155. customRenderTargets: RenderTargetTexture[];
  37156. /**
  37157. * Defines if texture loading must be delayed
  37158. * If true, textures will only be loaded when they need to be rendered
  37159. */
  37160. useDelayedTextureLoading: boolean;
  37161. /**
  37162. * Gets the list of meshes imported to the scene through SceneLoader
  37163. */
  37164. importedMeshesFiles: String[];
  37165. /**
  37166. * Gets or sets a boolean indicating if probes are enabled on this scene
  37167. */
  37168. probesEnabled: boolean;
  37169. /**
  37170. * Gets or sets the current offline provider to use to store scene data
  37171. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  37172. */
  37173. offlineProvider: IOfflineProvider;
  37174. /**
  37175. * Gets or sets the action manager associated with the scene
  37176. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  37177. */
  37178. actionManager: AbstractActionManager;
  37179. private _meshesForIntersections;
  37180. /**
  37181. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  37182. */
  37183. proceduralTexturesEnabled: boolean;
  37184. private _engine;
  37185. private _totalVertices;
  37186. /** @hidden */
  37187. _activeIndices: PerfCounter;
  37188. /** @hidden */
  37189. _activeParticles: PerfCounter;
  37190. /** @hidden */
  37191. _activeBones: PerfCounter;
  37192. private _animationRatio;
  37193. /** @hidden */
  37194. _animationTimeLast: number;
  37195. /** @hidden */
  37196. _animationTime: number;
  37197. /**
  37198. * Gets or sets a general scale for animation speed
  37199. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  37200. */
  37201. animationTimeScale: number;
  37202. /** @hidden */
  37203. _cachedMaterial: Nullable<Material>;
  37204. /** @hidden */
  37205. _cachedEffect: Nullable<Effect>;
  37206. /** @hidden */
  37207. _cachedVisibility: Nullable<number>;
  37208. private _renderId;
  37209. private _frameId;
  37210. private _executeWhenReadyTimeoutId;
  37211. private _intermediateRendering;
  37212. private _viewUpdateFlag;
  37213. private _projectionUpdateFlag;
  37214. /** @hidden */
  37215. _toBeDisposed: Nullable<IDisposable>[];
  37216. private _activeRequests;
  37217. /** @hidden */
  37218. _pendingData: any[];
  37219. private _isDisposed;
  37220. /**
  37221. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  37222. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  37223. */
  37224. dispatchAllSubMeshesOfActiveMeshes: boolean;
  37225. private _activeMeshes;
  37226. private _processedMaterials;
  37227. private _renderTargets;
  37228. /** @hidden */
  37229. _activeParticleSystems: SmartArray<IParticleSystem>;
  37230. private _activeSkeletons;
  37231. private _softwareSkinnedMeshes;
  37232. private _renderingManager;
  37233. /** @hidden */
  37234. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  37235. private _transformMatrix;
  37236. private _sceneUbo;
  37237. /** @hidden */
  37238. _viewMatrix: Matrix;
  37239. private _projectionMatrix;
  37240. /** @hidden */
  37241. _forcedViewPosition: Nullable<Vector3>;
  37242. /** @hidden */
  37243. _frustumPlanes: Plane[];
  37244. /**
  37245. * Gets the list of frustum planes (built from the active camera)
  37246. */
  37247. get frustumPlanes(): Plane[];
  37248. /**
  37249. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  37250. * This is useful if there are more lights that the maximum simulteanous authorized
  37251. */
  37252. requireLightSorting: boolean;
  37253. /** @hidden */
  37254. readonly useMaterialMeshMap: boolean;
  37255. /** @hidden */
  37256. readonly useClonedMeshMap: boolean;
  37257. private _externalData;
  37258. private _uid;
  37259. /**
  37260. * @hidden
  37261. * Backing store of defined scene components.
  37262. */
  37263. _components: ISceneComponent[];
  37264. /**
  37265. * @hidden
  37266. * Backing store of defined scene components.
  37267. */
  37268. _serializableComponents: ISceneSerializableComponent[];
  37269. /**
  37270. * List of components to register on the next registration step.
  37271. */
  37272. private _transientComponents;
  37273. /**
  37274. * Registers the transient components if needed.
  37275. */
  37276. private _registerTransientComponents;
  37277. /**
  37278. * @hidden
  37279. * Add a component to the scene.
  37280. * Note that the ccomponent could be registered on th next frame if this is called after
  37281. * the register component stage.
  37282. * @param component Defines the component to add to the scene
  37283. */
  37284. _addComponent(component: ISceneComponent): void;
  37285. /**
  37286. * @hidden
  37287. * Gets a component from the scene.
  37288. * @param name defines the name of the component to retrieve
  37289. * @returns the component or null if not present
  37290. */
  37291. _getComponent(name: string): Nullable<ISceneComponent>;
  37292. /**
  37293. * @hidden
  37294. * Defines the actions happening before camera updates.
  37295. */
  37296. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  37297. /**
  37298. * @hidden
  37299. * Defines the actions happening before clear the canvas.
  37300. */
  37301. _beforeClearStage: Stage<SimpleStageAction>;
  37302. /**
  37303. * @hidden
  37304. * Defines the actions when collecting render targets for the frame.
  37305. */
  37306. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37307. /**
  37308. * @hidden
  37309. * Defines the actions happening for one camera in the frame.
  37310. */
  37311. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  37312. /**
  37313. * @hidden
  37314. * Defines the actions happening during the per mesh ready checks.
  37315. */
  37316. _isReadyForMeshStage: Stage<MeshStageAction>;
  37317. /**
  37318. * @hidden
  37319. * Defines the actions happening before evaluate active mesh checks.
  37320. */
  37321. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  37322. /**
  37323. * @hidden
  37324. * Defines the actions happening during the evaluate sub mesh checks.
  37325. */
  37326. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  37327. /**
  37328. * @hidden
  37329. * Defines the actions happening during the active mesh stage.
  37330. */
  37331. _activeMeshStage: Stage<ActiveMeshStageAction>;
  37332. /**
  37333. * @hidden
  37334. * Defines the actions happening during the per camera render target step.
  37335. */
  37336. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  37337. /**
  37338. * @hidden
  37339. * Defines the actions happening just before the active camera is drawing.
  37340. */
  37341. _beforeCameraDrawStage: Stage<CameraStageAction>;
  37342. /**
  37343. * @hidden
  37344. * Defines the actions happening just before a render target is drawing.
  37345. */
  37346. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37347. /**
  37348. * @hidden
  37349. * Defines the actions happening just before a rendering group is drawing.
  37350. */
  37351. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37352. /**
  37353. * @hidden
  37354. * Defines the actions happening just before a mesh is drawing.
  37355. */
  37356. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37357. /**
  37358. * @hidden
  37359. * Defines the actions happening just after a mesh has been drawn.
  37360. */
  37361. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  37362. /**
  37363. * @hidden
  37364. * Defines the actions happening just after a rendering group has been drawn.
  37365. */
  37366. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  37367. /**
  37368. * @hidden
  37369. * Defines the actions happening just after the active camera has been drawn.
  37370. */
  37371. _afterCameraDrawStage: Stage<CameraStageAction>;
  37372. /**
  37373. * @hidden
  37374. * Defines the actions happening just after a render target has been drawn.
  37375. */
  37376. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  37377. /**
  37378. * @hidden
  37379. * Defines the actions happening just after rendering all cameras and computing intersections.
  37380. */
  37381. _afterRenderStage: Stage<SimpleStageAction>;
  37382. /**
  37383. * @hidden
  37384. * Defines the actions happening when a pointer move event happens.
  37385. */
  37386. _pointerMoveStage: Stage<PointerMoveStageAction>;
  37387. /**
  37388. * @hidden
  37389. * Defines the actions happening when a pointer down event happens.
  37390. */
  37391. _pointerDownStage: Stage<PointerUpDownStageAction>;
  37392. /**
  37393. * @hidden
  37394. * Defines the actions happening when a pointer up event happens.
  37395. */
  37396. _pointerUpStage: Stage<PointerUpDownStageAction>;
  37397. /**
  37398. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  37399. */
  37400. private geometriesByUniqueId;
  37401. /**
  37402. * Creates a new Scene
  37403. * @param engine defines the engine to use to render this scene
  37404. * @param options defines the scene options
  37405. */
  37406. constructor(engine: Engine, options?: SceneOptions);
  37407. /**
  37408. * Gets a string idenfifying the name of the class
  37409. * @returns "Scene" string
  37410. */
  37411. getClassName(): string;
  37412. private _defaultMeshCandidates;
  37413. /**
  37414. * @hidden
  37415. */
  37416. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  37417. private _defaultSubMeshCandidates;
  37418. /**
  37419. * @hidden
  37420. */
  37421. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  37422. /**
  37423. * Sets the default candidate providers for the scene.
  37424. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  37425. * and getCollidingSubMeshCandidates to their default function
  37426. */
  37427. setDefaultCandidateProviders(): void;
  37428. /**
  37429. * Gets the mesh that is currently under the pointer
  37430. */
  37431. get meshUnderPointer(): Nullable<AbstractMesh>;
  37432. /**
  37433. * Gets or sets the current on-screen X position of the pointer
  37434. */
  37435. get pointerX(): number;
  37436. set pointerX(value: number);
  37437. /**
  37438. * Gets or sets the current on-screen Y position of the pointer
  37439. */
  37440. get pointerY(): number;
  37441. set pointerY(value: number);
  37442. /**
  37443. * Gets the cached material (ie. the latest rendered one)
  37444. * @returns the cached material
  37445. */
  37446. getCachedMaterial(): Nullable<Material>;
  37447. /**
  37448. * Gets the cached effect (ie. the latest rendered one)
  37449. * @returns the cached effect
  37450. */
  37451. getCachedEffect(): Nullable<Effect>;
  37452. /**
  37453. * Gets the cached visibility state (ie. the latest rendered one)
  37454. * @returns the cached visibility state
  37455. */
  37456. getCachedVisibility(): Nullable<number>;
  37457. /**
  37458. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  37459. * @param material defines the current material
  37460. * @param effect defines the current effect
  37461. * @param visibility defines the current visibility state
  37462. * @returns true if one parameter is not cached
  37463. */
  37464. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  37465. /**
  37466. * Gets the engine associated with the scene
  37467. * @returns an Engine
  37468. */
  37469. getEngine(): Engine;
  37470. /**
  37471. * Gets the total number of vertices rendered per frame
  37472. * @returns the total number of vertices rendered per frame
  37473. */
  37474. getTotalVertices(): number;
  37475. /**
  37476. * Gets the performance counter for total vertices
  37477. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37478. */
  37479. get totalVerticesPerfCounter(): PerfCounter;
  37480. /**
  37481. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  37482. * @returns the total number of active indices rendered per frame
  37483. */
  37484. getActiveIndices(): number;
  37485. /**
  37486. * Gets the performance counter for active indices
  37487. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37488. */
  37489. get totalActiveIndicesPerfCounter(): PerfCounter;
  37490. /**
  37491. * Gets the total number of active particles rendered per frame
  37492. * @returns the total number of active particles rendered per frame
  37493. */
  37494. getActiveParticles(): number;
  37495. /**
  37496. * Gets the performance counter for active particles
  37497. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37498. */
  37499. get activeParticlesPerfCounter(): PerfCounter;
  37500. /**
  37501. * Gets the total number of active bones rendered per frame
  37502. * @returns the total number of active bones rendered per frame
  37503. */
  37504. getActiveBones(): number;
  37505. /**
  37506. * Gets the performance counter for active bones
  37507. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  37508. */
  37509. get activeBonesPerfCounter(): PerfCounter;
  37510. /**
  37511. * Gets the array of active meshes
  37512. * @returns an array of AbstractMesh
  37513. */
  37514. getActiveMeshes(): SmartArray<AbstractMesh>;
  37515. /**
  37516. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  37517. * @returns a number
  37518. */
  37519. getAnimationRatio(): number;
  37520. /**
  37521. * Gets an unique Id for the current render phase
  37522. * @returns a number
  37523. */
  37524. getRenderId(): number;
  37525. /**
  37526. * Gets an unique Id for the current frame
  37527. * @returns a number
  37528. */
  37529. getFrameId(): number;
  37530. /** Call this function if you want to manually increment the render Id*/
  37531. incrementRenderId(): void;
  37532. private _createUbo;
  37533. /**
  37534. * Use this method to simulate a pointer move on a mesh
  37535. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37536. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37537. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37538. * @returns the current scene
  37539. */
  37540. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37541. /**
  37542. * Use this method to simulate a pointer down on a mesh
  37543. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37544. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37545. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37546. * @returns the current scene
  37547. */
  37548. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  37549. /**
  37550. * Use this method to simulate a pointer up on a mesh
  37551. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  37552. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  37553. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  37554. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  37555. * @returns the current scene
  37556. */
  37557. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  37558. /**
  37559. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  37560. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  37561. * @returns true if the pointer was captured
  37562. */
  37563. isPointerCaptured(pointerId?: number): boolean;
  37564. /**
  37565. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  37566. * @param attachUp defines if you want to attach events to pointerup
  37567. * @param attachDown defines if you want to attach events to pointerdown
  37568. * @param attachMove defines if you want to attach events to pointermove
  37569. */
  37570. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  37571. /** Detaches all event handlers*/
  37572. detachControl(): void;
  37573. /**
  37574. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  37575. * Delay loaded resources are not taking in account
  37576. * @return true if all required resources are ready
  37577. */
  37578. isReady(): boolean;
  37579. /** Resets all cached information relative to material (including effect and visibility) */
  37580. resetCachedMaterial(): void;
  37581. /**
  37582. * Registers a function to be called before every frame render
  37583. * @param func defines the function to register
  37584. */
  37585. registerBeforeRender(func: () => void): void;
  37586. /**
  37587. * Unregisters a function called before every frame render
  37588. * @param func defines the function to unregister
  37589. */
  37590. unregisterBeforeRender(func: () => void): void;
  37591. /**
  37592. * Registers a function to be called after every frame render
  37593. * @param func defines the function to register
  37594. */
  37595. registerAfterRender(func: () => void): void;
  37596. /**
  37597. * Unregisters a function called after every frame render
  37598. * @param func defines the function to unregister
  37599. */
  37600. unregisterAfterRender(func: () => void): void;
  37601. private _executeOnceBeforeRender;
  37602. /**
  37603. * The provided function will run before render once and will be disposed afterwards.
  37604. * A timeout delay can be provided so that the function will be executed in N ms.
  37605. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  37606. * @param func The function to be executed.
  37607. * @param timeout optional delay in ms
  37608. */
  37609. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  37610. /** @hidden */
  37611. _addPendingData(data: any): void;
  37612. /** @hidden */
  37613. _removePendingData(data: any): void;
  37614. /**
  37615. * Returns the number of items waiting to be loaded
  37616. * @returns the number of items waiting to be loaded
  37617. */
  37618. getWaitingItemsCount(): number;
  37619. /**
  37620. * Returns a boolean indicating if the scene is still loading data
  37621. */
  37622. get isLoading(): boolean;
  37623. /**
  37624. * Registers a function to be executed when the scene is ready
  37625. * @param {Function} func - the function to be executed
  37626. */
  37627. executeWhenReady(func: () => void): void;
  37628. /**
  37629. * Returns a promise that resolves when the scene is ready
  37630. * @returns A promise that resolves when the scene is ready
  37631. */
  37632. whenReadyAsync(): Promise<void>;
  37633. /** @hidden */
  37634. _checkIsReady(): void;
  37635. /**
  37636. * Gets all animatable attached to the scene
  37637. */
  37638. get animatables(): Animatable[];
  37639. /**
  37640. * Resets the last animation time frame.
  37641. * Useful to override when animations start running when loading a scene for the first time.
  37642. */
  37643. resetLastAnimationTimeFrame(): void;
  37644. /**
  37645. * Gets the current view matrix
  37646. * @returns a Matrix
  37647. */
  37648. getViewMatrix(): Matrix;
  37649. /**
  37650. * Gets the current projection matrix
  37651. * @returns a Matrix
  37652. */
  37653. getProjectionMatrix(): Matrix;
  37654. /**
  37655. * Gets the current transform matrix
  37656. * @returns a Matrix made of View * Projection
  37657. */
  37658. getTransformMatrix(): Matrix;
  37659. /**
  37660. * Sets the current transform matrix
  37661. * @param viewL defines the View matrix to use
  37662. * @param projectionL defines the Projection matrix to use
  37663. * @param viewR defines the right View matrix to use (if provided)
  37664. * @param projectionR defines the right Projection matrix to use (if provided)
  37665. */
  37666. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  37667. /**
  37668. * Gets the uniform buffer used to store scene data
  37669. * @returns a UniformBuffer
  37670. */
  37671. getSceneUniformBuffer(): UniformBuffer;
  37672. /**
  37673. * Gets an unique (relatively to the current scene) Id
  37674. * @returns an unique number for the scene
  37675. */
  37676. getUniqueId(): number;
  37677. /**
  37678. * Add a mesh to the list of scene's meshes
  37679. * @param newMesh defines the mesh to add
  37680. * @param recursive if all child meshes should also be added to the scene
  37681. */
  37682. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  37683. /**
  37684. * Remove a mesh for the list of scene's meshes
  37685. * @param toRemove defines the mesh to remove
  37686. * @param recursive if all child meshes should also be removed from the scene
  37687. * @returns the index where the mesh was in the mesh list
  37688. */
  37689. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  37690. /**
  37691. * Add a transform node to the list of scene's transform nodes
  37692. * @param newTransformNode defines the transform node to add
  37693. */
  37694. addTransformNode(newTransformNode: TransformNode): void;
  37695. /**
  37696. * Remove a transform node for the list of scene's transform nodes
  37697. * @param toRemove defines the transform node to remove
  37698. * @returns the index where the transform node was in the transform node list
  37699. */
  37700. removeTransformNode(toRemove: TransformNode): number;
  37701. /**
  37702. * Remove a skeleton for the list of scene's skeletons
  37703. * @param toRemove defines the skeleton to remove
  37704. * @returns the index where the skeleton was in the skeleton list
  37705. */
  37706. removeSkeleton(toRemove: Skeleton): number;
  37707. /**
  37708. * Remove a morph target for the list of scene's morph targets
  37709. * @param toRemove defines the morph target to remove
  37710. * @returns the index where the morph target was in the morph target list
  37711. */
  37712. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  37713. /**
  37714. * Remove a light for the list of scene's lights
  37715. * @param toRemove defines the light to remove
  37716. * @returns the index where the light was in the light list
  37717. */
  37718. removeLight(toRemove: Light): number;
  37719. /**
  37720. * Remove a camera for the list of scene's cameras
  37721. * @param toRemove defines the camera to remove
  37722. * @returns the index where the camera was in the camera list
  37723. */
  37724. removeCamera(toRemove: Camera): number;
  37725. /**
  37726. * Remove a particle system for the list of scene's particle systems
  37727. * @param toRemove defines the particle system to remove
  37728. * @returns the index where the particle system was in the particle system list
  37729. */
  37730. removeParticleSystem(toRemove: IParticleSystem): number;
  37731. /**
  37732. * Remove a animation for the list of scene's animations
  37733. * @param toRemove defines the animation to remove
  37734. * @returns the index where the animation was in the animation list
  37735. */
  37736. removeAnimation(toRemove: Animation): number;
  37737. /**
  37738. * Will stop the animation of the given target
  37739. * @param target - the target
  37740. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  37741. * @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)
  37742. */
  37743. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  37744. /**
  37745. * Removes the given animation group from this scene.
  37746. * @param toRemove The animation group to remove
  37747. * @returns The index of the removed animation group
  37748. */
  37749. removeAnimationGroup(toRemove: AnimationGroup): number;
  37750. /**
  37751. * Removes the given multi-material from this scene.
  37752. * @param toRemove The multi-material to remove
  37753. * @returns The index of the removed multi-material
  37754. */
  37755. removeMultiMaterial(toRemove: MultiMaterial): number;
  37756. /**
  37757. * Removes the given material from this scene.
  37758. * @param toRemove The material to remove
  37759. * @returns The index of the removed material
  37760. */
  37761. removeMaterial(toRemove: Material): number;
  37762. /**
  37763. * Removes the given action manager from this scene.
  37764. * @param toRemove The action manager to remove
  37765. * @returns The index of the removed action manager
  37766. */
  37767. removeActionManager(toRemove: AbstractActionManager): number;
  37768. /**
  37769. * Removes the given texture from this scene.
  37770. * @param toRemove The texture to remove
  37771. * @returns The index of the removed texture
  37772. */
  37773. removeTexture(toRemove: BaseTexture): number;
  37774. /**
  37775. * Adds the given light to this scene
  37776. * @param newLight The light to add
  37777. */
  37778. addLight(newLight: Light): void;
  37779. /**
  37780. * Sorts the list list based on light priorities
  37781. */
  37782. sortLightsByPriority(): void;
  37783. /**
  37784. * Adds the given camera to this scene
  37785. * @param newCamera The camera to add
  37786. */
  37787. addCamera(newCamera: Camera): void;
  37788. /**
  37789. * Adds the given skeleton to this scene
  37790. * @param newSkeleton The skeleton to add
  37791. */
  37792. addSkeleton(newSkeleton: Skeleton): void;
  37793. /**
  37794. * Adds the given particle system to this scene
  37795. * @param newParticleSystem The particle system to add
  37796. */
  37797. addParticleSystem(newParticleSystem: IParticleSystem): void;
  37798. /**
  37799. * Adds the given animation to this scene
  37800. * @param newAnimation The animation to add
  37801. */
  37802. addAnimation(newAnimation: Animation): void;
  37803. /**
  37804. * Adds the given animation group to this scene.
  37805. * @param newAnimationGroup The animation group to add
  37806. */
  37807. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  37808. /**
  37809. * Adds the given multi-material to this scene
  37810. * @param newMultiMaterial The multi-material to add
  37811. */
  37812. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  37813. /**
  37814. * Adds the given material to this scene
  37815. * @param newMaterial The material to add
  37816. */
  37817. addMaterial(newMaterial: Material): void;
  37818. /**
  37819. * Adds the given morph target to this scene
  37820. * @param newMorphTargetManager The morph target to add
  37821. */
  37822. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  37823. /**
  37824. * Adds the given geometry to this scene
  37825. * @param newGeometry The geometry to add
  37826. */
  37827. addGeometry(newGeometry: Geometry): void;
  37828. /**
  37829. * Adds the given action manager to this scene
  37830. * @param newActionManager The action manager to add
  37831. */
  37832. addActionManager(newActionManager: AbstractActionManager): void;
  37833. /**
  37834. * Adds the given texture to this scene.
  37835. * @param newTexture The texture to add
  37836. */
  37837. addTexture(newTexture: BaseTexture): void;
  37838. /**
  37839. * Switch active camera
  37840. * @param newCamera defines the new active camera
  37841. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  37842. */
  37843. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  37844. /**
  37845. * sets the active camera of the scene using its ID
  37846. * @param id defines the camera's ID
  37847. * @return the new active camera or null if none found.
  37848. */
  37849. setActiveCameraByID(id: string): Nullable<Camera>;
  37850. /**
  37851. * sets the active camera of the scene using its name
  37852. * @param name defines the camera's name
  37853. * @returns the new active camera or null if none found.
  37854. */
  37855. setActiveCameraByName(name: string): Nullable<Camera>;
  37856. /**
  37857. * get an animation group using its name
  37858. * @param name defines the material's name
  37859. * @return the animation group or null if none found.
  37860. */
  37861. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  37862. /**
  37863. * Get a material using its unique id
  37864. * @param uniqueId defines the material's unique id
  37865. * @return the material or null if none found.
  37866. */
  37867. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  37868. /**
  37869. * get a material using its id
  37870. * @param id defines the material's ID
  37871. * @return the material or null if none found.
  37872. */
  37873. getMaterialByID(id: string): Nullable<Material>;
  37874. /**
  37875. * Gets a the last added material using a given id
  37876. * @param id defines the material's ID
  37877. * @return the last material with the given id or null if none found.
  37878. */
  37879. getLastMaterialByID(id: string): Nullable<Material>;
  37880. /**
  37881. * Gets a material using its name
  37882. * @param name defines the material's name
  37883. * @return the material or null if none found.
  37884. */
  37885. getMaterialByName(name: string): Nullable<Material>;
  37886. /**
  37887. * Get a texture using its unique id
  37888. * @param uniqueId defines the texture's unique id
  37889. * @return the texture or null if none found.
  37890. */
  37891. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  37892. /**
  37893. * Gets a camera using its id
  37894. * @param id defines the id to look for
  37895. * @returns the camera or null if not found
  37896. */
  37897. getCameraByID(id: string): Nullable<Camera>;
  37898. /**
  37899. * Gets a camera using its unique id
  37900. * @param uniqueId defines the unique id to look for
  37901. * @returns the camera or null if not found
  37902. */
  37903. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  37904. /**
  37905. * Gets a camera using its name
  37906. * @param name defines the camera's name
  37907. * @return the camera or null if none found.
  37908. */
  37909. getCameraByName(name: string): Nullable<Camera>;
  37910. /**
  37911. * Gets a bone using its id
  37912. * @param id defines the bone's id
  37913. * @return the bone or null if not found
  37914. */
  37915. getBoneByID(id: string): Nullable<Bone>;
  37916. /**
  37917. * Gets a bone using its id
  37918. * @param name defines the bone's name
  37919. * @return the bone or null if not found
  37920. */
  37921. getBoneByName(name: string): Nullable<Bone>;
  37922. /**
  37923. * Gets a light node using its name
  37924. * @param name defines the the light's name
  37925. * @return the light or null if none found.
  37926. */
  37927. getLightByName(name: string): Nullable<Light>;
  37928. /**
  37929. * Gets a light node using its id
  37930. * @param id defines the light's id
  37931. * @return the light or null if none found.
  37932. */
  37933. getLightByID(id: string): Nullable<Light>;
  37934. /**
  37935. * Gets a light node using its scene-generated unique ID
  37936. * @param uniqueId defines the light's unique id
  37937. * @return the light or null if none found.
  37938. */
  37939. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  37940. /**
  37941. * Gets a particle system by id
  37942. * @param id defines the particle system id
  37943. * @return the corresponding system or null if none found
  37944. */
  37945. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  37946. /**
  37947. * Gets a geometry using its ID
  37948. * @param id defines the geometry's id
  37949. * @return the geometry or null if none found.
  37950. */
  37951. getGeometryByID(id: string): Nullable<Geometry>;
  37952. private _getGeometryByUniqueID;
  37953. /**
  37954. * Add a new geometry to this scene
  37955. * @param geometry defines the geometry to be added to the scene.
  37956. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  37957. * @return a boolean defining if the geometry was added or not
  37958. */
  37959. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  37960. /**
  37961. * Removes an existing geometry
  37962. * @param geometry defines the geometry to be removed from the scene
  37963. * @return a boolean defining if the geometry was removed or not
  37964. */
  37965. removeGeometry(geometry: Geometry): boolean;
  37966. /**
  37967. * Gets the list of geometries attached to the scene
  37968. * @returns an array of Geometry
  37969. */
  37970. getGeometries(): Geometry[];
  37971. /**
  37972. * Gets the first added mesh found of a given ID
  37973. * @param id defines the id to search for
  37974. * @return the mesh found or null if not found at all
  37975. */
  37976. getMeshByID(id: string): Nullable<AbstractMesh>;
  37977. /**
  37978. * Gets a list of meshes using their id
  37979. * @param id defines the id to search for
  37980. * @returns a list of meshes
  37981. */
  37982. getMeshesByID(id: string): Array<AbstractMesh>;
  37983. /**
  37984. * Gets the first added transform node found of a given ID
  37985. * @param id defines the id to search for
  37986. * @return the found transform node or null if not found at all.
  37987. */
  37988. getTransformNodeByID(id: string): Nullable<TransformNode>;
  37989. /**
  37990. * Gets a transform node with its auto-generated unique id
  37991. * @param uniqueId efines the unique id to search for
  37992. * @return the found transform node or null if not found at all.
  37993. */
  37994. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  37995. /**
  37996. * Gets a list of transform nodes using their id
  37997. * @param id defines the id to search for
  37998. * @returns a list of transform nodes
  37999. */
  38000. getTransformNodesByID(id: string): Array<TransformNode>;
  38001. /**
  38002. * Gets a mesh with its auto-generated unique id
  38003. * @param uniqueId defines the unique id to search for
  38004. * @return the found mesh or null if not found at all.
  38005. */
  38006. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  38007. /**
  38008. * Gets a the last added mesh using a given id
  38009. * @param id defines the id to search for
  38010. * @return the found mesh or null if not found at all.
  38011. */
  38012. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  38013. /**
  38014. * Gets a the last added node (Mesh, Camera, Light) using a given id
  38015. * @param id defines the id to search for
  38016. * @return the found node or null if not found at all
  38017. */
  38018. getLastEntryByID(id: string): Nullable<Node>;
  38019. /**
  38020. * Gets a node (Mesh, Camera, Light) using a given id
  38021. * @param id defines the id to search for
  38022. * @return the found node or null if not found at all
  38023. */
  38024. getNodeByID(id: string): Nullable<Node>;
  38025. /**
  38026. * Gets a node (Mesh, Camera, Light) using a given name
  38027. * @param name defines the name to search for
  38028. * @return the found node or null if not found at all.
  38029. */
  38030. getNodeByName(name: string): Nullable<Node>;
  38031. /**
  38032. * Gets a mesh using a given name
  38033. * @param name defines the name to search for
  38034. * @return the found mesh or null if not found at all.
  38035. */
  38036. getMeshByName(name: string): Nullable<AbstractMesh>;
  38037. /**
  38038. * Gets a transform node using a given name
  38039. * @param name defines the name to search for
  38040. * @return the found transform node or null if not found at all.
  38041. */
  38042. getTransformNodeByName(name: string): Nullable<TransformNode>;
  38043. /**
  38044. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  38045. * @param id defines the id to search for
  38046. * @return the found skeleton or null if not found at all.
  38047. */
  38048. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  38049. /**
  38050. * Gets a skeleton using a given auto generated unique id
  38051. * @param uniqueId defines the unique id to search for
  38052. * @return the found skeleton or null if not found at all.
  38053. */
  38054. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  38055. /**
  38056. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  38057. * @param id defines the id to search for
  38058. * @return the found skeleton or null if not found at all.
  38059. */
  38060. getSkeletonById(id: string): Nullable<Skeleton>;
  38061. /**
  38062. * Gets a skeleton using a given name
  38063. * @param name defines the name to search for
  38064. * @return the found skeleton or null if not found at all.
  38065. */
  38066. getSkeletonByName(name: string): Nullable<Skeleton>;
  38067. /**
  38068. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  38069. * @param id defines the id to search for
  38070. * @return the found morph target manager or null if not found at all.
  38071. */
  38072. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  38073. /**
  38074. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  38075. * @param id defines the id to search for
  38076. * @return the found morph target or null if not found at all.
  38077. */
  38078. getMorphTargetById(id: string): Nullable<MorphTarget>;
  38079. /**
  38080. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  38081. * @param name defines the name to search for
  38082. * @return the found morph target or null if not found at all.
  38083. */
  38084. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  38085. /**
  38086. * Gets a boolean indicating if the given mesh is active
  38087. * @param mesh defines the mesh to look for
  38088. * @returns true if the mesh is in the active list
  38089. */
  38090. isActiveMesh(mesh: AbstractMesh): boolean;
  38091. /**
  38092. * Return a unique id as a string which can serve as an identifier for the scene
  38093. */
  38094. get uid(): string;
  38095. /**
  38096. * Add an externaly attached data from its key.
  38097. * This method call will fail and return false, if such key already exists.
  38098. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  38099. * @param key the unique key that identifies the data
  38100. * @param data the data object to associate to the key for this Engine instance
  38101. * @return true if no such key were already present and the data was added successfully, false otherwise
  38102. */
  38103. addExternalData<T>(key: string, data: T): boolean;
  38104. /**
  38105. * Get an externaly attached data from its key
  38106. * @param key the unique key that identifies the data
  38107. * @return the associated data, if present (can be null), or undefined if not present
  38108. */
  38109. getExternalData<T>(key: string): Nullable<T>;
  38110. /**
  38111. * Get an externaly attached data from its key, create it using a factory if it's not already present
  38112. * @param key the unique key that identifies the data
  38113. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  38114. * @return the associated data, can be null if the factory returned null.
  38115. */
  38116. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  38117. /**
  38118. * Remove an externaly attached data from the Engine instance
  38119. * @param key the unique key that identifies the data
  38120. * @return true if the data was successfully removed, false if it doesn't exist
  38121. */
  38122. removeExternalData(key: string): boolean;
  38123. private _evaluateSubMesh;
  38124. /**
  38125. * Clear the processed materials smart array preventing retention point in material dispose.
  38126. */
  38127. freeProcessedMaterials(): void;
  38128. private _preventFreeActiveMeshesAndRenderingGroups;
  38129. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  38130. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  38131. * when disposing several meshes in a row or a hierarchy of meshes.
  38132. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  38133. */
  38134. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  38135. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  38136. /**
  38137. * Clear the active meshes smart array preventing retention point in mesh dispose.
  38138. */
  38139. freeActiveMeshes(): void;
  38140. /**
  38141. * Clear the info related to rendering groups preventing retention points during dispose.
  38142. */
  38143. freeRenderingGroups(): void;
  38144. /** @hidden */
  38145. _isInIntermediateRendering(): boolean;
  38146. /**
  38147. * Lambda returning the list of potentially active meshes.
  38148. */
  38149. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  38150. /**
  38151. * Lambda returning the list of potentially active sub meshes.
  38152. */
  38153. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  38154. /**
  38155. * Lambda returning the list of potentially intersecting sub meshes.
  38156. */
  38157. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  38158. /**
  38159. * Lambda returning the list of potentially colliding sub meshes.
  38160. */
  38161. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  38162. private _activeMeshesFrozen;
  38163. private _skipEvaluateActiveMeshesCompletely;
  38164. /**
  38165. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  38166. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  38167. * @returns the current scene
  38168. */
  38169. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  38170. /**
  38171. * Use this function to restart evaluating active meshes on every frame
  38172. * @returns the current scene
  38173. */
  38174. unfreezeActiveMeshes(): Scene;
  38175. private _evaluateActiveMeshes;
  38176. private _activeMesh;
  38177. /**
  38178. * Update the transform matrix to update from the current active camera
  38179. * @param force defines a boolean used to force the update even if cache is up to date
  38180. */
  38181. updateTransformMatrix(force?: boolean): void;
  38182. private _bindFrameBuffer;
  38183. /** @hidden */
  38184. _allowPostProcessClearColor: boolean;
  38185. /** @hidden */
  38186. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  38187. private _processSubCameras;
  38188. private _checkIntersections;
  38189. /** @hidden */
  38190. _advancePhysicsEngineStep(step: number): void;
  38191. /**
  38192. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  38193. */
  38194. getDeterministicFrameTime: () => number;
  38195. /** @hidden */
  38196. _animate(): void;
  38197. /** Execute all animations (for a frame) */
  38198. animate(): void;
  38199. /**
  38200. * Render the scene
  38201. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  38202. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  38203. */
  38204. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  38205. /**
  38206. * Freeze all materials
  38207. * A frozen material will not be updatable but should be faster to render
  38208. */
  38209. freezeMaterials(): void;
  38210. /**
  38211. * Unfreeze all materials
  38212. * A frozen material will not be updatable but should be faster to render
  38213. */
  38214. unfreezeMaterials(): void;
  38215. /**
  38216. * Releases all held ressources
  38217. */
  38218. dispose(): void;
  38219. /**
  38220. * Gets if the scene is already disposed
  38221. */
  38222. get isDisposed(): boolean;
  38223. /**
  38224. * Call this function to reduce memory footprint of the scene.
  38225. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  38226. */
  38227. clearCachedVertexData(): void;
  38228. /**
  38229. * This function will remove the local cached buffer data from texture.
  38230. * It will save memory but will prevent the texture from being rebuilt
  38231. */
  38232. cleanCachedTextureBuffer(): void;
  38233. /**
  38234. * Get the world extend vectors with an optional filter
  38235. *
  38236. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  38237. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  38238. */
  38239. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  38240. min: Vector3;
  38241. max: Vector3;
  38242. };
  38243. /**
  38244. * Creates a ray that can be used to pick in the scene
  38245. * @param x defines the x coordinate of the origin (on-screen)
  38246. * @param y defines the y coordinate of the origin (on-screen)
  38247. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38248. * @param camera defines the camera to use for the picking
  38249. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38250. * @returns a Ray
  38251. */
  38252. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  38253. /**
  38254. * Creates a ray that can be used to pick in the scene
  38255. * @param x defines the x coordinate of the origin (on-screen)
  38256. * @param y defines the y coordinate of the origin (on-screen)
  38257. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  38258. * @param result defines the ray where to store the picking ray
  38259. * @param camera defines the camera to use for the picking
  38260. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  38261. * @returns the current scene
  38262. */
  38263. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  38264. /**
  38265. * Creates a ray that can be used to pick in the scene
  38266. * @param x defines the x coordinate of the origin (on-screen)
  38267. * @param y defines the y coordinate of the origin (on-screen)
  38268. * @param camera defines the camera to use for the picking
  38269. * @returns a Ray
  38270. */
  38271. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  38272. /**
  38273. * Creates a ray that can be used to pick in the scene
  38274. * @param x defines the x coordinate of the origin (on-screen)
  38275. * @param y defines the y coordinate of the origin (on-screen)
  38276. * @param result defines the ray where to store the picking ray
  38277. * @param camera defines the camera to use for the picking
  38278. * @returns the current scene
  38279. */
  38280. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  38281. /** Launch a ray to try to pick a mesh in the scene
  38282. * @param x position on screen
  38283. * @param y position on screen
  38284. * @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
  38285. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  38286. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38287. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38288. * @returns a PickingInfo
  38289. */
  38290. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38291. /** Use the given ray to pick a mesh in the scene
  38292. * @param ray The ray to use to pick meshes
  38293. * @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
  38294. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  38295. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38296. * @returns a PickingInfo
  38297. */
  38298. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  38299. /**
  38300. * Launch a ray to try to pick a mesh in the scene
  38301. * @param x X position on screen
  38302. * @param y Y position on screen
  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 camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  38305. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38306. * @returns an array of PickingInfo
  38307. */
  38308. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38309. /**
  38310. * Launch a ray to try to pick a mesh in the scene
  38311. * @param ray Ray to use
  38312. * @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
  38313. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  38314. * @returns an array of PickingInfo
  38315. */
  38316. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  38317. /**
  38318. * Force the value of meshUnderPointer
  38319. * @param mesh defines the mesh to use
  38320. */
  38321. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  38322. /**
  38323. * Gets the mesh under the pointer
  38324. * @returns a Mesh or null if no mesh is under the pointer
  38325. */
  38326. getPointerOverMesh(): Nullable<AbstractMesh>;
  38327. /** @hidden */
  38328. _rebuildGeometries(): void;
  38329. /** @hidden */
  38330. _rebuildTextures(): void;
  38331. private _getByTags;
  38332. /**
  38333. * Get a list of meshes by tags
  38334. * @param tagsQuery defines the tags query to use
  38335. * @param forEach defines a predicate used to filter results
  38336. * @returns an array of Mesh
  38337. */
  38338. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  38339. /**
  38340. * Get a list of cameras by tags
  38341. * @param tagsQuery defines the tags query to use
  38342. * @param forEach defines a predicate used to filter results
  38343. * @returns an array of Camera
  38344. */
  38345. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  38346. /**
  38347. * Get a list of lights by tags
  38348. * @param tagsQuery defines the tags query to use
  38349. * @param forEach defines a predicate used to filter results
  38350. * @returns an array of Light
  38351. */
  38352. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  38353. /**
  38354. * Get a list of materials by tags
  38355. * @param tagsQuery defines the tags query to use
  38356. * @param forEach defines a predicate used to filter results
  38357. * @returns an array of Material
  38358. */
  38359. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  38360. /**
  38361. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  38362. * This allowed control for front to back rendering or reversly depending of the special needs.
  38363. *
  38364. * @param renderingGroupId The rendering group id corresponding to its index
  38365. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  38366. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  38367. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  38368. */
  38369. 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;
  38370. /**
  38371. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  38372. *
  38373. * @param renderingGroupId The rendering group id corresponding to its index
  38374. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  38375. * @param depth Automatically clears depth between groups if true and autoClear is true.
  38376. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  38377. */
  38378. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  38379. /**
  38380. * Gets the current auto clear configuration for one rendering group of the rendering
  38381. * manager.
  38382. * @param index the rendering group index to get the information for
  38383. * @returns The auto clear setup for the requested rendering group
  38384. */
  38385. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  38386. private _blockMaterialDirtyMechanism;
  38387. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  38388. get blockMaterialDirtyMechanism(): boolean;
  38389. set blockMaterialDirtyMechanism(value: boolean);
  38390. /**
  38391. * Will flag all materials as dirty to trigger new shader compilation
  38392. * @param flag defines the flag used to specify which material part must be marked as dirty
  38393. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  38394. */
  38395. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  38396. /** @hidden */
  38397. _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;
  38398. /** @hidden */
  38399. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38400. /** @hidden */
  38401. _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;
  38402. /** @hidden */
  38403. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  38404. /** @hidden */
  38405. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  38406. /** @hidden */
  38407. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  38408. }
  38409. }
  38410. declare module "babylonjs/assetContainer" {
  38411. import { AbstractScene } from "babylonjs/abstractScene";
  38412. import { Scene } from "babylonjs/scene";
  38413. import { Mesh } from "babylonjs/Meshes/mesh";
  38414. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38415. import { Skeleton } from "babylonjs/Bones/skeleton";
  38416. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38417. import { Animatable } from "babylonjs/Animations/animatable";
  38418. import { Nullable } from "babylonjs/types";
  38419. import { Node } from "babylonjs/node";
  38420. /**
  38421. * Set of assets to keep when moving a scene into an asset container.
  38422. */
  38423. export class KeepAssets extends AbstractScene {
  38424. }
  38425. /**
  38426. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  38427. */
  38428. export class InstantiatedEntries {
  38429. /**
  38430. * List of new root nodes (eg. nodes with no parent)
  38431. */
  38432. rootNodes: TransformNode[];
  38433. /**
  38434. * List of new skeletons
  38435. */
  38436. skeletons: Skeleton[];
  38437. /**
  38438. * List of new animation groups
  38439. */
  38440. animationGroups: AnimationGroup[];
  38441. }
  38442. /**
  38443. * Container with a set of assets that can be added or removed from a scene.
  38444. */
  38445. export class AssetContainer extends AbstractScene {
  38446. private _wasAddedToScene;
  38447. /**
  38448. * The scene the AssetContainer belongs to.
  38449. */
  38450. scene: Scene;
  38451. /**
  38452. * Instantiates an AssetContainer.
  38453. * @param scene The scene the AssetContainer belongs to.
  38454. */
  38455. constructor(scene: Scene);
  38456. /**
  38457. * Instantiate or clone all meshes and add the new ones to the scene.
  38458. * Skeletons and animation groups will all be cloned
  38459. * @param nameFunction defines an optional function used to get new names for clones
  38460. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  38461. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  38462. */
  38463. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  38464. /**
  38465. * Adds all the assets from the container to the scene.
  38466. */
  38467. addAllToScene(): void;
  38468. /**
  38469. * Removes all the assets in the container from the scene
  38470. */
  38471. removeAllFromScene(): void;
  38472. /**
  38473. * Disposes all the assets in the container
  38474. */
  38475. dispose(): void;
  38476. private _moveAssets;
  38477. /**
  38478. * Removes all the assets contained in the scene and adds them to the container.
  38479. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  38480. */
  38481. moveAllFromScene(keepAssets?: KeepAssets): void;
  38482. /**
  38483. * 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.
  38484. * @returns the root mesh
  38485. */
  38486. createRootMesh(): Mesh;
  38487. /**
  38488. * Merge animations from this asset container into a scene
  38489. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  38490. * @param animatables set of animatables to retarget to a node from the scene
  38491. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  38492. */
  38493. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  38494. }
  38495. }
  38496. declare module "babylonjs/abstractScene" {
  38497. import { Scene } from "babylonjs/scene";
  38498. import { Nullable } from "babylonjs/types";
  38499. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  38500. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38501. import { Geometry } from "babylonjs/Meshes/geometry";
  38502. import { Skeleton } from "babylonjs/Bones/skeleton";
  38503. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  38504. import { AssetContainer } from "babylonjs/assetContainer";
  38505. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  38506. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  38507. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  38508. import { Material } from "babylonjs/Materials/material";
  38509. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  38510. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  38511. import { Camera } from "babylonjs/Cameras/camera";
  38512. import { Light } from "babylonjs/Lights/light";
  38513. import { Node } from "babylonjs/node";
  38514. import { Animation } from "babylonjs/Animations/animation";
  38515. /**
  38516. * Defines how the parser contract is defined.
  38517. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  38518. */
  38519. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  38520. /**
  38521. * Defines how the individual parser contract is defined.
  38522. * These parser can parse an individual asset
  38523. */
  38524. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  38525. /**
  38526. * Base class of the scene acting as a container for the different elements composing a scene.
  38527. * This class is dynamically extended by the different components of the scene increasing
  38528. * flexibility and reducing coupling
  38529. */
  38530. export abstract class AbstractScene {
  38531. /**
  38532. * Stores the list of available parsers in the application.
  38533. */
  38534. private static _BabylonFileParsers;
  38535. /**
  38536. * Stores the list of available individual parsers in the application.
  38537. */
  38538. private static _IndividualBabylonFileParsers;
  38539. /**
  38540. * Adds a parser in the list of available ones
  38541. * @param name Defines the name of the parser
  38542. * @param parser Defines the parser to add
  38543. */
  38544. static AddParser(name: string, parser: BabylonFileParser): void;
  38545. /**
  38546. * Gets a general parser from the list of avaialble ones
  38547. * @param name Defines the name of the parser
  38548. * @returns the requested parser or null
  38549. */
  38550. static GetParser(name: string): Nullable<BabylonFileParser>;
  38551. /**
  38552. * Adds n individual parser in the list of available ones
  38553. * @param name Defines the name of the parser
  38554. * @param parser Defines the parser to add
  38555. */
  38556. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  38557. /**
  38558. * Gets an individual parser from the list of avaialble ones
  38559. * @param name Defines the name of the parser
  38560. * @returns the requested parser or null
  38561. */
  38562. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  38563. /**
  38564. * Parser json data and populate both a scene and its associated container object
  38565. * @param jsonData Defines the data to parse
  38566. * @param scene Defines the scene to parse the data for
  38567. * @param container Defines the container attached to the parsing sequence
  38568. * @param rootUrl Defines the root url of the data
  38569. */
  38570. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  38571. /**
  38572. * Gets the list of root nodes (ie. nodes with no parent)
  38573. */
  38574. rootNodes: Node[];
  38575. /** All of the cameras added to this scene
  38576. * @see http://doc.babylonjs.com/babylon101/cameras
  38577. */
  38578. cameras: Camera[];
  38579. /**
  38580. * All of the lights added to this scene
  38581. * @see http://doc.babylonjs.com/babylon101/lights
  38582. */
  38583. lights: Light[];
  38584. /**
  38585. * All of the (abstract) meshes added to this scene
  38586. */
  38587. meshes: AbstractMesh[];
  38588. /**
  38589. * The list of skeletons added to the scene
  38590. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  38591. */
  38592. skeletons: Skeleton[];
  38593. /**
  38594. * All of the particle systems added to this scene
  38595. * @see http://doc.babylonjs.com/babylon101/particles
  38596. */
  38597. particleSystems: IParticleSystem[];
  38598. /**
  38599. * Gets a list of Animations associated with the scene
  38600. */
  38601. animations: Animation[];
  38602. /**
  38603. * All of the animation groups added to this scene
  38604. * @see http://doc.babylonjs.com/how_to/group
  38605. */
  38606. animationGroups: AnimationGroup[];
  38607. /**
  38608. * All of the multi-materials added to this scene
  38609. * @see http://doc.babylonjs.com/how_to/multi_materials
  38610. */
  38611. multiMaterials: MultiMaterial[];
  38612. /**
  38613. * All of the materials added to this scene
  38614. * In the context of a Scene, it is not supposed to be modified manually.
  38615. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  38616. * Note also that the order of the Material within the array is not significant and might change.
  38617. * @see http://doc.babylonjs.com/babylon101/materials
  38618. */
  38619. materials: Material[];
  38620. /**
  38621. * The list of morph target managers added to the scene
  38622. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  38623. */
  38624. morphTargetManagers: MorphTargetManager[];
  38625. /**
  38626. * The list of geometries used in the scene.
  38627. */
  38628. geometries: Geometry[];
  38629. /**
  38630. * All of the tranform nodes added to this scene
  38631. * In the context of a Scene, it is not supposed to be modified manually.
  38632. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  38633. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  38634. * @see http://doc.babylonjs.com/how_to/transformnode
  38635. */
  38636. transformNodes: TransformNode[];
  38637. /**
  38638. * ActionManagers available on the scene.
  38639. */
  38640. actionManagers: AbstractActionManager[];
  38641. /**
  38642. * Textures to keep.
  38643. */
  38644. textures: BaseTexture[];
  38645. /**
  38646. * Environment texture for the scene
  38647. */
  38648. environmentTexture: Nullable<BaseTexture>;
  38649. /**
  38650. * @returns all meshes, lights, cameras, transformNodes and bones
  38651. */
  38652. getNodes(): Array<Node>;
  38653. }
  38654. }
  38655. declare module "babylonjs/Audio/sound" {
  38656. import { Observable } from "babylonjs/Misc/observable";
  38657. import { Vector3 } from "babylonjs/Maths/math.vector";
  38658. import { Nullable } from "babylonjs/types";
  38659. import { Scene } from "babylonjs/scene";
  38660. import { TransformNode } from "babylonjs/Meshes/transformNode";
  38661. /**
  38662. * Interface used to define options for Sound class
  38663. */
  38664. export interface ISoundOptions {
  38665. /**
  38666. * Does the sound autoplay once loaded.
  38667. */
  38668. autoplay?: boolean;
  38669. /**
  38670. * Does the sound loop after it finishes playing once.
  38671. */
  38672. loop?: boolean;
  38673. /**
  38674. * Sound's volume
  38675. */
  38676. volume?: number;
  38677. /**
  38678. * Is it a spatial sound?
  38679. */
  38680. spatialSound?: boolean;
  38681. /**
  38682. * Maximum distance to hear that sound
  38683. */
  38684. maxDistance?: number;
  38685. /**
  38686. * Uses user defined attenuation function
  38687. */
  38688. useCustomAttenuation?: boolean;
  38689. /**
  38690. * Define the roll off factor of spatial sounds.
  38691. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38692. */
  38693. rolloffFactor?: number;
  38694. /**
  38695. * Define the reference distance the sound should be heard perfectly.
  38696. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38697. */
  38698. refDistance?: number;
  38699. /**
  38700. * Define the distance attenuation model the sound will follow.
  38701. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38702. */
  38703. distanceModel?: string;
  38704. /**
  38705. * Defines the playback speed (1 by default)
  38706. */
  38707. playbackRate?: number;
  38708. /**
  38709. * Defines if the sound is from a streaming source
  38710. */
  38711. streaming?: boolean;
  38712. /**
  38713. * Defines an optional length (in seconds) inside the sound file
  38714. */
  38715. length?: number;
  38716. /**
  38717. * Defines an optional offset (in seconds) inside the sound file
  38718. */
  38719. offset?: number;
  38720. /**
  38721. * If true, URLs will not be required to state the audio file codec to use.
  38722. */
  38723. skipCodecCheck?: boolean;
  38724. }
  38725. /**
  38726. * Defines a sound that can be played in the application.
  38727. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  38728. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  38729. */
  38730. export class Sound {
  38731. /**
  38732. * The name of the sound in the scene.
  38733. */
  38734. name: string;
  38735. /**
  38736. * Does the sound autoplay once loaded.
  38737. */
  38738. autoplay: boolean;
  38739. /**
  38740. * Does the sound loop after it finishes playing once.
  38741. */
  38742. loop: boolean;
  38743. /**
  38744. * Does the sound use a custom attenuation curve to simulate the falloff
  38745. * happening when the source gets further away from the camera.
  38746. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38747. */
  38748. useCustomAttenuation: boolean;
  38749. /**
  38750. * The sound track id this sound belongs to.
  38751. */
  38752. soundTrackId: number;
  38753. /**
  38754. * Is this sound currently played.
  38755. */
  38756. isPlaying: boolean;
  38757. /**
  38758. * Is this sound currently paused.
  38759. */
  38760. isPaused: boolean;
  38761. /**
  38762. * Does this sound enables spatial sound.
  38763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38764. */
  38765. spatialSound: boolean;
  38766. /**
  38767. * Define the reference distance the sound should be heard perfectly.
  38768. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38769. */
  38770. refDistance: number;
  38771. /**
  38772. * Define the roll off factor of spatial sounds.
  38773. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38774. */
  38775. rolloffFactor: number;
  38776. /**
  38777. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  38778. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38779. */
  38780. maxDistance: number;
  38781. /**
  38782. * Define the distance attenuation model the sound will follow.
  38783. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38784. */
  38785. distanceModel: string;
  38786. /**
  38787. * @hidden
  38788. * Back Compat
  38789. **/
  38790. onended: () => any;
  38791. /**
  38792. * Observable event when the current playing sound finishes.
  38793. */
  38794. onEndedObservable: Observable<Sound>;
  38795. private _panningModel;
  38796. private _playbackRate;
  38797. private _streaming;
  38798. private _startTime;
  38799. private _startOffset;
  38800. private _position;
  38801. /** @hidden */
  38802. _positionInEmitterSpace: boolean;
  38803. private _localDirection;
  38804. private _volume;
  38805. private _isReadyToPlay;
  38806. private _isDirectional;
  38807. private _readyToPlayCallback;
  38808. private _audioBuffer;
  38809. private _soundSource;
  38810. private _streamingSource;
  38811. private _soundPanner;
  38812. private _soundGain;
  38813. private _inputAudioNode;
  38814. private _outputAudioNode;
  38815. private _coneInnerAngle;
  38816. private _coneOuterAngle;
  38817. private _coneOuterGain;
  38818. private _scene;
  38819. private _connectedTransformNode;
  38820. private _customAttenuationFunction;
  38821. private _registerFunc;
  38822. private _isOutputConnected;
  38823. private _htmlAudioElement;
  38824. private _urlType;
  38825. private _length?;
  38826. private _offset?;
  38827. /** @hidden */
  38828. static _SceneComponentInitialization: (scene: Scene) => void;
  38829. /**
  38830. * Create a sound and attach it to a scene
  38831. * @param name Name of your sound
  38832. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  38833. * @param scene defines the scene the sound belongs to
  38834. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  38835. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  38836. */
  38837. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  38838. /**
  38839. * Release the sound and its associated resources
  38840. */
  38841. dispose(): void;
  38842. /**
  38843. * Gets if the sounds is ready to be played or not.
  38844. * @returns true if ready, otherwise false
  38845. */
  38846. isReady(): boolean;
  38847. private _soundLoaded;
  38848. /**
  38849. * Sets the data of the sound from an audiobuffer
  38850. * @param audioBuffer The audioBuffer containing the data
  38851. */
  38852. setAudioBuffer(audioBuffer: AudioBuffer): void;
  38853. /**
  38854. * Updates the current sounds options such as maxdistance, loop...
  38855. * @param options A JSON object containing values named as the object properties
  38856. */
  38857. updateOptions(options: ISoundOptions): void;
  38858. private _createSpatialParameters;
  38859. private _updateSpatialParameters;
  38860. /**
  38861. * Switch the panning model to HRTF:
  38862. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  38863. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38864. */
  38865. switchPanningModelToHRTF(): void;
  38866. /**
  38867. * Switch the panning model to Equal Power:
  38868. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  38869. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  38870. */
  38871. switchPanningModelToEqualPower(): void;
  38872. private _switchPanningModel;
  38873. /**
  38874. * Connect this sound to a sound track audio node like gain...
  38875. * @param soundTrackAudioNode the sound track audio node to connect to
  38876. */
  38877. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  38878. /**
  38879. * Transform this sound into a directional source
  38880. * @param coneInnerAngle Size of the inner cone in degree
  38881. * @param coneOuterAngle Size of the outer cone in degree
  38882. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  38883. */
  38884. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  38885. /**
  38886. * Gets or sets the inner angle for the directional cone.
  38887. */
  38888. get directionalConeInnerAngle(): number;
  38889. /**
  38890. * Gets or sets the inner angle for the directional cone.
  38891. */
  38892. set directionalConeInnerAngle(value: number);
  38893. /**
  38894. * Gets or sets the outer angle for the directional cone.
  38895. */
  38896. get directionalConeOuterAngle(): number;
  38897. /**
  38898. * Gets or sets the outer angle for the directional cone.
  38899. */
  38900. set directionalConeOuterAngle(value: number);
  38901. /**
  38902. * Sets the position of the emitter if spatial sound is enabled
  38903. * @param newPosition Defines the new posisiton
  38904. */
  38905. setPosition(newPosition: Vector3): void;
  38906. /**
  38907. * Sets the local direction of the emitter if spatial sound is enabled
  38908. * @param newLocalDirection Defines the new local direction
  38909. */
  38910. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  38911. private _updateDirection;
  38912. /** @hidden */
  38913. updateDistanceFromListener(): void;
  38914. /**
  38915. * Sets a new custom attenuation function for the sound.
  38916. * @param callback Defines the function used for the attenuation
  38917. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  38918. */
  38919. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  38920. /**
  38921. * Play the sound
  38922. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  38923. * @param offset (optional) Start the sound at a specific time in seconds
  38924. * @param length (optional) Sound duration (in seconds)
  38925. */
  38926. play(time?: number, offset?: number, length?: number): void;
  38927. private _onended;
  38928. /**
  38929. * Stop the sound
  38930. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  38931. */
  38932. stop(time?: number): void;
  38933. /**
  38934. * Put the sound in pause
  38935. */
  38936. pause(): void;
  38937. /**
  38938. * Sets a dedicated volume for this sounds
  38939. * @param newVolume Define the new volume of the sound
  38940. * @param time Define time for gradual change to new volume
  38941. */
  38942. setVolume(newVolume: number, time?: number): void;
  38943. /**
  38944. * Set the sound play back rate
  38945. * @param newPlaybackRate Define the playback rate the sound should be played at
  38946. */
  38947. setPlaybackRate(newPlaybackRate: number): void;
  38948. /**
  38949. * Gets the volume of the sound.
  38950. * @returns the volume of the sound
  38951. */
  38952. getVolume(): number;
  38953. /**
  38954. * Attach the sound to a dedicated mesh
  38955. * @param transformNode The transform node to connect the sound with
  38956. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38957. */
  38958. attachToMesh(transformNode: TransformNode): void;
  38959. /**
  38960. * Detach the sound from the previously attached mesh
  38961. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  38962. */
  38963. detachFromMesh(): void;
  38964. private _onRegisterAfterWorldMatrixUpdate;
  38965. /**
  38966. * Clone the current sound in the scene.
  38967. * @returns the new sound clone
  38968. */
  38969. clone(): Nullable<Sound>;
  38970. /**
  38971. * Gets the current underlying audio buffer containing the data
  38972. * @returns the audio buffer
  38973. */
  38974. getAudioBuffer(): Nullable<AudioBuffer>;
  38975. /**
  38976. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  38977. * @returns the source node
  38978. */
  38979. getSoundSource(): Nullable<AudioBufferSourceNode>;
  38980. /**
  38981. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  38982. * @returns the gain node
  38983. */
  38984. getSoundGain(): Nullable<GainNode>;
  38985. /**
  38986. * Serializes the Sound in a JSON representation
  38987. * @returns the JSON representation of the sound
  38988. */
  38989. serialize(): any;
  38990. /**
  38991. * Parse a JSON representation of a sound to innstantiate in a given scene
  38992. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  38993. * @param scene Define the scene the new parsed sound should be created in
  38994. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  38995. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  38996. * @returns the newly parsed sound
  38997. */
  38998. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  38999. }
  39000. }
  39001. declare module "babylonjs/Actions/directAudioActions" {
  39002. import { Action } from "babylonjs/Actions/action";
  39003. import { Condition } from "babylonjs/Actions/condition";
  39004. import { Sound } from "babylonjs/Audio/sound";
  39005. /**
  39006. * This defines an action helpful to play a defined sound on a triggered action.
  39007. */
  39008. export class PlaySoundAction extends Action {
  39009. private _sound;
  39010. /**
  39011. * Instantiate the action
  39012. * @param triggerOptions defines the trigger options
  39013. * @param sound defines the sound to play
  39014. * @param condition defines the trigger related conditions
  39015. */
  39016. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39017. /** @hidden */
  39018. _prepare(): void;
  39019. /**
  39020. * Execute the action and play the sound.
  39021. */
  39022. execute(): void;
  39023. /**
  39024. * Serializes the actions and its related information.
  39025. * @param parent defines the object to serialize in
  39026. * @returns the serialized object
  39027. */
  39028. serialize(parent: any): any;
  39029. }
  39030. /**
  39031. * This defines an action helpful to stop a defined sound on a triggered action.
  39032. */
  39033. export class StopSoundAction extends Action {
  39034. private _sound;
  39035. /**
  39036. * Instantiate the action
  39037. * @param triggerOptions defines the trigger options
  39038. * @param sound defines the sound to stop
  39039. * @param condition defines the trigger related conditions
  39040. */
  39041. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  39042. /** @hidden */
  39043. _prepare(): void;
  39044. /**
  39045. * Execute the action and stop the sound.
  39046. */
  39047. execute(): void;
  39048. /**
  39049. * Serializes the actions and its related information.
  39050. * @param parent defines the object to serialize in
  39051. * @returns the serialized object
  39052. */
  39053. serialize(parent: any): any;
  39054. }
  39055. }
  39056. declare module "babylonjs/Actions/interpolateValueAction" {
  39057. import { Action } from "babylonjs/Actions/action";
  39058. import { Condition } from "babylonjs/Actions/condition";
  39059. import { Observable } from "babylonjs/Misc/observable";
  39060. /**
  39061. * This defines an action responsible to change the value of a property
  39062. * by interpolating between its current value and the newly set one once triggered.
  39063. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  39064. */
  39065. export class InterpolateValueAction extends Action {
  39066. /**
  39067. * Defines the path of the property where the value should be interpolated
  39068. */
  39069. propertyPath: string;
  39070. /**
  39071. * Defines the target value at the end of the interpolation.
  39072. */
  39073. value: any;
  39074. /**
  39075. * Defines the time it will take for the property to interpolate to the value.
  39076. */
  39077. duration: number;
  39078. /**
  39079. * Defines if the other scene animations should be stopped when the action has been triggered
  39080. */
  39081. stopOtherAnimations?: boolean;
  39082. /**
  39083. * Defines a callback raised once the interpolation animation has been done.
  39084. */
  39085. onInterpolationDone?: () => void;
  39086. /**
  39087. * Observable triggered once the interpolation animation has been done.
  39088. */
  39089. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  39090. private _target;
  39091. private _effectiveTarget;
  39092. private _property;
  39093. /**
  39094. * Instantiate the action
  39095. * @param triggerOptions defines the trigger options
  39096. * @param target defines the object containing the value to interpolate
  39097. * @param propertyPath defines the path to the property in the target object
  39098. * @param value defines the target value at the end of the interpolation
  39099. * @param duration deines the time it will take for the property to interpolate to the value.
  39100. * @param condition defines the trigger related conditions
  39101. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  39102. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  39103. */
  39104. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  39105. /** @hidden */
  39106. _prepare(): void;
  39107. /**
  39108. * Execute the action starts the value interpolation.
  39109. */
  39110. execute(): void;
  39111. /**
  39112. * Serializes the actions and its related information.
  39113. * @param parent defines the object to serialize in
  39114. * @returns the serialized object
  39115. */
  39116. serialize(parent: any): any;
  39117. }
  39118. }
  39119. declare module "babylonjs/Actions/index" {
  39120. export * from "babylonjs/Actions/abstractActionManager";
  39121. export * from "babylonjs/Actions/action";
  39122. export * from "babylonjs/Actions/actionEvent";
  39123. export * from "babylonjs/Actions/actionManager";
  39124. export * from "babylonjs/Actions/condition";
  39125. export * from "babylonjs/Actions/directActions";
  39126. export * from "babylonjs/Actions/directAudioActions";
  39127. export * from "babylonjs/Actions/interpolateValueAction";
  39128. }
  39129. declare module "babylonjs/Animations/index" {
  39130. export * from "babylonjs/Animations/animatable";
  39131. export * from "babylonjs/Animations/animation";
  39132. export * from "babylonjs/Animations/animationGroup";
  39133. export * from "babylonjs/Animations/animationPropertiesOverride";
  39134. export * from "babylonjs/Animations/easing";
  39135. export * from "babylonjs/Animations/runtimeAnimation";
  39136. export * from "babylonjs/Animations/animationEvent";
  39137. export * from "babylonjs/Animations/animationGroup";
  39138. export * from "babylonjs/Animations/animationKey";
  39139. export * from "babylonjs/Animations/animationRange";
  39140. export * from "babylonjs/Animations/animatable.interface";
  39141. }
  39142. declare module "babylonjs/Audio/soundTrack" {
  39143. import { Sound } from "babylonjs/Audio/sound";
  39144. import { Analyser } from "babylonjs/Audio/analyser";
  39145. import { Scene } from "babylonjs/scene";
  39146. /**
  39147. * Options allowed during the creation of a sound track.
  39148. */
  39149. export interface ISoundTrackOptions {
  39150. /**
  39151. * The volume the sound track should take during creation
  39152. */
  39153. volume?: number;
  39154. /**
  39155. * Define if the sound track is the main sound track of the scene
  39156. */
  39157. mainTrack?: boolean;
  39158. }
  39159. /**
  39160. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  39161. * It will be also used in a future release to apply effects on a specific track.
  39162. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39163. */
  39164. export class SoundTrack {
  39165. /**
  39166. * The unique identifier of the sound track in the scene.
  39167. */
  39168. id: number;
  39169. /**
  39170. * The list of sounds included in the sound track.
  39171. */
  39172. soundCollection: Array<Sound>;
  39173. private _outputAudioNode;
  39174. private _scene;
  39175. private _connectedAnalyser;
  39176. private _options;
  39177. private _isInitialized;
  39178. /**
  39179. * Creates a new sound track.
  39180. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  39181. * @param scene Define the scene the sound track belongs to
  39182. * @param options
  39183. */
  39184. constructor(scene: Scene, options?: ISoundTrackOptions);
  39185. private _initializeSoundTrackAudioGraph;
  39186. /**
  39187. * Release the sound track and its associated resources
  39188. */
  39189. dispose(): void;
  39190. /**
  39191. * Adds a sound to this sound track
  39192. * @param sound define the cound to add
  39193. * @ignoreNaming
  39194. */
  39195. AddSound(sound: Sound): void;
  39196. /**
  39197. * Removes a sound to this sound track
  39198. * @param sound define the cound to remove
  39199. * @ignoreNaming
  39200. */
  39201. RemoveSound(sound: Sound): void;
  39202. /**
  39203. * Set a global volume for the full sound track.
  39204. * @param newVolume Define the new volume of the sound track
  39205. */
  39206. setVolume(newVolume: number): void;
  39207. /**
  39208. * Switch the panning model to HRTF:
  39209. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  39210. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39211. */
  39212. switchPanningModelToHRTF(): void;
  39213. /**
  39214. * Switch the panning model to Equal Power:
  39215. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  39216. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  39217. */
  39218. switchPanningModelToEqualPower(): void;
  39219. /**
  39220. * Connect the sound track to an audio analyser allowing some amazing
  39221. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  39222. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  39223. * @param analyser The analyser to connect to the engine
  39224. */
  39225. connectToAnalyser(analyser: Analyser): void;
  39226. }
  39227. }
  39228. declare module "babylonjs/Audio/audioSceneComponent" {
  39229. import { Sound } from "babylonjs/Audio/sound";
  39230. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  39231. import { Nullable } from "babylonjs/types";
  39232. import { Vector3 } from "babylonjs/Maths/math.vector";
  39233. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  39234. import { Scene } from "babylonjs/scene";
  39235. import { AbstractScene } from "babylonjs/abstractScene";
  39236. import "babylonjs/Audio/audioEngine";
  39237. module "babylonjs/abstractScene" {
  39238. interface AbstractScene {
  39239. /**
  39240. * The list of sounds used in the scene.
  39241. */
  39242. sounds: Nullable<Array<Sound>>;
  39243. }
  39244. }
  39245. module "babylonjs/scene" {
  39246. interface Scene {
  39247. /**
  39248. * @hidden
  39249. * Backing field
  39250. */
  39251. _mainSoundTrack: SoundTrack;
  39252. /**
  39253. * The main sound track played by the scene.
  39254. * It cotains your primary collection of sounds.
  39255. */
  39256. mainSoundTrack: SoundTrack;
  39257. /**
  39258. * The list of sound tracks added to the scene
  39259. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39260. */
  39261. soundTracks: Nullable<Array<SoundTrack>>;
  39262. /**
  39263. * Gets a sound using a given name
  39264. * @param name defines the name to search for
  39265. * @return the found sound or null if not found at all.
  39266. */
  39267. getSoundByName(name: string): Nullable<Sound>;
  39268. /**
  39269. * Gets or sets if audio support is enabled
  39270. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39271. */
  39272. audioEnabled: boolean;
  39273. /**
  39274. * Gets or sets if audio will be output to headphones
  39275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39276. */
  39277. headphone: boolean;
  39278. /**
  39279. * Gets or sets custom audio listener position provider
  39280. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  39281. */
  39282. audioListenerPositionProvider: Nullable<() => Vector3>;
  39283. /**
  39284. * Gets or sets a refresh rate when using 3D audio positioning
  39285. */
  39286. audioPositioningRefreshRate: number;
  39287. }
  39288. }
  39289. /**
  39290. * Defines the sound scene component responsible to manage any sounds
  39291. * in a given scene.
  39292. */
  39293. export class AudioSceneComponent implements ISceneSerializableComponent {
  39294. /**
  39295. * The component name helpfull to identify the component in the list of scene components.
  39296. */
  39297. readonly name: string;
  39298. /**
  39299. * The scene the component belongs to.
  39300. */
  39301. scene: Scene;
  39302. private _audioEnabled;
  39303. /**
  39304. * Gets whether audio is enabled or not.
  39305. * Please use related enable/disable method to switch state.
  39306. */
  39307. get audioEnabled(): boolean;
  39308. private _headphone;
  39309. /**
  39310. * Gets whether audio is outputing to headphone or not.
  39311. * Please use the according Switch methods to change output.
  39312. */
  39313. get headphone(): boolean;
  39314. /**
  39315. * Gets or sets a refresh rate when using 3D audio positioning
  39316. */
  39317. audioPositioningRefreshRate: number;
  39318. private _audioListenerPositionProvider;
  39319. /**
  39320. * Gets the current audio listener position provider
  39321. */
  39322. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  39323. /**
  39324. * Sets a custom listener position for all sounds in the scene
  39325. * By default, this is the position of the first active camera
  39326. */
  39327. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  39328. /**
  39329. * Creates a new instance of the component for the given scene
  39330. * @param scene Defines the scene to register the component in
  39331. */
  39332. constructor(scene: Scene);
  39333. /**
  39334. * Registers the component in a given scene
  39335. */
  39336. register(): void;
  39337. /**
  39338. * Rebuilds the elements related to this component in case of
  39339. * context lost for instance.
  39340. */
  39341. rebuild(): void;
  39342. /**
  39343. * Serializes the component data to the specified json object
  39344. * @param serializationObject The object to serialize to
  39345. */
  39346. serialize(serializationObject: any): void;
  39347. /**
  39348. * Adds all the elements from the container to the scene
  39349. * @param container the container holding the elements
  39350. */
  39351. addFromContainer(container: AbstractScene): void;
  39352. /**
  39353. * Removes all the elements in the container from the scene
  39354. * @param container contains the elements to remove
  39355. * @param dispose if the removed element should be disposed (default: false)
  39356. */
  39357. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  39358. /**
  39359. * Disposes the component and the associated ressources.
  39360. */
  39361. dispose(): void;
  39362. /**
  39363. * Disables audio in the associated scene.
  39364. */
  39365. disableAudio(): void;
  39366. /**
  39367. * Enables audio in the associated scene.
  39368. */
  39369. enableAudio(): void;
  39370. /**
  39371. * Switch audio to headphone output.
  39372. */
  39373. switchAudioModeForHeadphones(): void;
  39374. /**
  39375. * Switch audio to normal speakers.
  39376. */
  39377. switchAudioModeForNormalSpeakers(): void;
  39378. private _cachedCameraDirection;
  39379. private _cachedCameraPosition;
  39380. private _lastCheck;
  39381. private _afterRender;
  39382. }
  39383. }
  39384. declare module "babylonjs/Audio/weightedsound" {
  39385. import { Sound } from "babylonjs/Audio/sound";
  39386. /**
  39387. * Wraps one or more Sound objects and selects one with random weight for playback.
  39388. */
  39389. export class WeightedSound {
  39390. /** When true a Sound will be selected and played when the current playing Sound completes. */
  39391. loop: boolean;
  39392. private _coneInnerAngle;
  39393. private _coneOuterAngle;
  39394. private _volume;
  39395. /** A Sound is currently playing. */
  39396. isPlaying: boolean;
  39397. /** A Sound is currently paused. */
  39398. isPaused: boolean;
  39399. private _sounds;
  39400. private _weights;
  39401. private _currentIndex?;
  39402. /**
  39403. * Creates a new WeightedSound from the list of sounds given.
  39404. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  39405. * @param sounds Array of Sounds that will be selected from.
  39406. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  39407. */
  39408. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  39409. /**
  39410. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  39411. */
  39412. get directionalConeInnerAngle(): number;
  39413. /**
  39414. * The size of cone in degress for a directional sound in which there will be no attenuation.
  39415. */
  39416. set directionalConeInnerAngle(value: number);
  39417. /**
  39418. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39419. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39420. */
  39421. get directionalConeOuterAngle(): number;
  39422. /**
  39423. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  39424. * Listener angles between innerAngle and outerAngle will falloff linearly.
  39425. */
  39426. set directionalConeOuterAngle(value: number);
  39427. /**
  39428. * Playback volume.
  39429. */
  39430. get volume(): number;
  39431. /**
  39432. * Playback volume.
  39433. */
  39434. set volume(value: number);
  39435. private _onended;
  39436. /**
  39437. * Suspend playback
  39438. */
  39439. pause(): void;
  39440. /**
  39441. * Stop playback
  39442. */
  39443. stop(): void;
  39444. /**
  39445. * Start playback.
  39446. * @param startOffset Position the clip head at a specific time in seconds.
  39447. */
  39448. play(startOffset?: number): void;
  39449. }
  39450. }
  39451. declare module "babylonjs/Audio/index" {
  39452. export * from "babylonjs/Audio/analyser";
  39453. export * from "babylonjs/Audio/audioEngine";
  39454. export * from "babylonjs/Audio/audioSceneComponent";
  39455. export * from "babylonjs/Audio/sound";
  39456. export * from "babylonjs/Audio/soundTrack";
  39457. export * from "babylonjs/Audio/weightedsound";
  39458. }
  39459. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  39460. import { Behavior } from "babylonjs/Behaviors/behavior";
  39461. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39462. import { BackEase } from "babylonjs/Animations/easing";
  39463. /**
  39464. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  39465. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  39466. */
  39467. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  39468. /**
  39469. * Gets the name of the behavior.
  39470. */
  39471. get name(): string;
  39472. /**
  39473. * The easing function used by animations
  39474. */
  39475. static EasingFunction: BackEase;
  39476. /**
  39477. * The easing mode used by animations
  39478. */
  39479. static EasingMode: number;
  39480. /**
  39481. * The duration of the animation, in milliseconds
  39482. */
  39483. transitionDuration: number;
  39484. /**
  39485. * Length of the distance animated by the transition when lower radius is reached
  39486. */
  39487. lowerRadiusTransitionRange: number;
  39488. /**
  39489. * Length of the distance animated by the transition when upper radius is reached
  39490. */
  39491. upperRadiusTransitionRange: number;
  39492. private _autoTransitionRange;
  39493. /**
  39494. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39495. */
  39496. get autoTransitionRange(): boolean;
  39497. /**
  39498. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  39499. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  39500. */
  39501. set autoTransitionRange(value: boolean);
  39502. private _attachedCamera;
  39503. private _onAfterCheckInputsObserver;
  39504. private _onMeshTargetChangedObserver;
  39505. /**
  39506. * Initializes the behavior.
  39507. */
  39508. init(): void;
  39509. /**
  39510. * Attaches the behavior to its arc rotate camera.
  39511. * @param camera Defines the camera to attach the behavior to
  39512. */
  39513. attach(camera: ArcRotateCamera): void;
  39514. /**
  39515. * Detaches the behavior from its current arc rotate camera.
  39516. */
  39517. detach(): void;
  39518. private _radiusIsAnimating;
  39519. private _radiusBounceTransition;
  39520. private _animatables;
  39521. private _cachedWheelPrecision;
  39522. /**
  39523. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  39524. * @param radiusLimit The limit to check against.
  39525. * @return Bool to indicate if at limit.
  39526. */
  39527. private _isRadiusAtLimit;
  39528. /**
  39529. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  39530. * @param radiusDelta The delta by which to animate to. Can be negative.
  39531. */
  39532. private _applyBoundRadiusAnimation;
  39533. /**
  39534. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  39535. */
  39536. protected _clearAnimationLocks(): void;
  39537. /**
  39538. * Stops and removes all animations that have been applied to the camera
  39539. */
  39540. stopAllAnimations(): void;
  39541. }
  39542. }
  39543. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  39544. import { Behavior } from "babylonjs/Behaviors/behavior";
  39545. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39546. import { ExponentialEase } from "babylonjs/Animations/easing";
  39547. import { Nullable } from "babylonjs/types";
  39548. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39549. import { Vector3 } from "babylonjs/Maths/math.vector";
  39550. /**
  39551. * 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.
  39552. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  39553. */
  39554. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  39555. /**
  39556. * Gets the name of the behavior.
  39557. */
  39558. get name(): string;
  39559. private _mode;
  39560. private _radiusScale;
  39561. private _positionScale;
  39562. private _defaultElevation;
  39563. private _elevationReturnTime;
  39564. private _elevationReturnWaitTime;
  39565. private _zoomStopsAnimation;
  39566. private _framingTime;
  39567. /**
  39568. * The easing function used by animations
  39569. */
  39570. static EasingFunction: ExponentialEase;
  39571. /**
  39572. * The easing mode used by animations
  39573. */
  39574. static EasingMode: number;
  39575. /**
  39576. * Sets the current mode used by the behavior
  39577. */
  39578. set mode(mode: number);
  39579. /**
  39580. * Gets current mode used by the behavior.
  39581. */
  39582. get mode(): number;
  39583. /**
  39584. * Sets the scale applied to the radius (1 by default)
  39585. */
  39586. set radiusScale(radius: number);
  39587. /**
  39588. * Gets the scale applied to the radius
  39589. */
  39590. get radiusScale(): number;
  39591. /**
  39592. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39593. */
  39594. set positionScale(scale: number);
  39595. /**
  39596. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  39597. */
  39598. get positionScale(): number;
  39599. /**
  39600. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39601. * behaviour is triggered, in radians.
  39602. */
  39603. set defaultElevation(elevation: number);
  39604. /**
  39605. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  39606. * behaviour is triggered, in radians.
  39607. */
  39608. get defaultElevation(): number;
  39609. /**
  39610. * Sets the time (in milliseconds) taken to return to the default beta position.
  39611. * Negative value indicates camera should not return to default.
  39612. */
  39613. set elevationReturnTime(speed: number);
  39614. /**
  39615. * Gets the time (in milliseconds) taken to return to the default beta position.
  39616. * Negative value indicates camera should not return to default.
  39617. */
  39618. get elevationReturnTime(): number;
  39619. /**
  39620. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39621. */
  39622. set elevationReturnWaitTime(time: number);
  39623. /**
  39624. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  39625. */
  39626. get elevationReturnWaitTime(): number;
  39627. /**
  39628. * Sets the flag that indicates if user zooming should stop animation.
  39629. */
  39630. set zoomStopsAnimation(flag: boolean);
  39631. /**
  39632. * Gets the flag that indicates if user zooming should stop animation.
  39633. */
  39634. get zoomStopsAnimation(): boolean;
  39635. /**
  39636. * Sets the transition time when framing the mesh, in milliseconds
  39637. */
  39638. set framingTime(time: number);
  39639. /**
  39640. * Gets the transition time when framing the mesh, in milliseconds
  39641. */
  39642. get framingTime(): number;
  39643. /**
  39644. * Define if the behavior should automatically change the configured
  39645. * camera limits and sensibilities.
  39646. */
  39647. autoCorrectCameraLimitsAndSensibility: boolean;
  39648. private _onPrePointerObservableObserver;
  39649. private _onAfterCheckInputsObserver;
  39650. private _onMeshTargetChangedObserver;
  39651. private _attachedCamera;
  39652. private _isPointerDown;
  39653. private _lastInteractionTime;
  39654. /**
  39655. * Initializes the behavior.
  39656. */
  39657. init(): void;
  39658. /**
  39659. * Attaches the behavior to its arc rotate camera.
  39660. * @param camera Defines the camera to attach the behavior to
  39661. */
  39662. attach(camera: ArcRotateCamera): void;
  39663. /**
  39664. * Detaches the behavior from its current arc rotate camera.
  39665. */
  39666. detach(): void;
  39667. private _animatables;
  39668. private _betaIsAnimating;
  39669. private _betaTransition;
  39670. private _radiusTransition;
  39671. private _vectorTransition;
  39672. /**
  39673. * Targets the given mesh and updates zoom level accordingly.
  39674. * @param mesh The mesh to target.
  39675. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39676. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39677. */
  39678. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39679. /**
  39680. * Targets the given mesh with its children and updates zoom level accordingly.
  39681. * @param mesh The mesh to target.
  39682. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39683. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39684. */
  39685. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39686. /**
  39687. * Targets the given meshes with their children and updates zoom level accordingly.
  39688. * @param meshes The mesh to target.
  39689. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39690. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39691. */
  39692. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39693. /**
  39694. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  39695. * @param minimumWorld Determines the smaller position of the bounding box extend
  39696. * @param maximumWorld Determines the bigger position of the bounding box extend
  39697. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  39698. * @param onAnimationEnd Callback triggered at the end of the framing animation
  39699. */
  39700. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  39701. /**
  39702. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  39703. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  39704. * frustum width.
  39705. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  39706. * to fully enclose the mesh in the viewing frustum.
  39707. */
  39708. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  39709. /**
  39710. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  39711. * is automatically returned to its default position (expected to be above ground plane).
  39712. */
  39713. private _maintainCameraAboveGround;
  39714. /**
  39715. * Returns the frustum slope based on the canvas ratio and camera FOV
  39716. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  39717. */
  39718. private _getFrustumSlope;
  39719. /**
  39720. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  39721. */
  39722. private _clearAnimationLocks;
  39723. /**
  39724. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  39725. */
  39726. private _applyUserInteraction;
  39727. /**
  39728. * Stops and removes all animations that have been applied to the camera
  39729. */
  39730. stopAllAnimations(): void;
  39731. /**
  39732. * Gets a value indicating if the user is moving the camera
  39733. */
  39734. get isUserIsMoving(): boolean;
  39735. /**
  39736. * The camera can move all the way towards the mesh.
  39737. */
  39738. static IgnoreBoundsSizeMode: number;
  39739. /**
  39740. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  39741. */
  39742. static FitFrustumSidesMode: number;
  39743. }
  39744. }
  39745. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  39746. import { Nullable } from "babylonjs/types";
  39747. import { Camera } from "babylonjs/Cameras/camera";
  39748. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39749. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39750. /**
  39751. * Base class for Camera Pointer Inputs.
  39752. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  39753. * for example usage.
  39754. */
  39755. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  39756. /**
  39757. * Defines the camera the input is attached to.
  39758. */
  39759. abstract camera: Camera;
  39760. /**
  39761. * Whether keyboard modifier keys are pressed at time of last mouse event.
  39762. */
  39763. protected _altKey: boolean;
  39764. protected _ctrlKey: boolean;
  39765. protected _metaKey: boolean;
  39766. protected _shiftKey: boolean;
  39767. /**
  39768. * Which mouse buttons were pressed at time of last mouse event.
  39769. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  39770. */
  39771. protected _buttonsPressed: number;
  39772. /**
  39773. * Defines the buttons associated with the input to handle camera move.
  39774. */
  39775. buttons: number[];
  39776. /**
  39777. * Attach the input controls to a specific dom element to get the input from.
  39778. * @param element Defines the element the controls should be listened from
  39779. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  39780. */
  39781. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  39782. /**
  39783. * Detach the current controls from the specified dom element.
  39784. * @param element Defines the element to stop listening the inputs from
  39785. */
  39786. detachControl(element: Nullable<HTMLElement>): void;
  39787. /**
  39788. * Gets the class name of the current input.
  39789. * @returns the class name
  39790. */
  39791. getClassName(): string;
  39792. /**
  39793. * Get the friendly name associated with the input class.
  39794. * @returns the input friendly name
  39795. */
  39796. getSimpleName(): string;
  39797. /**
  39798. * Called on pointer POINTERDOUBLETAP event.
  39799. * Override this method to provide functionality on POINTERDOUBLETAP event.
  39800. */
  39801. protected onDoubleTap(type: string): void;
  39802. /**
  39803. * Called on pointer POINTERMOVE event if only a single touch is active.
  39804. * Override this method to provide functionality.
  39805. */
  39806. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39807. /**
  39808. * Called on pointer POINTERMOVE event if multiple touches are active.
  39809. * Override this method to provide functionality.
  39810. */
  39811. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39812. /**
  39813. * Called on JS contextmenu event.
  39814. * Override this method to provide functionality.
  39815. */
  39816. protected onContextMenu(evt: PointerEvent): void;
  39817. /**
  39818. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39819. * press.
  39820. * Override this method to provide functionality.
  39821. */
  39822. protected onButtonDown(evt: PointerEvent): void;
  39823. /**
  39824. * Called each time a new POINTERUP event occurs. Ie, for each button
  39825. * release.
  39826. * Override this method to provide functionality.
  39827. */
  39828. protected onButtonUp(evt: PointerEvent): void;
  39829. /**
  39830. * Called when window becomes inactive.
  39831. * Override this method to provide functionality.
  39832. */
  39833. protected onLostFocus(): void;
  39834. private _pointerInput;
  39835. private _observer;
  39836. private _onLostFocus;
  39837. private pointA;
  39838. private pointB;
  39839. }
  39840. }
  39841. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  39842. import { Nullable } from "babylonjs/types";
  39843. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39844. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  39845. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  39846. /**
  39847. * Manage the pointers inputs to control an arc rotate camera.
  39848. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39849. */
  39850. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  39851. /**
  39852. * Defines the camera the input is attached to.
  39853. */
  39854. camera: ArcRotateCamera;
  39855. /**
  39856. * Gets the class name of the current input.
  39857. * @returns the class name
  39858. */
  39859. getClassName(): string;
  39860. /**
  39861. * Defines the buttons associated with the input to handle camera move.
  39862. */
  39863. buttons: number[];
  39864. /**
  39865. * Defines the pointer angular sensibility along the X axis or how fast is
  39866. * the camera rotating.
  39867. */
  39868. angularSensibilityX: number;
  39869. /**
  39870. * Defines the pointer angular sensibility along the Y axis or how fast is
  39871. * the camera rotating.
  39872. */
  39873. angularSensibilityY: number;
  39874. /**
  39875. * Defines the pointer pinch precision or how fast is the camera zooming.
  39876. */
  39877. pinchPrecision: number;
  39878. /**
  39879. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  39880. * from 0.
  39881. * It defines the percentage of current camera.radius to use as delta when
  39882. * pinch zoom is used.
  39883. */
  39884. pinchDeltaPercentage: number;
  39885. /**
  39886. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  39887. * that any object in the plane at the camera's target point will scale
  39888. * perfectly with finger motion.
  39889. * Overrides pinchDeltaPercentage and pinchPrecision.
  39890. */
  39891. useNaturalPinchZoom: boolean;
  39892. /**
  39893. * Defines the pointer panning sensibility or how fast is the camera moving.
  39894. */
  39895. panningSensibility: number;
  39896. /**
  39897. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  39898. */
  39899. multiTouchPanning: boolean;
  39900. /**
  39901. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  39902. * zoom (pinch) through multitouch.
  39903. */
  39904. multiTouchPanAndZoom: boolean;
  39905. /**
  39906. * Revers pinch action direction.
  39907. */
  39908. pinchInwards: boolean;
  39909. private _isPanClick;
  39910. private _twoFingerActivityCount;
  39911. private _isPinching;
  39912. /**
  39913. * Called on pointer POINTERMOVE event if only a single touch is active.
  39914. */
  39915. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  39916. /**
  39917. * Called on pointer POINTERDOUBLETAP event.
  39918. */
  39919. protected onDoubleTap(type: string): void;
  39920. /**
  39921. * Called on pointer POINTERMOVE event if multiple touches are active.
  39922. */
  39923. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  39924. /**
  39925. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  39926. * press.
  39927. */
  39928. protected onButtonDown(evt: PointerEvent): void;
  39929. /**
  39930. * Called each time a new POINTERUP event occurs. Ie, for each button
  39931. * release.
  39932. */
  39933. protected onButtonUp(evt: PointerEvent): void;
  39934. /**
  39935. * Called when window becomes inactive.
  39936. */
  39937. protected onLostFocus(): void;
  39938. }
  39939. }
  39940. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  39941. import { Nullable } from "babylonjs/types";
  39942. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  39943. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  39944. /**
  39945. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  39946. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  39947. */
  39948. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  39949. /**
  39950. * Defines the camera the input is attached to.
  39951. */
  39952. camera: ArcRotateCamera;
  39953. /**
  39954. * Defines the list of key codes associated with the up action (increase alpha)
  39955. */
  39956. keysUp: number[];
  39957. /**
  39958. * Defines the list of key codes associated with the down action (decrease alpha)
  39959. */
  39960. keysDown: number[];
  39961. /**
  39962. * Defines the list of key codes associated with the left action (increase beta)
  39963. */
  39964. keysLeft: number[];
  39965. /**
  39966. * Defines the list of key codes associated with the right action (decrease beta)
  39967. */
  39968. keysRight: number[];
  39969. /**
  39970. * Defines the list of key codes associated with the reset action.
  39971. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  39972. */
  39973. keysReset: number[];
  39974. /**
  39975. * Defines the panning sensibility of the inputs.
  39976. * (How fast is the camera panning)
  39977. */
  39978. panningSensibility: number;
  39979. /**
  39980. * Defines the zooming sensibility of the inputs.
  39981. * (How fast is the camera zooming)
  39982. */
  39983. zoomingSensibility: number;
  39984. /**
  39985. * Defines whether maintaining the alt key down switch the movement mode from
  39986. * orientation to zoom.
  39987. */
  39988. useAltToZoom: boolean;
  39989. /**
  39990. * Rotation speed of the camera
  39991. */
  39992. angularSpeed: number;
  39993. private _keys;
  39994. private _ctrlPressed;
  39995. private _altPressed;
  39996. private _onCanvasBlurObserver;
  39997. private _onKeyboardObserver;
  39998. private _engine;
  39999. private _scene;
  40000. /**
  40001. * Attach the input controls to a specific dom element to get the input from.
  40002. * @param element Defines the element the controls should be listened from
  40003. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40004. */
  40005. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40006. /**
  40007. * Detach the current controls from the specified dom element.
  40008. * @param element Defines the element to stop listening the inputs from
  40009. */
  40010. detachControl(element: Nullable<HTMLElement>): void;
  40011. /**
  40012. * Update the current camera state depending on the inputs that have been used this frame.
  40013. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  40014. */
  40015. checkInputs(): void;
  40016. /**
  40017. * Gets the class name of the current intput.
  40018. * @returns the class name
  40019. */
  40020. getClassName(): string;
  40021. /**
  40022. * Get the friendly name associated with the input class.
  40023. * @returns the input friendly name
  40024. */
  40025. getSimpleName(): string;
  40026. }
  40027. }
  40028. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  40029. import { Nullable } from "babylonjs/types";
  40030. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40031. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  40032. /**
  40033. * Manage the mouse wheel inputs to control an arc rotate camera.
  40034. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40035. */
  40036. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  40037. /**
  40038. * Defines the camera the input is attached to.
  40039. */
  40040. camera: ArcRotateCamera;
  40041. /**
  40042. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40043. */
  40044. wheelPrecision: number;
  40045. /**
  40046. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  40047. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  40048. */
  40049. wheelDeltaPercentage: number;
  40050. private _wheel;
  40051. private _observer;
  40052. private computeDeltaFromMouseWheelLegacyEvent;
  40053. /**
  40054. * Attach the input controls to a specific dom element to get the input from.
  40055. * @param element Defines the element the controls should be listened from
  40056. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40057. */
  40058. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  40059. /**
  40060. * Detach the current controls from the specified dom element.
  40061. * @param element Defines the element to stop listening the inputs from
  40062. */
  40063. detachControl(element: Nullable<HTMLElement>): void;
  40064. /**
  40065. * Gets the class name of the current intput.
  40066. * @returns the class name
  40067. */
  40068. getClassName(): string;
  40069. /**
  40070. * Get the friendly name associated with the input class.
  40071. * @returns the input friendly name
  40072. */
  40073. getSimpleName(): string;
  40074. }
  40075. }
  40076. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40077. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40078. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  40079. /**
  40080. * Default Inputs manager for the ArcRotateCamera.
  40081. * It groups all the default supported inputs for ease of use.
  40082. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  40083. */
  40084. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  40085. /**
  40086. * Instantiates a new ArcRotateCameraInputsManager.
  40087. * @param camera Defines the camera the inputs belong to
  40088. */
  40089. constructor(camera: ArcRotateCamera);
  40090. /**
  40091. * Add mouse wheel input support to the input manager.
  40092. * @returns the current input manager
  40093. */
  40094. addMouseWheel(): ArcRotateCameraInputsManager;
  40095. /**
  40096. * Add pointers input support to the input manager.
  40097. * @returns the current input manager
  40098. */
  40099. addPointers(): ArcRotateCameraInputsManager;
  40100. /**
  40101. * Add keyboard input support to the input manager.
  40102. * @returns the current input manager
  40103. */
  40104. addKeyboard(): ArcRotateCameraInputsManager;
  40105. }
  40106. }
  40107. declare module "babylonjs/Cameras/arcRotateCamera" {
  40108. import { Observable } from "babylonjs/Misc/observable";
  40109. import { Nullable } from "babylonjs/types";
  40110. import { Scene } from "babylonjs/scene";
  40111. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  40112. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40113. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40114. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40115. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  40116. import { Camera } from "babylonjs/Cameras/camera";
  40117. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  40118. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  40119. import { Collider } from "babylonjs/Collisions/collider";
  40120. /**
  40121. * This represents an orbital type of camera.
  40122. *
  40123. * 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.
  40124. * 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.
  40125. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  40126. */
  40127. export class ArcRotateCamera extends TargetCamera {
  40128. /**
  40129. * Defines the rotation angle of the camera along the longitudinal axis.
  40130. */
  40131. alpha: number;
  40132. /**
  40133. * Defines the rotation angle of the camera along the latitudinal axis.
  40134. */
  40135. beta: number;
  40136. /**
  40137. * Defines the radius of the camera from it s target point.
  40138. */
  40139. radius: number;
  40140. protected _target: Vector3;
  40141. protected _targetHost: Nullable<AbstractMesh>;
  40142. /**
  40143. * Defines the target point of the camera.
  40144. * The camera looks towards it form the radius distance.
  40145. */
  40146. get target(): Vector3;
  40147. set target(value: Vector3);
  40148. /**
  40149. * Define the current local position of the camera in the scene
  40150. */
  40151. get position(): Vector3;
  40152. set position(newPosition: Vector3);
  40153. protected _upVector: Vector3;
  40154. protected _upToYMatrix: Matrix;
  40155. protected _YToUpMatrix: Matrix;
  40156. /**
  40157. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  40158. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  40159. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  40160. */
  40161. set upVector(vec: Vector3);
  40162. get upVector(): Vector3;
  40163. /**
  40164. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  40165. */
  40166. setMatUp(): void;
  40167. /**
  40168. * Current inertia value on the longitudinal axis.
  40169. * The bigger this number the longer it will take for the camera to stop.
  40170. */
  40171. inertialAlphaOffset: number;
  40172. /**
  40173. * Current inertia value on the latitudinal axis.
  40174. * The bigger this number the longer it will take for the camera to stop.
  40175. */
  40176. inertialBetaOffset: number;
  40177. /**
  40178. * Current inertia value on the radius axis.
  40179. * The bigger this number the longer it will take for the camera to stop.
  40180. */
  40181. inertialRadiusOffset: number;
  40182. /**
  40183. * Minimum allowed angle on the longitudinal axis.
  40184. * This can help limiting how the Camera is able to move in the scene.
  40185. */
  40186. lowerAlphaLimit: Nullable<number>;
  40187. /**
  40188. * Maximum allowed angle on the longitudinal axis.
  40189. * This can help limiting how the Camera is able to move in the scene.
  40190. */
  40191. upperAlphaLimit: Nullable<number>;
  40192. /**
  40193. * Minimum allowed angle on the latitudinal axis.
  40194. * This can help limiting how the Camera is able to move in the scene.
  40195. */
  40196. lowerBetaLimit: number;
  40197. /**
  40198. * Maximum allowed angle on the latitudinal axis.
  40199. * This can help limiting how the Camera is able to move in the scene.
  40200. */
  40201. upperBetaLimit: number;
  40202. /**
  40203. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  40204. * This can help limiting how the Camera is able to move in the scene.
  40205. */
  40206. lowerRadiusLimit: Nullable<number>;
  40207. /**
  40208. * Maximum allowed distance of the camera to the target (The camera can not get further).
  40209. * This can help limiting how the Camera is able to move in the scene.
  40210. */
  40211. upperRadiusLimit: Nullable<number>;
  40212. /**
  40213. * Defines the current inertia value used during panning of the camera along the X axis.
  40214. */
  40215. inertialPanningX: number;
  40216. /**
  40217. * Defines the current inertia value used during panning of the camera along the Y axis.
  40218. */
  40219. inertialPanningY: number;
  40220. /**
  40221. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  40222. * Basically if your fingers moves away from more than this distance you will be considered
  40223. * in pinch mode.
  40224. */
  40225. pinchToPanMaxDistance: number;
  40226. /**
  40227. * Defines the maximum distance the camera can pan.
  40228. * This could help keeping the cammera always in your scene.
  40229. */
  40230. panningDistanceLimit: Nullable<number>;
  40231. /**
  40232. * Defines the target of the camera before paning.
  40233. */
  40234. panningOriginTarget: Vector3;
  40235. /**
  40236. * Defines the value of the inertia used during panning.
  40237. * 0 would mean stop inertia and one would mean no decelleration at all.
  40238. */
  40239. panningInertia: number;
  40240. /**
  40241. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  40242. */
  40243. get angularSensibilityX(): number;
  40244. set angularSensibilityX(value: number);
  40245. /**
  40246. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  40247. */
  40248. get angularSensibilityY(): number;
  40249. set angularSensibilityY(value: number);
  40250. /**
  40251. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  40252. */
  40253. get pinchPrecision(): number;
  40254. set pinchPrecision(value: number);
  40255. /**
  40256. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  40257. * It will be used instead of pinchDeltaPrecision if different from 0.
  40258. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40259. */
  40260. get pinchDeltaPercentage(): number;
  40261. set pinchDeltaPercentage(value: number);
  40262. /**
  40263. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  40264. * and pinch delta percentage.
  40265. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  40266. * that any object in the plane at the camera's target point will scale
  40267. * perfectly with finger motion.
  40268. */
  40269. get useNaturalPinchZoom(): boolean;
  40270. set useNaturalPinchZoom(value: boolean);
  40271. /**
  40272. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  40273. */
  40274. get panningSensibility(): number;
  40275. set panningSensibility(value: number);
  40276. /**
  40277. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  40278. */
  40279. get keysUp(): number[];
  40280. set keysUp(value: number[]);
  40281. /**
  40282. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  40283. */
  40284. get keysDown(): number[];
  40285. set keysDown(value: number[]);
  40286. /**
  40287. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  40288. */
  40289. get keysLeft(): number[];
  40290. set keysLeft(value: number[]);
  40291. /**
  40292. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  40293. */
  40294. get keysRight(): number[];
  40295. set keysRight(value: number[]);
  40296. /**
  40297. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  40298. */
  40299. get wheelPrecision(): number;
  40300. set wheelPrecision(value: number);
  40301. /**
  40302. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  40303. * It will be used instead of pinchDeltaPrecision if different from 0.
  40304. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  40305. */
  40306. get wheelDeltaPercentage(): number;
  40307. set wheelDeltaPercentage(value: number);
  40308. /**
  40309. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  40310. */
  40311. zoomOnFactor: number;
  40312. /**
  40313. * Defines a screen offset for the camera position.
  40314. */
  40315. targetScreenOffset: Vector2;
  40316. /**
  40317. * Allows the camera to be completely reversed.
  40318. * If false the camera can not arrive upside down.
  40319. */
  40320. allowUpsideDown: boolean;
  40321. /**
  40322. * Define if double tap/click is used to restore the previously saved state of the camera.
  40323. */
  40324. useInputToRestoreState: boolean;
  40325. /** @hidden */
  40326. _viewMatrix: Matrix;
  40327. /** @hidden */
  40328. _useCtrlForPanning: boolean;
  40329. /** @hidden */
  40330. _panningMouseButton: number;
  40331. /**
  40332. * Defines the input associated to the camera.
  40333. */
  40334. inputs: ArcRotateCameraInputsManager;
  40335. /** @hidden */
  40336. _reset: () => void;
  40337. /**
  40338. * Defines the allowed panning axis.
  40339. */
  40340. panningAxis: Vector3;
  40341. protected _localDirection: Vector3;
  40342. protected _transformedDirection: Vector3;
  40343. private _bouncingBehavior;
  40344. /**
  40345. * Gets the bouncing behavior of the camera if it has been enabled.
  40346. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40347. */
  40348. get bouncingBehavior(): Nullable<BouncingBehavior>;
  40349. /**
  40350. * Defines if the bouncing behavior of the camera is enabled on the camera.
  40351. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  40352. */
  40353. get useBouncingBehavior(): boolean;
  40354. set useBouncingBehavior(value: boolean);
  40355. private _framingBehavior;
  40356. /**
  40357. * Gets the framing behavior of the camera if it has been enabled.
  40358. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40359. */
  40360. get framingBehavior(): Nullable<FramingBehavior>;
  40361. /**
  40362. * Defines if the framing behavior of the camera is enabled on the camera.
  40363. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  40364. */
  40365. get useFramingBehavior(): boolean;
  40366. set useFramingBehavior(value: boolean);
  40367. private _autoRotationBehavior;
  40368. /**
  40369. * Gets the auto rotation behavior of the camera if it has been enabled.
  40370. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40371. */
  40372. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  40373. /**
  40374. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  40375. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40376. */
  40377. get useAutoRotationBehavior(): boolean;
  40378. set useAutoRotationBehavior(value: boolean);
  40379. /**
  40380. * Observable triggered when the mesh target has been changed on the camera.
  40381. */
  40382. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  40383. /**
  40384. * Event raised when the camera is colliding with a mesh.
  40385. */
  40386. onCollide: (collidedMesh: AbstractMesh) => void;
  40387. /**
  40388. * Defines whether the camera should check collision with the objects oh the scene.
  40389. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  40390. */
  40391. checkCollisions: boolean;
  40392. /**
  40393. * Defines the collision radius of the camera.
  40394. * This simulates a sphere around the camera.
  40395. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  40396. */
  40397. collisionRadius: Vector3;
  40398. protected _collider: Collider;
  40399. protected _previousPosition: Vector3;
  40400. protected _collisionVelocity: Vector3;
  40401. protected _newPosition: Vector3;
  40402. protected _previousAlpha: number;
  40403. protected _previousBeta: number;
  40404. protected _previousRadius: number;
  40405. protected _collisionTriggered: boolean;
  40406. protected _targetBoundingCenter: Nullable<Vector3>;
  40407. private _computationVector;
  40408. /**
  40409. * Instantiates a new ArcRotateCamera in a given scene
  40410. * @param name Defines the name of the camera
  40411. * @param alpha Defines the camera rotation along the logitudinal axis
  40412. * @param beta Defines the camera rotation along the latitudinal axis
  40413. * @param radius Defines the camera distance from its target
  40414. * @param target Defines the camera target
  40415. * @param scene Defines the scene the camera belongs to
  40416. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  40417. */
  40418. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  40419. /** @hidden */
  40420. _initCache(): void;
  40421. /** @hidden */
  40422. _updateCache(ignoreParentClass?: boolean): void;
  40423. protected _getTargetPosition(): Vector3;
  40424. private _storedAlpha;
  40425. private _storedBeta;
  40426. private _storedRadius;
  40427. private _storedTarget;
  40428. private _storedTargetScreenOffset;
  40429. /**
  40430. * Stores the current state of the camera (alpha, beta, radius and target)
  40431. * @returns the camera itself
  40432. */
  40433. storeState(): Camera;
  40434. /**
  40435. * @hidden
  40436. * Restored camera state. You must call storeState() first
  40437. */
  40438. _restoreStateValues(): boolean;
  40439. /** @hidden */
  40440. _isSynchronizedViewMatrix(): boolean;
  40441. /**
  40442. * Attached controls to the current camera.
  40443. * @param element Defines the element the controls should be listened from
  40444. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  40445. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  40446. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  40447. */
  40448. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  40449. /**
  40450. * Detach the current controls from the camera.
  40451. * The camera will stop reacting to inputs.
  40452. * @param element Defines the element to stop listening the inputs from
  40453. */
  40454. detachControl(element: HTMLElement): void;
  40455. /** @hidden */
  40456. _checkInputs(): void;
  40457. protected _checkLimits(): void;
  40458. /**
  40459. * Rebuilds angles (alpha, beta) and radius from the give position and target
  40460. */
  40461. rebuildAnglesAndRadius(): void;
  40462. /**
  40463. * Use a position to define the current camera related information like alpha, beta and radius
  40464. * @param position Defines the position to set the camera at
  40465. */
  40466. setPosition(position: Vector3): void;
  40467. /**
  40468. * Defines the target the camera should look at.
  40469. * This will automatically adapt alpha beta and radius to fit within the new target.
  40470. * @param target Defines the new target as a Vector or a mesh
  40471. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  40472. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  40473. */
  40474. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  40475. /** @hidden */
  40476. _getViewMatrix(): Matrix;
  40477. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  40478. /**
  40479. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  40480. * @param meshes Defines the mesh to zoom on
  40481. * @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)
  40482. */
  40483. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  40484. /**
  40485. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  40486. * The target will be changed but the radius
  40487. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  40488. * @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)
  40489. */
  40490. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  40491. min: Vector3;
  40492. max: Vector3;
  40493. distance: number;
  40494. }, doNotUpdateMaxZ?: boolean): void;
  40495. /**
  40496. * @override
  40497. * Override Camera.createRigCamera
  40498. */
  40499. createRigCamera(name: string, cameraIndex: number): Camera;
  40500. /**
  40501. * @hidden
  40502. * @override
  40503. * Override Camera._updateRigCameras
  40504. */
  40505. _updateRigCameras(): void;
  40506. /**
  40507. * Destroy the camera and release the current resources hold by it.
  40508. */
  40509. dispose(): void;
  40510. /**
  40511. * Gets the current object class name.
  40512. * @return the class name
  40513. */
  40514. getClassName(): string;
  40515. }
  40516. }
  40517. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  40518. import { Behavior } from "babylonjs/Behaviors/behavior";
  40519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  40520. /**
  40521. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  40522. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  40523. */
  40524. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  40525. /**
  40526. * Gets the name of the behavior.
  40527. */
  40528. get name(): string;
  40529. private _zoomStopsAnimation;
  40530. private _idleRotationSpeed;
  40531. private _idleRotationWaitTime;
  40532. private _idleRotationSpinupTime;
  40533. /**
  40534. * Sets the flag that indicates if user zooming should stop animation.
  40535. */
  40536. set zoomStopsAnimation(flag: boolean);
  40537. /**
  40538. * Gets the flag that indicates if user zooming should stop animation.
  40539. */
  40540. get zoomStopsAnimation(): boolean;
  40541. /**
  40542. * Sets the default speed at which the camera rotates around the model.
  40543. */
  40544. set idleRotationSpeed(speed: number);
  40545. /**
  40546. * Gets the default speed at which the camera rotates around the model.
  40547. */
  40548. get idleRotationSpeed(): number;
  40549. /**
  40550. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  40551. */
  40552. set idleRotationWaitTime(time: number);
  40553. /**
  40554. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  40555. */
  40556. get idleRotationWaitTime(): number;
  40557. /**
  40558. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40559. */
  40560. set idleRotationSpinupTime(time: number);
  40561. /**
  40562. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  40563. */
  40564. get idleRotationSpinupTime(): number;
  40565. /**
  40566. * Gets a value indicating if the camera is currently rotating because of this behavior
  40567. */
  40568. get rotationInProgress(): boolean;
  40569. private _onPrePointerObservableObserver;
  40570. private _onAfterCheckInputsObserver;
  40571. private _attachedCamera;
  40572. private _isPointerDown;
  40573. private _lastFrameTime;
  40574. private _lastInteractionTime;
  40575. private _cameraRotationSpeed;
  40576. /**
  40577. * Initializes the behavior.
  40578. */
  40579. init(): void;
  40580. /**
  40581. * Attaches the behavior to its arc rotate camera.
  40582. * @param camera Defines the camera to attach the behavior to
  40583. */
  40584. attach(camera: ArcRotateCamera): void;
  40585. /**
  40586. * Detaches the behavior from its current arc rotate camera.
  40587. */
  40588. detach(): void;
  40589. /**
  40590. * Returns true if user is scrolling.
  40591. * @return true if user is scrolling.
  40592. */
  40593. private _userIsZooming;
  40594. private _lastFrameRadius;
  40595. private _shouldAnimationStopForInteraction;
  40596. /**
  40597. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  40598. */
  40599. private _applyUserInteraction;
  40600. private _userIsMoving;
  40601. }
  40602. }
  40603. declare module "babylonjs/Behaviors/Cameras/index" {
  40604. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  40605. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  40606. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  40607. }
  40608. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  40609. import { Mesh } from "babylonjs/Meshes/mesh";
  40610. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40611. import { Behavior } from "babylonjs/Behaviors/behavior";
  40612. /**
  40613. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  40614. */
  40615. export class AttachToBoxBehavior implements Behavior<Mesh> {
  40616. private ui;
  40617. /**
  40618. * The name of the behavior
  40619. */
  40620. name: string;
  40621. /**
  40622. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  40623. */
  40624. distanceAwayFromFace: number;
  40625. /**
  40626. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  40627. */
  40628. distanceAwayFromBottomOfFace: number;
  40629. private _faceVectors;
  40630. private _target;
  40631. private _scene;
  40632. private _onRenderObserver;
  40633. private _tmpMatrix;
  40634. private _tmpVector;
  40635. /**
  40636. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  40637. * @param ui The transform node that should be attched to the mesh
  40638. */
  40639. constructor(ui: TransformNode);
  40640. /**
  40641. * Initializes the behavior
  40642. */
  40643. init(): void;
  40644. private _closestFace;
  40645. private _zeroVector;
  40646. private _lookAtTmpMatrix;
  40647. private _lookAtToRef;
  40648. /**
  40649. * Attaches the AttachToBoxBehavior to the passed in mesh
  40650. * @param target The mesh that the specified node will be attached to
  40651. */
  40652. attach(target: Mesh): void;
  40653. /**
  40654. * Detaches the behavior from the mesh
  40655. */
  40656. detach(): void;
  40657. }
  40658. }
  40659. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  40660. import { Behavior } from "babylonjs/Behaviors/behavior";
  40661. import { Mesh } from "babylonjs/Meshes/mesh";
  40662. /**
  40663. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  40664. */
  40665. export class FadeInOutBehavior implements Behavior<Mesh> {
  40666. /**
  40667. * Time in milliseconds to delay before fading in (Default: 0)
  40668. */
  40669. delay: number;
  40670. /**
  40671. * Time in milliseconds for the mesh to fade in (Default: 300)
  40672. */
  40673. fadeInTime: number;
  40674. private _millisecondsPerFrame;
  40675. private _hovered;
  40676. private _hoverValue;
  40677. private _ownerNode;
  40678. /**
  40679. * Instatiates the FadeInOutBehavior
  40680. */
  40681. constructor();
  40682. /**
  40683. * The name of the behavior
  40684. */
  40685. get name(): string;
  40686. /**
  40687. * Initializes the behavior
  40688. */
  40689. init(): void;
  40690. /**
  40691. * Attaches the fade behavior on the passed in mesh
  40692. * @param ownerNode The mesh that will be faded in/out once attached
  40693. */
  40694. attach(ownerNode: Mesh): void;
  40695. /**
  40696. * Detaches the behavior from the mesh
  40697. */
  40698. detach(): void;
  40699. /**
  40700. * Triggers the mesh to begin fading in or out
  40701. * @param value if the object should fade in or out (true to fade in)
  40702. */
  40703. fadeIn(value: boolean): void;
  40704. private _update;
  40705. private _setAllVisibility;
  40706. }
  40707. }
  40708. declare module "babylonjs/Misc/pivotTools" {
  40709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40710. /**
  40711. * Class containing a set of static utilities functions for managing Pivots
  40712. * @hidden
  40713. */
  40714. export class PivotTools {
  40715. private static _PivotCached;
  40716. private static _OldPivotPoint;
  40717. private static _PivotTranslation;
  40718. private static _PivotTmpVector;
  40719. /** @hidden */
  40720. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  40721. /** @hidden */
  40722. static _RestorePivotPoint(mesh: AbstractMesh): void;
  40723. }
  40724. }
  40725. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  40726. import { Scene } from "babylonjs/scene";
  40727. import { Vector4 } from "babylonjs/Maths/math.vector";
  40728. import { Mesh } from "babylonjs/Meshes/mesh";
  40729. import { Nullable } from "babylonjs/types";
  40730. import { Plane } from "babylonjs/Maths/math.plane";
  40731. /**
  40732. * Class containing static functions to help procedurally build meshes
  40733. */
  40734. export class PlaneBuilder {
  40735. /**
  40736. * Creates a plane mesh
  40737. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  40738. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  40739. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  40740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40743. * @param name defines the name of the mesh
  40744. * @param options defines the options used to create the mesh
  40745. * @param scene defines the hosting scene
  40746. * @returns the plane mesh
  40747. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  40748. */
  40749. static CreatePlane(name: string, options: {
  40750. size?: number;
  40751. width?: number;
  40752. height?: number;
  40753. sideOrientation?: number;
  40754. frontUVs?: Vector4;
  40755. backUVs?: Vector4;
  40756. updatable?: boolean;
  40757. sourcePlane?: Plane;
  40758. }, scene?: Nullable<Scene>): Mesh;
  40759. }
  40760. }
  40761. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  40762. import { Behavior } from "babylonjs/Behaviors/behavior";
  40763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40764. import { Observable } from "babylonjs/Misc/observable";
  40765. import { Vector3 } from "babylonjs/Maths/math.vector";
  40766. import { Ray } from "babylonjs/Culling/ray";
  40767. import "babylonjs/Meshes/Builders/planeBuilder";
  40768. /**
  40769. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  40770. */
  40771. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  40772. private static _AnyMouseID;
  40773. /**
  40774. * Abstract mesh the behavior is set on
  40775. */
  40776. attachedNode: AbstractMesh;
  40777. private _dragPlane;
  40778. private _scene;
  40779. private _pointerObserver;
  40780. private _beforeRenderObserver;
  40781. private static _planeScene;
  40782. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  40783. /**
  40784. * 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)
  40785. */
  40786. maxDragAngle: number;
  40787. /**
  40788. * @hidden
  40789. */
  40790. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  40791. /**
  40792. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  40793. */
  40794. currentDraggingPointerID: number;
  40795. /**
  40796. * The last position where the pointer hit the drag plane in world space
  40797. */
  40798. lastDragPosition: Vector3;
  40799. /**
  40800. * If the behavior is currently in a dragging state
  40801. */
  40802. dragging: boolean;
  40803. /**
  40804. * 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)
  40805. */
  40806. dragDeltaRatio: number;
  40807. /**
  40808. * If the drag plane orientation should be updated during the dragging (Default: true)
  40809. */
  40810. updateDragPlane: boolean;
  40811. private _debugMode;
  40812. private _moving;
  40813. /**
  40814. * Fires each time the attached mesh is dragged with the pointer
  40815. * * delta between last drag position and current drag position in world space
  40816. * * dragDistance along the drag axis
  40817. * * dragPlaneNormal normal of the current drag plane used during the drag
  40818. * * dragPlanePoint in world space where the drag intersects the drag plane
  40819. */
  40820. onDragObservable: Observable<{
  40821. delta: Vector3;
  40822. dragPlanePoint: Vector3;
  40823. dragPlaneNormal: Vector3;
  40824. dragDistance: number;
  40825. pointerId: number;
  40826. }>;
  40827. /**
  40828. * Fires each time a drag begins (eg. mouse down on mesh)
  40829. */
  40830. onDragStartObservable: Observable<{
  40831. dragPlanePoint: Vector3;
  40832. pointerId: number;
  40833. }>;
  40834. /**
  40835. * Fires each time a drag ends (eg. mouse release after drag)
  40836. */
  40837. onDragEndObservable: Observable<{
  40838. dragPlanePoint: Vector3;
  40839. pointerId: number;
  40840. }>;
  40841. /**
  40842. * If the attached mesh should be moved when dragged
  40843. */
  40844. moveAttached: boolean;
  40845. /**
  40846. * If the drag behavior will react to drag events (Default: true)
  40847. */
  40848. enabled: boolean;
  40849. /**
  40850. * If pointer events should start and release the drag (Default: true)
  40851. */
  40852. startAndReleaseDragOnPointerEvents: boolean;
  40853. /**
  40854. * If camera controls should be detached during the drag
  40855. */
  40856. detachCameraControls: boolean;
  40857. /**
  40858. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  40859. */
  40860. useObjectOrientationForDragging: boolean;
  40861. private _options;
  40862. /**
  40863. * Gets the options used by the behavior
  40864. */
  40865. get options(): {
  40866. dragAxis?: Vector3;
  40867. dragPlaneNormal?: Vector3;
  40868. };
  40869. /**
  40870. * Sets the options used by the behavior
  40871. */
  40872. set options(options: {
  40873. dragAxis?: Vector3;
  40874. dragPlaneNormal?: Vector3;
  40875. });
  40876. /**
  40877. * Creates a pointer drag behavior that can be attached to a mesh
  40878. * @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)
  40879. */
  40880. constructor(options?: {
  40881. dragAxis?: Vector3;
  40882. dragPlaneNormal?: Vector3;
  40883. });
  40884. /**
  40885. * Predicate to determine if it is valid to move the object to a new position when it is moved
  40886. */
  40887. validateDrag: (targetPosition: Vector3) => boolean;
  40888. /**
  40889. * The name of the behavior
  40890. */
  40891. get name(): string;
  40892. /**
  40893. * Initializes the behavior
  40894. */
  40895. init(): void;
  40896. private _tmpVector;
  40897. private _alternatePickedPoint;
  40898. private _worldDragAxis;
  40899. private _targetPosition;
  40900. private _attachedElement;
  40901. /**
  40902. * Attaches the drag behavior the passed in mesh
  40903. * @param ownerNode The mesh that will be dragged around once attached
  40904. * @param predicate Predicate to use for pick filtering
  40905. */
  40906. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  40907. /**
  40908. * Force relase the drag action by code.
  40909. */
  40910. releaseDrag(): void;
  40911. private _startDragRay;
  40912. private _lastPointerRay;
  40913. /**
  40914. * Simulates the start of a pointer drag event on the behavior
  40915. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  40916. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  40917. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  40918. */
  40919. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  40920. private _startDrag;
  40921. private _dragDelta;
  40922. private _moveDrag;
  40923. private _pickWithRayOnDragPlane;
  40924. private _pointA;
  40925. private _pointB;
  40926. private _pointC;
  40927. private _lineA;
  40928. private _lineB;
  40929. private _localAxis;
  40930. private _lookAt;
  40931. private _updateDragPlanePosition;
  40932. /**
  40933. * Detaches the behavior from the mesh
  40934. */
  40935. detach(): void;
  40936. }
  40937. }
  40938. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  40939. import { Mesh } from "babylonjs/Meshes/mesh";
  40940. import { Behavior } from "babylonjs/Behaviors/behavior";
  40941. /**
  40942. * A behavior that when attached to a mesh will allow the mesh to be scaled
  40943. */
  40944. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  40945. private _dragBehaviorA;
  40946. private _dragBehaviorB;
  40947. private _startDistance;
  40948. private _initialScale;
  40949. private _targetScale;
  40950. private _ownerNode;
  40951. private _sceneRenderObserver;
  40952. /**
  40953. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  40954. */
  40955. constructor();
  40956. /**
  40957. * The name of the behavior
  40958. */
  40959. get name(): string;
  40960. /**
  40961. * Initializes the behavior
  40962. */
  40963. init(): void;
  40964. private _getCurrentDistance;
  40965. /**
  40966. * Attaches the scale behavior the passed in mesh
  40967. * @param ownerNode The mesh that will be scaled around once attached
  40968. */
  40969. attach(ownerNode: Mesh): void;
  40970. /**
  40971. * Detaches the behavior from the mesh
  40972. */
  40973. detach(): void;
  40974. }
  40975. }
  40976. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  40977. import { Behavior } from "babylonjs/Behaviors/behavior";
  40978. import { Mesh } from "babylonjs/Meshes/mesh";
  40979. import { Observable } from "babylonjs/Misc/observable";
  40980. /**
  40981. * 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
  40982. */
  40983. export class SixDofDragBehavior implements Behavior<Mesh> {
  40984. private static _virtualScene;
  40985. private _ownerNode;
  40986. private _sceneRenderObserver;
  40987. private _scene;
  40988. private _targetPosition;
  40989. private _virtualOriginMesh;
  40990. private _virtualDragMesh;
  40991. private _pointerObserver;
  40992. private _moving;
  40993. private _startingOrientation;
  40994. private _attachedElement;
  40995. /**
  40996. * 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)
  40997. */
  40998. private zDragFactor;
  40999. /**
  41000. * If the object should rotate to face the drag origin
  41001. */
  41002. rotateDraggedObject: boolean;
  41003. /**
  41004. * If the behavior is currently in a dragging state
  41005. */
  41006. dragging: boolean;
  41007. /**
  41008. * 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)
  41009. */
  41010. dragDeltaRatio: number;
  41011. /**
  41012. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  41013. */
  41014. currentDraggingPointerID: number;
  41015. /**
  41016. * If camera controls should be detached during the drag
  41017. */
  41018. detachCameraControls: boolean;
  41019. /**
  41020. * Fires each time a drag starts
  41021. */
  41022. onDragStartObservable: Observable<{}>;
  41023. /**
  41024. * Fires each time a drag ends (eg. mouse release after drag)
  41025. */
  41026. onDragEndObservable: Observable<{}>;
  41027. /**
  41028. * 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
  41029. */
  41030. constructor();
  41031. /**
  41032. * The name of the behavior
  41033. */
  41034. get name(): string;
  41035. /**
  41036. * Initializes the behavior
  41037. */
  41038. init(): void;
  41039. /**
  41040. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  41041. */
  41042. private get _pointerCamera();
  41043. /**
  41044. * Attaches the scale behavior the passed in mesh
  41045. * @param ownerNode The mesh that will be scaled around once attached
  41046. */
  41047. attach(ownerNode: Mesh): void;
  41048. /**
  41049. * Detaches the behavior from the mesh
  41050. */
  41051. detach(): void;
  41052. }
  41053. }
  41054. declare module "babylonjs/Behaviors/Meshes/index" {
  41055. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  41056. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  41057. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  41058. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  41059. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  41060. }
  41061. declare module "babylonjs/Behaviors/index" {
  41062. export * from "babylonjs/Behaviors/behavior";
  41063. export * from "babylonjs/Behaviors/Cameras/index";
  41064. export * from "babylonjs/Behaviors/Meshes/index";
  41065. }
  41066. declare module "babylonjs/Bones/boneIKController" {
  41067. import { Bone } from "babylonjs/Bones/bone";
  41068. import { Vector3 } from "babylonjs/Maths/math.vector";
  41069. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41070. import { Nullable } from "babylonjs/types";
  41071. /**
  41072. * Class used to apply inverse kinematics to bones
  41073. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  41074. */
  41075. export class BoneIKController {
  41076. private static _tmpVecs;
  41077. private static _tmpQuat;
  41078. private static _tmpMats;
  41079. /**
  41080. * Gets or sets the target mesh
  41081. */
  41082. targetMesh: AbstractMesh;
  41083. /** Gets or sets the mesh used as pole */
  41084. poleTargetMesh: AbstractMesh;
  41085. /**
  41086. * Gets or sets the bone used as pole
  41087. */
  41088. poleTargetBone: Nullable<Bone>;
  41089. /**
  41090. * Gets or sets the target position
  41091. */
  41092. targetPosition: Vector3;
  41093. /**
  41094. * Gets or sets the pole target position
  41095. */
  41096. poleTargetPosition: Vector3;
  41097. /**
  41098. * Gets or sets the pole target local offset
  41099. */
  41100. poleTargetLocalOffset: Vector3;
  41101. /**
  41102. * Gets or sets the pole angle
  41103. */
  41104. poleAngle: number;
  41105. /**
  41106. * Gets or sets the mesh associated with the controller
  41107. */
  41108. mesh: AbstractMesh;
  41109. /**
  41110. * 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)
  41111. */
  41112. slerpAmount: number;
  41113. private _bone1Quat;
  41114. private _bone1Mat;
  41115. private _bone2Ang;
  41116. private _bone1;
  41117. private _bone2;
  41118. private _bone1Length;
  41119. private _bone2Length;
  41120. private _maxAngle;
  41121. private _maxReach;
  41122. private _rightHandedSystem;
  41123. private _bendAxis;
  41124. private _slerping;
  41125. private _adjustRoll;
  41126. /**
  41127. * Gets or sets maximum allowed angle
  41128. */
  41129. get maxAngle(): number;
  41130. set maxAngle(value: number);
  41131. /**
  41132. * Creates a new BoneIKController
  41133. * @param mesh defines the mesh to control
  41134. * @param bone defines the bone to control
  41135. * @param options defines options to set up the controller
  41136. */
  41137. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  41138. targetMesh?: AbstractMesh;
  41139. poleTargetMesh?: AbstractMesh;
  41140. poleTargetBone?: Bone;
  41141. poleTargetLocalOffset?: Vector3;
  41142. poleAngle?: number;
  41143. bendAxis?: Vector3;
  41144. maxAngle?: number;
  41145. slerpAmount?: number;
  41146. });
  41147. private _setMaxAngle;
  41148. /**
  41149. * Force the controller to update the bones
  41150. */
  41151. update(): void;
  41152. }
  41153. }
  41154. declare module "babylonjs/Bones/boneLookController" {
  41155. import { Vector3 } from "babylonjs/Maths/math.vector";
  41156. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41157. import { Bone } from "babylonjs/Bones/bone";
  41158. import { Space } from "babylonjs/Maths/math.axis";
  41159. /**
  41160. * Class used to make a bone look toward a point in space
  41161. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  41162. */
  41163. export class BoneLookController {
  41164. private static _tmpVecs;
  41165. private static _tmpQuat;
  41166. private static _tmpMats;
  41167. /**
  41168. * The target Vector3 that the bone will look at
  41169. */
  41170. target: Vector3;
  41171. /**
  41172. * The mesh that the bone is attached to
  41173. */
  41174. mesh: AbstractMesh;
  41175. /**
  41176. * The bone that will be looking to the target
  41177. */
  41178. bone: Bone;
  41179. /**
  41180. * The up axis of the coordinate system that is used when the bone is rotated
  41181. */
  41182. upAxis: Vector3;
  41183. /**
  41184. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  41185. */
  41186. upAxisSpace: Space;
  41187. /**
  41188. * Used to make an adjustment to the yaw of the bone
  41189. */
  41190. adjustYaw: number;
  41191. /**
  41192. * Used to make an adjustment to the pitch of the bone
  41193. */
  41194. adjustPitch: number;
  41195. /**
  41196. * Used to make an adjustment to the roll of the bone
  41197. */
  41198. adjustRoll: number;
  41199. /**
  41200. * 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)
  41201. */
  41202. slerpAmount: number;
  41203. private _minYaw;
  41204. private _maxYaw;
  41205. private _minPitch;
  41206. private _maxPitch;
  41207. private _minYawSin;
  41208. private _minYawCos;
  41209. private _maxYawSin;
  41210. private _maxYawCos;
  41211. private _midYawConstraint;
  41212. private _minPitchTan;
  41213. private _maxPitchTan;
  41214. private _boneQuat;
  41215. private _slerping;
  41216. private _transformYawPitch;
  41217. private _transformYawPitchInv;
  41218. private _firstFrameSkipped;
  41219. private _yawRange;
  41220. private _fowardAxis;
  41221. /**
  41222. * Gets or sets the minimum yaw angle that the bone can look to
  41223. */
  41224. get minYaw(): number;
  41225. set minYaw(value: number);
  41226. /**
  41227. * Gets or sets the maximum yaw angle that the bone can look to
  41228. */
  41229. get maxYaw(): number;
  41230. set maxYaw(value: number);
  41231. /**
  41232. * Gets or sets the minimum pitch angle that the bone can look to
  41233. */
  41234. get minPitch(): number;
  41235. set minPitch(value: number);
  41236. /**
  41237. * Gets or sets the maximum pitch angle that the bone can look to
  41238. */
  41239. get maxPitch(): number;
  41240. set maxPitch(value: number);
  41241. /**
  41242. * Create a BoneLookController
  41243. * @param mesh the mesh that the bone belongs to
  41244. * @param bone the bone that will be looking to the target
  41245. * @param target the target Vector3 to look at
  41246. * @param options optional settings:
  41247. * * maxYaw: the maximum angle the bone will yaw to
  41248. * * minYaw: the minimum angle the bone will yaw to
  41249. * * maxPitch: the maximum angle the bone will pitch to
  41250. * * minPitch: the minimum angle the bone will yaw to
  41251. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  41252. * * upAxis: the up axis of the coordinate system
  41253. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  41254. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  41255. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  41256. * * adjustYaw: used to make an adjustment to the yaw of the bone
  41257. * * adjustPitch: used to make an adjustment to the pitch of the bone
  41258. * * adjustRoll: used to make an adjustment to the roll of the bone
  41259. **/
  41260. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  41261. maxYaw?: number;
  41262. minYaw?: number;
  41263. maxPitch?: number;
  41264. minPitch?: number;
  41265. slerpAmount?: number;
  41266. upAxis?: Vector3;
  41267. upAxisSpace?: Space;
  41268. yawAxis?: Vector3;
  41269. pitchAxis?: Vector3;
  41270. adjustYaw?: number;
  41271. adjustPitch?: number;
  41272. adjustRoll?: number;
  41273. });
  41274. /**
  41275. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  41276. */
  41277. update(): void;
  41278. private _getAngleDiff;
  41279. private _getAngleBetween;
  41280. private _isAngleBetween;
  41281. }
  41282. }
  41283. declare module "babylonjs/Bones/index" {
  41284. export * from "babylonjs/Bones/bone";
  41285. export * from "babylonjs/Bones/boneIKController";
  41286. export * from "babylonjs/Bones/boneLookController";
  41287. export * from "babylonjs/Bones/skeleton";
  41288. }
  41289. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  41290. import { Nullable } from "babylonjs/types";
  41291. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41292. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41293. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  41294. /**
  41295. * Manage the gamepad inputs to control an arc rotate camera.
  41296. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41297. */
  41298. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  41299. /**
  41300. * Defines the camera the input is attached to.
  41301. */
  41302. camera: ArcRotateCamera;
  41303. /**
  41304. * Defines the gamepad the input is gathering event from.
  41305. */
  41306. gamepad: Nullable<Gamepad>;
  41307. /**
  41308. * Defines the gamepad rotation sensiblity.
  41309. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  41310. */
  41311. gamepadRotationSensibility: number;
  41312. /**
  41313. * Defines the gamepad move sensiblity.
  41314. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  41315. */
  41316. gamepadMoveSensibility: number;
  41317. private _yAxisScale;
  41318. /**
  41319. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  41320. */
  41321. get invertYAxis(): boolean;
  41322. set invertYAxis(value: boolean);
  41323. private _onGamepadConnectedObserver;
  41324. private _onGamepadDisconnectedObserver;
  41325. /**
  41326. * Attach the input controls to a specific dom element to get the input from.
  41327. * @param element Defines the element the controls should be listened from
  41328. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41329. */
  41330. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41331. /**
  41332. * Detach the current controls from the specified dom element.
  41333. * @param element Defines the element to stop listening the inputs from
  41334. */
  41335. detachControl(element: Nullable<HTMLElement>): void;
  41336. /**
  41337. * Update the current camera state depending on the inputs that have been used this frame.
  41338. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41339. */
  41340. checkInputs(): void;
  41341. /**
  41342. * Gets the class name of the current intput.
  41343. * @returns the class name
  41344. */
  41345. getClassName(): string;
  41346. /**
  41347. * Get the friendly name associated with the input class.
  41348. * @returns the input friendly name
  41349. */
  41350. getSimpleName(): string;
  41351. }
  41352. }
  41353. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  41354. import { Nullable } from "babylonjs/types";
  41355. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  41356. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41357. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  41358. interface ArcRotateCameraInputsManager {
  41359. /**
  41360. * Add orientation input support to the input manager.
  41361. * @returns the current input manager
  41362. */
  41363. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  41364. }
  41365. }
  41366. /**
  41367. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  41368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41369. */
  41370. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  41371. /**
  41372. * Defines the camera the input is attached to.
  41373. */
  41374. camera: ArcRotateCamera;
  41375. /**
  41376. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  41377. */
  41378. alphaCorrection: number;
  41379. /**
  41380. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  41381. */
  41382. gammaCorrection: number;
  41383. private _alpha;
  41384. private _gamma;
  41385. private _dirty;
  41386. private _deviceOrientationHandler;
  41387. /**
  41388. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  41389. */
  41390. constructor();
  41391. /**
  41392. * Attach the input controls to a specific dom element to get the input from.
  41393. * @param element Defines the element the controls should be listened from
  41394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41395. */
  41396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41397. /** @hidden */
  41398. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  41399. /**
  41400. * Update the current camera state depending on the inputs that have been used this frame.
  41401. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41402. */
  41403. checkInputs(): void;
  41404. /**
  41405. * Detach the current controls from the specified dom element.
  41406. * @param element Defines the element to stop listening the inputs from
  41407. */
  41408. detachControl(element: Nullable<HTMLElement>): void;
  41409. /**
  41410. * Gets the class name of the current intput.
  41411. * @returns the class name
  41412. */
  41413. getClassName(): string;
  41414. /**
  41415. * Get the friendly name associated with the input class.
  41416. * @returns the input friendly name
  41417. */
  41418. getSimpleName(): string;
  41419. }
  41420. }
  41421. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  41422. import { Nullable } from "babylonjs/types";
  41423. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41424. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41425. /**
  41426. * Listen to mouse events to control the camera.
  41427. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41428. */
  41429. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  41430. /**
  41431. * Defines the camera the input is attached to.
  41432. */
  41433. camera: FlyCamera;
  41434. /**
  41435. * Defines if touch is enabled. (Default is true.)
  41436. */
  41437. touchEnabled: boolean;
  41438. /**
  41439. * Defines the buttons associated with the input to handle camera rotation.
  41440. */
  41441. buttons: number[];
  41442. /**
  41443. * Assign buttons for Yaw control.
  41444. */
  41445. buttonsYaw: number[];
  41446. /**
  41447. * Assign buttons for Pitch control.
  41448. */
  41449. buttonsPitch: number[];
  41450. /**
  41451. * Assign buttons for Roll control.
  41452. */
  41453. buttonsRoll: number[];
  41454. /**
  41455. * Detect if any button is being pressed while mouse is moved.
  41456. * -1 = Mouse locked.
  41457. * 0 = Left button.
  41458. * 1 = Middle Button.
  41459. * 2 = Right Button.
  41460. */
  41461. activeButton: number;
  41462. /**
  41463. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  41464. * Higher values reduce its sensitivity.
  41465. */
  41466. angularSensibility: number;
  41467. private _mousemoveCallback;
  41468. private _observer;
  41469. private _rollObserver;
  41470. private previousPosition;
  41471. private noPreventDefault;
  41472. private element;
  41473. /**
  41474. * Listen to mouse events to control the camera.
  41475. * @param touchEnabled Define if touch is enabled. (Default is true.)
  41476. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41477. */
  41478. constructor(touchEnabled?: boolean);
  41479. /**
  41480. * Attach the mouse control to the HTML DOM element.
  41481. * @param element Defines the element that listens to the input events.
  41482. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  41483. */
  41484. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41485. /**
  41486. * Detach the current controls from the specified dom element.
  41487. * @param element Defines the element to stop listening the inputs from
  41488. */
  41489. detachControl(element: Nullable<HTMLElement>): void;
  41490. /**
  41491. * Gets the class name of the current input.
  41492. * @returns the class name.
  41493. */
  41494. getClassName(): string;
  41495. /**
  41496. * Get the friendly name associated with the input class.
  41497. * @returns the input's friendly name.
  41498. */
  41499. getSimpleName(): string;
  41500. private _pointerInput;
  41501. private _onMouseMove;
  41502. /**
  41503. * Rotate camera by mouse offset.
  41504. */
  41505. private rotateCamera;
  41506. }
  41507. }
  41508. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  41509. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41510. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41511. /**
  41512. * Default Inputs manager for the FlyCamera.
  41513. * It groups all the default supported inputs for ease of use.
  41514. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41515. */
  41516. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  41517. /**
  41518. * Instantiates a new FlyCameraInputsManager.
  41519. * @param camera Defines the camera the inputs belong to.
  41520. */
  41521. constructor(camera: FlyCamera);
  41522. /**
  41523. * Add keyboard input support to the input manager.
  41524. * @returns the new FlyCameraKeyboardMoveInput().
  41525. */
  41526. addKeyboard(): FlyCameraInputsManager;
  41527. /**
  41528. * Add mouse input support to the input manager.
  41529. * @param touchEnabled Enable touch screen support.
  41530. * @returns the new FlyCameraMouseInput().
  41531. */
  41532. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  41533. }
  41534. }
  41535. declare module "babylonjs/Cameras/flyCamera" {
  41536. import { Scene } from "babylonjs/scene";
  41537. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  41538. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41539. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41540. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  41541. /**
  41542. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41543. * such as in a 3D Space Shooter or a Flight Simulator.
  41544. */
  41545. export class FlyCamera extends TargetCamera {
  41546. /**
  41547. * Define the collision ellipsoid of the camera.
  41548. * This is helpful for simulating a camera body, like a player's body.
  41549. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  41550. */
  41551. ellipsoid: Vector3;
  41552. /**
  41553. * Define an offset for the position of the ellipsoid around the camera.
  41554. * This can be helpful if the camera is attached away from the player's body center,
  41555. * such as at its head.
  41556. */
  41557. ellipsoidOffset: Vector3;
  41558. /**
  41559. * Enable or disable collisions of the camera with the rest of the scene objects.
  41560. */
  41561. checkCollisions: boolean;
  41562. /**
  41563. * Enable or disable gravity on the camera.
  41564. */
  41565. applyGravity: boolean;
  41566. /**
  41567. * Define the current direction the camera is moving to.
  41568. */
  41569. cameraDirection: Vector3;
  41570. /**
  41571. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  41572. * This overrides and empties cameraRotation.
  41573. */
  41574. rotationQuaternion: Quaternion;
  41575. /**
  41576. * Track Roll to maintain the wanted Rolling when looking around.
  41577. */
  41578. _trackRoll: number;
  41579. /**
  41580. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  41581. */
  41582. rollCorrect: number;
  41583. /**
  41584. * Mimic a banked turn, Rolling the camera when Yawing.
  41585. * It's recommended to use rollCorrect = 10 for faster banking correction.
  41586. */
  41587. bankedTurn: boolean;
  41588. /**
  41589. * Limit in radians for how much Roll banking will add. (Default: 90°)
  41590. */
  41591. bankedTurnLimit: number;
  41592. /**
  41593. * Value of 0 disables the banked Roll.
  41594. * Value of 1 is equal to the Yaw angle in radians.
  41595. */
  41596. bankedTurnMultiplier: number;
  41597. /**
  41598. * The inputs manager loads all the input sources, such as keyboard and mouse.
  41599. */
  41600. inputs: FlyCameraInputsManager;
  41601. /**
  41602. * Gets the input sensibility for mouse input.
  41603. * Higher values reduce sensitivity.
  41604. */
  41605. get angularSensibility(): number;
  41606. /**
  41607. * Sets the input sensibility for a mouse input.
  41608. * Higher values reduce sensitivity.
  41609. */
  41610. set angularSensibility(value: number);
  41611. /**
  41612. * Get the keys for camera movement forward.
  41613. */
  41614. get keysForward(): number[];
  41615. /**
  41616. * Set the keys for camera movement forward.
  41617. */
  41618. set keysForward(value: number[]);
  41619. /**
  41620. * Get the keys for camera movement backward.
  41621. */
  41622. get keysBackward(): number[];
  41623. set keysBackward(value: number[]);
  41624. /**
  41625. * Get the keys for camera movement up.
  41626. */
  41627. get keysUp(): number[];
  41628. /**
  41629. * Set the keys for camera movement up.
  41630. */
  41631. set keysUp(value: number[]);
  41632. /**
  41633. * Get the keys for camera movement down.
  41634. */
  41635. get keysDown(): number[];
  41636. /**
  41637. * Set the keys for camera movement down.
  41638. */
  41639. set keysDown(value: number[]);
  41640. /**
  41641. * Get the keys for camera movement left.
  41642. */
  41643. get keysLeft(): number[];
  41644. /**
  41645. * Set the keys for camera movement left.
  41646. */
  41647. set keysLeft(value: number[]);
  41648. /**
  41649. * Set the keys for camera movement right.
  41650. */
  41651. get keysRight(): number[];
  41652. /**
  41653. * Set the keys for camera movement right.
  41654. */
  41655. set keysRight(value: number[]);
  41656. /**
  41657. * Event raised when the camera collides with a mesh in the scene.
  41658. */
  41659. onCollide: (collidedMesh: AbstractMesh) => void;
  41660. private _collider;
  41661. private _needMoveForGravity;
  41662. private _oldPosition;
  41663. private _diffPosition;
  41664. private _newPosition;
  41665. /** @hidden */
  41666. _localDirection: Vector3;
  41667. /** @hidden */
  41668. _transformedDirection: Vector3;
  41669. /**
  41670. * Instantiates a FlyCamera.
  41671. * This is a flying camera, designed for 3D movement and rotation in all directions,
  41672. * such as in a 3D Space Shooter or a Flight Simulator.
  41673. * @param name Define the name of the camera in the scene.
  41674. * @param position Define the starting position of the camera in the scene.
  41675. * @param scene Define the scene the camera belongs to.
  41676. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  41677. */
  41678. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  41679. /**
  41680. * Attach a control to the HTML DOM element.
  41681. * @param element Defines the element that listens to the input events.
  41682. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  41683. */
  41684. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41685. /**
  41686. * Detach a control from the HTML DOM element.
  41687. * The camera will stop reacting to that input.
  41688. * @param element Defines the element that listens to the input events.
  41689. */
  41690. detachControl(element: HTMLElement): void;
  41691. private _collisionMask;
  41692. /**
  41693. * Get the mask that the camera ignores in collision events.
  41694. */
  41695. get collisionMask(): number;
  41696. /**
  41697. * Set the mask that the camera ignores in collision events.
  41698. */
  41699. set collisionMask(mask: number);
  41700. /** @hidden */
  41701. _collideWithWorld(displacement: Vector3): void;
  41702. /** @hidden */
  41703. private _onCollisionPositionChange;
  41704. /** @hidden */
  41705. _checkInputs(): void;
  41706. /** @hidden */
  41707. _decideIfNeedsToMove(): boolean;
  41708. /** @hidden */
  41709. _updatePosition(): void;
  41710. /**
  41711. * Restore the Roll to its target value at the rate specified.
  41712. * @param rate - Higher means slower restoring.
  41713. * @hidden
  41714. */
  41715. restoreRoll(rate: number): void;
  41716. /**
  41717. * Destroy the camera and release the current resources held by it.
  41718. */
  41719. dispose(): void;
  41720. /**
  41721. * Get the current object class name.
  41722. * @returns the class name.
  41723. */
  41724. getClassName(): string;
  41725. }
  41726. }
  41727. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  41728. import { Nullable } from "babylonjs/types";
  41729. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41730. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  41731. /**
  41732. * Listen to keyboard events to control the camera.
  41733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41734. */
  41735. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  41736. /**
  41737. * Defines the camera the input is attached to.
  41738. */
  41739. camera: FlyCamera;
  41740. /**
  41741. * The list of keyboard keys used to control the forward move of the camera.
  41742. */
  41743. keysForward: number[];
  41744. /**
  41745. * The list of keyboard keys used to control the backward move of the camera.
  41746. */
  41747. keysBackward: number[];
  41748. /**
  41749. * The list of keyboard keys used to control the forward move of the camera.
  41750. */
  41751. keysUp: number[];
  41752. /**
  41753. * The list of keyboard keys used to control the backward move of the camera.
  41754. */
  41755. keysDown: number[];
  41756. /**
  41757. * The list of keyboard keys used to control the right strafe move of the camera.
  41758. */
  41759. keysRight: number[];
  41760. /**
  41761. * The list of keyboard keys used to control the left strafe move of the camera.
  41762. */
  41763. keysLeft: number[];
  41764. private _keys;
  41765. private _onCanvasBlurObserver;
  41766. private _onKeyboardObserver;
  41767. private _engine;
  41768. private _scene;
  41769. /**
  41770. * Attach the input controls to a specific dom element to get the input from.
  41771. * @param element Defines the element the controls should be listened from
  41772. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41773. */
  41774. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41775. /**
  41776. * Detach the current controls from the specified dom element.
  41777. * @param element Defines the element to stop listening the inputs from
  41778. */
  41779. detachControl(element: Nullable<HTMLElement>): void;
  41780. /**
  41781. * Gets the class name of the current intput.
  41782. * @returns the class name
  41783. */
  41784. getClassName(): string;
  41785. /** @hidden */
  41786. _onLostFocus(e: FocusEvent): void;
  41787. /**
  41788. * Get the friendly name associated with the input class.
  41789. * @returns the input friendly name
  41790. */
  41791. getSimpleName(): string;
  41792. /**
  41793. * Update the current camera state depending on the inputs that have been used this frame.
  41794. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  41795. */
  41796. checkInputs(): void;
  41797. }
  41798. }
  41799. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  41800. import { Nullable } from "babylonjs/types";
  41801. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41802. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  41803. /**
  41804. * Manage the mouse wheel inputs to control a follow camera.
  41805. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41806. */
  41807. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  41808. /**
  41809. * Defines the camera the input is attached to.
  41810. */
  41811. camera: FollowCamera;
  41812. /**
  41813. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  41814. */
  41815. axisControlRadius: boolean;
  41816. /**
  41817. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  41818. */
  41819. axisControlHeight: boolean;
  41820. /**
  41821. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  41822. */
  41823. axisControlRotation: boolean;
  41824. /**
  41825. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  41826. * relation to mouseWheel events.
  41827. */
  41828. wheelPrecision: number;
  41829. /**
  41830. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  41831. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  41832. */
  41833. wheelDeltaPercentage: number;
  41834. private _wheel;
  41835. private _observer;
  41836. /**
  41837. * Attach the input controls to a specific dom element to get the input from.
  41838. * @param element Defines the element the controls should be listened from
  41839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  41840. */
  41841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  41842. /**
  41843. * Detach the current controls from the specified dom element.
  41844. * @param element Defines the element to stop listening the inputs from
  41845. */
  41846. detachControl(element: Nullable<HTMLElement>): void;
  41847. /**
  41848. * Gets the class name of the current intput.
  41849. * @returns the class name
  41850. */
  41851. getClassName(): string;
  41852. /**
  41853. * Get the friendly name associated with the input class.
  41854. * @returns the input friendly name
  41855. */
  41856. getSimpleName(): string;
  41857. }
  41858. }
  41859. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  41860. import { Nullable } from "babylonjs/types";
  41861. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41862. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  41863. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  41864. /**
  41865. * Manage the pointers inputs to control an follow camera.
  41866. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41867. */
  41868. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  41869. /**
  41870. * Defines the camera the input is attached to.
  41871. */
  41872. camera: FollowCamera;
  41873. /**
  41874. * Gets the class name of the current input.
  41875. * @returns the class name
  41876. */
  41877. getClassName(): string;
  41878. /**
  41879. * Defines the pointer angular sensibility along the X axis or how fast is
  41880. * the camera rotating.
  41881. * A negative number will reverse the axis direction.
  41882. */
  41883. angularSensibilityX: number;
  41884. /**
  41885. * Defines the pointer angular sensibility along the Y axis or how fast is
  41886. * the camera rotating.
  41887. * A negative number will reverse the axis direction.
  41888. */
  41889. angularSensibilityY: number;
  41890. /**
  41891. * Defines the pointer pinch precision or how fast is the camera zooming.
  41892. * A negative number will reverse the axis direction.
  41893. */
  41894. pinchPrecision: number;
  41895. /**
  41896. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  41897. * from 0.
  41898. * It defines the percentage of current camera.radius to use as delta when
  41899. * pinch zoom is used.
  41900. */
  41901. pinchDeltaPercentage: number;
  41902. /**
  41903. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  41904. */
  41905. axisXControlRadius: boolean;
  41906. /**
  41907. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  41908. */
  41909. axisXControlHeight: boolean;
  41910. /**
  41911. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  41912. */
  41913. axisXControlRotation: boolean;
  41914. /**
  41915. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  41916. */
  41917. axisYControlRadius: boolean;
  41918. /**
  41919. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  41920. */
  41921. axisYControlHeight: boolean;
  41922. /**
  41923. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  41924. */
  41925. axisYControlRotation: boolean;
  41926. /**
  41927. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  41928. */
  41929. axisPinchControlRadius: boolean;
  41930. /**
  41931. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  41932. */
  41933. axisPinchControlHeight: boolean;
  41934. /**
  41935. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  41936. */
  41937. axisPinchControlRotation: boolean;
  41938. /**
  41939. * Log error messages if basic misconfiguration has occurred.
  41940. */
  41941. warningEnable: boolean;
  41942. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  41943. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  41944. private _warningCounter;
  41945. private _warning;
  41946. }
  41947. }
  41948. declare module "babylonjs/Cameras/followCameraInputsManager" {
  41949. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  41950. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  41951. /**
  41952. * Default Inputs manager for the FollowCamera.
  41953. * It groups all the default supported inputs for ease of use.
  41954. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  41955. */
  41956. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  41957. /**
  41958. * Instantiates a new FollowCameraInputsManager.
  41959. * @param camera Defines the camera the inputs belong to
  41960. */
  41961. constructor(camera: FollowCamera);
  41962. /**
  41963. * Add keyboard input support to the input manager.
  41964. * @returns the current input manager
  41965. */
  41966. addKeyboard(): FollowCameraInputsManager;
  41967. /**
  41968. * Add mouse wheel input support to the input manager.
  41969. * @returns the current input manager
  41970. */
  41971. addMouseWheel(): FollowCameraInputsManager;
  41972. /**
  41973. * Add pointers input support to the input manager.
  41974. * @returns the current input manager
  41975. */
  41976. addPointers(): FollowCameraInputsManager;
  41977. /**
  41978. * Add orientation input support to the input manager.
  41979. * @returns the current input manager
  41980. */
  41981. addVRDeviceOrientation(): FollowCameraInputsManager;
  41982. }
  41983. }
  41984. declare module "babylonjs/Cameras/followCamera" {
  41985. import { Nullable } from "babylonjs/types";
  41986. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  41987. import { Scene } from "babylonjs/scene";
  41988. import { Vector3 } from "babylonjs/Maths/math.vector";
  41989. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41990. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  41991. /**
  41992. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  41993. * an arc rotate version arcFollowCamera are available.
  41994. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  41995. */
  41996. export class FollowCamera extends TargetCamera {
  41997. /**
  41998. * Distance the follow camera should follow an object at
  41999. */
  42000. radius: number;
  42001. /**
  42002. * Minimum allowed distance of the camera to the axis of rotation
  42003. * (The camera can not get closer).
  42004. * This can help limiting how the Camera is able to move in the scene.
  42005. */
  42006. lowerRadiusLimit: Nullable<number>;
  42007. /**
  42008. * Maximum allowed distance of the camera to the axis of rotation
  42009. * (The camera can not get further).
  42010. * This can help limiting how the Camera is able to move in the scene.
  42011. */
  42012. upperRadiusLimit: Nullable<number>;
  42013. /**
  42014. * Define a rotation offset between the camera and the object it follows
  42015. */
  42016. rotationOffset: number;
  42017. /**
  42018. * Minimum allowed angle to camera position relative to target object.
  42019. * This can help limiting how the Camera is able to move in the scene.
  42020. */
  42021. lowerRotationOffsetLimit: Nullable<number>;
  42022. /**
  42023. * Maximum allowed angle to camera position relative to target object.
  42024. * This can help limiting how the Camera is able to move in the scene.
  42025. */
  42026. upperRotationOffsetLimit: Nullable<number>;
  42027. /**
  42028. * Define a height offset between the camera and the object it follows.
  42029. * It can help following an object from the top (like a car chaing a plane)
  42030. */
  42031. heightOffset: number;
  42032. /**
  42033. * Minimum allowed height of camera position relative to target object.
  42034. * This can help limiting how the Camera is able to move in the scene.
  42035. */
  42036. lowerHeightOffsetLimit: Nullable<number>;
  42037. /**
  42038. * Maximum allowed height of camera position relative to target object.
  42039. * This can help limiting how the Camera is able to move in the scene.
  42040. */
  42041. upperHeightOffsetLimit: Nullable<number>;
  42042. /**
  42043. * Define how fast the camera can accelerate to follow it s target.
  42044. */
  42045. cameraAcceleration: number;
  42046. /**
  42047. * Define the speed limit of the camera following an object.
  42048. */
  42049. maxCameraSpeed: number;
  42050. /**
  42051. * Define the target of the camera.
  42052. */
  42053. lockedTarget: Nullable<AbstractMesh>;
  42054. /**
  42055. * Defines the input associated with the camera.
  42056. */
  42057. inputs: FollowCameraInputsManager;
  42058. /**
  42059. * Instantiates the follow camera.
  42060. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42061. * @param name Define the name of the camera in the scene
  42062. * @param position Define the position of the camera
  42063. * @param scene Define the scene the camera belong to
  42064. * @param lockedTarget Define the target of the camera
  42065. */
  42066. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  42067. private _follow;
  42068. /**
  42069. * Attached controls to the current camera.
  42070. * @param element Defines the element the controls should be listened from
  42071. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42072. */
  42073. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42074. /**
  42075. * Detach the current controls from the camera.
  42076. * The camera will stop reacting to inputs.
  42077. * @param element Defines the element to stop listening the inputs from
  42078. */
  42079. detachControl(element: HTMLElement): void;
  42080. /** @hidden */
  42081. _checkInputs(): void;
  42082. private _checkLimits;
  42083. /**
  42084. * Gets the camera class name.
  42085. * @returns the class name
  42086. */
  42087. getClassName(): string;
  42088. }
  42089. /**
  42090. * Arc Rotate version of the follow camera.
  42091. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  42092. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42093. */
  42094. export class ArcFollowCamera extends TargetCamera {
  42095. /** The longitudinal angle of the camera */
  42096. alpha: number;
  42097. /** The latitudinal angle of the camera */
  42098. beta: number;
  42099. /** The radius of the camera from its target */
  42100. radius: number;
  42101. /** Define the camera target (the messh it should follow) */
  42102. target: Nullable<AbstractMesh>;
  42103. private _cartesianCoordinates;
  42104. /**
  42105. * Instantiates a new ArcFollowCamera
  42106. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  42107. * @param name Define the name of the camera
  42108. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  42109. * @param beta Define the rotation angle of the camera around the elevation axis
  42110. * @param radius Define the radius of the camera from its target point
  42111. * @param target Define the target of the camera
  42112. * @param scene Define the scene the camera belongs to
  42113. */
  42114. constructor(name: string,
  42115. /** The longitudinal angle of the camera */
  42116. alpha: number,
  42117. /** The latitudinal angle of the camera */
  42118. beta: number,
  42119. /** The radius of the camera from its target */
  42120. radius: number,
  42121. /** Define the camera target (the messh it should follow) */
  42122. target: Nullable<AbstractMesh>, scene: Scene);
  42123. private _follow;
  42124. /** @hidden */
  42125. _checkInputs(): void;
  42126. /**
  42127. * Returns the class name of the object.
  42128. * It is mostly used internally for serialization purposes.
  42129. */
  42130. getClassName(): string;
  42131. }
  42132. }
  42133. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  42134. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42135. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  42136. import { Nullable } from "babylonjs/types";
  42137. /**
  42138. * Manage the keyboard inputs to control the movement of a follow camera.
  42139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42140. */
  42141. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  42142. /**
  42143. * Defines the camera the input is attached to.
  42144. */
  42145. camera: FollowCamera;
  42146. /**
  42147. * Defines the list of key codes associated with the up action (increase heightOffset)
  42148. */
  42149. keysHeightOffsetIncr: number[];
  42150. /**
  42151. * Defines the list of key codes associated with the down action (decrease heightOffset)
  42152. */
  42153. keysHeightOffsetDecr: number[];
  42154. /**
  42155. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  42156. */
  42157. keysHeightOffsetModifierAlt: boolean;
  42158. /**
  42159. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  42160. */
  42161. keysHeightOffsetModifierCtrl: boolean;
  42162. /**
  42163. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  42164. */
  42165. keysHeightOffsetModifierShift: boolean;
  42166. /**
  42167. * Defines the list of key codes associated with the left action (increase rotationOffset)
  42168. */
  42169. keysRotationOffsetIncr: number[];
  42170. /**
  42171. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  42172. */
  42173. keysRotationOffsetDecr: number[];
  42174. /**
  42175. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  42176. */
  42177. keysRotationOffsetModifierAlt: boolean;
  42178. /**
  42179. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  42180. */
  42181. keysRotationOffsetModifierCtrl: boolean;
  42182. /**
  42183. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  42184. */
  42185. keysRotationOffsetModifierShift: boolean;
  42186. /**
  42187. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  42188. */
  42189. keysRadiusIncr: number[];
  42190. /**
  42191. * Defines the list of key codes associated with the zoom-out action (increase radius)
  42192. */
  42193. keysRadiusDecr: number[];
  42194. /**
  42195. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  42196. */
  42197. keysRadiusModifierAlt: boolean;
  42198. /**
  42199. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  42200. */
  42201. keysRadiusModifierCtrl: boolean;
  42202. /**
  42203. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  42204. */
  42205. keysRadiusModifierShift: boolean;
  42206. /**
  42207. * Defines the rate of change of heightOffset.
  42208. */
  42209. heightSensibility: number;
  42210. /**
  42211. * Defines the rate of change of rotationOffset.
  42212. */
  42213. rotationSensibility: number;
  42214. /**
  42215. * Defines the rate of change of radius.
  42216. */
  42217. radiusSensibility: number;
  42218. private _keys;
  42219. private _ctrlPressed;
  42220. private _altPressed;
  42221. private _shiftPressed;
  42222. private _onCanvasBlurObserver;
  42223. private _onKeyboardObserver;
  42224. private _engine;
  42225. private _scene;
  42226. /**
  42227. * Attach the input controls to a specific dom element to get the input from.
  42228. * @param element Defines the element the controls should be listened from
  42229. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42230. */
  42231. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42232. /**
  42233. * Detach the current controls from the specified dom element.
  42234. * @param element Defines the element to stop listening the inputs from
  42235. */
  42236. detachControl(element: Nullable<HTMLElement>): void;
  42237. /**
  42238. * Update the current camera state depending on the inputs that have been used this frame.
  42239. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42240. */
  42241. checkInputs(): void;
  42242. /**
  42243. * Gets the class name of the current input.
  42244. * @returns the class name
  42245. */
  42246. getClassName(): string;
  42247. /**
  42248. * Get the friendly name associated with the input class.
  42249. * @returns the input friendly name
  42250. */
  42251. getSimpleName(): string;
  42252. /**
  42253. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42254. * allow modification of the heightOffset value.
  42255. */
  42256. private _modifierHeightOffset;
  42257. /**
  42258. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42259. * allow modification of the rotationOffset value.
  42260. */
  42261. private _modifierRotationOffset;
  42262. /**
  42263. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  42264. * allow modification of the radius value.
  42265. */
  42266. private _modifierRadius;
  42267. }
  42268. }
  42269. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  42270. import { Nullable } from "babylonjs/types";
  42271. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42272. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42273. import { Observable } from "babylonjs/Misc/observable";
  42274. module "babylonjs/Cameras/freeCameraInputsManager" {
  42275. interface FreeCameraInputsManager {
  42276. /**
  42277. * @hidden
  42278. */
  42279. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  42280. /**
  42281. * Add orientation input support to the input manager.
  42282. * @returns the current input manager
  42283. */
  42284. addDeviceOrientation(): FreeCameraInputsManager;
  42285. }
  42286. }
  42287. /**
  42288. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  42289. * Screen rotation is taken into account.
  42290. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42291. */
  42292. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  42293. private _camera;
  42294. private _screenOrientationAngle;
  42295. private _constantTranform;
  42296. private _screenQuaternion;
  42297. private _alpha;
  42298. private _beta;
  42299. private _gamma;
  42300. /**
  42301. * Can be used to detect if a device orientation sensor is available on a device
  42302. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  42303. * @returns a promise that will resolve on orientation change
  42304. */
  42305. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  42306. /**
  42307. * @hidden
  42308. */
  42309. _onDeviceOrientationChangedObservable: Observable<void>;
  42310. /**
  42311. * Instantiates a new input
  42312. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42313. */
  42314. constructor();
  42315. /**
  42316. * Define the camera controlled by the input.
  42317. */
  42318. get camera(): FreeCamera;
  42319. set camera(camera: FreeCamera);
  42320. /**
  42321. * Attach the input controls to a specific dom element to get the input from.
  42322. * @param element Defines the element the controls should be listened from
  42323. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42324. */
  42325. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42326. private _orientationChanged;
  42327. private _deviceOrientation;
  42328. /**
  42329. * Detach the current controls from the specified dom element.
  42330. * @param element Defines the element to stop listening the inputs from
  42331. */
  42332. detachControl(element: Nullable<HTMLElement>): void;
  42333. /**
  42334. * Update the current camera state depending on the inputs that have been used this frame.
  42335. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42336. */
  42337. checkInputs(): void;
  42338. /**
  42339. * Gets the class name of the current intput.
  42340. * @returns the class name
  42341. */
  42342. getClassName(): string;
  42343. /**
  42344. * Get the friendly name associated with the input class.
  42345. * @returns the input friendly name
  42346. */
  42347. getSimpleName(): string;
  42348. }
  42349. }
  42350. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  42351. import { Nullable } from "babylonjs/types";
  42352. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42353. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42354. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42355. /**
  42356. * Manage the gamepad inputs to control a free camera.
  42357. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42358. */
  42359. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  42360. /**
  42361. * Define the camera the input is attached to.
  42362. */
  42363. camera: FreeCamera;
  42364. /**
  42365. * Define the Gamepad controlling the input
  42366. */
  42367. gamepad: Nullable<Gamepad>;
  42368. /**
  42369. * Defines the gamepad rotation sensiblity.
  42370. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  42371. */
  42372. gamepadAngularSensibility: number;
  42373. /**
  42374. * Defines the gamepad move sensiblity.
  42375. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  42376. */
  42377. gamepadMoveSensibility: number;
  42378. private _yAxisScale;
  42379. /**
  42380. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  42381. */
  42382. get invertYAxis(): boolean;
  42383. set invertYAxis(value: boolean);
  42384. private _onGamepadConnectedObserver;
  42385. private _onGamepadDisconnectedObserver;
  42386. private _cameraTransform;
  42387. private _deltaTransform;
  42388. private _vector3;
  42389. private _vector2;
  42390. /**
  42391. * Attach the input controls to a specific dom element to get the input from.
  42392. * @param element Defines the element the controls should be listened from
  42393. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42394. */
  42395. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42396. /**
  42397. * Detach the current controls from the specified dom element.
  42398. * @param element Defines the element to stop listening the inputs from
  42399. */
  42400. detachControl(element: Nullable<HTMLElement>): void;
  42401. /**
  42402. * Update the current camera state depending on the inputs that have been used this frame.
  42403. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42404. */
  42405. checkInputs(): void;
  42406. /**
  42407. * Gets the class name of the current intput.
  42408. * @returns the class name
  42409. */
  42410. getClassName(): string;
  42411. /**
  42412. * Get the friendly name associated with the input class.
  42413. * @returns the input friendly name
  42414. */
  42415. getSimpleName(): string;
  42416. }
  42417. }
  42418. declare module "babylonjs/Misc/virtualJoystick" {
  42419. import { Nullable } from "babylonjs/types";
  42420. import { Vector3 } from "babylonjs/Maths/math.vector";
  42421. /**
  42422. * Defines the potential axis of a Joystick
  42423. */
  42424. export enum JoystickAxis {
  42425. /** X axis */
  42426. X = 0,
  42427. /** Y axis */
  42428. Y = 1,
  42429. /** Z axis */
  42430. Z = 2
  42431. }
  42432. /**
  42433. * Class used to define virtual joystick (used in touch mode)
  42434. */
  42435. export class VirtualJoystick {
  42436. /**
  42437. * Gets or sets a boolean indicating that left and right values must be inverted
  42438. */
  42439. reverseLeftRight: boolean;
  42440. /**
  42441. * Gets or sets a boolean indicating that up and down values must be inverted
  42442. */
  42443. reverseUpDown: boolean;
  42444. /**
  42445. * Gets the offset value for the position (ie. the change of the position value)
  42446. */
  42447. deltaPosition: Vector3;
  42448. /**
  42449. * Gets a boolean indicating if the virtual joystick was pressed
  42450. */
  42451. pressed: boolean;
  42452. /**
  42453. * Canvas the virtual joystick will render onto, default z-index of this is 5
  42454. */
  42455. static Canvas: Nullable<HTMLCanvasElement>;
  42456. private static _globalJoystickIndex;
  42457. private static vjCanvasContext;
  42458. private static vjCanvasWidth;
  42459. private static vjCanvasHeight;
  42460. private static halfWidth;
  42461. private _action;
  42462. private _axisTargetedByLeftAndRight;
  42463. private _axisTargetedByUpAndDown;
  42464. private _joystickSensibility;
  42465. private _inversedSensibility;
  42466. private _joystickPointerID;
  42467. private _joystickColor;
  42468. private _joystickPointerPos;
  42469. private _joystickPreviousPointerPos;
  42470. private _joystickPointerStartPos;
  42471. private _deltaJoystickVector;
  42472. private _leftJoystick;
  42473. private _touches;
  42474. private _onPointerDownHandlerRef;
  42475. private _onPointerMoveHandlerRef;
  42476. private _onPointerUpHandlerRef;
  42477. private _onResize;
  42478. /**
  42479. * Creates a new virtual joystick
  42480. * @param leftJoystick defines that the joystick is for left hand (false by default)
  42481. */
  42482. constructor(leftJoystick?: boolean);
  42483. /**
  42484. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  42485. * @param newJoystickSensibility defines the new sensibility
  42486. */
  42487. setJoystickSensibility(newJoystickSensibility: number): void;
  42488. private _onPointerDown;
  42489. private _onPointerMove;
  42490. private _onPointerUp;
  42491. /**
  42492. * Change the color of the virtual joystick
  42493. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  42494. */
  42495. setJoystickColor(newColor: string): void;
  42496. /**
  42497. * Defines a callback to call when the joystick is touched
  42498. * @param action defines the callback
  42499. */
  42500. setActionOnTouch(action: () => any): void;
  42501. /**
  42502. * Defines which axis you'd like to control for left & right
  42503. * @param axis defines the axis to use
  42504. */
  42505. setAxisForLeftRight(axis: JoystickAxis): void;
  42506. /**
  42507. * Defines which axis you'd like to control for up & down
  42508. * @param axis defines the axis to use
  42509. */
  42510. setAxisForUpDown(axis: JoystickAxis): void;
  42511. private _drawVirtualJoystick;
  42512. /**
  42513. * Release internal HTML canvas
  42514. */
  42515. releaseCanvas(): void;
  42516. }
  42517. }
  42518. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  42519. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  42520. import { Nullable } from "babylonjs/types";
  42521. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  42522. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42523. module "babylonjs/Cameras/freeCameraInputsManager" {
  42524. interface FreeCameraInputsManager {
  42525. /**
  42526. * Add virtual joystick input support to the input manager.
  42527. * @returns the current input manager
  42528. */
  42529. addVirtualJoystick(): FreeCameraInputsManager;
  42530. }
  42531. }
  42532. /**
  42533. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  42534. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  42535. */
  42536. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  42537. /**
  42538. * Defines the camera the input is attached to.
  42539. */
  42540. camera: FreeCamera;
  42541. private _leftjoystick;
  42542. private _rightjoystick;
  42543. /**
  42544. * Gets the left stick of the virtual joystick.
  42545. * @returns The virtual Joystick
  42546. */
  42547. getLeftJoystick(): VirtualJoystick;
  42548. /**
  42549. * Gets the right stick of the virtual joystick.
  42550. * @returns The virtual Joystick
  42551. */
  42552. getRightJoystick(): VirtualJoystick;
  42553. /**
  42554. * Update the current camera state depending on the inputs that have been used this frame.
  42555. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  42556. */
  42557. checkInputs(): void;
  42558. /**
  42559. * Attach the input controls to a specific dom element to get the input from.
  42560. * @param element Defines the element the controls should be listened from
  42561. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  42562. */
  42563. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  42564. /**
  42565. * Detach the current controls from the specified dom element.
  42566. * @param element Defines the element to stop listening the inputs from
  42567. */
  42568. detachControl(element: Nullable<HTMLElement>): void;
  42569. /**
  42570. * Gets the class name of the current intput.
  42571. * @returns the class name
  42572. */
  42573. getClassName(): string;
  42574. /**
  42575. * Get the friendly name associated with the input class.
  42576. * @returns the input friendly name
  42577. */
  42578. getSimpleName(): string;
  42579. }
  42580. }
  42581. declare module "babylonjs/Cameras/Inputs/index" {
  42582. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  42583. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  42584. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  42585. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  42586. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  42587. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  42588. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  42589. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  42590. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  42591. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  42592. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42593. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  42594. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  42595. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  42596. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  42597. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  42598. }
  42599. declare module "babylonjs/Cameras/touchCamera" {
  42600. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42601. import { Scene } from "babylonjs/scene";
  42602. import { Vector3 } from "babylonjs/Maths/math.vector";
  42603. /**
  42604. * This represents a FPS type of camera controlled by touch.
  42605. * This is like a universal camera minus the Gamepad controls.
  42606. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42607. */
  42608. export class TouchCamera extends FreeCamera {
  42609. /**
  42610. * Defines the touch sensibility for rotation.
  42611. * The higher the faster.
  42612. */
  42613. get touchAngularSensibility(): number;
  42614. set touchAngularSensibility(value: number);
  42615. /**
  42616. * Defines the touch sensibility for move.
  42617. * The higher the faster.
  42618. */
  42619. get touchMoveSensibility(): number;
  42620. set touchMoveSensibility(value: number);
  42621. /**
  42622. * Instantiates a new touch camera.
  42623. * This represents a FPS type of camera controlled by touch.
  42624. * This is like a universal camera minus the Gamepad controls.
  42625. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  42626. * @param name Define the name of the camera in the scene
  42627. * @param position Define the start position of the camera in the scene
  42628. * @param scene Define the scene the camera belongs to
  42629. */
  42630. constructor(name: string, position: Vector3, scene: Scene);
  42631. /**
  42632. * Gets the current object class name.
  42633. * @return the class name
  42634. */
  42635. getClassName(): string;
  42636. /** @hidden */
  42637. _setupInputs(): void;
  42638. }
  42639. }
  42640. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  42641. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  42642. import { Scene } from "babylonjs/scene";
  42643. import { Vector3 } from "babylonjs/Maths/math.vector";
  42644. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  42645. import { Axis } from "babylonjs/Maths/math.axis";
  42646. /**
  42647. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  42648. * being tilted forward or back and left or right.
  42649. */
  42650. export class DeviceOrientationCamera extends FreeCamera {
  42651. private _initialQuaternion;
  42652. private _quaternionCache;
  42653. private _tmpDragQuaternion;
  42654. private _disablePointerInputWhenUsingDeviceOrientation;
  42655. /**
  42656. * Creates a new device orientation camera
  42657. * @param name The name of the camera
  42658. * @param position The start position camera
  42659. * @param scene The scene the camera belongs to
  42660. */
  42661. constructor(name: string, position: Vector3, scene: Scene);
  42662. /**
  42663. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  42664. */
  42665. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  42666. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  42667. private _dragFactor;
  42668. /**
  42669. * Enabled turning on the y axis when the orientation sensor is active
  42670. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  42671. */
  42672. enableHorizontalDragging(dragFactor?: number): void;
  42673. /**
  42674. * Gets the current instance class name ("DeviceOrientationCamera").
  42675. * This helps avoiding instanceof at run time.
  42676. * @returns the class name
  42677. */
  42678. getClassName(): string;
  42679. /**
  42680. * @hidden
  42681. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  42682. */
  42683. _checkInputs(): void;
  42684. /**
  42685. * Reset the camera to its default orientation on the specified axis only.
  42686. * @param axis The axis to reset
  42687. */
  42688. resetToCurrentRotation(axis?: Axis): void;
  42689. }
  42690. }
  42691. declare module "babylonjs/Gamepads/xboxGamepad" {
  42692. import { Observable } from "babylonjs/Misc/observable";
  42693. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42694. /**
  42695. * Defines supported buttons for XBox360 compatible gamepads
  42696. */
  42697. export enum Xbox360Button {
  42698. /** A */
  42699. A = 0,
  42700. /** B */
  42701. B = 1,
  42702. /** X */
  42703. X = 2,
  42704. /** Y */
  42705. Y = 3,
  42706. /** Left button */
  42707. LB = 4,
  42708. /** Right button */
  42709. RB = 5,
  42710. /** Back */
  42711. Back = 8,
  42712. /** Start */
  42713. Start = 9,
  42714. /** Left stick */
  42715. LeftStick = 10,
  42716. /** Right stick */
  42717. RightStick = 11
  42718. }
  42719. /** Defines values for XBox360 DPad */
  42720. export enum Xbox360Dpad {
  42721. /** Up */
  42722. Up = 12,
  42723. /** Down */
  42724. Down = 13,
  42725. /** Left */
  42726. Left = 14,
  42727. /** Right */
  42728. Right = 15
  42729. }
  42730. /**
  42731. * Defines a XBox360 gamepad
  42732. */
  42733. export class Xbox360Pad extends Gamepad {
  42734. private _leftTrigger;
  42735. private _rightTrigger;
  42736. private _onlefttriggerchanged;
  42737. private _onrighttriggerchanged;
  42738. private _onbuttondown;
  42739. private _onbuttonup;
  42740. private _ondpaddown;
  42741. private _ondpadup;
  42742. /** Observable raised when a button is pressed */
  42743. onButtonDownObservable: Observable<Xbox360Button>;
  42744. /** Observable raised when a button is released */
  42745. onButtonUpObservable: Observable<Xbox360Button>;
  42746. /** Observable raised when a pad is pressed */
  42747. onPadDownObservable: Observable<Xbox360Dpad>;
  42748. /** Observable raised when a pad is released */
  42749. onPadUpObservable: Observable<Xbox360Dpad>;
  42750. private _buttonA;
  42751. private _buttonB;
  42752. private _buttonX;
  42753. private _buttonY;
  42754. private _buttonBack;
  42755. private _buttonStart;
  42756. private _buttonLB;
  42757. private _buttonRB;
  42758. private _buttonLeftStick;
  42759. private _buttonRightStick;
  42760. private _dPadUp;
  42761. private _dPadDown;
  42762. private _dPadLeft;
  42763. private _dPadRight;
  42764. private _isXboxOnePad;
  42765. /**
  42766. * Creates a new XBox360 gamepad object
  42767. * @param id defines the id of this gamepad
  42768. * @param index defines its index
  42769. * @param gamepad defines the internal HTML gamepad object
  42770. * @param xboxOne defines if it is a XBox One gamepad
  42771. */
  42772. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  42773. /**
  42774. * Defines the callback to call when left trigger is pressed
  42775. * @param callback defines the callback to use
  42776. */
  42777. onlefttriggerchanged(callback: (value: number) => void): void;
  42778. /**
  42779. * Defines the callback to call when right trigger is pressed
  42780. * @param callback defines the callback to use
  42781. */
  42782. onrighttriggerchanged(callback: (value: number) => void): void;
  42783. /**
  42784. * Gets the left trigger value
  42785. */
  42786. get leftTrigger(): number;
  42787. /**
  42788. * Sets the left trigger value
  42789. */
  42790. set leftTrigger(newValue: number);
  42791. /**
  42792. * Gets the right trigger value
  42793. */
  42794. get rightTrigger(): number;
  42795. /**
  42796. * Sets the right trigger value
  42797. */
  42798. set rightTrigger(newValue: number);
  42799. /**
  42800. * Defines the callback to call when a button is pressed
  42801. * @param callback defines the callback to use
  42802. */
  42803. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  42804. /**
  42805. * Defines the callback to call when a button is released
  42806. * @param callback defines the callback to use
  42807. */
  42808. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  42809. /**
  42810. * Defines the callback to call when a pad is pressed
  42811. * @param callback defines the callback to use
  42812. */
  42813. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  42814. /**
  42815. * Defines the callback to call when a pad is released
  42816. * @param callback defines the callback to use
  42817. */
  42818. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  42819. private _setButtonValue;
  42820. private _setDPadValue;
  42821. /**
  42822. * Gets the value of the `A` button
  42823. */
  42824. get buttonA(): number;
  42825. /**
  42826. * Sets the value of the `A` button
  42827. */
  42828. set buttonA(value: number);
  42829. /**
  42830. * Gets the value of the `B` button
  42831. */
  42832. get buttonB(): number;
  42833. /**
  42834. * Sets the value of the `B` button
  42835. */
  42836. set buttonB(value: number);
  42837. /**
  42838. * Gets the value of the `X` button
  42839. */
  42840. get buttonX(): number;
  42841. /**
  42842. * Sets the value of the `X` button
  42843. */
  42844. set buttonX(value: number);
  42845. /**
  42846. * Gets the value of the `Y` button
  42847. */
  42848. get buttonY(): number;
  42849. /**
  42850. * Sets the value of the `Y` button
  42851. */
  42852. set buttonY(value: number);
  42853. /**
  42854. * Gets the value of the `Start` button
  42855. */
  42856. get buttonStart(): number;
  42857. /**
  42858. * Sets the value of the `Start` button
  42859. */
  42860. set buttonStart(value: number);
  42861. /**
  42862. * Gets the value of the `Back` button
  42863. */
  42864. get buttonBack(): number;
  42865. /**
  42866. * Sets the value of the `Back` button
  42867. */
  42868. set buttonBack(value: number);
  42869. /**
  42870. * Gets the value of the `Left` button
  42871. */
  42872. get buttonLB(): number;
  42873. /**
  42874. * Sets the value of the `Left` button
  42875. */
  42876. set buttonLB(value: number);
  42877. /**
  42878. * Gets the value of the `Right` button
  42879. */
  42880. get buttonRB(): number;
  42881. /**
  42882. * Sets the value of the `Right` button
  42883. */
  42884. set buttonRB(value: number);
  42885. /**
  42886. * Gets the value of the Left joystick
  42887. */
  42888. get buttonLeftStick(): number;
  42889. /**
  42890. * Sets the value of the Left joystick
  42891. */
  42892. set buttonLeftStick(value: number);
  42893. /**
  42894. * Gets the value of the Right joystick
  42895. */
  42896. get buttonRightStick(): number;
  42897. /**
  42898. * Sets the value of the Right joystick
  42899. */
  42900. set buttonRightStick(value: number);
  42901. /**
  42902. * Gets the value of D-pad up
  42903. */
  42904. get dPadUp(): number;
  42905. /**
  42906. * Sets the value of D-pad up
  42907. */
  42908. set dPadUp(value: number);
  42909. /**
  42910. * Gets the value of D-pad down
  42911. */
  42912. get dPadDown(): number;
  42913. /**
  42914. * Sets the value of D-pad down
  42915. */
  42916. set dPadDown(value: number);
  42917. /**
  42918. * Gets the value of D-pad left
  42919. */
  42920. get dPadLeft(): number;
  42921. /**
  42922. * Sets the value of D-pad left
  42923. */
  42924. set dPadLeft(value: number);
  42925. /**
  42926. * Gets the value of D-pad right
  42927. */
  42928. get dPadRight(): number;
  42929. /**
  42930. * Sets the value of D-pad right
  42931. */
  42932. set dPadRight(value: number);
  42933. /**
  42934. * Force the gamepad to synchronize with device values
  42935. */
  42936. update(): void;
  42937. /**
  42938. * Disposes the gamepad
  42939. */
  42940. dispose(): void;
  42941. }
  42942. }
  42943. declare module "babylonjs/Gamepads/dualShockGamepad" {
  42944. import { Observable } from "babylonjs/Misc/observable";
  42945. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  42946. /**
  42947. * Defines supported buttons for DualShock compatible gamepads
  42948. */
  42949. export enum DualShockButton {
  42950. /** Cross */
  42951. Cross = 0,
  42952. /** Circle */
  42953. Circle = 1,
  42954. /** Square */
  42955. Square = 2,
  42956. /** Triangle */
  42957. Triangle = 3,
  42958. /** L1 */
  42959. L1 = 4,
  42960. /** R1 */
  42961. R1 = 5,
  42962. /** Share */
  42963. Share = 8,
  42964. /** Options */
  42965. Options = 9,
  42966. /** Left stick */
  42967. LeftStick = 10,
  42968. /** Right stick */
  42969. RightStick = 11
  42970. }
  42971. /** Defines values for DualShock DPad */
  42972. export enum DualShockDpad {
  42973. /** Up */
  42974. Up = 12,
  42975. /** Down */
  42976. Down = 13,
  42977. /** Left */
  42978. Left = 14,
  42979. /** Right */
  42980. Right = 15
  42981. }
  42982. /**
  42983. * Defines a DualShock gamepad
  42984. */
  42985. export class DualShockPad extends Gamepad {
  42986. private _leftTrigger;
  42987. private _rightTrigger;
  42988. private _onlefttriggerchanged;
  42989. private _onrighttriggerchanged;
  42990. private _onbuttondown;
  42991. private _onbuttonup;
  42992. private _ondpaddown;
  42993. private _ondpadup;
  42994. /** Observable raised when a button is pressed */
  42995. onButtonDownObservable: Observable<DualShockButton>;
  42996. /** Observable raised when a button is released */
  42997. onButtonUpObservable: Observable<DualShockButton>;
  42998. /** Observable raised when a pad is pressed */
  42999. onPadDownObservable: Observable<DualShockDpad>;
  43000. /** Observable raised when a pad is released */
  43001. onPadUpObservable: Observable<DualShockDpad>;
  43002. private _buttonCross;
  43003. private _buttonCircle;
  43004. private _buttonSquare;
  43005. private _buttonTriangle;
  43006. private _buttonShare;
  43007. private _buttonOptions;
  43008. private _buttonL1;
  43009. private _buttonR1;
  43010. private _buttonLeftStick;
  43011. private _buttonRightStick;
  43012. private _dPadUp;
  43013. private _dPadDown;
  43014. private _dPadLeft;
  43015. private _dPadRight;
  43016. /**
  43017. * Creates a new DualShock gamepad object
  43018. * @param id defines the id of this gamepad
  43019. * @param index defines its index
  43020. * @param gamepad defines the internal HTML gamepad object
  43021. */
  43022. constructor(id: string, index: number, gamepad: any);
  43023. /**
  43024. * Defines the callback to call when left trigger is pressed
  43025. * @param callback defines the callback to use
  43026. */
  43027. onlefttriggerchanged(callback: (value: number) => void): void;
  43028. /**
  43029. * Defines the callback to call when right trigger is pressed
  43030. * @param callback defines the callback to use
  43031. */
  43032. onrighttriggerchanged(callback: (value: number) => void): void;
  43033. /**
  43034. * Gets the left trigger value
  43035. */
  43036. get leftTrigger(): number;
  43037. /**
  43038. * Sets the left trigger value
  43039. */
  43040. set leftTrigger(newValue: number);
  43041. /**
  43042. * Gets the right trigger value
  43043. */
  43044. get rightTrigger(): number;
  43045. /**
  43046. * Sets the right trigger value
  43047. */
  43048. set rightTrigger(newValue: number);
  43049. /**
  43050. * Defines the callback to call when a button is pressed
  43051. * @param callback defines the callback to use
  43052. */
  43053. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  43054. /**
  43055. * Defines the callback to call when a button is released
  43056. * @param callback defines the callback to use
  43057. */
  43058. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  43059. /**
  43060. * Defines the callback to call when a pad is pressed
  43061. * @param callback defines the callback to use
  43062. */
  43063. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  43064. /**
  43065. * Defines the callback to call when a pad is released
  43066. * @param callback defines the callback to use
  43067. */
  43068. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  43069. private _setButtonValue;
  43070. private _setDPadValue;
  43071. /**
  43072. * Gets the value of the `Cross` button
  43073. */
  43074. get buttonCross(): number;
  43075. /**
  43076. * Sets the value of the `Cross` button
  43077. */
  43078. set buttonCross(value: number);
  43079. /**
  43080. * Gets the value of the `Circle` button
  43081. */
  43082. get buttonCircle(): number;
  43083. /**
  43084. * Sets the value of the `Circle` button
  43085. */
  43086. set buttonCircle(value: number);
  43087. /**
  43088. * Gets the value of the `Square` button
  43089. */
  43090. get buttonSquare(): number;
  43091. /**
  43092. * Sets the value of the `Square` button
  43093. */
  43094. set buttonSquare(value: number);
  43095. /**
  43096. * Gets the value of the `Triangle` button
  43097. */
  43098. get buttonTriangle(): number;
  43099. /**
  43100. * Sets the value of the `Triangle` button
  43101. */
  43102. set buttonTriangle(value: number);
  43103. /**
  43104. * Gets the value of the `Options` button
  43105. */
  43106. get buttonOptions(): number;
  43107. /**
  43108. * Sets the value of the `Options` button
  43109. */
  43110. set buttonOptions(value: number);
  43111. /**
  43112. * Gets the value of the `Share` button
  43113. */
  43114. get buttonShare(): number;
  43115. /**
  43116. * Sets the value of the `Share` button
  43117. */
  43118. set buttonShare(value: number);
  43119. /**
  43120. * Gets the value of the `L1` button
  43121. */
  43122. get buttonL1(): number;
  43123. /**
  43124. * Sets the value of the `L1` button
  43125. */
  43126. set buttonL1(value: number);
  43127. /**
  43128. * Gets the value of the `R1` button
  43129. */
  43130. get buttonR1(): number;
  43131. /**
  43132. * Sets the value of the `R1` button
  43133. */
  43134. set buttonR1(value: number);
  43135. /**
  43136. * Gets the value of the Left joystick
  43137. */
  43138. get buttonLeftStick(): number;
  43139. /**
  43140. * Sets the value of the Left joystick
  43141. */
  43142. set buttonLeftStick(value: number);
  43143. /**
  43144. * Gets the value of the Right joystick
  43145. */
  43146. get buttonRightStick(): number;
  43147. /**
  43148. * Sets the value of the Right joystick
  43149. */
  43150. set buttonRightStick(value: number);
  43151. /**
  43152. * Gets the value of D-pad up
  43153. */
  43154. get dPadUp(): number;
  43155. /**
  43156. * Sets the value of D-pad up
  43157. */
  43158. set dPadUp(value: number);
  43159. /**
  43160. * Gets the value of D-pad down
  43161. */
  43162. get dPadDown(): number;
  43163. /**
  43164. * Sets the value of D-pad down
  43165. */
  43166. set dPadDown(value: number);
  43167. /**
  43168. * Gets the value of D-pad left
  43169. */
  43170. get dPadLeft(): number;
  43171. /**
  43172. * Sets the value of D-pad left
  43173. */
  43174. set dPadLeft(value: number);
  43175. /**
  43176. * Gets the value of D-pad right
  43177. */
  43178. get dPadRight(): number;
  43179. /**
  43180. * Sets the value of D-pad right
  43181. */
  43182. set dPadRight(value: number);
  43183. /**
  43184. * Force the gamepad to synchronize with device values
  43185. */
  43186. update(): void;
  43187. /**
  43188. * Disposes the gamepad
  43189. */
  43190. dispose(): void;
  43191. }
  43192. }
  43193. declare module "babylonjs/Gamepads/gamepadManager" {
  43194. import { Observable } from "babylonjs/Misc/observable";
  43195. import { Nullable } from "babylonjs/types";
  43196. import { Scene } from "babylonjs/scene";
  43197. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  43198. /**
  43199. * Manager for handling gamepads
  43200. */
  43201. export class GamepadManager {
  43202. private _scene?;
  43203. private _babylonGamepads;
  43204. private _oneGamepadConnected;
  43205. /** @hidden */
  43206. _isMonitoring: boolean;
  43207. private _gamepadEventSupported;
  43208. private _gamepadSupport?;
  43209. /**
  43210. * observable to be triggered when the gamepad controller has been connected
  43211. */
  43212. onGamepadConnectedObservable: Observable<Gamepad>;
  43213. /**
  43214. * observable to be triggered when the gamepad controller has been disconnected
  43215. */
  43216. onGamepadDisconnectedObservable: Observable<Gamepad>;
  43217. private _onGamepadConnectedEvent;
  43218. private _onGamepadDisconnectedEvent;
  43219. /**
  43220. * Initializes the gamepad manager
  43221. * @param _scene BabylonJS scene
  43222. */
  43223. constructor(_scene?: Scene | undefined);
  43224. /**
  43225. * The gamepads in the game pad manager
  43226. */
  43227. get gamepads(): Gamepad[];
  43228. /**
  43229. * Get the gamepad controllers based on type
  43230. * @param type The type of gamepad controller
  43231. * @returns Nullable gamepad
  43232. */
  43233. getGamepadByType(type?: number): Nullable<Gamepad>;
  43234. /**
  43235. * Disposes the gamepad manager
  43236. */
  43237. dispose(): void;
  43238. private _addNewGamepad;
  43239. private _startMonitoringGamepads;
  43240. private _stopMonitoringGamepads;
  43241. /** @hidden */
  43242. _checkGamepadsStatus(): void;
  43243. private _updateGamepadObjects;
  43244. }
  43245. }
  43246. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  43247. import { Nullable } from "babylonjs/types";
  43248. import { Scene } from "babylonjs/scene";
  43249. import { ISceneComponent } from "babylonjs/sceneComponent";
  43250. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  43251. module "babylonjs/scene" {
  43252. interface Scene {
  43253. /** @hidden */
  43254. _gamepadManager: Nullable<GamepadManager>;
  43255. /**
  43256. * Gets the gamepad manager associated with the scene
  43257. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  43258. */
  43259. gamepadManager: GamepadManager;
  43260. }
  43261. }
  43262. module "babylonjs/Cameras/freeCameraInputsManager" {
  43263. /**
  43264. * Interface representing a free camera inputs manager
  43265. */
  43266. interface FreeCameraInputsManager {
  43267. /**
  43268. * Adds gamepad input support to the FreeCameraInputsManager.
  43269. * @returns the FreeCameraInputsManager
  43270. */
  43271. addGamepad(): FreeCameraInputsManager;
  43272. }
  43273. }
  43274. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  43275. /**
  43276. * Interface representing an arc rotate camera inputs manager
  43277. */
  43278. interface ArcRotateCameraInputsManager {
  43279. /**
  43280. * Adds gamepad input support to the ArcRotateCamera InputManager.
  43281. * @returns the camera inputs manager
  43282. */
  43283. addGamepad(): ArcRotateCameraInputsManager;
  43284. }
  43285. }
  43286. /**
  43287. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  43288. */
  43289. export class GamepadSystemSceneComponent implements ISceneComponent {
  43290. /**
  43291. * The component name helpfull to identify the component in the list of scene components.
  43292. */
  43293. readonly name: string;
  43294. /**
  43295. * The scene the component belongs to.
  43296. */
  43297. scene: Scene;
  43298. /**
  43299. * Creates a new instance of the component for the given scene
  43300. * @param scene Defines the scene to register the component in
  43301. */
  43302. constructor(scene: Scene);
  43303. /**
  43304. * Registers the component in a given scene
  43305. */
  43306. register(): void;
  43307. /**
  43308. * Rebuilds the elements related to this component in case of
  43309. * context lost for instance.
  43310. */
  43311. rebuild(): void;
  43312. /**
  43313. * Disposes the component and the associated ressources
  43314. */
  43315. dispose(): void;
  43316. private _beforeCameraUpdate;
  43317. }
  43318. }
  43319. declare module "babylonjs/Cameras/universalCamera" {
  43320. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  43321. import { Scene } from "babylonjs/scene";
  43322. import { Vector3 } from "babylonjs/Maths/math.vector";
  43323. import "babylonjs/Gamepads/gamepadSceneComponent";
  43324. /**
  43325. * 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,
  43326. * which still works and will still be found in many Playgrounds.
  43327. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43328. */
  43329. export class UniversalCamera extends TouchCamera {
  43330. /**
  43331. * Defines the gamepad rotation sensiblity.
  43332. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  43333. */
  43334. get gamepadAngularSensibility(): number;
  43335. set gamepadAngularSensibility(value: number);
  43336. /**
  43337. * Defines the gamepad move sensiblity.
  43338. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  43339. */
  43340. get gamepadMoveSensibility(): number;
  43341. set gamepadMoveSensibility(value: number);
  43342. /**
  43343. * 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,
  43344. * which still works and will still be found in many Playgrounds.
  43345. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43346. * @param name Define the name of the camera in the scene
  43347. * @param position Define the start position of the camera in the scene
  43348. * @param scene Define the scene the camera belongs to
  43349. */
  43350. constructor(name: string, position: Vector3, scene: Scene);
  43351. /**
  43352. * Gets the current object class name.
  43353. * @return the class name
  43354. */
  43355. getClassName(): string;
  43356. }
  43357. }
  43358. declare module "babylonjs/Cameras/gamepadCamera" {
  43359. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43360. import { Scene } from "babylonjs/scene";
  43361. import { Vector3 } from "babylonjs/Maths/math.vector";
  43362. /**
  43363. * This represents a FPS type of camera. This is only here for back compat purpose.
  43364. * Please use the UniversalCamera instead as both are identical.
  43365. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43366. */
  43367. export class GamepadCamera extends UniversalCamera {
  43368. /**
  43369. * Instantiates a new Gamepad Camera
  43370. * This represents a FPS type of camera. This is only here for back compat purpose.
  43371. * Please use the UniversalCamera instead as both are identical.
  43372. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  43373. * @param name Define the name of the camera in the scene
  43374. * @param position Define the start position of the camera in the scene
  43375. * @param scene Define the scene the camera belongs to
  43376. */
  43377. constructor(name: string, position: Vector3, scene: Scene);
  43378. /**
  43379. * Gets the current object class name.
  43380. * @return the class name
  43381. */
  43382. getClassName(): string;
  43383. }
  43384. }
  43385. declare module "babylonjs/Shaders/pass.fragment" {
  43386. /** @hidden */
  43387. export var passPixelShader: {
  43388. name: string;
  43389. shader: string;
  43390. };
  43391. }
  43392. declare module "babylonjs/Shaders/passCube.fragment" {
  43393. /** @hidden */
  43394. export var passCubePixelShader: {
  43395. name: string;
  43396. shader: string;
  43397. };
  43398. }
  43399. declare module "babylonjs/PostProcesses/passPostProcess" {
  43400. import { Nullable } from "babylonjs/types";
  43401. import { Camera } from "babylonjs/Cameras/camera";
  43402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43403. import { Engine } from "babylonjs/Engines/engine";
  43404. import "babylonjs/Shaders/pass.fragment";
  43405. import "babylonjs/Shaders/passCube.fragment";
  43406. /**
  43407. * PassPostProcess which produces an output the same as it's input
  43408. */
  43409. export class PassPostProcess extends PostProcess {
  43410. /**
  43411. * Creates the PassPostProcess
  43412. * @param name The name of the effect.
  43413. * @param options The required width/height ratio to downsize to before computing the render pass.
  43414. * @param camera The camera to apply the render pass to.
  43415. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43416. * @param engine The engine which the post process will be applied. (default: current engine)
  43417. * @param reusable If the post process can be reused on the same frame. (default: false)
  43418. * @param textureType The type of texture to be used when performing the post processing.
  43419. * @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)
  43420. */
  43421. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43422. }
  43423. /**
  43424. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  43425. */
  43426. export class PassCubePostProcess extends PostProcess {
  43427. private _face;
  43428. /**
  43429. * Gets or sets the cube face to display.
  43430. * * 0 is +X
  43431. * * 1 is -X
  43432. * * 2 is +Y
  43433. * * 3 is -Y
  43434. * * 4 is +Z
  43435. * * 5 is -Z
  43436. */
  43437. get face(): number;
  43438. set face(value: number);
  43439. /**
  43440. * Creates the PassCubePostProcess
  43441. * @param name The name of the effect.
  43442. * @param options The required width/height ratio to downsize to before computing the render pass.
  43443. * @param camera The camera to apply the render pass to.
  43444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43445. * @param engine The engine which the post process will be applied. (default: current engine)
  43446. * @param reusable If the post process can be reused on the same frame. (default: false)
  43447. * @param textureType The type of texture to be used when performing the post processing.
  43448. * @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)
  43449. */
  43450. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  43451. }
  43452. }
  43453. declare module "babylonjs/Shaders/anaglyph.fragment" {
  43454. /** @hidden */
  43455. export var anaglyphPixelShader: {
  43456. name: string;
  43457. shader: string;
  43458. };
  43459. }
  43460. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  43461. import { Engine } from "babylonjs/Engines/engine";
  43462. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  43463. import { Camera } from "babylonjs/Cameras/camera";
  43464. import "babylonjs/Shaders/anaglyph.fragment";
  43465. /**
  43466. * Postprocess used to generate anaglyphic rendering
  43467. */
  43468. export class AnaglyphPostProcess extends PostProcess {
  43469. private _passedProcess;
  43470. /**
  43471. * Creates a new AnaglyphPostProcess
  43472. * @param name defines postprocess name
  43473. * @param options defines creation options or target ratio scale
  43474. * @param rigCameras defines cameras using this postprocess
  43475. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  43476. * @param engine defines hosting engine
  43477. * @param reusable defines if the postprocess will be reused multiple times per frame
  43478. */
  43479. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  43480. }
  43481. }
  43482. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  43483. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  43484. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43485. import { Scene } from "babylonjs/scene";
  43486. import { Vector3 } from "babylonjs/Maths/math.vector";
  43487. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43488. /**
  43489. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  43490. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43491. */
  43492. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  43493. /**
  43494. * Creates a new AnaglyphArcRotateCamera
  43495. * @param name defines camera name
  43496. * @param alpha defines alpha angle (in radians)
  43497. * @param beta defines beta angle (in radians)
  43498. * @param radius defines radius
  43499. * @param target defines camera target
  43500. * @param interaxialDistance defines distance between each color axis
  43501. * @param scene defines the hosting scene
  43502. */
  43503. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  43504. /**
  43505. * Gets camera class name
  43506. * @returns AnaglyphArcRotateCamera
  43507. */
  43508. getClassName(): string;
  43509. }
  43510. }
  43511. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  43512. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43513. import { Scene } from "babylonjs/scene";
  43514. import { Vector3 } from "babylonjs/Maths/math.vector";
  43515. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43516. /**
  43517. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  43518. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43519. */
  43520. export class AnaglyphFreeCamera extends FreeCamera {
  43521. /**
  43522. * Creates a new AnaglyphFreeCamera
  43523. * @param name defines camera name
  43524. * @param position defines initial position
  43525. * @param interaxialDistance defines distance between each color axis
  43526. * @param scene defines the hosting scene
  43527. */
  43528. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43529. /**
  43530. * Gets camera class name
  43531. * @returns AnaglyphFreeCamera
  43532. */
  43533. getClassName(): string;
  43534. }
  43535. }
  43536. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  43537. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43538. import { Scene } from "babylonjs/scene";
  43539. import { Vector3 } from "babylonjs/Maths/math.vector";
  43540. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43541. /**
  43542. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  43543. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43544. */
  43545. export class AnaglyphGamepadCamera extends GamepadCamera {
  43546. /**
  43547. * Creates a new AnaglyphGamepadCamera
  43548. * @param name defines camera name
  43549. * @param position defines initial position
  43550. * @param interaxialDistance defines distance between each color axis
  43551. * @param scene defines the hosting scene
  43552. */
  43553. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43554. /**
  43555. * Gets camera class name
  43556. * @returns AnaglyphGamepadCamera
  43557. */
  43558. getClassName(): string;
  43559. }
  43560. }
  43561. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  43562. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43563. import { Scene } from "babylonjs/scene";
  43564. import { Vector3 } from "babylonjs/Maths/math.vector";
  43565. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  43566. /**
  43567. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  43568. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  43569. */
  43570. export class AnaglyphUniversalCamera extends UniversalCamera {
  43571. /**
  43572. * Creates a new AnaglyphUniversalCamera
  43573. * @param name defines camera name
  43574. * @param position defines initial position
  43575. * @param interaxialDistance defines distance between each color axis
  43576. * @param scene defines the hosting scene
  43577. */
  43578. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  43579. /**
  43580. * Gets camera class name
  43581. * @returns AnaglyphUniversalCamera
  43582. */
  43583. getClassName(): string;
  43584. }
  43585. }
  43586. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  43587. /** @hidden */
  43588. export var stereoscopicInterlacePixelShader: {
  43589. name: string;
  43590. shader: string;
  43591. };
  43592. }
  43593. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  43594. import { Camera } from "babylonjs/Cameras/camera";
  43595. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43596. import { Engine } from "babylonjs/Engines/engine";
  43597. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  43598. /**
  43599. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  43600. */
  43601. export class StereoscopicInterlacePostProcessI extends PostProcess {
  43602. private _stepSize;
  43603. private _passedProcess;
  43604. /**
  43605. * Initializes a StereoscopicInterlacePostProcessI
  43606. * @param name The name of the effect.
  43607. * @param rigCameras The rig cameras to be appled to the post process
  43608. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  43609. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  43610. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43611. * @param engine The engine which the post process will be applied. (default: current engine)
  43612. * @param reusable If the post process can be reused on the same frame. (default: false)
  43613. */
  43614. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43615. }
  43616. /**
  43617. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  43618. */
  43619. export class StereoscopicInterlacePostProcess extends PostProcess {
  43620. private _stepSize;
  43621. private _passedProcess;
  43622. /**
  43623. * Initializes a StereoscopicInterlacePostProcess
  43624. * @param name The name of the effect.
  43625. * @param rigCameras The rig cameras to be appled to the post process
  43626. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  43627. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  43628. * @param engine The engine which the post process will be applied. (default: current engine)
  43629. * @param reusable If the post process can be reused on the same frame. (default: false)
  43630. */
  43631. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  43632. }
  43633. }
  43634. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  43635. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  43636. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43637. import { Scene } from "babylonjs/scene";
  43638. import { Vector3 } from "babylonjs/Maths/math.vector";
  43639. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43640. /**
  43641. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  43642. * @see http://doc.babylonjs.com/features/cameras
  43643. */
  43644. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  43645. /**
  43646. * Creates a new StereoscopicArcRotateCamera
  43647. * @param name defines camera name
  43648. * @param alpha defines alpha angle (in radians)
  43649. * @param beta defines beta angle (in radians)
  43650. * @param radius defines radius
  43651. * @param target defines camera target
  43652. * @param interaxialDistance defines distance between each color axis
  43653. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43654. * @param scene defines the hosting scene
  43655. */
  43656. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43657. /**
  43658. * Gets camera class name
  43659. * @returns StereoscopicArcRotateCamera
  43660. */
  43661. getClassName(): string;
  43662. }
  43663. }
  43664. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  43665. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43666. import { Scene } from "babylonjs/scene";
  43667. import { Vector3 } from "babylonjs/Maths/math.vector";
  43668. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43669. /**
  43670. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  43671. * @see http://doc.babylonjs.com/features/cameras
  43672. */
  43673. export class StereoscopicFreeCamera extends FreeCamera {
  43674. /**
  43675. * Creates a new StereoscopicFreeCamera
  43676. * @param name defines camera name
  43677. * @param position defines initial position
  43678. * @param interaxialDistance defines distance between each color axis
  43679. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43680. * @param scene defines the hosting scene
  43681. */
  43682. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43683. /**
  43684. * Gets camera class name
  43685. * @returns StereoscopicFreeCamera
  43686. */
  43687. getClassName(): string;
  43688. }
  43689. }
  43690. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  43691. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  43692. import { Scene } from "babylonjs/scene";
  43693. import { Vector3 } from "babylonjs/Maths/math.vector";
  43694. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43695. /**
  43696. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  43697. * @see http://doc.babylonjs.com/features/cameras
  43698. */
  43699. export class StereoscopicGamepadCamera extends GamepadCamera {
  43700. /**
  43701. * Creates a new StereoscopicGamepadCamera
  43702. * @param name defines camera name
  43703. * @param position defines initial position
  43704. * @param interaxialDistance defines distance between each color axis
  43705. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43706. * @param scene defines the hosting scene
  43707. */
  43708. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43709. /**
  43710. * Gets camera class name
  43711. * @returns StereoscopicGamepadCamera
  43712. */
  43713. getClassName(): string;
  43714. }
  43715. }
  43716. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  43717. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  43718. import { Scene } from "babylonjs/scene";
  43719. import { Vector3 } from "babylonjs/Maths/math.vector";
  43720. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  43721. /**
  43722. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  43723. * @see http://doc.babylonjs.com/features/cameras
  43724. */
  43725. export class StereoscopicUniversalCamera extends UniversalCamera {
  43726. /**
  43727. * Creates a new StereoscopicUniversalCamera
  43728. * @param name defines camera name
  43729. * @param position defines initial position
  43730. * @param interaxialDistance defines distance between each color axis
  43731. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  43732. * @param scene defines the hosting scene
  43733. */
  43734. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  43735. /**
  43736. * Gets camera class name
  43737. * @returns StereoscopicUniversalCamera
  43738. */
  43739. getClassName(): string;
  43740. }
  43741. }
  43742. declare module "babylonjs/Cameras/Stereoscopic/index" {
  43743. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  43744. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  43745. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  43746. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  43747. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  43748. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  43749. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  43750. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  43751. }
  43752. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  43753. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  43754. import { Scene } from "babylonjs/scene";
  43755. import { Vector3 } from "babylonjs/Maths/math.vector";
  43756. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  43757. /**
  43758. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  43759. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43760. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43761. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43762. */
  43763. export class VirtualJoysticksCamera extends FreeCamera {
  43764. /**
  43765. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  43766. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  43767. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  43768. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  43769. * @param name Define the name of the camera in the scene
  43770. * @param position Define the start position of the camera in the scene
  43771. * @param scene Define the scene the camera belongs to
  43772. */
  43773. constructor(name: string, position: Vector3, scene: Scene);
  43774. /**
  43775. * Gets the current object class name.
  43776. * @return the class name
  43777. */
  43778. getClassName(): string;
  43779. }
  43780. }
  43781. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  43782. import { Matrix } from "babylonjs/Maths/math.vector";
  43783. /**
  43784. * This represents all the required metrics to create a VR camera.
  43785. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  43786. */
  43787. export class VRCameraMetrics {
  43788. /**
  43789. * Define the horizontal resolution off the screen.
  43790. */
  43791. hResolution: number;
  43792. /**
  43793. * Define the vertical resolution off the screen.
  43794. */
  43795. vResolution: number;
  43796. /**
  43797. * Define the horizontal screen size.
  43798. */
  43799. hScreenSize: number;
  43800. /**
  43801. * Define the vertical screen size.
  43802. */
  43803. vScreenSize: number;
  43804. /**
  43805. * Define the vertical screen center position.
  43806. */
  43807. vScreenCenter: number;
  43808. /**
  43809. * Define the distance of the eyes to the screen.
  43810. */
  43811. eyeToScreenDistance: number;
  43812. /**
  43813. * Define the distance between both lenses
  43814. */
  43815. lensSeparationDistance: number;
  43816. /**
  43817. * Define the distance between both viewer's eyes.
  43818. */
  43819. interpupillaryDistance: number;
  43820. /**
  43821. * Define the distortion factor of the VR postprocess.
  43822. * Please, touch with care.
  43823. */
  43824. distortionK: number[];
  43825. /**
  43826. * Define the chromatic aberration correction factors for the VR post process.
  43827. */
  43828. chromaAbCorrection: number[];
  43829. /**
  43830. * Define the scale factor of the post process.
  43831. * The smaller the better but the slower.
  43832. */
  43833. postProcessScaleFactor: number;
  43834. /**
  43835. * Define an offset for the lens center.
  43836. */
  43837. lensCenterOffset: number;
  43838. /**
  43839. * Define if the current vr camera should compensate the distortion of the lense or not.
  43840. */
  43841. compensateDistortion: boolean;
  43842. /**
  43843. * Defines if multiview should be enabled when rendering (Default: false)
  43844. */
  43845. multiviewEnabled: boolean;
  43846. /**
  43847. * Gets the rendering aspect ratio based on the provided resolutions.
  43848. */
  43849. get aspectRatio(): number;
  43850. /**
  43851. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  43852. */
  43853. get aspectRatioFov(): number;
  43854. /**
  43855. * @hidden
  43856. */
  43857. get leftHMatrix(): Matrix;
  43858. /**
  43859. * @hidden
  43860. */
  43861. get rightHMatrix(): Matrix;
  43862. /**
  43863. * @hidden
  43864. */
  43865. get leftPreViewMatrix(): Matrix;
  43866. /**
  43867. * @hidden
  43868. */
  43869. get rightPreViewMatrix(): Matrix;
  43870. /**
  43871. * Get the default VRMetrics based on the most generic setup.
  43872. * @returns the default vr metrics
  43873. */
  43874. static GetDefault(): VRCameraMetrics;
  43875. }
  43876. }
  43877. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  43878. /** @hidden */
  43879. export var vrDistortionCorrectionPixelShader: {
  43880. name: string;
  43881. shader: string;
  43882. };
  43883. }
  43884. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  43885. import { Camera } from "babylonjs/Cameras/camera";
  43886. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43887. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  43888. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  43889. /**
  43890. * VRDistortionCorrectionPostProcess used for mobile VR
  43891. */
  43892. export class VRDistortionCorrectionPostProcess extends PostProcess {
  43893. private _isRightEye;
  43894. private _distortionFactors;
  43895. private _postProcessScaleFactor;
  43896. private _lensCenterOffset;
  43897. private _scaleIn;
  43898. private _scaleFactor;
  43899. private _lensCenter;
  43900. /**
  43901. * Initializes the VRDistortionCorrectionPostProcess
  43902. * @param name The name of the effect.
  43903. * @param camera The camera to apply the render pass to.
  43904. * @param isRightEye If this is for the right eye distortion
  43905. * @param vrMetrics All the required metrics for the VR camera
  43906. */
  43907. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  43908. }
  43909. }
  43910. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  43911. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  43912. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43913. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43914. import { Scene } from "babylonjs/scene";
  43915. import { Vector3 } from "babylonjs/Maths/math.vector";
  43916. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  43917. import "babylonjs/Cameras/RigModes/vrRigMode";
  43918. /**
  43919. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  43920. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43921. */
  43922. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  43923. /**
  43924. * Creates a new VRDeviceOrientationArcRotateCamera
  43925. * @param name defines camera name
  43926. * @param alpha defines the camera rotation along the logitudinal axis
  43927. * @param beta defines the camera rotation along the latitudinal axis
  43928. * @param radius defines the camera distance from its target
  43929. * @param target defines the camera target
  43930. * @param scene defines the scene the camera belongs to
  43931. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43932. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43933. */
  43934. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43935. /**
  43936. * Gets camera class name
  43937. * @returns VRDeviceOrientationArcRotateCamera
  43938. */
  43939. getClassName(): string;
  43940. }
  43941. }
  43942. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  43943. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  43944. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43945. import { Scene } from "babylonjs/scene";
  43946. import { Vector3 } from "babylonjs/Maths/math.vector";
  43947. import "babylonjs/Cameras/RigModes/vrRigMode";
  43948. /**
  43949. * Camera used to simulate VR rendering (based on FreeCamera)
  43950. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43951. */
  43952. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  43953. /**
  43954. * Creates a new VRDeviceOrientationFreeCamera
  43955. * @param name defines camera name
  43956. * @param position defines the start position of the camera
  43957. * @param scene defines the scene the camera belongs to
  43958. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43959. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43960. */
  43961. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43962. /**
  43963. * Gets camera class name
  43964. * @returns VRDeviceOrientationFreeCamera
  43965. */
  43966. getClassName(): string;
  43967. }
  43968. }
  43969. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  43970. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  43971. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  43972. import { Scene } from "babylonjs/scene";
  43973. import { Vector3 } from "babylonjs/Maths/math.vector";
  43974. import "babylonjs/Gamepads/gamepadSceneComponent";
  43975. /**
  43976. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  43977. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  43978. */
  43979. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  43980. /**
  43981. * Creates a new VRDeviceOrientationGamepadCamera
  43982. * @param name defines camera name
  43983. * @param position defines the start position of the camera
  43984. * @param scene defines the scene the camera belongs to
  43985. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  43986. * @param vrCameraMetrics defines the vr metrics associated to the camera
  43987. */
  43988. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  43989. /**
  43990. * Gets camera class name
  43991. * @returns VRDeviceOrientationGamepadCamera
  43992. */
  43993. getClassName(): string;
  43994. }
  43995. }
  43996. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  43997. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  43998. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  43999. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44000. /** @hidden */
  44001. export var imageProcessingPixelShader: {
  44002. name: string;
  44003. shader: string;
  44004. };
  44005. }
  44006. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  44007. import { Nullable } from "babylonjs/types";
  44008. import { Color4 } from "babylonjs/Maths/math.color";
  44009. import { Camera } from "babylonjs/Cameras/camera";
  44010. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44011. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44012. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44013. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  44014. import { Engine } from "babylonjs/Engines/engine";
  44015. import "babylonjs/Shaders/imageProcessing.fragment";
  44016. import "babylonjs/Shaders/postprocess.vertex";
  44017. /**
  44018. * ImageProcessingPostProcess
  44019. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  44020. */
  44021. export class ImageProcessingPostProcess extends PostProcess {
  44022. /**
  44023. * Default configuration related to image processing available in the PBR Material.
  44024. */
  44025. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44026. /**
  44027. * Gets the image processing configuration used either in this material.
  44028. */
  44029. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  44030. /**
  44031. * Sets the Default image processing configuration used either in the this material.
  44032. *
  44033. * If sets to null, the scene one is in use.
  44034. */
  44035. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  44036. /**
  44037. * Keep track of the image processing observer to allow dispose and replace.
  44038. */
  44039. private _imageProcessingObserver;
  44040. /**
  44041. * Attaches a new image processing configuration to the PBR Material.
  44042. * @param configuration
  44043. */
  44044. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  44045. /**
  44046. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44047. */
  44048. get colorCurves(): Nullable<ColorCurves>;
  44049. /**
  44050. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  44051. */
  44052. set colorCurves(value: Nullable<ColorCurves>);
  44053. /**
  44054. * Gets wether the color curves effect is enabled.
  44055. */
  44056. get colorCurvesEnabled(): boolean;
  44057. /**
  44058. * Sets wether the color curves effect is enabled.
  44059. */
  44060. set colorCurvesEnabled(value: boolean);
  44061. /**
  44062. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44063. */
  44064. get colorGradingTexture(): Nullable<BaseTexture>;
  44065. /**
  44066. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  44067. */
  44068. set colorGradingTexture(value: Nullable<BaseTexture>);
  44069. /**
  44070. * Gets wether the color grading effect is enabled.
  44071. */
  44072. get colorGradingEnabled(): boolean;
  44073. /**
  44074. * Gets wether the color grading effect is enabled.
  44075. */
  44076. set colorGradingEnabled(value: boolean);
  44077. /**
  44078. * Gets exposure used in the effect.
  44079. */
  44080. get exposure(): number;
  44081. /**
  44082. * Sets exposure used in the effect.
  44083. */
  44084. set exposure(value: number);
  44085. /**
  44086. * Gets wether tonemapping is enabled or not.
  44087. */
  44088. get toneMappingEnabled(): boolean;
  44089. /**
  44090. * Sets wether tonemapping is enabled or not
  44091. */
  44092. set toneMappingEnabled(value: boolean);
  44093. /**
  44094. * Gets the type of tone mapping effect.
  44095. */
  44096. get toneMappingType(): number;
  44097. /**
  44098. * Sets the type of tone mapping effect.
  44099. */
  44100. set toneMappingType(value: number);
  44101. /**
  44102. * Gets contrast used in the effect.
  44103. */
  44104. get contrast(): number;
  44105. /**
  44106. * Sets contrast used in the effect.
  44107. */
  44108. set contrast(value: number);
  44109. /**
  44110. * Gets Vignette stretch size.
  44111. */
  44112. get vignetteStretch(): number;
  44113. /**
  44114. * Sets Vignette stretch size.
  44115. */
  44116. set vignetteStretch(value: number);
  44117. /**
  44118. * Gets Vignette centre X Offset.
  44119. */
  44120. get vignetteCentreX(): number;
  44121. /**
  44122. * Sets Vignette centre X Offset.
  44123. */
  44124. set vignetteCentreX(value: number);
  44125. /**
  44126. * Gets Vignette centre Y Offset.
  44127. */
  44128. get vignetteCentreY(): number;
  44129. /**
  44130. * Sets Vignette centre Y Offset.
  44131. */
  44132. set vignetteCentreY(value: number);
  44133. /**
  44134. * Gets Vignette weight or intensity of the vignette effect.
  44135. */
  44136. get vignetteWeight(): number;
  44137. /**
  44138. * Sets Vignette weight or intensity of the vignette effect.
  44139. */
  44140. set vignetteWeight(value: number);
  44141. /**
  44142. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44143. * if vignetteEnabled is set to true.
  44144. */
  44145. get vignetteColor(): Color4;
  44146. /**
  44147. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  44148. * if vignetteEnabled is set to true.
  44149. */
  44150. set vignetteColor(value: Color4);
  44151. /**
  44152. * Gets Camera field of view used by the Vignette effect.
  44153. */
  44154. get vignetteCameraFov(): number;
  44155. /**
  44156. * Sets Camera field of view used by the Vignette effect.
  44157. */
  44158. set vignetteCameraFov(value: number);
  44159. /**
  44160. * Gets the vignette blend mode allowing different kind of effect.
  44161. */
  44162. get vignetteBlendMode(): number;
  44163. /**
  44164. * Sets the vignette blend mode allowing different kind of effect.
  44165. */
  44166. set vignetteBlendMode(value: number);
  44167. /**
  44168. * Gets wether the vignette effect is enabled.
  44169. */
  44170. get vignetteEnabled(): boolean;
  44171. /**
  44172. * Sets wether the vignette effect is enabled.
  44173. */
  44174. set vignetteEnabled(value: boolean);
  44175. private _fromLinearSpace;
  44176. /**
  44177. * Gets wether the input of the processing is in Gamma or Linear Space.
  44178. */
  44179. get fromLinearSpace(): boolean;
  44180. /**
  44181. * Sets wether the input of the processing is in Gamma or Linear Space.
  44182. */
  44183. set fromLinearSpace(value: boolean);
  44184. /**
  44185. * Defines cache preventing GC.
  44186. */
  44187. private _defines;
  44188. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  44189. /**
  44190. * "ImageProcessingPostProcess"
  44191. * @returns "ImageProcessingPostProcess"
  44192. */
  44193. getClassName(): string;
  44194. protected _updateParameters(): void;
  44195. dispose(camera?: Camera): void;
  44196. }
  44197. }
  44198. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  44199. import { Scene } from "babylonjs/scene";
  44200. import { Color3 } from "babylonjs/Maths/math.color";
  44201. import { Mesh } from "babylonjs/Meshes/mesh";
  44202. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  44203. import { Nullable } from "babylonjs/types";
  44204. /**
  44205. * Class containing static functions to help procedurally build meshes
  44206. */
  44207. export class GroundBuilder {
  44208. /**
  44209. * Creates a ground mesh
  44210. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  44211. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  44212. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44213. * @param name defines the name of the mesh
  44214. * @param options defines the options used to create the mesh
  44215. * @param scene defines the hosting scene
  44216. * @returns the ground mesh
  44217. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  44218. */
  44219. static CreateGround(name: string, options: {
  44220. width?: number;
  44221. height?: number;
  44222. subdivisions?: number;
  44223. subdivisionsX?: number;
  44224. subdivisionsY?: number;
  44225. updatable?: boolean;
  44226. }, scene: any): Mesh;
  44227. /**
  44228. * Creates a tiled ground mesh
  44229. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  44230. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  44231. * * 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
  44232. * * 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
  44233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44234. * @param name defines the name of the mesh
  44235. * @param options defines the options used to create the mesh
  44236. * @param scene defines the hosting scene
  44237. * @returns the tiled ground mesh
  44238. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  44239. */
  44240. static CreateTiledGround(name: string, options: {
  44241. xmin: number;
  44242. zmin: number;
  44243. xmax: number;
  44244. zmax: number;
  44245. subdivisions?: {
  44246. w: number;
  44247. h: number;
  44248. };
  44249. precision?: {
  44250. w: number;
  44251. h: number;
  44252. };
  44253. updatable?: boolean;
  44254. }, scene?: Nullable<Scene>): Mesh;
  44255. /**
  44256. * Creates a ground mesh from a height map
  44257. * * The parameter `url` sets the URL of the height map image resource.
  44258. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  44259. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  44260. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  44261. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  44262. * * 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.
  44263. * * 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).
  44264. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  44265. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44266. * @param name defines the name of the mesh
  44267. * @param url defines the url to the height map
  44268. * @param options defines the options used to create the mesh
  44269. * @param scene defines the hosting scene
  44270. * @returns the ground mesh
  44271. * @see https://doc.babylonjs.com/babylon101/height_map
  44272. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  44273. */
  44274. static CreateGroundFromHeightMap(name: string, url: string, options: {
  44275. width?: number;
  44276. height?: number;
  44277. subdivisions?: number;
  44278. minHeight?: number;
  44279. maxHeight?: number;
  44280. colorFilter?: Color3;
  44281. alphaFilter?: number;
  44282. updatable?: boolean;
  44283. onReady?: (mesh: GroundMesh) => void;
  44284. }, scene?: Nullable<Scene>): GroundMesh;
  44285. }
  44286. }
  44287. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  44288. import { Vector4 } from "babylonjs/Maths/math.vector";
  44289. import { Mesh } from "babylonjs/Meshes/mesh";
  44290. /**
  44291. * Class containing static functions to help procedurally build meshes
  44292. */
  44293. export class TorusBuilder {
  44294. /**
  44295. * Creates a torus mesh
  44296. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  44297. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  44298. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  44299. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44300. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44301. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44302. * @param name defines the name of the mesh
  44303. * @param options defines the options used to create the mesh
  44304. * @param scene defines the hosting scene
  44305. * @returns the torus mesh
  44306. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  44307. */
  44308. static CreateTorus(name: string, options: {
  44309. diameter?: number;
  44310. thickness?: number;
  44311. tessellation?: number;
  44312. updatable?: boolean;
  44313. sideOrientation?: number;
  44314. frontUVs?: Vector4;
  44315. backUVs?: Vector4;
  44316. }, scene: any): Mesh;
  44317. }
  44318. }
  44319. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  44320. import { Vector4 } from "babylonjs/Maths/math.vector";
  44321. import { Color4 } from "babylonjs/Maths/math.color";
  44322. import { Mesh } from "babylonjs/Meshes/mesh";
  44323. /**
  44324. * Class containing static functions to help procedurally build meshes
  44325. */
  44326. export class CylinderBuilder {
  44327. /**
  44328. * Creates a cylinder or a cone mesh
  44329. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  44330. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  44331. * * 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.
  44332. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  44333. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  44334. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  44335. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  44336. * * 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).
  44337. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  44338. * * 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).
  44339. * * 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
  44340. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  44341. * * 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
  44342. * * 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.
  44343. * * If `enclose` is false, a ring surface is one element.
  44344. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  44345. * * 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
  44346. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44347. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44348. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  44349. * @param name defines the name of the mesh
  44350. * @param options defines the options used to create the mesh
  44351. * @param scene defines the hosting scene
  44352. * @returns the cylinder mesh
  44353. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  44354. */
  44355. static CreateCylinder(name: string, options: {
  44356. height?: number;
  44357. diameterTop?: number;
  44358. diameterBottom?: number;
  44359. diameter?: number;
  44360. tessellation?: number;
  44361. subdivisions?: number;
  44362. arc?: number;
  44363. faceColors?: Color4[];
  44364. faceUV?: Vector4[];
  44365. updatable?: boolean;
  44366. hasRings?: boolean;
  44367. enclose?: boolean;
  44368. cap?: number;
  44369. sideOrientation?: number;
  44370. frontUVs?: Vector4;
  44371. backUVs?: Vector4;
  44372. }, scene: any): Mesh;
  44373. }
  44374. }
  44375. declare module "babylonjs/XR/webXRTypes" {
  44376. import { Nullable } from "babylonjs/types";
  44377. import { IDisposable } from "babylonjs/scene";
  44378. /**
  44379. * States of the webXR experience
  44380. */
  44381. export enum WebXRState {
  44382. /**
  44383. * Transitioning to being in XR mode
  44384. */
  44385. ENTERING_XR = 0,
  44386. /**
  44387. * Transitioning to non XR mode
  44388. */
  44389. EXITING_XR = 1,
  44390. /**
  44391. * In XR mode and presenting
  44392. */
  44393. IN_XR = 2,
  44394. /**
  44395. * Not entered XR mode
  44396. */
  44397. NOT_IN_XR = 3
  44398. }
  44399. /**
  44400. * Abstraction of the XR render target
  44401. */
  44402. export interface WebXRRenderTarget extends IDisposable {
  44403. /**
  44404. * xrpresent context of the canvas which can be used to display/mirror xr content
  44405. */
  44406. canvasContext: WebGLRenderingContext;
  44407. /**
  44408. * xr layer for the canvas
  44409. */
  44410. xrLayer: Nullable<XRWebGLLayer>;
  44411. /**
  44412. * Initializes the xr layer for the session
  44413. * @param xrSession xr session
  44414. * @returns a promise that will resolve once the XR Layer has been created
  44415. */
  44416. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44417. }
  44418. }
  44419. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  44420. import { Nullable } from "babylonjs/types";
  44421. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44422. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44423. /**
  44424. * COnfiguration object for WebXR output canvas
  44425. */
  44426. export class WebXRManagedOutputCanvasOptions {
  44427. /**
  44428. * An optional canvas in case you wish to create it yourself and provide it here.
  44429. * If not provided, a new canvas will be created
  44430. */
  44431. canvasElement?: HTMLCanvasElement;
  44432. /**
  44433. * Options for this XR Layer output
  44434. */
  44435. canvasOptions?: XRWebGLLayerOptions;
  44436. /**
  44437. * CSS styling for a newly created canvas (if not provided)
  44438. */
  44439. newCanvasCssStyle?: string;
  44440. /**
  44441. * Get the default values of the configuration object
  44442. * @returns default values of this configuration object
  44443. */
  44444. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  44445. }
  44446. /**
  44447. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  44448. */
  44449. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  44450. private _options;
  44451. private _canvas;
  44452. private _engine;
  44453. /**
  44454. * Rendering context of the canvas which can be used to display/mirror xr content
  44455. */
  44456. canvasContext: WebGLRenderingContext;
  44457. /**
  44458. * xr layer for the canvas
  44459. */
  44460. xrLayer: Nullable<XRWebGLLayer>;
  44461. /**
  44462. * Initializes the canvas to be added/removed upon entering/exiting xr
  44463. * @param _xrSessionManager The XR Session manager
  44464. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  44465. */
  44466. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  44467. /**
  44468. * Disposes of the object
  44469. */
  44470. dispose(): void;
  44471. /**
  44472. * Initializes the xr layer for the session
  44473. * @param xrSession xr session
  44474. * @returns a promise that will resolve once the XR Layer has been created
  44475. */
  44476. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  44477. private _addCanvas;
  44478. private _removeCanvas;
  44479. private _setManagedOutputCanvas;
  44480. }
  44481. }
  44482. declare module "babylonjs/XR/webXRSessionManager" {
  44483. import { Observable } from "babylonjs/Misc/observable";
  44484. import { Nullable } from "babylonjs/types";
  44485. import { IDisposable, Scene } from "babylonjs/scene";
  44486. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  44487. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44488. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  44489. /**
  44490. * Manages an XRSession to work with Babylon's engine
  44491. * @see https://doc.babylonjs.com/how_to/webxr
  44492. */
  44493. export class WebXRSessionManager implements IDisposable {
  44494. /** The scene which the session should be created for */
  44495. scene: Scene;
  44496. private _referenceSpace;
  44497. private _rttProvider;
  44498. private _sessionEnded;
  44499. private _xrNavigator;
  44500. private baseLayer;
  44501. /**
  44502. * The base reference space from which the session started. good if you want to reset your
  44503. * reference space
  44504. */
  44505. baseReferenceSpace: XRReferenceSpace;
  44506. /**
  44507. * Current XR frame
  44508. */
  44509. currentFrame: Nullable<XRFrame>;
  44510. /** WebXR timestamp updated every frame */
  44511. currentTimestamp: number;
  44512. /**
  44513. * Used just in case of a failure to initialize an immersive session.
  44514. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  44515. */
  44516. defaultHeightCompensation: number;
  44517. /**
  44518. * Fires every time a new xrFrame arrives which can be used to update the camera
  44519. */
  44520. onXRFrameObservable: Observable<XRFrame>;
  44521. /**
  44522. * Fires when the reference space changed
  44523. */
  44524. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  44525. /**
  44526. * Fires when the xr session is ended either by the device or manually done
  44527. */
  44528. onXRSessionEnded: Observable<any>;
  44529. /**
  44530. * Fires when the xr session is ended either by the device or manually done
  44531. */
  44532. onXRSessionInit: Observable<XRSession>;
  44533. /**
  44534. * Underlying xr session
  44535. */
  44536. session: XRSession;
  44537. /**
  44538. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  44539. * or get the offset the player is currently at.
  44540. */
  44541. viewerReferenceSpace: XRReferenceSpace;
  44542. /**
  44543. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  44544. * @param scene The scene which the session should be created for
  44545. */
  44546. constructor(
  44547. /** The scene which the session should be created for */
  44548. scene: Scene);
  44549. /**
  44550. * The current reference space used in this session. This reference space can constantly change!
  44551. * It is mainly used to offset the camera's position.
  44552. */
  44553. get referenceSpace(): XRReferenceSpace;
  44554. /**
  44555. * Set a new reference space and triggers the observable
  44556. */
  44557. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  44558. /**
  44559. * Disposes of the session manager
  44560. */
  44561. dispose(): void;
  44562. /**
  44563. * Stops the xrSession and restores the render loop
  44564. * @returns Promise which resolves after it exits XR
  44565. */
  44566. exitXRAsync(): Promise<void>;
  44567. /**
  44568. * Gets the correct render target texture to be rendered this frame for this eye
  44569. * @param eye the eye for which to get the render target
  44570. * @returns the render target for the specified eye
  44571. */
  44572. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  44573. /**
  44574. * Creates a WebXRRenderTarget object for the XR session
  44575. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  44576. * @param options optional options to provide when creating a new render target
  44577. * @returns a WebXR render target to which the session can render
  44578. */
  44579. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  44580. /**
  44581. * Initializes the manager
  44582. * After initialization enterXR can be called to start an XR session
  44583. * @returns Promise which resolves after it is initialized
  44584. */
  44585. initializeAsync(): Promise<void>;
  44586. /**
  44587. * Initializes an xr session
  44588. * @param xrSessionMode mode to initialize
  44589. * @param xrSessionInit defines optional and required values to pass to the session builder
  44590. * @returns a promise which will resolve once the session has been initialized
  44591. */
  44592. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  44593. /**
  44594. * Checks if a session would be supported for the creation options specified
  44595. * @param sessionMode session mode to check if supported eg. immersive-vr
  44596. * @returns A Promise that resolves to true if supported and false if not
  44597. */
  44598. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44599. /**
  44600. * Resets the reference space to the one started the session
  44601. */
  44602. resetReferenceSpace(): void;
  44603. /**
  44604. * Starts rendering to the xr layer
  44605. */
  44606. runXRRenderLoop(): void;
  44607. /**
  44608. * Sets the reference space on the xr session
  44609. * @param referenceSpaceType space to set
  44610. * @returns a promise that will resolve once the reference space has been set
  44611. */
  44612. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  44613. /**
  44614. * Updates the render state of the session
  44615. * @param state state to set
  44616. * @returns a promise that resolves once the render state has been updated
  44617. */
  44618. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  44619. /**
  44620. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  44621. * @param sessionMode defines the session to test
  44622. * @returns a promise with boolean as final value
  44623. */
  44624. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  44625. private _createRenderTargetTexture;
  44626. }
  44627. }
  44628. declare module "babylonjs/XR/webXRCamera" {
  44629. import { Scene } from "babylonjs/scene";
  44630. import { Camera } from "babylonjs/Cameras/camera";
  44631. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  44632. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44633. /**
  44634. * WebXR Camera which holds the views for the xrSession
  44635. * @see https://doc.babylonjs.com/how_to/webxr_camera
  44636. */
  44637. export class WebXRCamera extends FreeCamera {
  44638. private _xrSessionManager;
  44639. private _firstFrame;
  44640. private _referenceQuaternion;
  44641. private _referencedPosition;
  44642. private _xrInvPositionCache;
  44643. private _xrInvQuaternionCache;
  44644. /**
  44645. * Should position compensation execute on first frame.
  44646. * This is used when copying the position from a native (non XR) camera
  44647. */
  44648. compensateOnFirstFrame: boolean;
  44649. /**
  44650. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  44651. * @param name the name of the camera
  44652. * @param scene the scene to add the camera to
  44653. * @param _xrSessionManager a constructed xr session manager
  44654. */
  44655. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  44656. /**
  44657. * Return the user's height, unrelated to the current ground.
  44658. * This will be the y position of this camera, when ground level is 0.
  44659. */
  44660. get realWorldHeight(): number;
  44661. /** @hidden */
  44662. _updateForDualEyeDebugging(): void;
  44663. /**
  44664. * Sets this camera's transformation based on a non-vr camera
  44665. * @param otherCamera the non-vr camera to copy the transformation from
  44666. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  44667. */
  44668. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  44669. /**
  44670. * Gets the current instance class name ("WebXRCamera").
  44671. * @returns the class name
  44672. */
  44673. getClassName(): string;
  44674. private _updateFromXRSession;
  44675. private _updateNumberOfRigCameras;
  44676. private _updateReferenceSpace;
  44677. private _updateReferenceSpaceOffset;
  44678. }
  44679. }
  44680. declare module "babylonjs/XR/webXRFeaturesManager" {
  44681. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44682. import { IDisposable } from "babylonjs/scene";
  44683. /**
  44684. * Defining the interface required for a (webxr) feature
  44685. */
  44686. export interface IWebXRFeature extends IDisposable {
  44687. /**
  44688. * Is this feature attached
  44689. */
  44690. attached: boolean;
  44691. /**
  44692. * Should auto-attach be disabled?
  44693. */
  44694. disableAutoAttach: boolean;
  44695. /**
  44696. * Attach the feature to the session
  44697. * Will usually be called by the features manager
  44698. *
  44699. * @param force should attachment be forced (even when already attached)
  44700. * @returns true if successful.
  44701. */
  44702. attach(force?: boolean): boolean;
  44703. /**
  44704. * Detach the feature from the session
  44705. * Will usually be called by the features manager
  44706. *
  44707. * @returns true if successful.
  44708. */
  44709. detach(): boolean;
  44710. }
  44711. /**
  44712. * A list of the currently available features without referencing them
  44713. */
  44714. export class WebXRFeatureName {
  44715. /**
  44716. * The name of the anchor system feature
  44717. */
  44718. static ANCHOR_SYSTEM: string;
  44719. /**
  44720. * The name of the background remover feature
  44721. */
  44722. static BACKGROUND_REMOVER: string;
  44723. /**
  44724. * The name of the hit test feature
  44725. */
  44726. static HIT_TEST: string;
  44727. /**
  44728. * physics impostors for xr controllers feature
  44729. */
  44730. static PHYSICS_CONTROLLERS: string;
  44731. /**
  44732. * The name of the plane detection feature
  44733. */
  44734. static PLANE_DETECTION: string;
  44735. /**
  44736. * The name of the pointer selection feature
  44737. */
  44738. static POINTER_SELECTION: string;
  44739. /**
  44740. * The name of the teleportation feature
  44741. */
  44742. static TELEPORTATION: string;
  44743. }
  44744. /**
  44745. * Defining the constructor of a feature. Used to register the modules.
  44746. */
  44747. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  44748. /**
  44749. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  44750. * It is mainly used in AR sessions.
  44751. *
  44752. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  44753. */
  44754. export class WebXRFeaturesManager implements IDisposable {
  44755. private _xrSessionManager;
  44756. private static readonly _AvailableFeatures;
  44757. private _features;
  44758. /**
  44759. * constructs a new features manages.
  44760. *
  44761. * @param _xrSessionManager an instance of WebXRSessionManager
  44762. */
  44763. constructor(_xrSessionManager: WebXRSessionManager);
  44764. /**
  44765. * Used to register a module. After calling this function a developer can use this feature in the scene.
  44766. * Mainly used internally.
  44767. *
  44768. * @param featureName the name of the feature to register
  44769. * @param constructorFunction the function used to construct the module
  44770. * @param version the (babylon) version of the module
  44771. * @param stable is that a stable version of this module
  44772. */
  44773. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  44774. /**
  44775. * Returns a constructor of a specific feature.
  44776. *
  44777. * @param featureName the name of the feature to construct
  44778. * @param version the version of the feature to load
  44779. * @param xrSessionManager the xrSessionManager. Used to construct the module
  44780. * @param options optional options provided to the module.
  44781. * @returns a function that, when called, will return a new instance of this feature
  44782. */
  44783. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  44784. /**
  44785. * Can be used to return the list of features currently registered
  44786. *
  44787. * @returns an Array of available features
  44788. */
  44789. static GetAvailableFeatures(): string[];
  44790. /**
  44791. * Gets the versions available for a specific feature
  44792. * @param featureName the name of the feature
  44793. * @returns an array with the available versions
  44794. */
  44795. static GetAvailableVersions(featureName: string): string[];
  44796. /**
  44797. * Return the latest unstable version of this feature
  44798. * @param featureName the name of the feature to search
  44799. * @returns the version number. if not found will return -1
  44800. */
  44801. static GetLatestVersionOfFeature(featureName: string): number;
  44802. /**
  44803. * Return the latest stable version of this feature
  44804. * @param featureName the name of the feature to search
  44805. * @returns the version number. if not found will return -1
  44806. */
  44807. static GetStableVersionOfFeature(featureName: string): number;
  44808. /**
  44809. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  44810. * Can be used during a session to start a feature
  44811. * @param featureName the name of feature to attach
  44812. */
  44813. attachFeature(featureName: string): void;
  44814. /**
  44815. * Can be used inside a session or when the session ends to detach a specific feature
  44816. * @param featureName the name of the feature to detach
  44817. */
  44818. detachFeature(featureName: string): void;
  44819. /**
  44820. * Used to disable an already-enabled feature
  44821. * The feature will be disposed and will be recreated once enabled.
  44822. * @param featureName the feature to disable
  44823. * @returns true if disable was successful
  44824. */
  44825. disableFeature(featureName: string | {
  44826. Name: string;
  44827. }): boolean;
  44828. /**
  44829. * dispose this features manager
  44830. */
  44831. dispose(): void;
  44832. /**
  44833. * 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.
  44834. * 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.
  44835. *
  44836. * @param featureName the name of the feature to load or the class of the feature
  44837. * @param version optional version to load. if not provided the latest version will be enabled
  44838. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  44839. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  44840. * @returns a new constructed feature or throws an error if feature not found.
  44841. */
  44842. enableFeature(featureName: string | {
  44843. Name: string;
  44844. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  44845. /**
  44846. * get the implementation of an enabled feature.
  44847. * @param featureName the name of the feature to load
  44848. * @returns the feature class, if found
  44849. */
  44850. getEnabledFeature(featureName: string): IWebXRFeature;
  44851. /**
  44852. * Get the list of enabled features
  44853. * @returns an array of enabled features
  44854. */
  44855. getEnabledFeatures(): string[];
  44856. }
  44857. }
  44858. declare module "babylonjs/XR/webXRExperienceHelper" {
  44859. import { Observable } from "babylonjs/Misc/observable";
  44860. import { IDisposable, Scene } from "babylonjs/scene";
  44861. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  44862. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  44863. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  44864. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  44865. /**
  44866. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  44867. * @see https://doc.babylonjs.com/how_to/webxr
  44868. */
  44869. export class WebXRExperienceHelper implements IDisposable {
  44870. private scene;
  44871. private _nonVRCamera;
  44872. private _originalSceneAutoClear;
  44873. private _supported;
  44874. /**
  44875. * Camera used to render xr content
  44876. */
  44877. camera: WebXRCamera;
  44878. /** A features manager for this xr session */
  44879. featuresManager: WebXRFeaturesManager;
  44880. /**
  44881. * Observers registered here will be triggered after the camera's initial transformation is set
  44882. * This can be used to set a different ground level or an extra rotation.
  44883. *
  44884. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  44885. * to the position set after this observable is done executing.
  44886. */
  44887. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  44888. /**
  44889. * Fires when the state of the experience helper has changed
  44890. */
  44891. onStateChangedObservable: Observable<WebXRState>;
  44892. /** Session manager used to keep track of xr session */
  44893. sessionManager: WebXRSessionManager;
  44894. /**
  44895. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  44896. */
  44897. state: WebXRState;
  44898. /**
  44899. * Creates a WebXRExperienceHelper
  44900. * @param scene The scene the helper should be created in
  44901. */
  44902. private constructor();
  44903. /**
  44904. * Creates the experience helper
  44905. * @param scene the scene to attach the experience helper to
  44906. * @returns a promise for the experience helper
  44907. */
  44908. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  44909. /**
  44910. * Disposes of the experience helper
  44911. */
  44912. dispose(): void;
  44913. /**
  44914. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  44915. * @param sessionMode options for the XR session
  44916. * @param referenceSpaceType frame of reference of the XR session
  44917. * @param renderTarget the output canvas that will be used to enter XR mode
  44918. * @returns promise that resolves after xr mode has entered
  44919. */
  44920. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  44921. /**
  44922. * Exits XR mode and returns the scene to its original state
  44923. * @returns promise that resolves after xr mode has exited
  44924. */
  44925. exitXRAsync(): Promise<void>;
  44926. private _nonXRToXRCamera;
  44927. private _setState;
  44928. }
  44929. }
  44930. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  44931. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  44932. import { Observable } from "babylonjs/Misc/observable";
  44933. import { IDisposable } from "babylonjs/scene";
  44934. /**
  44935. * X-Y values for axes in WebXR
  44936. */
  44937. export interface IWebXRMotionControllerAxesValue {
  44938. /**
  44939. * The value of the x axis
  44940. */
  44941. x: number;
  44942. /**
  44943. * The value of the y-axis
  44944. */
  44945. y: number;
  44946. }
  44947. /**
  44948. * changed / previous values for the values of this component
  44949. */
  44950. export interface IWebXRMotionControllerComponentChangesValues<T> {
  44951. /**
  44952. * current (this frame) value
  44953. */
  44954. current: T;
  44955. /**
  44956. * previous (last change) value
  44957. */
  44958. previous: T;
  44959. }
  44960. /**
  44961. * Represents changes in the component between current frame and last values recorded
  44962. */
  44963. export interface IWebXRMotionControllerComponentChanges {
  44964. /**
  44965. * will be populated with previous and current values if axes changed
  44966. */
  44967. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  44968. /**
  44969. * will be populated with previous and current values if pressed changed
  44970. */
  44971. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44972. /**
  44973. * will be populated with previous and current values if touched changed
  44974. */
  44975. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  44976. /**
  44977. * will be populated with previous and current values if value changed
  44978. */
  44979. value?: IWebXRMotionControllerComponentChangesValues<number>;
  44980. }
  44981. /**
  44982. * This class represents a single component (for example button or thumbstick) of a motion controller
  44983. */
  44984. export class WebXRControllerComponent implements IDisposable {
  44985. /**
  44986. * the id of this component
  44987. */
  44988. id: string;
  44989. /**
  44990. * the type of the component
  44991. */
  44992. type: MotionControllerComponentType;
  44993. private _buttonIndex;
  44994. private _axesIndices;
  44995. private _axes;
  44996. private _changes;
  44997. private _currentValue;
  44998. private _hasChanges;
  44999. private _pressed;
  45000. private _touched;
  45001. /**
  45002. * button component type
  45003. */
  45004. static BUTTON_TYPE: MotionControllerComponentType;
  45005. /**
  45006. * squeeze component type
  45007. */
  45008. static SQUEEZE_TYPE: MotionControllerComponentType;
  45009. /**
  45010. * Thumbstick component type
  45011. */
  45012. static THUMBSTICK_TYPE: MotionControllerComponentType;
  45013. /**
  45014. * Touchpad component type
  45015. */
  45016. static TOUCHPAD_TYPE: MotionControllerComponentType;
  45017. /**
  45018. * trigger component type
  45019. */
  45020. static TRIGGER_TYPE: MotionControllerComponentType;
  45021. /**
  45022. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  45023. * the axes data changes
  45024. */
  45025. onAxisValueChangedObservable: Observable<{
  45026. x: number;
  45027. y: number;
  45028. }>;
  45029. /**
  45030. * Observers registered here will be triggered when the state of a button changes
  45031. * State change is either pressed / touched / value
  45032. */
  45033. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  45034. /**
  45035. * Creates a new component for a motion controller.
  45036. * It is created by the motion controller itself
  45037. *
  45038. * @param id the id of this component
  45039. * @param type the type of the component
  45040. * @param _buttonIndex index in the buttons array of the gamepad
  45041. * @param _axesIndices indices of the values in the axes array of the gamepad
  45042. */
  45043. constructor(
  45044. /**
  45045. * the id of this component
  45046. */
  45047. id: string,
  45048. /**
  45049. * the type of the component
  45050. */
  45051. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  45052. /**
  45053. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  45054. */
  45055. get axes(): IWebXRMotionControllerAxesValue;
  45056. /**
  45057. * Get the changes. Elements will be populated only if they changed with their previous and current value
  45058. */
  45059. get changes(): IWebXRMotionControllerComponentChanges;
  45060. /**
  45061. * Return whether or not the component changed the last frame
  45062. */
  45063. get hasChanges(): boolean;
  45064. /**
  45065. * is the button currently pressed
  45066. */
  45067. get pressed(): boolean;
  45068. /**
  45069. * is the button currently touched
  45070. */
  45071. get touched(): boolean;
  45072. /**
  45073. * Get the current value of this component
  45074. */
  45075. get value(): number;
  45076. /**
  45077. * Dispose this component
  45078. */
  45079. dispose(): void;
  45080. /**
  45081. * Are there axes correlating to this component
  45082. * @return true is axes data is available
  45083. */
  45084. isAxes(): boolean;
  45085. /**
  45086. * Is this component a button (hence - pressable)
  45087. * @returns true if can be pressed
  45088. */
  45089. isButton(): boolean;
  45090. /**
  45091. * update this component using the gamepad object it is in. Called on every frame
  45092. * @param nativeController the native gamepad controller object
  45093. */
  45094. update(nativeController: IMinimalMotionControllerObject): void;
  45095. }
  45096. }
  45097. declare module "babylonjs/Loading/sceneLoader" {
  45098. import { Observable } from "babylonjs/Misc/observable";
  45099. import { Nullable } from "babylonjs/types";
  45100. import { Scene } from "babylonjs/scene";
  45101. import { Engine } from "babylonjs/Engines/engine";
  45102. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45103. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  45104. import { AssetContainer } from "babylonjs/assetContainer";
  45105. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  45106. import { Skeleton } from "babylonjs/Bones/skeleton";
  45107. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  45108. import { WebRequest } from "babylonjs/Misc/webRequest";
  45109. /**
  45110. * Class used to represent data loading progression
  45111. */
  45112. export class SceneLoaderProgressEvent {
  45113. /** defines if data length to load can be evaluated */
  45114. readonly lengthComputable: boolean;
  45115. /** defines the loaded data length */
  45116. readonly loaded: number;
  45117. /** defines the data length to load */
  45118. readonly total: number;
  45119. /**
  45120. * Create a new progress event
  45121. * @param lengthComputable defines if data length to load can be evaluated
  45122. * @param loaded defines the loaded data length
  45123. * @param total defines the data length to load
  45124. */
  45125. constructor(
  45126. /** defines if data length to load can be evaluated */
  45127. lengthComputable: boolean,
  45128. /** defines the loaded data length */
  45129. loaded: number,
  45130. /** defines the data length to load */
  45131. total: number);
  45132. /**
  45133. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  45134. * @param event defines the source event
  45135. * @returns a new SceneLoaderProgressEvent
  45136. */
  45137. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  45138. }
  45139. /**
  45140. * Interface used by SceneLoader plugins to define supported file extensions
  45141. */
  45142. export interface ISceneLoaderPluginExtensions {
  45143. /**
  45144. * Defines the list of supported extensions
  45145. */
  45146. [extension: string]: {
  45147. isBinary: boolean;
  45148. };
  45149. }
  45150. /**
  45151. * Interface used by SceneLoader plugin factory
  45152. */
  45153. export interface ISceneLoaderPluginFactory {
  45154. /**
  45155. * Defines the name of the factory
  45156. */
  45157. name: string;
  45158. /**
  45159. * Function called to create a new plugin
  45160. * @return the new plugin
  45161. */
  45162. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  45163. /**
  45164. * The callback that returns true if the data can be directly loaded.
  45165. * @param data string containing the file data
  45166. * @returns if the data can be loaded directly
  45167. */
  45168. canDirectLoad?(data: string): boolean;
  45169. }
  45170. /**
  45171. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  45172. */
  45173. export interface ISceneLoaderPluginBase {
  45174. /**
  45175. * The friendly name of this plugin.
  45176. */
  45177. name: string;
  45178. /**
  45179. * The file extensions supported by this plugin.
  45180. */
  45181. extensions: string | ISceneLoaderPluginExtensions;
  45182. /**
  45183. * The callback called when loading from a url.
  45184. * @param scene scene loading this url
  45185. * @param url url to load
  45186. * @param onSuccess callback called when the file successfully loads
  45187. * @param onProgress callback called while file is loading (if the server supports this mode)
  45188. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  45189. * @param onError callback called when the file fails to load
  45190. * @returns a file request object
  45191. */
  45192. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45193. /**
  45194. * The callback called when loading from a file object.
  45195. * @param scene scene loading this file
  45196. * @param file defines the file to load
  45197. * @param onSuccess defines the callback to call when data is loaded
  45198. * @param onProgress defines the callback to call during loading process
  45199. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  45200. * @param onError defines the callback to call when an error occurs
  45201. * @returns a file request object
  45202. */
  45203. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  45204. /**
  45205. * The callback that returns true if the data can be directly loaded.
  45206. * @param data string containing the file data
  45207. * @returns if the data can be loaded directly
  45208. */
  45209. canDirectLoad?(data: string): boolean;
  45210. /**
  45211. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  45212. * @param scene scene loading this data
  45213. * @param data string containing the data
  45214. * @returns data to pass to the plugin
  45215. */
  45216. directLoad?(scene: Scene, data: string): any;
  45217. /**
  45218. * The callback that allows custom handling of the root url based on the response url.
  45219. * @param rootUrl the original root url
  45220. * @param responseURL the response url if available
  45221. * @returns the new root url
  45222. */
  45223. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  45224. }
  45225. /**
  45226. * Interface used to define a SceneLoader plugin
  45227. */
  45228. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  45229. /**
  45230. * Import meshes into a scene.
  45231. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45232. * @param scene The scene to import into
  45233. * @param data The data to import
  45234. * @param rootUrl The root url for scene and resources
  45235. * @param meshes The meshes array to import into
  45236. * @param particleSystems The particle systems array to import into
  45237. * @param skeletons The skeletons array to import into
  45238. * @param onError The callback when import fails
  45239. * @returns True if successful or false otherwise
  45240. */
  45241. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  45242. /**
  45243. * Load into a scene.
  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 True if successful or false otherwise
  45249. */
  45250. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  45251. /**
  45252. * Load into an asset container.
  45253. * @param scene The scene to load into
  45254. * @param data The data to import
  45255. * @param rootUrl The root url for scene and resources
  45256. * @param onError The callback when import fails
  45257. * @returns The loaded asset container
  45258. */
  45259. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  45260. }
  45261. /**
  45262. * Interface used to define an async SceneLoader plugin
  45263. */
  45264. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  45265. /**
  45266. * Import meshes into a scene.
  45267. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45268. * @param scene The scene to import into
  45269. * @param data The data to import
  45270. * @param rootUrl The root url for scene and resources
  45271. * @param onProgress The callback when the load progresses
  45272. * @param fileName Defines the name of the file to load
  45273. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  45274. */
  45275. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  45276. meshes: AbstractMesh[];
  45277. particleSystems: IParticleSystem[];
  45278. skeletons: Skeleton[];
  45279. animationGroups: AnimationGroup[];
  45280. }>;
  45281. /**
  45282. * Load into a scene.
  45283. * @param scene The scene to load into
  45284. * @param data The data to import
  45285. * @param rootUrl The root url for scene and resources
  45286. * @param onProgress The callback when the load progresses
  45287. * @param fileName Defines the name of the file to load
  45288. * @returns Nothing
  45289. */
  45290. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  45291. /**
  45292. * Load into an asset container.
  45293. * @param scene The scene to load into
  45294. * @param data The data to import
  45295. * @param rootUrl The root url for scene and resources
  45296. * @param onProgress The callback when the load progresses
  45297. * @param fileName Defines the name of the file to load
  45298. * @returns The loaded asset container
  45299. */
  45300. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  45301. }
  45302. /**
  45303. * Mode that determines how to handle old animation groups before loading new ones.
  45304. */
  45305. export enum SceneLoaderAnimationGroupLoadingMode {
  45306. /**
  45307. * Reset all old animations to initial state then dispose them.
  45308. */
  45309. Clean = 0,
  45310. /**
  45311. * Stop all old animations.
  45312. */
  45313. Stop = 1,
  45314. /**
  45315. * Restart old animations from first frame.
  45316. */
  45317. Sync = 2,
  45318. /**
  45319. * Old animations remains untouched.
  45320. */
  45321. NoSync = 3
  45322. }
  45323. /**
  45324. * Class used to load scene from various file formats using registered plugins
  45325. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  45326. */
  45327. export class SceneLoader {
  45328. /**
  45329. * No logging while loading
  45330. */
  45331. static readonly NO_LOGGING: number;
  45332. /**
  45333. * Minimal logging while loading
  45334. */
  45335. static readonly MINIMAL_LOGGING: number;
  45336. /**
  45337. * Summary logging while loading
  45338. */
  45339. static readonly SUMMARY_LOGGING: number;
  45340. /**
  45341. * Detailled logging while loading
  45342. */
  45343. static readonly DETAILED_LOGGING: number;
  45344. /**
  45345. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  45346. */
  45347. static get ForceFullSceneLoadingForIncremental(): boolean;
  45348. static set ForceFullSceneLoadingForIncremental(value: boolean);
  45349. /**
  45350. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  45351. */
  45352. static get ShowLoadingScreen(): boolean;
  45353. static set ShowLoadingScreen(value: boolean);
  45354. /**
  45355. * Defines the current logging level (while loading the scene)
  45356. * @ignorenaming
  45357. */
  45358. static get loggingLevel(): number;
  45359. static set loggingLevel(value: number);
  45360. /**
  45361. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  45362. */
  45363. static get CleanBoneMatrixWeights(): boolean;
  45364. static set CleanBoneMatrixWeights(value: boolean);
  45365. /**
  45366. * Event raised when a plugin is used to load a scene
  45367. */
  45368. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  45369. private static _registeredPlugins;
  45370. private static _getDefaultPlugin;
  45371. private static _getPluginForExtension;
  45372. private static _getPluginForDirectLoad;
  45373. private static _getPluginForFilename;
  45374. private static _getDirectLoad;
  45375. private static _loadData;
  45376. private static _getFileInfo;
  45377. /**
  45378. * Gets a plugin that can load the given extension
  45379. * @param extension defines the extension to load
  45380. * @returns a plugin or null if none works
  45381. */
  45382. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  45383. /**
  45384. * Gets a boolean indicating that the given extension can be loaded
  45385. * @param extension defines the extension to load
  45386. * @returns true if the extension is supported
  45387. */
  45388. static IsPluginForExtensionAvailable(extension: string): boolean;
  45389. /**
  45390. * Adds a new plugin to the list of registered plugins
  45391. * @param plugin defines the plugin to add
  45392. */
  45393. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  45394. /**
  45395. * Import meshes into a scene
  45396. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45397. * @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)
  45398. * @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)
  45399. * @param scene the instance of BABYLON.Scene to append to
  45400. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  45401. * @param onProgress a callback with a progress event for each file being loaded
  45402. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45403. * @param pluginExtension the extension used to determine the plugin
  45404. * @returns The loaded plugin
  45405. */
  45406. 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>;
  45407. /**
  45408. * Import meshes into a scene
  45409. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  45410. * @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)
  45411. * @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)
  45412. * @param scene the instance of BABYLON.Scene to append to
  45413. * @param onProgress a callback with a progress event for each file being loaded
  45414. * @param pluginExtension the extension used to determine the plugin
  45415. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  45416. */
  45417. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  45418. meshes: AbstractMesh[];
  45419. particleSystems: IParticleSystem[];
  45420. skeletons: Skeleton[];
  45421. animationGroups: AnimationGroup[];
  45422. }>;
  45423. /**
  45424. * Load a scene
  45425. * @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)
  45426. * @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)
  45427. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45428. * @param onSuccess a callback with the scene when import succeeds
  45429. * @param onProgress a callback with a progress event for each file being loaded
  45430. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45431. * @param pluginExtension the extension used to determine the plugin
  45432. * @returns The loaded plugin
  45433. */
  45434. 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>;
  45435. /**
  45436. * Load a scene
  45437. * @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)
  45438. * @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)
  45439. * @param engine is the instance of BABYLON.Engine to use to create the scene
  45440. * @param onProgress a callback with a progress event for each file being loaded
  45441. * @param pluginExtension the extension used to determine the plugin
  45442. * @returns The loaded scene
  45443. */
  45444. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45445. /**
  45446. * Append a scene
  45447. * @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)
  45448. * @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)
  45449. * @param scene is the instance of BABYLON.Scene to append to
  45450. * @param onSuccess a callback with the scene when import succeeds
  45451. * @param onProgress a callback with a progress event for each file being loaded
  45452. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45453. * @param pluginExtension the extension used to determine the plugin
  45454. * @returns The loaded plugin
  45455. */
  45456. 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>;
  45457. /**
  45458. * Append a scene
  45459. * @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)
  45460. * @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)
  45461. * @param scene is the instance of BABYLON.Scene to append to
  45462. * @param onProgress a callback with a progress event for each file being loaded
  45463. * @param pluginExtension the extension used to determine the plugin
  45464. * @returns The given scene
  45465. */
  45466. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  45467. /**
  45468. * Load a scene into an asset container
  45469. * @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)
  45470. * @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)
  45471. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45472. * @param onSuccess a callback with the scene when import succeeds
  45473. * @param onProgress a callback with a progress event for each file being loaded
  45474. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45475. * @param pluginExtension the extension used to determine the plugin
  45476. * @returns The loaded plugin
  45477. */
  45478. 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>;
  45479. /**
  45480. * Load a scene into an asset container
  45481. * @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)
  45482. * @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)
  45483. * @param scene is the instance of Scene to append to
  45484. * @param onProgress a callback with a progress event for each file being loaded
  45485. * @param pluginExtension the extension used to determine the plugin
  45486. * @returns The loaded asset container
  45487. */
  45488. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  45489. /**
  45490. * Import animations from a file into a scene
  45491. * @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)
  45492. * @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)
  45493. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45494. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45495. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45496. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45497. * @param onSuccess a callback with the scene when import succeeds
  45498. * @param onProgress a callback with a progress event for each file being loaded
  45499. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45500. */
  45501. 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;
  45502. /**
  45503. * Import animations from a file into a scene
  45504. * @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)
  45505. * @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)
  45506. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  45507. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  45508. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  45509. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  45510. * @param onSuccess a callback with the scene when import succeeds
  45511. * @param onProgress a callback with a progress event for each file being loaded
  45512. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  45513. * @returns the updated scene with imported animations
  45514. */
  45515. 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>;
  45516. }
  45517. }
  45518. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  45519. import { IDisposable, Scene } from "babylonjs/scene";
  45520. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  45521. import { Observable } from "babylonjs/Misc/observable";
  45522. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45523. import { Nullable } from "babylonjs/types";
  45524. /**
  45525. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  45526. */
  45527. export type MotionControllerHandness = "none" | "left" | "right";
  45528. /**
  45529. * The type of components available in motion controllers.
  45530. * This is not the name of the component.
  45531. */
  45532. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  45533. /**
  45534. * The state of a controller component
  45535. */
  45536. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  45537. /**
  45538. * The schema of motion controller layout.
  45539. * No object will be initialized using this interface
  45540. * This is used just to define the profile.
  45541. */
  45542. export interface IMotionControllerLayout {
  45543. /**
  45544. * Path to load the assets. Usually relative to the base path
  45545. */
  45546. assetPath: string;
  45547. /**
  45548. * Available components (unsorted)
  45549. */
  45550. components: {
  45551. /**
  45552. * A map of component Ids
  45553. */
  45554. [componentId: string]: {
  45555. /**
  45556. * The type of input the component outputs
  45557. */
  45558. type: MotionControllerComponentType;
  45559. /**
  45560. * The indices of this component in the gamepad object
  45561. */
  45562. gamepadIndices: {
  45563. /**
  45564. * Index of button
  45565. */
  45566. button?: number;
  45567. /**
  45568. * If available, index of x-axis
  45569. */
  45570. xAxis?: number;
  45571. /**
  45572. * If available, index of y-axis
  45573. */
  45574. yAxis?: number;
  45575. };
  45576. /**
  45577. * The mesh's root node name
  45578. */
  45579. rootNodeName: string;
  45580. /**
  45581. * Animation definitions for this model
  45582. */
  45583. visualResponses: {
  45584. [stateKey: string]: {
  45585. /**
  45586. * What property will be animated
  45587. */
  45588. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  45589. /**
  45590. * What states influence this visual response
  45591. */
  45592. states: MotionControllerComponentStateType[];
  45593. /**
  45594. * Type of animation - movement or visibility
  45595. */
  45596. valueNodeProperty: "transform" | "visibility";
  45597. /**
  45598. * Base node name to move. Its position will be calculated according to the min and max nodes
  45599. */
  45600. valueNodeName?: string;
  45601. /**
  45602. * Minimum movement node
  45603. */
  45604. minNodeName?: string;
  45605. /**
  45606. * Max movement node
  45607. */
  45608. maxNodeName?: string;
  45609. };
  45610. };
  45611. /**
  45612. * If touch enabled, what is the name of node to display user feedback
  45613. */
  45614. touchPointNodeName?: string;
  45615. };
  45616. };
  45617. /**
  45618. * Is it xr standard mapping or not
  45619. */
  45620. gamepadMapping: "" | "xr-standard";
  45621. /**
  45622. * Base root node of this entire model
  45623. */
  45624. rootNodeName: string;
  45625. /**
  45626. * Defines the main button component id
  45627. */
  45628. selectComponentId: string;
  45629. }
  45630. /**
  45631. * A definition for the layout map in the input profile
  45632. */
  45633. export interface IMotionControllerLayoutMap {
  45634. /**
  45635. * Layouts with handness type as a key
  45636. */
  45637. [handness: string]: IMotionControllerLayout;
  45638. }
  45639. /**
  45640. * The XR Input profile schema
  45641. * Profiles can be found here:
  45642. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  45643. */
  45644. export interface IMotionControllerProfile {
  45645. /**
  45646. * fallback profiles for this profileId
  45647. */
  45648. fallbackProfileIds: string[];
  45649. /**
  45650. * The layout map, with handness as key
  45651. */
  45652. layouts: IMotionControllerLayoutMap;
  45653. /**
  45654. * The id of this profile
  45655. * correlates to the profile(s) in the xrInput.profiles array
  45656. */
  45657. profileId: string;
  45658. }
  45659. /**
  45660. * A helper-interface for the 3 meshes needed for controller button animation
  45661. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  45662. */
  45663. export interface IMotionControllerButtonMeshMap {
  45664. /**
  45665. * the mesh that defines the pressed value mesh position.
  45666. * This is used to find the max-position of this button
  45667. */
  45668. pressedMesh: AbstractMesh;
  45669. /**
  45670. * the mesh that defines the unpressed value mesh position.
  45671. * This is used to find the min (or initial) position of this button
  45672. */
  45673. unpressedMesh: AbstractMesh;
  45674. /**
  45675. * The mesh that will be changed when value changes
  45676. */
  45677. valueMesh: AbstractMesh;
  45678. }
  45679. /**
  45680. * A helper-interface for the 3 meshes needed for controller axis animation.
  45681. * This will be expanded when touchpad animations are fully supported
  45682. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  45683. */
  45684. export interface IMotionControllerMeshMap {
  45685. /**
  45686. * the mesh that defines the maximum value mesh position.
  45687. */
  45688. maxMesh?: AbstractMesh;
  45689. /**
  45690. * the mesh that defines the minimum value mesh position.
  45691. */
  45692. minMesh?: AbstractMesh;
  45693. /**
  45694. * The mesh that will be changed when axis value changes
  45695. */
  45696. valueMesh: AbstractMesh;
  45697. }
  45698. /**
  45699. * The elements needed for change-detection of the gamepad objects in motion controllers
  45700. */
  45701. export interface IMinimalMotionControllerObject {
  45702. /**
  45703. * Available axes of this controller
  45704. */
  45705. axes: number[];
  45706. /**
  45707. * An array of available buttons
  45708. */
  45709. buttons: Array<{
  45710. /**
  45711. * Value of the button/trigger
  45712. */
  45713. value: number;
  45714. /**
  45715. * If the button/trigger is currently touched
  45716. */
  45717. touched: boolean;
  45718. /**
  45719. * If the button/trigger is currently pressed
  45720. */
  45721. pressed: boolean;
  45722. }>;
  45723. }
  45724. /**
  45725. * An Abstract Motion controller
  45726. * This class receives an xrInput and a profile layout and uses those to initialize the components
  45727. * Each component has an observable to check for changes in value and state
  45728. */
  45729. export abstract class WebXRAbstractMotionController implements IDisposable {
  45730. protected scene: Scene;
  45731. protected layout: IMotionControllerLayout;
  45732. /**
  45733. * The gamepad object correlating to this controller
  45734. */
  45735. gamepadObject: IMinimalMotionControllerObject;
  45736. /**
  45737. * handness (left/right/none) of this controller
  45738. */
  45739. handness: MotionControllerHandness;
  45740. private _initComponent;
  45741. private _modelReady;
  45742. /**
  45743. * A map of components (WebXRControllerComponent) in this motion controller
  45744. * Components have a ComponentType and can also have both button and axis definitions
  45745. */
  45746. readonly components: {
  45747. [id: string]: WebXRControllerComponent;
  45748. };
  45749. /**
  45750. * Disable the model's animation. Can be set at any time.
  45751. */
  45752. disableAnimation: boolean;
  45753. /**
  45754. * Observers registered here will be triggered when the model of this controller is done loading
  45755. */
  45756. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  45757. /**
  45758. * The profile id of this motion controller
  45759. */
  45760. abstract profileId: string;
  45761. /**
  45762. * The root mesh of the model. It is null if the model was not yet initialized
  45763. */
  45764. rootMesh: Nullable<AbstractMesh>;
  45765. /**
  45766. * constructs a new abstract motion controller
  45767. * @param scene the scene to which the model of the controller will be added
  45768. * @param layout The profile layout to load
  45769. * @param gamepadObject The gamepad object correlating to this controller
  45770. * @param handness handness (left/right/none) of this controller
  45771. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  45772. */
  45773. constructor(scene: Scene, layout: IMotionControllerLayout,
  45774. /**
  45775. * The gamepad object correlating to this controller
  45776. */
  45777. gamepadObject: IMinimalMotionControllerObject,
  45778. /**
  45779. * handness (left/right/none) of this controller
  45780. */
  45781. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  45782. /**
  45783. * Dispose this controller, the model mesh and all its components
  45784. */
  45785. dispose(): void;
  45786. /**
  45787. * Returns all components of specific type
  45788. * @param type the type to search for
  45789. * @return an array of components with this type
  45790. */
  45791. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  45792. /**
  45793. * get a component based an its component id as defined in layout.components
  45794. * @param id the id of the component
  45795. * @returns the component correlates to the id or undefined if not found
  45796. */
  45797. getComponent(id: string): WebXRControllerComponent;
  45798. /**
  45799. * Get the list of components available in this motion controller
  45800. * @returns an array of strings correlating to available components
  45801. */
  45802. getComponentIds(): string[];
  45803. /**
  45804. * Get the first component of specific type
  45805. * @param type type of component to find
  45806. * @return a controller component or null if not found
  45807. */
  45808. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  45809. /**
  45810. * Get the main (Select) component of this controller as defined in the layout
  45811. * @returns the main component of this controller
  45812. */
  45813. getMainComponent(): WebXRControllerComponent;
  45814. /**
  45815. * Loads the model correlating to this controller
  45816. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  45817. * @returns A promise fulfilled with the result of the model loading
  45818. */
  45819. loadModel(): Promise<boolean>;
  45820. /**
  45821. * Update this model using the current XRFrame
  45822. * @param xrFrame the current xr frame to use and update the model
  45823. */
  45824. updateFromXRFrame(xrFrame: XRFrame): void;
  45825. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45826. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  45827. /**
  45828. * Moves the axis on the controller mesh based on its current state
  45829. * @param axis the index of the axis
  45830. * @param axisValue the value of the axis which determines the meshes new position
  45831. * @hidden
  45832. */
  45833. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  45834. /**
  45835. * Update the model itself with the current frame data
  45836. * @param xrFrame the frame to use for updating the model mesh
  45837. */
  45838. protected updateModel(xrFrame: XRFrame): void;
  45839. /**
  45840. * Get the filename and path for this controller's model
  45841. * @returns a map of filename and path
  45842. */
  45843. protected abstract _getFilenameAndPath(): {
  45844. filename: string;
  45845. path: string;
  45846. };
  45847. /**
  45848. * This function is called before the mesh is loaded. It checks for loading constraints.
  45849. * For example, this function can check if the GLB loader is available
  45850. * If this function returns false, the generic controller will be loaded instead
  45851. * @returns Is the client ready to load the mesh
  45852. */
  45853. protected abstract _getModelLoadingConstraints(): boolean;
  45854. /**
  45855. * This function will be called after the model was successfully loaded and can be used
  45856. * for mesh transformations before it is available for the user
  45857. * @param meshes the loaded meshes
  45858. */
  45859. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  45860. /**
  45861. * Set the root mesh for this controller. Important for the WebXR controller class
  45862. * @param meshes the loaded meshes
  45863. */
  45864. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  45865. /**
  45866. * A function executed each frame that updates the mesh (if needed)
  45867. * @param xrFrame the current xrFrame
  45868. */
  45869. protected abstract _updateModel(xrFrame: XRFrame): void;
  45870. private _getGenericFilenameAndPath;
  45871. private _getGenericParentMesh;
  45872. }
  45873. }
  45874. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  45875. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45876. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45877. import { Scene } from "babylonjs/scene";
  45878. /**
  45879. * A generic trigger-only motion controller for WebXR
  45880. */
  45881. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  45882. /**
  45883. * Static version of the profile id of this controller
  45884. */
  45885. static ProfileId: string;
  45886. profileId: string;
  45887. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  45888. protected _getFilenameAndPath(): {
  45889. filename: string;
  45890. path: string;
  45891. };
  45892. protected _getModelLoadingConstraints(): boolean;
  45893. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  45894. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45895. protected _updateModel(): void;
  45896. }
  45897. }
  45898. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  45899. import { Vector4 } from "babylonjs/Maths/math.vector";
  45900. import { Mesh } from "babylonjs/Meshes/mesh";
  45901. import { Scene } from "babylonjs/scene";
  45902. import { Nullable } from "babylonjs/types";
  45903. /**
  45904. * Class containing static functions to help procedurally build meshes
  45905. */
  45906. export class SphereBuilder {
  45907. /**
  45908. * Creates a sphere mesh
  45909. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  45910. * * 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`)
  45911. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  45912. * * 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
  45913. * * 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)
  45914. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45915. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45916. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45917. * @param name defines the name of the mesh
  45918. * @param options defines the options used to create the mesh
  45919. * @param scene defines the hosting scene
  45920. * @returns the sphere mesh
  45921. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  45922. */
  45923. static CreateSphere(name: string, options: {
  45924. segments?: number;
  45925. diameter?: number;
  45926. diameterX?: number;
  45927. diameterY?: number;
  45928. diameterZ?: number;
  45929. arc?: number;
  45930. slice?: number;
  45931. sideOrientation?: number;
  45932. frontUVs?: Vector4;
  45933. backUVs?: Vector4;
  45934. updatable?: boolean;
  45935. }, scene?: Nullable<Scene>): Mesh;
  45936. }
  45937. }
  45938. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  45939. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45940. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45941. import { Scene } from "babylonjs/scene";
  45942. /**
  45943. * A profiled motion controller has its profile loaded from an online repository.
  45944. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  45945. */
  45946. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  45947. private _repositoryUrl;
  45948. private _buttonMeshMapping;
  45949. private _touchDots;
  45950. /**
  45951. * The profile ID of this controller. Will be populated when the controller initializes.
  45952. */
  45953. profileId: string;
  45954. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  45955. dispose(): void;
  45956. protected _getFilenameAndPath(): {
  45957. filename: string;
  45958. path: string;
  45959. };
  45960. protected _getModelLoadingConstraints(): boolean;
  45961. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  45962. protected _setRootMesh(meshes: AbstractMesh[]): void;
  45963. protected _updateModel(_xrFrame: XRFrame): void;
  45964. }
  45965. }
  45966. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  45967. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  45968. import { Scene } from "babylonjs/scene";
  45969. /**
  45970. * A construction function type to create a new controller based on an xrInput object
  45971. */
  45972. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  45973. /**
  45974. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  45975. *
  45976. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  45977. * it should be replaced with auto-loaded controllers.
  45978. *
  45979. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  45980. */
  45981. export class WebXRMotionControllerManager {
  45982. private static _AvailableControllers;
  45983. private static _Fallbacks;
  45984. private static _ProfileLoadingPromises;
  45985. private static _ProfilesList;
  45986. /**
  45987. * The base URL of the online controller repository. Can be changed at any time.
  45988. */
  45989. static BaseRepositoryUrl: string;
  45990. /**
  45991. * Which repository gets priority - local or online
  45992. */
  45993. static PrioritizeOnlineRepository: boolean;
  45994. /**
  45995. * Use the online repository, or use only locally-defined controllers
  45996. */
  45997. static UseOnlineRepository: boolean;
  45998. /**
  45999. * Clear the cache used for profile loading and reload when requested again
  46000. */
  46001. static ClearProfilesCache(): void;
  46002. /**
  46003. * Register the default fallbacks.
  46004. * This function is called automatically when this file is imported.
  46005. */
  46006. static DefaultFallbacks(): void;
  46007. /**
  46008. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  46009. * @param profileId the profile to which a fallback needs to be found
  46010. * @return an array with corresponding fallback profiles
  46011. */
  46012. static FindFallbackWithProfileId(profileId: string): string[];
  46013. /**
  46014. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  46015. * The order of search:
  46016. *
  46017. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  46018. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  46019. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  46020. * 4) return the generic trigger controller if none were found
  46021. *
  46022. * @param xrInput the xrInput to which a new controller is initialized
  46023. * @param scene the scene to which the model will be added
  46024. * @param forceProfile force a certain profile for this controller
  46025. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  46026. */
  46027. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  46028. /**
  46029. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  46030. *
  46031. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  46032. *
  46033. * @param type the profile type to register
  46034. * @param constructFunction the function to be called when loading this profile
  46035. */
  46036. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  46037. /**
  46038. * Register a fallback to a specific profile.
  46039. * @param profileId the profileId that will receive the fallbacks
  46040. * @param fallbacks A list of fallback profiles
  46041. */
  46042. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  46043. /**
  46044. * Will update the list of profiles available in the repository
  46045. * @return a promise that resolves to a map of profiles available online
  46046. */
  46047. static UpdateProfilesList(): Promise<{
  46048. [profile: string]: string;
  46049. }>;
  46050. private static _LoadProfileFromRepository;
  46051. private static _LoadProfilesFromAvailableControllers;
  46052. }
  46053. }
  46054. declare module "babylonjs/XR/webXRInputSource" {
  46055. import { Observable } from "babylonjs/Misc/observable";
  46056. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46057. import { Ray } from "babylonjs/Culling/ray";
  46058. import { Scene } from "babylonjs/scene";
  46059. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  46060. /**
  46061. * Configuration options for the WebXR controller creation
  46062. */
  46063. export interface IWebXRControllerOptions {
  46064. /**
  46065. * Should the controller mesh be animated when a user interacts with it
  46066. * The pressed buttons / thumbstick and touchpad animations will be disabled
  46067. */
  46068. disableMotionControllerAnimation?: boolean;
  46069. /**
  46070. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  46071. */
  46072. doNotLoadControllerMesh?: boolean;
  46073. /**
  46074. * Force a specific controller type for this controller.
  46075. * This can be used when creating your own profile or when testing different controllers
  46076. */
  46077. forceControllerProfile?: string;
  46078. }
  46079. /**
  46080. * Represents an XR controller
  46081. */
  46082. export class WebXRInputSource {
  46083. private _scene;
  46084. /** The underlying input source for the controller */
  46085. inputSource: XRInputSource;
  46086. private _options;
  46087. private _tmpQuaternion;
  46088. private _tmpVector;
  46089. private _uniqueId;
  46090. /**
  46091. * 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
  46092. */
  46093. grip?: AbstractMesh;
  46094. /**
  46095. * If available, this is the gamepad object related to this controller.
  46096. * Using this object it is possible to get click events and trackpad changes of the
  46097. * webxr controller that is currently being used.
  46098. */
  46099. motionController?: WebXRAbstractMotionController;
  46100. /**
  46101. * Event that fires when the controller is removed/disposed.
  46102. * The object provided as event data is this controller, after associated assets were disposed.
  46103. * uniqueId is still available.
  46104. */
  46105. onDisposeObservable: Observable<WebXRInputSource>;
  46106. /**
  46107. * Will be triggered when the mesh associated with the motion controller is done loading.
  46108. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  46109. * A shortened version of controller -> motion controller -> on mesh loaded.
  46110. */
  46111. onMeshLoadedObservable: Observable<AbstractMesh>;
  46112. /**
  46113. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  46114. */
  46115. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  46116. /**
  46117. * Pointer which can be used to select objects or attach a visible laser to
  46118. */
  46119. pointer: AbstractMesh;
  46120. /**
  46121. * Creates the controller
  46122. * @see https://doc.babylonjs.com/how_to/webxr
  46123. * @param _scene the scene which the controller should be associated to
  46124. * @param inputSource the underlying input source for the controller
  46125. * @param _options options for this controller creation
  46126. */
  46127. constructor(_scene: Scene,
  46128. /** The underlying input source for the controller */
  46129. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  46130. /**
  46131. * Get this controllers unique id
  46132. */
  46133. get uniqueId(): string;
  46134. /**
  46135. * Disposes of the object
  46136. */
  46137. dispose(): void;
  46138. /**
  46139. * Gets a world space ray coming from the pointer or grip
  46140. * @param result the resulting ray
  46141. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  46142. */
  46143. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  46144. /**
  46145. * Updates the controller pose based on the given XRFrame
  46146. * @param xrFrame xr frame to update the pose with
  46147. * @param referenceSpace reference space to use
  46148. */
  46149. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  46150. }
  46151. }
  46152. declare module "babylonjs/XR/webXRInput" {
  46153. import { Observable } from "babylonjs/Misc/observable";
  46154. import { IDisposable } from "babylonjs/scene";
  46155. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46156. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46157. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  46158. /**
  46159. * The schema for initialization options of the XR Input class
  46160. */
  46161. export interface IWebXRInputOptions {
  46162. /**
  46163. * If set to true no model will be automatically loaded
  46164. */
  46165. doNotLoadControllerMeshes?: boolean;
  46166. /**
  46167. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  46168. * If not found, the xr input profile data will be used.
  46169. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  46170. */
  46171. forceInputProfile?: string;
  46172. /**
  46173. * Do not send a request to the controller repository to load the profile.
  46174. *
  46175. * Instead, use the controllers available in babylon itself.
  46176. */
  46177. disableOnlineControllerRepository?: boolean;
  46178. /**
  46179. * A custom URL for the controllers repository
  46180. */
  46181. customControllersRepositoryURL?: string;
  46182. /**
  46183. * Should the controller model's components not move according to the user input
  46184. */
  46185. disableControllerAnimation?: boolean;
  46186. }
  46187. /**
  46188. * XR input used to track XR inputs such as controllers/rays
  46189. */
  46190. export class WebXRInput implements IDisposable {
  46191. /**
  46192. * the xr session manager for this session
  46193. */
  46194. xrSessionManager: WebXRSessionManager;
  46195. /**
  46196. * the WebXR camera for this session. Mainly used for teleportation
  46197. */
  46198. xrCamera: WebXRCamera;
  46199. private readonly options;
  46200. /**
  46201. * XR controllers being tracked
  46202. */
  46203. controllers: Array<WebXRInputSource>;
  46204. private _frameObserver;
  46205. private _sessionEndedObserver;
  46206. private _sessionInitObserver;
  46207. /**
  46208. * Event when a controller has been connected/added
  46209. */
  46210. onControllerAddedObservable: Observable<WebXRInputSource>;
  46211. /**
  46212. * Event when a controller has been removed/disconnected
  46213. */
  46214. onControllerRemovedObservable: Observable<WebXRInputSource>;
  46215. /**
  46216. * Initializes the WebXRInput
  46217. * @param xrSessionManager the xr session manager for this session
  46218. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  46219. * @param options = initialization options for this xr input
  46220. */
  46221. constructor(
  46222. /**
  46223. * the xr session manager for this session
  46224. */
  46225. xrSessionManager: WebXRSessionManager,
  46226. /**
  46227. * the WebXR camera for this session. Mainly used for teleportation
  46228. */
  46229. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  46230. private _onInputSourcesChange;
  46231. private _addAndRemoveControllers;
  46232. /**
  46233. * Disposes of the object
  46234. */
  46235. dispose(): void;
  46236. }
  46237. }
  46238. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  46239. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46240. import { Observable, EventState } from "babylonjs/Misc/observable";
  46241. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46242. /**
  46243. * This is the base class for all WebXR features.
  46244. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  46245. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  46246. */
  46247. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  46248. protected _xrSessionManager: WebXRSessionManager;
  46249. private _attached;
  46250. private _removeOnDetach;
  46251. /**
  46252. * Should auto-attach be disabled?
  46253. */
  46254. disableAutoAttach: boolean;
  46255. /**
  46256. * Construct a new (abstract) WebXR feature
  46257. * @param _xrSessionManager the xr session manager for this feature
  46258. */
  46259. constructor(_xrSessionManager: WebXRSessionManager);
  46260. /**
  46261. * Is this feature attached
  46262. */
  46263. get attached(): boolean;
  46264. /**
  46265. * attach this feature
  46266. *
  46267. * @param force should attachment be forced (even when already attached)
  46268. * @returns true if successful, false is failed or already attached
  46269. */
  46270. attach(force?: boolean): boolean;
  46271. /**
  46272. * detach this feature.
  46273. *
  46274. * @returns true if successful, false if failed or already detached
  46275. */
  46276. detach(): boolean;
  46277. /**
  46278. * Dispose this feature and all of the resources attached
  46279. */
  46280. dispose(): void;
  46281. /**
  46282. * This is used to register callbacks that will automatically be removed when detach is called.
  46283. * @param observable the observable to which the observer will be attached
  46284. * @param callback the callback to register
  46285. */
  46286. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  46287. /**
  46288. * Code in this function will be executed on each xrFrame received from the browser.
  46289. * This function will not execute after the feature is detached.
  46290. * @param _xrFrame the current frame
  46291. */
  46292. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  46293. }
  46294. }
  46295. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  46296. import { IDisposable, Scene } from "babylonjs/scene";
  46297. import { Nullable } from "babylonjs/types";
  46298. import { Observable } from "babylonjs/Misc/observable";
  46299. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46300. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  46301. import { Camera } from "babylonjs/Cameras/camera";
  46302. /**
  46303. * Renders a layer on top of an existing scene
  46304. */
  46305. export class UtilityLayerRenderer implements IDisposable {
  46306. /** the original scene that will be rendered on top of */
  46307. originalScene: Scene;
  46308. private _pointerCaptures;
  46309. private _lastPointerEvents;
  46310. private static _DefaultUtilityLayer;
  46311. private static _DefaultKeepDepthUtilityLayer;
  46312. private _sharedGizmoLight;
  46313. private _renderCamera;
  46314. /**
  46315. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  46316. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  46317. * @returns the camera that is used when rendering the utility layer
  46318. */
  46319. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  46320. /**
  46321. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  46322. * @param cam the camera that should be used when rendering the utility layer
  46323. */
  46324. setRenderCamera(cam: Nullable<Camera>): void;
  46325. /**
  46326. * @hidden
  46327. * Light which used by gizmos to get light shading
  46328. */
  46329. _getSharedGizmoLight(): HemisphericLight;
  46330. /**
  46331. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  46332. */
  46333. pickUtilitySceneFirst: boolean;
  46334. /**
  46335. * 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)
  46336. */
  46337. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  46338. /**
  46339. * 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)
  46340. */
  46341. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  46342. /**
  46343. * The scene that is rendered on top of the original scene
  46344. */
  46345. utilityLayerScene: Scene;
  46346. /**
  46347. * If the utility layer should automatically be rendered on top of existing scene
  46348. */
  46349. shouldRender: boolean;
  46350. /**
  46351. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  46352. */
  46353. onlyCheckPointerDownEvents: boolean;
  46354. /**
  46355. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  46356. */
  46357. processAllEvents: boolean;
  46358. /**
  46359. * Observable raised when the pointer move from the utility layer scene to the main scene
  46360. */
  46361. onPointerOutObservable: Observable<number>;
  46362. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  46363. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  46364. private _afterRenderObserver;
  46365. private _sceneDisposeObserver;
  46366. private _originalPointerObserver;
  46367. /**
  46368. * Instantiates a UtilityLayerRenderer
  46369. * @param originalScene the original scene that will be rendered on top of
  46370. * @param handleEvents boolean indicating if the utility layer should handle events
  46371. */
  46372. constructor(
  46373. /** the original scene that will be rendered on top of */
  46374. originalScene: Scene, handleEvents?: boolean);
  46375. private _notifyObservers;
  46376. /**
  46377. * Renders the utility layers scene on top of the original scene
  46378. */
  46379. render(): void;
  46380. /**
  46381. * Disposes of the renderer
  46382. */
  46383. dispose(): void;
  46384. private _updateCamera;
  46385. }
  46386. }
  46387. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  46388. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46389. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46390. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46391. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  46392. import { Scene } from "babylonjs/scene";
  46393. import { Nullable } from "babylonjs/types";
  46394. import { Color3 } from "babylonjs/Maths/math.color";
  46395. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46396. /**
  46397. * Options interface for the pointer selection module
  46398. */
  46399. export interface IWebXRControllerPointerSelectionOptions {
  46400. /**
  46401. * if provided, this scene will be used to render meshes.
  46402. */
  46403. customUtilityLayerScene?: Scene;
  46404. /**
  46405. * 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)
  46406. * If not disabled, the last picked point will be used to execute a pointer up event
  46407. * If disabled, pointer up event will be triggered right after the pointer down event.
  46408. * Used in screen and gaze target ray mode only
  46409. */
  46410. disablePointerUpOnTouchOut: boolean;
  46411. /**
  46412. * For gaze mode (time to select instead of press)
  46413. */
  46414. forceGazeMode: boolean;
  46415. /**
  46416. * 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
  46417. * to start a new countdown to the pointer down event.
  46418. * Defaults to 1.
  46419. */
  46420. gazeModePointerMovedFactor?: number;
  46421. /**
  46422. * Different button type to use instead of the main component
  46423. */
  46424. overrideButtonId?: string;
  46425. /**
  46426. * use this rendering group id for the meshes (optional)
  46427. */
  46428. renderingGroupId?: number;
  46429. /**
  46430. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  46431. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  46432. * 3000 means 3 seconds between pointing at something and selecting it
  46433. */
  46434. timeToSelect?: number;
  46435. /**
  46436. * Should meshes created here be added to a utility layer or the main scene
  46437. */
  46438. useUtilityLayer?: boolean;
  46439. /**
  46440. * the xr input to use with this pointer selection
  46441. */
  46442. xrInput: WebXRInput;
  46443. }
  46444. /**
  46445. * A module that will enable pointer selection for motion controllers of XR Input Sources
  46446. */
  46447. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  46448. private readonly _options;
  46449. private static _idCounter;
  46450. private _attachController;
  46451. private _controllers;
  46452. private _scene;
  46453. private _tmpVectorForPickCompare;
  46454. /**
  46455. * The module's name
  46456. */
  46457. static readonly Name: string;
  46458. /**
  46459. * The (Babylon) version of this module.
  46460. * This is an integer representing the implementation version.
  46461. * This number does not correspond to the WebXR specs version
  46462. */
  46463. static readonly Version: number;
  46464. /**
  46465. * Disable lighting on the laser pointer (so it will always be visible)
  46466. */
  46467. disablePointerLighting: boolean;
  46468. /**
  46469. * Disable lighting on the selection mesh (so it will always be visible)
  46470. */
  46471. disableSelectionMeshLighting: boolean;
  46472. /**
  46473. * Should the laser pointer be displayed
  46474. */
  46475. displayLaserPointer: boolean;
  46476. /**
  46477. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  46478. */
  46479. displaySelectionMesh: boolean;
  46480. /**
  46481. * This color will be set to the laser pointer when selection is triggered
  46482. */
  46483. laserPointerPickedColor: Color3;
  46484. /**
  46485. * Default color of the laser pointer
  46486. */
  46487. lasterPointerDefaultColor: Color3;
  46488. /**
  46489. * default color of the selection ring
  46490. */
  46491. selectionMeshDefaultColor: Color3;
  46492. /**
  46493. * This color will be applied to the selection ring when selection is triggered
  46494. */
  46495. selectionMeshPickedColor: Color3;
  46496. /**
  46497. * Optional filter to be used for ray selection. This predicate shares behavior with
  46498. * scene.pointerMovePredicate which takes priority if it is also assigned.
  46499. */
  46500. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  46501. /**
  46502. * constructs a new background remover module
  46503. * @param _xrSessionManager the session manager for this module
  46504. * @param _options read-only options to be used in this module
  46505. */
  46506. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  46507. /**
  46508. * attach this feature
  46509. * Will usually be called by the features manager
  46510. *
  46511. * @returns true if successful.
  46512. */
  46513. attach(): boolean;
  46514. /**
  46515. * detach this feature.
  46516. * Will usually be called by the features manager
  46517. *
  46518. * @returns true if successful.
  46519. */
  46520. detach(): boolean;
  46521. /**
  46522. * Will get the mesh under a specific pointer.
  46523. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  46524. * @param controllerId the controllerId to check
  46525. * @returns The mesh under pointer or null if no mesh is under the pointer
  46526. */
  46527. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  46528. /**
  46529. * Get the xr controller that correlates to the pointer id in the pointer event
  46530. *
  46531. * @param id the pointer id to search for
  46532. * @returns the controller that correlates to this id or null if not found
  46533. */
  46534. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  46535. protected _onXRFrame(_xrFrame: XRFrame): void;
  46536. private _attachGazeMode;
  46537. private _attachScreenRayMode;
  46538. private _attachTrackedPointerRayMode;
  46539. private _convertNormalToDirectionOfRay;
  46540. private _detachController;
  46541. private _generateNewMeshPair;
  46542. private _pickingMoved;
  46543. private _updatePointerDistance;
  46544. }
  46545. }
  46546. declare module "babylonjs/XR/webXREnterExitUI" {
  46547. import { Nullable } from "babylonjs/types";
  46548. import { Observable } from "babylonjs/Misc/observable";
  46549. import { IDisposable, Scene } from "babylonjs/scene";
  46550. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46551. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46552. /**
  46553. * Button which can be used to enter a different mode of XR
  46554. */
  46555. export class WebXREnterExitUIButton {
  46556. /** button element */
  46557. element: HTMLElement;
  46558. /** XR initialization options for the button */
  46559. sessionMode: XRSessionMode;
  46560. /** Reference space type */
  46561. referenceSpaceType: XRReferenceSpaceType;
  46562. /**
  46563. * Creates a WebXREnterExitUIButton
  46564. * @param element button element
  46565. * @param sessionMode XR initialization session mode
  46566. * @param referenceSpaceType the type of reference space to be used
  46567. */
  46568. constructor(
  46569. /** button element */
  46570. element: HTMLElement,
  46571. /** XR initialization options for the button */
  46572. sessionMode: XRSessionMode,
  46573. /** Reference space type */
  46574. referenceSpaceType: XRReferenceSpaceType);
  46575. /**
  46576. * Extendable function which can be used to update the button's visuals when the state changes
  46577. * @param activeButton the current active button in the UI
  46578. */
  46579. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  46580. }
  46581. /**
  46582. * Options to create the webXR UI
  46583. */
  46584. export class WebXREnterExitUIOptions {
  46585. /**
  46586. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  46587. */
  46588. customButtons?: Array<WebXREnterExitUIButton>;
  46589. /**
  46590. * A reference space type to use when creating the default button.
  46591. * Default is local-floor
  46592. */
  46593. referenceSpaceType?: XRReferenceSpaceType;
  46594. /**
  46595. * Context to enter xr with
  46596. */
  46597. renderTarget?: Nullable<WebXRRenderTarget>;
  46598. /**
  46599. * A session mode to use when creating the default button.
  46600. * Default is immersive-vr
  46601. */
  46602. sessionMode?: XRSessionMode;
  46603. }
  46604. /**
  46605. * UI to allow the user to enter/exit XR mode
  46606. */
  46607. export class WebXREnterExitUI implements IDisposable {
  46608. private scene;
  46609. /** version of the options passed to this UI */
  46610. options: WebXREnterExitUIOptions;
  46611. private _activeButton;
  46612. private _buttons;
  46613. private _overlay;
  46614. /**
  46615. * Fired every time the active button is changed.
  46616. *
  46617. * When xr is entered via a button that launches xr that button will be the callback parameter
  46618. *
  46619. * When exiting xr the callback parameter will be null)
  46620. */
  46621. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  46622. /**
  46623. *
  46624. * @param scene babylon scene object to use
  46625. * @param options (read-only) version of the options passed to this UI
  46626. */
  46627. private constructor();
  46628. /**
  46629. * Creates UI to allow the user to enter/exit XR mode
  46630. * @param scene the scene to add the ui to
  46631. * @param helper the xr experience helper to enter/exit xr with
  46632. * @param options options to configure the UI
  46633. * @returns the created ui
  46634. */
  46635. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  46636. /**
  46637. * Disposes of the XR UI component
  46638. */
  46639. dispose(): void;
  46640. private _updateButtons;
  46641. }
  46642. }
  46643. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  46644. import { Vector3 } from "babylonjs/Maths/math.vector";
  46645. import { Color4 } from "babylonjs/Maths/math.color";
  46646. import { Nullable } from "babylonjs/types";
  46647. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  46648. import { Scene } from "babylonjs/scene";
  46649. /**
  46650. * Class containing static functions to help procedurally build meshes
  46651. */
  46652. export class LinesBuilder {
  46653. /**
  46654. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  46655. * * 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
  46656. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  46657. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  46658. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  46659. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  46660. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46661. * * 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
  46662. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  46663. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  46665. * @param name defines the name of the new line system
  46666. * @param options defines the options used to create the line system
  46667. * @param scene defines the hosting scene
  46668. * @returns a new line system mesh
  46669. */
  46670. static CreateLineSystem(name: string, options: {
  46671. lines: Vector3[][];
  46672. updatable?: boolean;
  46673. instance?: Nullable<LinesMesh>;
  46674. colors?: Nullable<Color4[][]>;
  46675. useVertexAlpha?: boolean;
  46676. }, scene: Nullable<Scene>): LinesMesh;
  46677. /**
  46678. * Creates a line mesh
  46679. * 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
  46680. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46681. * * The parameter `points` is an array successive Vector3
  46682. * * 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
  46683. * * The optional parameter `colors` is an array of successive Color4, one per line point
  46684. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  46685. * * When updating an instance, remember that only point positions can change, not the number of points
  46686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46687. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  46688. * @param name defines the name of the new line system
  46689. * @param options defines the options used to create the line system
  46690. * @param scene defines the hosting scene
  46691. * @returns a new line mesh
  46692. */
  46693. static CreateLines(name: string, options: {
  46694. points: Vector3[];
  46695. updatable?: boolean;
  46696. instance?: Nullable<LinesMesh>;
  46697. colors?: Color4[];
  46698. useVertexAlpha?: boolean;
  46699. }, scene?: Nullable<Scene>): LinesMesh;
  46700. /**
  46701. * Creates a dashed line mesh
  46702. * * 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
  46703. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  46704. * * The parameter `points` is an array successive Vector3
  46705. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  46706. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  46707. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  46708. * * 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
  46709. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  46710. * * When updating an instance, remember that only point positions can change, not the number of points
  46711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  46712. * @param name defines the name of the mesh
  46713. * @param options defines the options used to create the mesh
  46714. * @param scene defines the hosting scene
  46715. * @returns the dashed line mesh
  46716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  46717. */
  46718. static CreateDashedLines(name: string, options: {
  46719. points: Vector3[];
  46720. dashSize?: number;
  46721. gapSize?: number;
  46722. dashNb?: number;
  46723. updatable?: boolean;
  46724. instance?: LinesMesh;
  46725. useVertexAlpha?: boolean;
  46726. }, scene?: Nullable<Scene>): LinesMesh;
  46727. }
  46728. }
  46729. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  46730. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  46731. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  46732. import { WebXRInput } from "babylonjs/XR/webXRInput";
  46733. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46734. import { Vector3 } from "babylonjs/Maths/math.vector";
  46735. import { Material } from "babylonjs/Materials/material";
  46736. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  46737. import { Scene } from "babylonjs/scene";
  46738. /**
  46739. * The options container for the teleportation module
  46740. */
  46741. export interface IWebXRTeleportationOptions {
  46742. /**
  46743. * if provided, this scene will be used to render meshes.
  46744. */
  46745. customUtilityLayerScene?: Scene;
  46746. /**
  46747. * Values to configure the default target mesh
  46748. */
  46749. defaultTargetMeshOptions?: {
  46750. /**
  46751. * Fill color of the teleportation area
  46752. */
  46753. teleportationFillColor?: string;
  46754. /**
  46755. * Border color for the teleportation area
  46756. */
  46757. teleportationBorderColor?: string;
  46758. /**
  46759. * Disable the mesh's animation sequence
  46760. */
  46761. disableAnimation?: boolean;
  46762. /**
  46763. * Disable lighting on the material or the ring and arrow
  46764. */
  46765. disableLighting?: boolean;
  46766. /**
  46767. * Override the default material of the torus and arrow
  46768. */
  46769. torusArrowMaterial?: Material;
  46770. };
  46771. /**
  46772. * A list of meshes to use as floor meshes.
  46773. * Meshes can be added and removed after initializing the feature using the
  46774. * addFloorMesh and removeFloorMesh functions
  46775. * If empty, rotation will still work
  46776. */
  46777. floorMeshes?: AbstractMesh[];
  46778. /**
  46779. * use this rendering group id for the meshes (optional)
  46780. */
  46781. renderingGroupId?: number;
  46782. /**
  46783. * Should teleportation move only to snap points
  46784. */
  46785. snapPointsOnly?: boolean;
  46786. /**
  46787. * An array of points to which the teleportation will snap to.
  46788. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  46789. */
  46790. snapPositions?: Vector3[];
  46791. /**
  46792. * How close should the teleportation ray be in order to snap to position.
  46793. * Default to 0.8 units (meters)
  46794. */
  46795. snapToPositionRadius?: number;
  46796. /**
  46797. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  46798. * If you want to support rotation, make sure your mesh has a direction indicator.
  46799. *
  46800. * When left untouched, the default mesh will be initialized.
  46801. */
  46802. teleportationTargetMesh?: AbstractMesh;
  46803. /**
  46804. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  46805. */
  46806. timeToTeleport?: number;
  46807. /**
  46808. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  46809. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  46810. */
  46811. useMainComponentOnly?: boolean;
  46812. /**
  46813. * Should meshes created here be added to a utility layer or the main scene
  46814. */
  46815. useUtilityLayer?: boolean;
  46816. /**
  46817. * Babylon XR Input class for controller
  46818. */
  46819. xrInput: WebXRInput;
  46820. }
  46821. /**
  46822. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  46823. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  46824. * the input of the attached controllers.
  46825. */
  46826. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  46827. private _options;
  46828. private _controllers;
  46829. private _currentTeleportationControllerId;
  46830. private _floorMeshes;
  46831. private _quadraticBezierCurve;
  46832. private _selectionFeature;
  46833. private _snapToPositions;
  46834. private _snappedToPoint;
  46835. private _teleportationRingMaterial?;
  46836. private _tmpRay;
  46837. private _tmpVector;
  46838. /**
  46839. * The module's name
  46840. */
  46841. static readonly Name: string;
  46842. /**
  46843. * The (Babylon) version of this module.
  46844. * This is an integer representing the implementation version.
  46845. * This number does not correspond to the webxr specs version
  46846. */
  46847. static readonly Version: number;
  46848. /**
  46849. * Is movement backwards enabled
  46850. */
  46851. backwardsMovementEnabled: boolean;
  46852. /**
  46853. * Distance to travel when moving backwards
  46854. */
  46855. backwardsTeleportationDistance: number;
  46856. /**
  46857. * The distance from the user to the inspection point in the direction of the controller
  46858. * A higher number will allow the user to move further
  46859. * defaults to 5 (meters, in xr units)
  46860. */
  46861. parabolicCheckRadius: number;
  46862. /**
  46863. * Should the module support parabolic ray on top of direct ray
  46864. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  46865. * Very helpful when moving between floors / different heights
  46866. */
  46867. parabolicRayEnabled: boolean;
  46868. /**
  46869. * How much rotation should be applied when rotating right and left
  46870. */
  46871. rotationAngle: number;
  46872. /**
  46873. * Is rotation enabled when moving forward?
  46874. * Disabling this feature will prevent the user from deciding the direction when teleporting
  46875. */
  46876. rotationEnabled: boolean;
  46877. /**
  46878. * constructs a new anchor system
  46879. * @param _xrSessionManager an instance of WebXRSessionManager
  46880. * @param _options configuration object for this feature
  46881. */
  46882. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  46883. /**
  46884. * Get the snapPointsOnly flag
  46885. */
  46886. get snapPointsOnly(): boolean;
  46887. /**
  46888. * Sets the snapPointsOnly flag
  46889. * @param snapToPoints should teleportation be exclusively to snap points
  46890. */
  46891. set snapPointsOnly(snapToPoints: boolean);
  46892. /**
  46893. * Add a new mesh to the floor meshes array
  46894. * @param mesh the mesh to use as floor mesh
  46895. */
  46896. addFloorMesh(mesh: AbstractMesh): void;
  46897. /**
  46898. * Add a new snap-to point to fix teleportation to this position
  46899. * @param newSnapPoint The new Snap-To point
  46900. */
  46901. addSnapPoint(newSnapPoint: Vector3): void;
  46902. attach(): boolean;
  46903. detach(): boolean;
  46904. dispose(): void;
  46905. /**
  46906. * Remove a mesh from the floor meshes array
  46907. * @param mesh the mesh to remove
  46908. */
  46909. removeFloorMesh(mesh: AbstractMesh): void;
  46910. /**
  46911. * Remove a mesh from the floor meshes array using its name
  46912. * @param name the mesh name to remove
  46913. */
  46914. removeFloorMeshByName(name: string): void;
  46915. /**
  46916. * 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
  46917. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  46918. * @returns was the point found and removed or not
  46919. */
  46920. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  46921. /**
  46922. * This function sets a selection feature that will be disabled when
  46923. * the forward ray is shown and will be reattached when hidden.
  46924. * This is used to remove the selection rays when moving.
  46925. * @param selectionFeature the feature to disable when forward movement is enabled
  46926. */
  46927. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  46928. protected _onXRFrame(_xrFrame: XRFrame): void;
  46929. private _attachController;
  46930. private _createDefaultTargetMesh;
  46931. private _detachController;
  46932. private _findClosestSnapPointWithRadius;
  46933. private _setTargetMeshPosition;
  46934. private _setTargetMeshVisibility;
  46935. private _showParabolicPath;
  46936. private _teleportForward;
  46937. }
  46938. }
  46939. declare module "babylonjs/XR/webXRDefaultExperience" {
  46940. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  46941. import { Scene } from "babylonjs/scene";
  46942. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  46943. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  46944. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  46945. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  46946. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46947. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  46948. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  46949. /**
  46950. * Options for the default xr helper
  46951. */
  46952. export class WebXRDefaultExperienceOptions {
  46953. /**
  46954. * Enable or disable default UI to enter XR
  46955. */
  46956. disableDefaultUI?: boolean;
  46957. /**
  46958. * Should teleportation not initialize. defaults to false.
  46959. */
  46960. disableTeleportation?: boolean;
  46961. /**
  46962. * Floor meshes that will be used for teleport
  46963. */
  46964. floorMeshes?: Array<AbstractMesh>;
  46965. /**
  46966. * If set to true, the first frame will not be used to reset position
  46967. * The first frame is mainly used when copying transformation from the old camera
  46968. * Mainly used in AR
  46969. */
  46970. ignoreNativeCameraTransformation?: boolean;
  46971. /**
  46972. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  46973. */
  46974. inputOptions?: IWebXRInputOptions;
  46975. /**
  46976. * optional configuration for the output canvas
  46977. */
  46978. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  46979. /**
  46980. * optional UI options. This can be used among other to change session mode and reference space type
  46981. */
  46982. uiOptions?: WebXREnterExitUIOptions;
  46983. /**
  46984. * When loading teleportation and pointer select, use stable versions instead of latest.
  46985. */
  46986. useStablePlugins?: boolean;
  46987. }
  46988. /**
  46989. * Default experience which provides a similar setup to the previous webVRExperience
  46990. */
  46991. export class WebXRDefaultExperience {
  46992. /**
  46993. * Base experience
  46994. */
  46995. baseExperience: WebXRExperienceHelper;
  46996. /**
  46997. * Enables ui for entering/exiting xr
  46998. */
  46999. enterExitUI: WebXREnterExitUI;
  47000. /**
  47001. * Input experience extension
  47002. */
  47003. input: WebXRInput;
  47004. /**
  47005. * Enables laser pointer and selection
  47006. */
  47007. pointerSelection: WebXRControllerPointerSelection;
  47008. /**
  47009. * Default target xr should render to
  47010. */
  47011. renderTarget: WebXRRenderTarget;
  47012. /**
  47013. * Enables teleportation
  47014. */
  47015. teleportation: WebXRMotionControllerTeleportation;
  47016. private constructor();
  47017. /**
  47018. * Creates the default xr experience
  47019. * @param scene scene
  47020. * @param options options for basic configuration
  47021. * @returns resulting WebXRDefaultExperience
  47022. */
  47023. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  47024. /**
  47025. * DIsposes of the experience helper
  47026. */
  47027. dispose(): void;
  47028. }
  47029. }
  47030. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  47031. import { Observable } from "babylonjs/Misc/observable";
  47032. import { Nullable } from "babylonjs/types";
  47033. import { Camera } from "babylonjs/Cameras/camera";
  47034. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  47035. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47036. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  47037. import { Scene } from "babylonjs/scene";
  47038. import { Vector3 } from "babylonjs/Maths/math.vector";
  47039. import { Color3 } from "babylonjs/Maths/math.color";
  47040. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  47041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47042. import { Mesh } from "babylonjs/Meshes/mesh";
  47043. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  47044. import { EasingFunction } from "babylonjs/Animations/easing";
  47045. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  47046. import "babylonjs/Meshes/Builders/groundBuilder";
  47047. import "babylonjs/Meshes/Builders/torusBuilder";
  47048. import "babylonjs/Meshes/Builders/cylinderBuilder";
  47049. import "babylonjs/Gamepads/gamepadSceneComponent";
  47050. import "babylonjs/Animations/animatable";
  47051. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  47052. /**
  47053. * Options to modify the vr teleportation behavior.
  47054. */
  47055. export interface VRTeleportationOptions {
  47056. /**
  47057. * The name of the mesh which should be used as the teleportation floor. (default: null)
  47058. */
  47059. floorMeshName?: string;
  47060. /**
  47061. * A list of meshes to be used as the teleportation floor. (default: empty)
  47062. */
  47063. floorMeshes?: Mesh[];
  47064. /**
  47065. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  47066. */
  47067. teleportationMode?: number;
  47068. /**
  47069. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  47070. */
  47071. teleportationTime?: number;
  47072. /**
  47073. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  47074. */
  47075. teleportationSpeed?: number;
  47076. /**
  47077. * The easing function used in the animation or null for Linear. (default CircleEase)
  47078. */
  47079. easingFunction?: EasingFunction;
  47080. }
  47081. /**
  47082. * Options to modify the vr experience helper's behavior.
  47083. */
  47084. export interface VRExperienceHelperOptions extends WebVROptions {
  47085. /**
  47086. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  47087. */
  47088. createDeviceOrientationCamera?: boolean;
  47089. /**
  47090. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  47091. */
  47092. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  47093. /**
  47094. * Uses the main button on the controller to toggle the laser casted. (default: true)
  47095. */
  47096. laserToggle?: boolean;
  47097. /**
  47098. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  47099. */
  47100. floorMeshes?: Mesh[];
  47101. /**
  47102. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  47103. */
  47104. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  47105. /**
  47106. * Defines if WebXR should be used instead of WebVR (if available)
  47107. */
  47108. useXR?: boolean;
  47109. }
  47110. /**
  47111. * Event containing information after VR has been entered
  47112. */
  47113. export class OnAfterEnteringVRObservableEvent {
  47114. /**
  47115. * If entering vr was successful
  47116. */
  47117. success: boolean;
  47118. }
  47119. /**
  47120. * Helps to quickly add VR support to an existing scene.
  47121. * See http://doc.babylonjs.com/how_to/webvr_helper
  47122. */
  47123. export class VRExperienceHelper {
  47124. /** Options to modify the vr experience helper's behavior. */
  47125. webVROptions: VRExperienceHelperOptions;
  47126. private _scene;
  47127. private _position;
  47128. private _btnVR;
  47129. private _btnVRDisplayed;
  47130. private _webVRsupported;
  47131. private _webVRready;
  47132. private _webVRrequesting;
  47133. private _webVRpresenting;
  47134. private _hasEnteredVR;
  47135. private _fullscreenVRpresenting;
  47136. private _inputElement;
  47137. private _webVRCamera;
  47138. private _vrDeviceOrientationCamera;
  47139. private _deviceOrientationCamera;
  47140. private _existingCamera;
  47141. private _onKeyDown;
  47142. private _onVrDisplayPresentChange;
  47143. private _onVRDisplayChanged;
  47144. private _onVRRequestPresentStart;
  47145. private _onVRRequestPresentComplete;
  47146. /**
  47147. * 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)
  47148. */
  47149. enableGazeEvenWhenNoPointerLock: boolean;
  47150. /**
  47151. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  47152. */
  47153. exitVROnDoubleTap: boolean;
  47154. /**
  47155. * Observable raised right before entering VR.
  47156. */
  47157. onEnteringVRObservable: Observable<VRExperienceHelper>;
  47158. /**
  47159. * Observable raised when entering VR has completed.
  47160. */
  47161. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  47162. /**
  47163. * Observable raised when exiting VR.
  47164. */
  47165. onExitingVRObservable: Observable<VRExperienceHelper>;
  47166. /**
  47167. * Observable raised when controller mesh is loaded.
  47168. */
  47169. onControllerMeshLoadedObservable: Observable<WebVRController>;
  47170. /** Return this.onEnteringVRObservable
  47171. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  47172. */
  47173. get onEnteringVR(): Observable<VRExperienceHelper>;
  47174. /** Return this.onExitingVRObservable
  47175. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  47176. */
  47177. get onExitingVR(): Observable<VRExperienceHelper>;
  47178. /** Return this.onControllerMeshLoadedObservable
  47179. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  47180. */
  47181. get onControllerMeshLoaded(): Observable<WebVRController>;
  47182. private _rayLength;
  47183. private _useCustomVRButton;
  47184. private _teleportationRequested;
  47185. private _teleportActive;
  47186. private _floorMeshName;
  47187. private _floorMeshesCollection;
  47188. private _teleportationMode;
  47189. private _teleportationTime;
  47190. private _teleportationSpeed;
  47191. private _teleportationEasing;
  47192. private _rotationAllowed;
  47193. private _teleportBackwardsVector;
  47194. private _teleportationTarget;
  47195. private _isDefaultTeleportationTarget;
  47196. private _postProcessMove;
  47197. private _teleportationFillColor;
  47198. private _teleportationBorderColor;
  47199. private _rotationAngle;
  47200. private _haloCenter;
  47201. private _cameraGazer;
  47202. private _padSensibilityUp;
  47203. private _padSensibilityDown;
  47204. private _leftController;
  47205. private _rightController;
  47206. private _gazeColor;
  47207. private _laserColor;
  47208. private _pickedLaserColor;
  47209. private _pickedGazeColor;
  47210. /**
  47211. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  47212. */
  47213. onNewMeshSelected: Observable<AbstractMesh>;
  47214. /**
  47215. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  47216. * This observable will provide the mesh and the controller used to select the mesh
  47217. */
  47218. onMeshSelectedWithController: Observable<{
  47219. mesh: AbstractMesh;
  47220. controller: WebVRController;
  47221. }>;
  47222. /**
  47223. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  47224. */
  47225. onNewMeshPicked: Observable<PickingInfo>;
  47226. private _circleEase;
  47227. /**
  47228. * Observable raised before camera teleportation
  47229. */
  47230. onBeforeCameraTeleport: Observable<Vector3>;
  47231. /**
  47232. * Observable raised after camera teleportation
  47233. */
  47234. onAfterCameraTeleport: Observable<Vector3>;
  47235. /**
  47236. * Observable raised when current selected mesh gets unselected
  47237. */
  47238. onSelectedMeshUnselected: Observable<AbstractMesh>;
  47239. private _raySelectionPredicate;
  47240. /**
  47241. * To be optionaly changed by user to define custom ray selection
  47242. */
  47243. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  47244. /**
  47245. * To be optionaly changed by user to define custom selection logic (after ray selection)
  47246. */
  47247. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  47248. /**
  47249. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  47250. */
  47251. teleportationEnabled: boolean;
  47252. private _defaultHeight;
  47253. private _teleportationInitialized;
  47254. private _interactionsEnabled;
  47255. private _interactionsRequested;
  47256. private _displayGaze;
  47257. private _displayLaserPointer;
  47258. /**
  47259. * The mesh used to display where the user is going to teleport.
  47260. */
  47261. get teleportationTarget(): Mesh;
  47262. /**
  47263. * Sets the mesh to be used to display where the user is going to teleport.
  47264. */
  47265. set teleportationTarget(value: Mesh);
  47266. /**
  47267. * 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
  47268. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  47269. * See http://doc.babylonjs.com/resources/baking_transformations
  47270. */
  47271. get gazeTrackerMesh(): Mesh;
  47272. set gazeTrackerMesh(value: Mesh);
  47273. /**
  47274. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  47275. */
  47276. updateGazeTrackerScale: boolean;
  47277. /**
  47278. * If the gaze trackers color should be updated when selecting meshes
  47279. */
  47280. updateGazeTrackerColor: boolean;
  47281. /**
  47282. * If the controller laser color should be updated when selecting meshes
  47283. */
  47284. updateControllerLaserColor: boolean;
  47285. /**
  47286. * The gaze tracking mesh corresponding to the left controller
  47287. */
  47288. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  47289. /**
  47290. * The gaze tracking mesh corresponding to the right controller
  47291. */
  47292. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  47293. /**
  47294. * If the ray of the gaze should be displayed.
  47295. */
  47296. get displayGaze(): boolean;
  47297. /**
  47298. * Sets if the ray of the gaze should be displayed.
  47299. */
  47300. set displayGaze(value: boolean);
  47301. /**
  47302. * If the ray of the LaserPointer should be displayed.
  47303. */
  47304. get displayLaserPointer(): boolean;
  47305. /**
  47306. * Sets if the ray of the LaserPointer should be displayed.
  47307. */
  47308. set displayLaserPointer(value: boolean);
  47309. /**
  47310. * The deviceOrientationCamera used as the camera when not in VR.
  47311. */
  47312. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  47313. /**
  47314. * Based on the current WebVR support, returns the current VR camera used.
  47315. */
  47316. get currentVRCamera(): Nullable<Camera>;
  47317. /**
  47318. * The webVRCamera which is used when in VR.
  47319. */
  47320. get webVRCamera(): WebVRFreeCamera;
  47321. /**
  47322. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  47323. */
  47324. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  47325. /**
  47326. * The html button that is used to trigger entering into VR.
  47327. */
  47328. get vrButton(): Nullable<HTMLButtonElement>;
  47329. private get _teleportationRequestInitiated();
  47330. /**
  47331. * Defines whether or not Pointer lock should be requested when switching to
  47332. * full screen.
  47333. */
  47334. requestPointerLockOnFullScreen: boolean;
  47335. /**
  47336. * If asking to force XR, this will be populated with the default xr experience
  47337. */
  47338. xr: WebXRDefaultExperience;
  47339. /**
  47340. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  47341. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  47342. */
  47343. xrTestDone: boolean;
  47344. /**
  47345. * Instantiates a VRExperienceHelper.
  47346. * Helps to quickly add VR support to an existing scene.
  47347. * @param scene The scene the VRExperienceHelper belongs to.
  47348. * @param webVROptions Options to modify the vr experience helper's behavior.
  47349. */
  47350. constructor(scene: Scene,
  47351. /** Options to modify the vr experience helper's behavior. */
  47352. webVROptions?: VRExperienceHelperOptions);
  47353. private completeVRInit;
  47354. private _onDefaultMeshLoaded;
  47355. private _onResize;
  47356. private _onFullscreenChange;
  47357. /**
  47358. * Gets a value indicating if we are currently in VR mode.
  47359. */
  47360. get isInVRMode(): boolean;
  47361. private onVrDisplayPresentChange;
  47362. private onVRDisplayChanged;
  47363. private moveButtonToBottomRight;
  47364. private displayVRButton;
  47365. private updateButtonVisibility;
  47366. private _cachedAngularSensibility;
  47367. /**
  47368. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  47369. * Otherwise, will use the fullscreen API.
  47370. */
  47371. enterVR(): void;
  47372. /**
  47373. * Attempt to exit VR, or fullscreen.
  47374. */
  47375. exitVR(): void;
  47376. /**
  47377. * The position of the vr experience helper.
  47378. */
  47379. get position(): Vector3;
  47380. /**
  47381. * Sets the position of the vr experience helper.
  47382. */
  47383. set position(value: Vector3);
  47384. /**
  47385. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  47386. */
  47387. enableInteractions(): void;
  47388. private get _noControllerIsActive();
  47389. private beforeRender;
  47390. private _isTeleportationFloor;
  47391. /**
  47392. * Adds a floor mesh to be used for teleportation.
  47393. * @param floorMesh the mesh to be used for teleportation.
  47394. */
  47395. addFloorMesh(floorMesh: Mesh): void;
  47396. /**
  47397. * Removes a floor mesh from being used for teleportation.
  47398. * @param floorMesh the mesh to be removed.
  47399. */
  47400. removeFloorMesh(floorMesh: Mesh): void;
  47401. /**
  47402. * Enables interactions and teleportation using the VR controllers and gaze.
  47403. * @param vrTeleportationOptions options to modify teleportation behavior.
  47404. */
  47405. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  47406. private _onNewGamepadConnected;
  47407. private _tryEnableInteractionOnController;
  47408. private _onNewGamepadDisconnected;
  47409. private _enableInteractionOnController;
  47410. private _checkTeleportWithRay;
  47411. private _checkRotate;
  47412. private _checkTeleportBackwards;
  47413. private _enableTeleportationOnController;
  47414. private _createTeleportationCircles;
  47415. private _displayTeleportationTarget;
  47416. private _hideTeleportationTarget;
  47417. private _rotateCamera;
  47418. private _moveTeleportationSelectorTo;
  47419. private _workingVector;
  47420. private _workingQuaternion;
  47421. private _workingMatrix;
  47422. /**
  47423. * Time Constant Teleportation Mode
  47424. */
  47425. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  47426. /**
  47427. * Speed Constant Teleportation Mode
  47428. */
  47429. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  47430. /**
  47431. * Teleports the users feet to the desired location
  47432. * @param location The location where the user's feet should be placed
  47433. */
  47434. teleportCamera(location: Vector3): void;
  47435. private _convertNormalToDirectionOfRay;
  47436. private _castRayAndSelectObject;
  47437. private _notifySelectedMeshUnselected;
  47438. /**
  47439. * Permanently set new colors for the laser pointer
  47440. * @param color the new laser color
  47441. * @param pickedColor the new laser color when picked mesh detected
  47442. */
  47443. setLaserColor(color: Color3, pickedColor?: Color3): void;
  47444. /**
  47445. * Set lighting enabled / disabled on the laser pointer of both controllers
  47446. * @param enabled should the lighting be enabled on the laser pointer
  47447. */
  47448. setLaserLightingState(enabled?: boolean): void;
  47449. /**
  47450. * Permanently set new colors for the gaze pointer
  47451. * @param color the new gaze color
  47452. * @param pickedColor the new gaze color when picked mesh detected
  47453. */
  47454. setGazeColor(color: Color3, pickedColor?: Color3): void;
  47455. /**
  47456. * Sets the color of the laser ray from the vr controllers.
  47457. * @param color new color for the ray.
  47458. */
  47459. changeLaserColor(color: Color3): void;
  47460. /**
  47461. * Sets the color of the ray from the vr headsets gaze.
  47462. * @param color new color for the ray.
  47463. */
  47464. changeGazeColor(color: Color3): void;
  47465. /**
  47466. * Exits VR and disposes of the vr experience helper
  47467. */
  47468. dispose(): void;
  47469. /**
  47470. * Gets the name of the VRExperienceHelper class
  47471. * @returns "VRExperienceHelper"
  47472. */
  47473. getClassName(): string;
  47474. }
  47475. }
  47476. declare module "babylonjs/Cameras/VR/index" {
  47477. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  47478. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  47479. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  47480. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  47481. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  47482. export * from "babylonjs/Cameras/VR/webVRCamera";
  47483. }
  47484. declare module "babylonjs/Cameras/RigModes/index" {
  47485. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  47486. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  47487. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  47488. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  47489. }
  47490. declare module "babylonjs/Cameras/index" {
  47491. export * from "babylonjs/Cameras/Inputs/index";
  47492. export * from "babylonjs/Cameras/cameraInputsManager";
  47493. export * from "babylonjs/Cameras/camera";
  47494. export * from "babylonjs/Cameras/targetCamera";
  47495. export * from "babylonjs/Cameras/freeCamera";
  47496. export * from "babylonjs/Cameras/freeCameraInputsManager";
  47497. export * from "babylonjs/Cameras/touchCamera";
  47498. export * from "babylonjs/Cameras/arcRotateCamera";
  47499. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  47500. export * from "babylonjs/Cameras/deviceOrientationCamera";
  47501. export * from "babylonjs/Cameras/flyCamera";
  47502. export * from "babylonjs/Cameras/flyCameraInputsManager";
  47503. export * from "babylonjs/Cameras/followCamera";
  47504. export * from "babylonjs/Cameras/followCameraInputsManager";
  47505. export * from "babylonjs/Cameras/gamepadCamera";
  47506. export * from "babylonjs/Cameras/Stereoscopic/index";
  47507. export * from "babylonjs/Cameras/universalCamera";
  47508. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  47509. export * from "babylonjs/Cameras/VR/index";
  47510. export * from "babylonjs/Cameras/RigModes/index";
  47511. }
  47512. declare module "babylonjs/Collisions/index" {
  47513. export * from "babylonjs/Collisions/collider";
  47514. export * from "babylonjs/Collisions/collisionCoordinator";
  47515. export * from "babylonjs/Collisions/pickingInfo";
  47516. export * from "babylonjs/Collisions/intersectionInfo";
  47517. export * from "babylonjs/Collisions/meshCollisionData";
  47518. }
  47519. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  47520. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  47521. import { Vector3 } from "babylonjs/Maths/math.vector";
  47522. import { Ray } from "babylonjs/Culling/ray";
  47523. import { Plane } from "babylonjs/Maths/math.plane";
  47524. /**
  47525. * Contains an array of blocks representing the octree
  47526. */
  47527. export interface IOctreeContainer<T> {
  47528. /**
  47529. * Blocks within the octree
  47530. */
  47531. blocks: Array<OctreeBlock<T>>;
  47532. }
  47533. /**
  47534. * Class used to store a cell in an octree
  47535. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47536. */
  47537. export class OctreeBlock<T> {
  47538. /**
  47539. * Gets the content of the current block
  47540. */
  47541. entries: T[];
  47542. /**
  47543. * Gets the list of block children
  47544. */
  47545. blocks: Array<OctreeBlock<T>>;
  47546. private _depth;
  47547. private _maxDepth;
  47548. private _capacity;
  47549. private _minPoint;
  47550. private _maxPoint;
  47551. private _boundingVectors;
  47552. private _creationFunc;
  47553. /**
  47554. * Creates a new block
  47555. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  47556. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  47557. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47558. * @param depth defines the current depth of this block in the octree
  47559. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  47560. * @param creationFunc defines a callback to call when an element is added to the block
  47561. */
  47562. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  47563. /**
  47564. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  47565. */
  47566. get capacity(): number;
  47567. /**
  47568. * Gets the minimum vector (in world space) of the block's bounding box
  47569. */
  47570. get minPoint(): Vector3;
  47571. /**
  47572. * Gets the maximum vector (in world space) of the block's bounding box
  47573. */
  47574. get maxPoint(): Vector3;
  47575. /**
  47576. * Add a new element to this block
  47577. * @param entry defines the element to add
  47578. */
  47579. addEntry(entry: T): void;
  47580. /**
  47581. * Remove an element from this block
  47582. * @param entry defines the element to remove
  47583. */
  47584. removeEntry(entry: T): void;
  47585. /**
  47586. * Add an array of elements to this block
  47587. * @param entries defines the array of elements to add
  47588. */
  47589. addEntries(entries: T[]): void;
  47590. /**
  47591. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  47592. * @param frustumPlanes defines the frustum planes to test
  47593. * @param selection defines the array to store current content if selection is positive
  47594. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47595. */
  47596. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47597. /**
  47598. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  47599. * @param sphereCenter defines the bounding sphere center
  47600. * @param sphereRadius defines the bounding sphere radius
  47601. * @param selection defines the array to store current content if selection is positive
  47602. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47603. */
  47604. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  47605. /**
  47606. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  47607. * @param ray defines the ray to test with
  47608. * @param selection defines the array to store current content if selection is positive
  47609. */
  47610. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  47611. /**
  47612. * Subdivide the content into child blocks (this block will then be empty)
  47613. */
  47614. createInnerBlocks(): void;
  47615. /**
  47616. * @hidden
  47617. */
  47618. 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;
  47619. }
  47620. }
  47621. declare module "babylonjs/Culling/Octrees/octree" {
  47622. import { SmartArray } from "babylonjs/Misc/smartArray";
  47623. import { Vector3 } from "babylonjs/Maths/math.vector";
  47624. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47625. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47626. import { Ray } from "babylonjs/Culling/ray";
  47627. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  47628. import { Plane } from "babylonjs/Maths/math.plane";
  47629. /**
  47630. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  47631. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47632. */
  47633. export class Octree<T> {
  47634. /** 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.) */
  47635. maxDepth: number;
  47636. /**
  47637. * Blocks within the octree containing objects
  47638. */
  47639. blocks: Array<OctreeBlock<T>>;
  47640. /**
  47641. * Content stored in the octree
  47642. */
  47643. dynamicContent: T[];
  47644. private _maxBlockCapacity;
  47645. private _selectionContent;
  47646. private _creationFunc;
  47647. /**
  47648. * Creates a octree
  47649. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47650. * @param creationFunc function to be used to instatiate the octree
  47651. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  47652. * @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.)
  47653. */
  47654. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  47655. /** 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.) */
  47656. maxDepth?: number);
  47657. /**
  47658. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  47659. * @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);
  47660. * @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);
  47661. * @param entries meshes to be added to the octree blocks
  47662. */
  47663. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  47664. /**
  47665. * Adds a mesh to the octree
  47666. * @param entry Mesh to add to the octree
  47667. */
  47668. addMesh(entry: T): void;
  47669. /**
  47670. * Remove an element from the octree
  47671. * @param entry defines the element to remove
  47672. */
  47673. removeMesh(entry: T): void;
  47674. /**
  47675. * Selects an array of meshes within the frustum
  47676. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  47677. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  47678. * @returns array of meshes within the frustum
  47679. */
  47680. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  47681. /**
  47682. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  47683. * @param sphereCenter defines the bounding sphere center
  47684. * @param sphereRadius defines the bounding sphere radius
  47685. * @param allowDuplicate defines if the selection array can contains duplicated entries
  47686. * @returns an array of objects that intersect the sphere
  47687. */
  47688. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  47689. /**
  47690. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  47691. * @param ray defines the ray to test with
  47692. * @returns array of intersected objects
  47693. */
  47694. intersectsRay(ray: Ray): SmartArray<T>;
  47695. /**
  47696. * Adds a mesh into the octree block if it intersects the block
  47697. */
  47698. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  47699. /**
  47700. * Adds a submesh into the octree block if it intersects the block
  47701. */
  47702. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  47703. }
  47704. }
  47705. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  47706. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  47707. import { Scene } from "babylonjs/scene";
  47708. import { SubMesh } from "babylonjs/Meshes/subMesh";
  47709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47710. import { Ray } from "babylonjs/Culling/ray";
  47711. import { Octree } from "babylonjs/Culling/Octrees/octree";
  47712. import { Collider } from "babylonjs/Collisions/collider";
  47713. module "babylonjs/scene" {
  47714. interface Scene {
  47715. /**
  47716. * @hidden
  47717. * Backing Filed
  47718. */
  47719. _selectionOctree: Octree<AbstractMesh>;
  47720. /**
  47721. * Gets the octree used to boost mesh selection (picking)
  47722. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47723. */
  47724. selectionOctree: Octree<AbstractMesh>;
  47725. /**
  47726. * Creates or updates the octree used to boost selection (picking)
  47727. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47728. * @param maxCapacity defines the maximum capacity per leaf
  47729. * @param maxDepth defines the maximum depth of the octree
  47730. * @returns an octree of AbstractMesh
  47731. */
  47732. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  47733. }
  47734. }
  47735. module "babylonjs/Meshes/abstractMesh" {
  47736. interface AbstractMesh {
  47737. /**
  47738. * @hidden
  47739. * Backing Field
  47740. */
  47741. _submeshesOctree: Octree<SubMesh>;
  47742. /**
  47743. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  47744. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  47745. * @param maxCapacity defines the maximum size of each block (64 by default)
  47746. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  47747. * @returns the new octree
  47748. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  47749. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  47750. */
  47751. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  47752. }
  47753. }
  47754. /**
  47755. * Defines the octree scene component responsible to manage any octrees
  47756. * in a given scene.
  47757. */
  47758. export class OctreeSceneComponent {
  47759. /**
  47760. * The component name help to identify the component in the list of scene components.
  47761. */
  47762. readonly name: string;
  47763. /**
  47764. * The scene the component belongs to.
  47765. */
  47766. scene: Scene;
  47767. /**
  47768. * Indicates if the meshes have been checked to make sure they are isEnabled()
  47769. */
  47770. readonly checksIsEnabled: boolean;
  47771. /**
  47772. * Creates a new instance of the component for the given scene
  47773. * @param scene Defines the scene to register the component in
  47774. */
  47775. constructor(scene: Scene);
  47776. /**
  47777. * Registers the component in a given scene
  47778. */
  47779. register(): void;
  47780. /**
  47781. * Return the list of active meshes
  47782. * @returns the list of active meshes
  47783. */
  47784. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  47785. /**
  47786. * Return the list of active sub meshes
  47787. * @param mesh The mesh to get the candidates sub meshes from
  47788. * @returns the list of active sub meshes
  47789. */
  47790. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  47791. private _tempRay;
  47792. /**
  47793. * Return the list of sub meshes intersecting with a given local ray
  47794. * @param mesh defines the mesh to find the submesh for
  47795. * @param localRay defines the ray in local space
  47796. * @returns the list of intersecting sub meshes
  47797. */
  47798. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  47799. /**
  47800. * Return the list of sub meshes colliding with a collider
  47801. * @param mesh defines the mesh to find the submesh for
  47802. * @param collider defines the collider to evaluate the collision against
  47803. * @returns the list of colliding sub meshes
  47804. */
  47805. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  47806. /**
  47807. * Rebuilds the elements related to this component in case of
  47808. * context lost for instance.
  47809. */
  47810. rebuild(): void;
  47811. /**
  47812. * Disposes the component and the associated ressources.
  47813. */
  47814. dispose(): void;
  47815. }
  47816. }
  47817. declare module "babylonjs/Culling/Octrees/index" {
  47818. export * from "babylonjs/Culling/Octrees/octree";
  47819. export * from "babylonjs/Culling/Octrees/octreeBlock";
  47820. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  47821. }
  47822. declare module "babylonjs/Culling/index" {
  47823. export * from "babylonjs/Culling/boundingBox";
  47824. export * from "babylonjs/Culling/boundingInfo";
  47825. export * from "babylonjs/Culling/boundingSphere";
  47826. export * from "babylonjs/Culling/Octrees/index";
  47827. export * from "babylonjs/Culling/ray";
  47828. }
  47829. declare module "babylonjs/Gizmos/gizmo" {
  47830. import { Nullable } from "babylonjs/types";
  47831. import { IDisposable } from "babylonjs/scene";
  47832. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47833. import { Mesh } from "babylonjs/Meshes/mesh";
  47834. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47835. /**
  47836. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  47837. */
  47838. export class Gizmo implements IDisposable {
  47839. /** The utility layer the gizmo will be added to */
  47840. gizmoLayer: UtilityLayerRenderer;
  47841. /**
  47842. * The root mesh of the gizmo
  47843. */
  47844. _rootMesh: Mesh;
  47845. private _attachedMesh;
  47846. /**
  47847. * Ratio for the scale of the gizmo (Default: 1)
  47848. */
  47849. scaleRatio: number;
  47850. /**
  47851. * If a custom mesh has been set (Default: false)
  47852. */
  47853. protected _customMeshSet: boolean;
  47854. /**
  47855. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  47856. * * When set, interactions will be enabled
  47857. */
  47858. get attachedMesh(): Nullable<AbstractMesh>;
  47859. set attachedMesh(value: Nullable<AbstractMesh>);
  47860. /**
  47861. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  47862. * @param mesh The mesh to replace the default mesh of the gizmo
  47863. */
  47864. setCustomMesh(mesh: Mesh): void;
  47865. /**
  47866. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  47867. */
  47868. updateGizmoRotationToMatchAttachedMesh: boolean;
  47869. /**
  47870. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  47871. */
  47872. updateGizmoPositionToMatchAttachedMesh: boolean;
  47873. /**
  47874. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  47875. */
  47876. updateScale: boolean;
  47877. protected _interactionsEnabled: boolean;
  47878. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47879. private _beforeRenderObserver;
  47880. private _tempVector;
  47881. /**
  47882. * Creates a gizmo
  47883. * @param gizmoLayer The utility layer the gizmo will be added to
  47884. */
  47885. constructor(
  47886. /** The utility layer the gizmo will be added to */
  47887. gizmoLayer?: UtilityLayerRenderer);
  47888. /**
  47889. * Updates the gizmo to match the attached mesh's position/rotation
  47890. */
  47891. protected _update(): void;
  47892. /**
  47893. * Disposes of the gizmo
  47894. */
  47895. dispose(): void;
  47896. }
  47897. }
  47898. declare module "babylonjs/Gizmos/planeDragGizmo" {
  47899. import { Observable } from "babylonjs/Misc/observable";
  47900. import { Nullable } from "babylonjs/types";
  47901. import { Vector3 } from "babylonjs/Maths/math.vector";
  47902. import { Color3 } from "babylonjs/Maths/math.color";
  47903. import { TransformNode } from "babylonjs/Meshes/transformNode";
  47904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47905. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  47906. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47907. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47908. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  47909. import { Scene } from "babylonjs/scene";
  47910. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  47911. /**
  47912. * Single plane drag gizmo
  47913. */
  47914. export class PlaneDragGizmo extends Gizmo {
  47915. /**
  47916. * Drag behavior responsible for the gizmos dragging interactions
  47917. */
  47918. dragBehavior: PointerDragBehavior;
  47919. private _pointerObserver;
  47920. /**
  47921. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  47922. */
  47923. snapDistance: number;
  47924. /**
  47925. * Event that fires each time the gizmo snaps to a new location.
  47926. * * snapDistance is the the change in distance
  47927. */
  47928. onSnapObservable: Observable<{
  47929. snapDistance: number;
  47930. }>;
  47931. private _plane;
  47932. private _coloredMaterial;
  47933. private _hoverMaterial;
  47934. private _isEnabled;
  47935. private _parent;
  47936. /** @hidden */
  47937. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  47938. /** @hidden */
  47939. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  47940. /**
  47941. * Creates a PlaneDragGizmo
  47942. * @param gizmoLayer The utility layer the gizmo will be added to
  47943. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  47944. * @param color The color of the gizmo
  47945. */
  47946. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  47947. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  47948. /**
  47949. * If the gizmo is enabled
  47950. */
  47951. set isEnabled(value: boolean);
  47952. get isEnabled(): boolean;
  47953. /**
  47954. * Disposes of the gizmo
  47955. */
  47956. dispose(): void;
  47957. }
  47958. }
  47959. declare module "babylonjs/Gizmos/positionGizmo" {
  47960. import { Observable } from "babylonjs/Misc/observable";
  47961. import { Nullable } from "babylonjs/types";
  47962. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  47963. import { Mesh } from "babylonjs/Meshes/mesh";
  47964. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  47965. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  47966. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  47967. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  47968. /**
  47969. * Gizmo that enables dragging a mesh along 3 axis
  47970. */
  47971. export class PositionGizmo extends Gizmo {
  47972. /**
  47973. * Internal gizmo used for interactions on the x axis
  47974. */
  47975. xGizmo: AxisDragGizmo;
  47976. /**
  47977. * Internal gizmo used for interactions on the y axis
  47978. */
  47979. yGizmo: AxisDragGizmo;
  47980. /**
  47981. * Internal gizmo used for interactions on the z axis
  47982. */
  47983. zGizmo: AxisDragGizmo;
  47984. /**
  47985. * Internal gizmo used for interactions on the yz plane
  47986. */
  47987. xPlaneGizmo: PlaneDragGizmo;
  47988. /**
  47989. * Internal gizmo used for interactions on the xz plane
  47990. */
  47991. yPlaneGizmo: PlaneDragGizmo;
  47992. /**
  47993. * Internal gizmo used for interactions on the xy plane
  47994. */
  47995. zPlaneGizmo: PlaneDragGizmo;
  47996. /**
  47997. * private variables
  47998. */
  47999. private _meshAttached;
  48000. private _updateGizmoRotationToMatchAttachedMesh;
  48001. private _snapDistance;
  48002. private _scaleRatio;
  48003. /** Fires an event when any of it's sub gizmos are dragged */
  48004. onDragStartObservable: Observable<unknown>;
  48005. /** Fires an event when any of it's sub gizmos are released from dragging */
  48006. onDragEndObservable: Observable<unknown>;
  48007. /**
  48008. * If set to true, planar drag is enabled
  48009. */
  48010. private _planarGizmoEnabled;
  48011. get attachedMesh(): Nullable<AbstractMesh>;
  48012. set attachedMesh(mesh: Nullable<AbstractMesh>);
  48013. /**
  48014. * Creates a PositionGizmo
  48015. * @param gizmoLayer The utility layer the gizmo will be added to
  48016. */
  48017. constructor(gizmoLayer?: UtilityLayerRenderer);
  48018. /**
  48019. * If the planar drag gizmo is enabled
  48020. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  48021. */
  48022. set planarGizmoEnabled(value: boolean);
  48023. get planarGizmoEnabled(): boolean;
  48024. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  48025. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  48026. /**
  48027. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48028. */
  48029. set snapDistance(value: number);
  48030. get snapDistance(): number;
  48031. /**
  48032. * Ratio for the scale of the gizmo (Default: 1)
  48033. */
  48034. set scaleRatio(value: number);
  48035. get scaleRatio(): number;
  48036. /**
  48037. * Disposes of the gizmo
  48038. */
  48039. dispose(): void;
  48040. /**
  48041. * CustomMeshes are not supported by this gizmo
  48042. * @param mesh The mesh to replace the default mesh of the gizmo
  48043. */
  48044. setCustomMesh(mesh: Mesh): void;
  48045. }
  48046. }
  48047. declare module "babylonjs/Gizmos/axisDragGizmo" {
  48048. import { Observable } from "babylonjs/Misc/observable";
  48049. import { Nullable } from "babylonjs/types";
  48050. import { Vector3 } from "babylonjs/Maths/math.vector";
  48051. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48052. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48053. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  48054. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  48055. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  48056. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  48057. import { Scene } from "babylonjs/scene";
  48058. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  48059. import { Color3 } from "babylonjs/Maths/math.color";
  48060. /**
  48061. * Single axis drag gizmo
  48062. */
  48063. export class AxisDragGizmo extends Gizmo {
  48064. /**
  48065. * Drag behavior responsible for the gizmos dragging interactions
  48066. */
  48067. dragBehavior: PointerDragBehavior;
  48068. private _pointerObserver;
  48069. /**
  48070. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  48071. */
  48072. snapDistance: number;
  48073. /**
  48074. * Event that fires each time the gizmo snaps to a new location.
  48075. * * snapDistance is the the change in distance
  48076. */
  48077. onSnapObservable: Observable<{
  48078. snapDistance: number;
  48079. }>;
  48080. private _isEnabled;
  48081. private _parent;
  48082. private _arrow;
  48083. private _coloredMaterial;
  48084. private _hoverMaterial;
  48085. /** @hidden */
  48086. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  48087. /** @hidden */
  48088. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  48089. /**
  48090. * Creates an AxisDragGizmo
  48091. * @param gizmoLayer The utility layer the gizmo will be added to
  48092. * @param dragAxis The axis which the gizmo will be able to drag on
  48093. * @param color The color of the gizmo
  48094. */
  48095. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  48096. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  48097. /**
  48098. * If the gizmo is enabled
  48099. */
  48100. set isEnabled(value: boolean);
  48101. get isEnabled(): boolean;
  48102. /**
  48103. * Disposes of the gizmo
  48104. */
  48105. dispose(): void;
  48106. }
  48107. }
  48108. declare module "babylonjs/Debug/axesViewer" {
  48109. import { Vector3 } from "babylonjs/Maths/math.vector";
  48110. import { Nullable } from "babylonjs/types";
  48111. import { Scene } from "babylonjs/scene";
  48112. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48113. /**
  48114. * The Axes viewer will show 3 axes in a specific point in space
  48115. */
  48116. export class AxesViewer {
  48117. private _xAxis;
  48118. private _yAxis;
  48119. private _zAxis;
  48120. private _scaleLinesFactor;
  48121. private _instanced;
  48122. /**
  48123. * Gets the hosting scene
  48124. */
  48125. scene: Scene;
  48126. /**
  48127. * Gets or sets a number used to scale line length
  48128. */
  48129. scaleLines: number;
  48130. /** Gets the node hierarchy used to render x-axis */
  48131. get xAxis(): TransformNode;
  48132. /** Gets the node hierarchy used to render y-axis */
  48133. get yAxis(): TransformNode;
  48134. /** Gets the node hierarchy used to render z-axis */
  48135. get zAxis(): TransformNode;
  48136. /**
  48137. * Creates a new AxesViewer
  48138. * @param scene defines the hosting scene
  48139. * @param scaleLines defines a number used to scale line length (1 by default)
  48140. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  48141. * @param xAxis defines the node hierarchy used to render the x-axis
  48142. * @param yAxis defines the node hierarchy used to render the y-axis
  48143. * @param zAxis defines the node hierarchy used to render the z-axis
  48144. */
  48145. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  48146. /**
  48147. * Force the viewer to update
  48148. * @param position defines the position of the viewer
  48149. * @param xaxis defines the x axis of the viewer
  48150. * @param yaxis defines the y axis of the viewer
  48151. * @param zaxis defines the z axis of the viewer
  48152. */
  48153. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  48154. /**
  48155. * Creates an instance of this axes viewer.
  48156. * @returns a new axes viewer with instanced meshes
  48157. */
  48158. createInstance(): AxesViewer;
  48159. /** Releases resources */
  48160. dispose(): void;
  48161. private static _SetRenderingGroupId;
  48162. }
  48163. }
  48164. declare module "babylonjs/Debug/boneAxesViewer" {
  48165. import { Nullable } from "babylonjs/types";
  48166. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  48167. import { Vector3 } from "babylonjs/Maths/math.vector";
  48168. import { Mesh } from "babylonjs/Meshes/mesh";
  48169. import { Bone } from "babylonjs/Bones/bone";
  48170. import { Scene } from "babylonjs/scene";
  48171. /**
  48172. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  48173. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  48174. */
  48175. export class BoneAxesViewer extends AxesViewer {
  48176. /**
  48177. * Gets or sets the target mesh where to display the axes viewer
  48178. */
  48179. mesh: Nullable<Mesh>;
  48180. /**
  48181. * Gets or sets the target bone where to display the axes viewer
  48182. */
  48183. bone: Nullable<Bone>;
  48184. /** Gets current position */
  48185. pos: Vector3;
  48186. /** Gets direction of X axis */
  48187. xaxis: Vector3;
  48188. /** Gets direction of Y axis */
  48189. yaxis: Vector3;
  48190. /** Gets direction of Z axis */
  48191. zaxis: Vector3;
  48192. /**
  48193. * Creates a new BoneAxesViewer
  48194. * @param scene defines the hosting scene
  48195. * @param bone defines the target bone
  48196. * @param mesh defines the target mesh
  48197. * @param scaleLines defines a scaling factor for line length (1 by default)
  48198. */
  48199. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  48200. /**
  48201. * Force the viewer to update
  48202. */
  48203. update(): void;
  48204. /** Releases resources */
  48205. dispose(): void;
  48206. }
  48207. }
  48208. declare module "babylonjs/Debug/debugLayer" {
  48209. import { Scene } from "babylonjs/scene";
  48210. /**
  48211. * Interface used to define scene explorer extensibility option
  48212. */
  48213. export interface IExplorerExtensibilityOption {
  48214. /**
  48215. * Define the option label
  48216. */
  48217. label: string;
  48218. /**
  48219. * Defines the action to execute on click
  48220. */
  48221. action: (entity: any) => void;
  48222. }
  48223. /**
  48224. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  48225. */
  48226. export interface IExplorerExtensibilityGroup {
  48227. /**
  48228. * Defines a predicate to test if a given type mut be extended
  48229. */
  48230. predicate: (entity: any) => boolean;
  48231. /**
  48232. * Gets the list of options added to a type
  48233. */
  48234. entries: IExplorerExtensibilityOption[];
  48235. }
  48236. /**
  48237. * Interface used to define the options to use to create the Inspector
  48238. */
  48239. export interface IInspectorOptions {
  48240. /**
  48241. * Display in overlay mode (default: false)
  48242. */
  48243. overlay?: boolean;
  48244. /**
  48245. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  48246. */
  48247. globalRoot?: HTMLElement;
  48248. /**
  48249. * Display the Scene explorer
  48250. */
  48251. showExplorer?: boolean;
  48252. /**
  48253. * Display the property inspector
  48254. */
  48255. showInspector?: boolean;
  48256. /**
  48257. * Display in embed mode (both panes on the right)
  48258. */
  48259. embedMode?: boolean;
  48260. /**
  48261. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  48262. */
  48263. handleResize?: boolean;
  48264. /**
  48265. * Allow the panes to popup (default: true)
  48266. */
  48267. enablePopup?: boolean;
  48268. /**
  48269. * Allow the panes to be closed by users (default: true)
  48270. */
  48271. enableClose?: boolean;
  48272. /**
  48273. * Optional list of extensibility entries
  48274. */
  48275. explorerExtensibility?: IExplorerExtensibilityGroup[];
  48276. /**
  48277. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  48278. */
  48279. inspectorURL?: string;
  48280. /**
  48281. * Optional initial tab (default to DebugLayerTab.Properties)
  48282. */
  48283. initialTab?: DebugLayerTab;
  48284. }
  48285. module "babylonjs/scene" {
  48286. interface Scene {
  48287. /**
  48288. * @hidden
  48289. * Backing field
  48290. */
  48291. _debugLayer: DebugLayer;
  48292. /**
  48293. * Gets the debug layer (aka Inspector) associated with the scene
  48294. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48295. */
  48296. debugLayer: DebugLayer;
  48297. }
  48298. }
  48299. /**
  48300. * Enum of inspector action tab
  48301. */
  48302. export enum DebugLayerTab {
  48303. /**
  48304. * Properties tag (default)
  48305. */
  48306. Properties = 0,
  48307. /**
  48308. * Debug tab
  48309. */
  48310. Debug = 1,
  48311. /**
  48312. * Statistics tab
  48313. */
  48314. Statistics = 2,
  48315. /**
  48316. * Tools tab
  48317. */
  48318. Tools = 3,
  48319. /**
  48320. * Settings tab
  48321. */
  48322. Settings = 4
  48323. }
  48324. /**
  48325. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48326. * what is happening in your scene
  48327. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48328. */
  48329. export class DebugLayer {
  48330. /**
  48331. * Define the url to get the inspector script from.
  48332. * By default it uses the babylonjs CDN.
  48333. * @ignoreNaming
  48334. */
  48335. static InspectorURL: string;
  48336. private _scene;
  48337. private BJSINSPECTOR;
  48338. private _onPropertyChangedObservable?;
  48339. /**
  48340. * Observable triggered when a property is changed through the inspector.
  48341. */
  48342. get onPropertyChangedObservable(): any;
  48343. /**
  48344. * Instantiates a new debug layer.
  48345. * The debug layer (aka Inspector) is the go to tool in order to better understand
  48346. * what is happening in your scene
  48347. * @see http://doc.babylonjs.com/features/playground_debuglayer
  48348. * @param scene Defines the scene to inspect
  48349. */
  48350. constructor(scene: Scene);
  48351. /** Creates the inspector window. */
  48352. private _createInspector;
  48353. /**
  48354. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  48355. * @param entity defines the entity to select
  48356. * @param lineContainerTitle defines the specific block to highlight
  48357. */
  48358. select(entity: any, lineContainerTitle?: string): void;
  48359. /** Get the inspector from bundle or global */
  48360. private _getGlobalInspector;
  48361. /**
  48362. * Get if the inspector is visible or not.
  48363. * @returns true if visible otherwise, false
  48364. */
  48365. isVisible(): boolean;
  48366. /**
  48367. * Hide the inspector and close its window.
  48368. */
  48369. hide(): void;
  48370. /**
  48371. * Launch the debugLayer.
  48372. * @param config Define the configuration of the inspector
  48373. * @return a promise fulfilled when the debug layer is visible
  48374. */
  48375. show(config?: IInspectorOptions): Promise<DebugLayer>;
  48376. }
  48377. }
  48378. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  48379. import { Nullable } from "babylonjs/types";
  48380. import { Scene } from "babylonjs/scene";
  48381. import { Vector4 } from "babylonjs/Maths/math.vector";
  48382. import { Color4 } from "babylonjs/Maths/math.color";
  48383. import { Mesh } from "babylonjs/Meshes/mesh";
  48384. /**
  48385. * Class containing static functions to help procedurally build meshes
  48386. */
  48387. export class BoxBuilder {
  48388. /**
  48389. * Creates a box mesh
  48390. * * The parameter `size` sets the size (float) of each box side (default 1)
  48391. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  48392. * * 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)
  48393. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  48394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48396. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48397. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  48398. * @param name defines the name of the mesh
  48399. * @param options defines the options used to create the mesh
  48400. * @param scene defines the hosting scene
  48401. * @returns the box mesh
  48402. */
  48403. static CreateBox(name: string, options: {
  48404. size?: number;
  48405. width?: number;
  48406. height?: number;
  48407. depth?: number;
  48408. faceUV?: Vector4[];
  48409. faceColors?: Color4[];
  48410. sideOrientation?: number;
  48411. frontUVs?: Vector4;
  48412. backUVs?: Vector4;
  48413. wrap?: boolean;
  48414. topBaseAt?: number;
  48415. bottomBaseAt?: number;
  48416. updatable?: boolean;
  48417. }, scene?: Nullable<Scene>): Mesh;
  48418. }
  48419. }
  48420. declare module "babylonjs/Debug/physicsViewer" {
  48421. import { Nullable } from "babylonjs/types";
  48422. import { Scene } from "babylonjs/scene";
  48423. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48424. import { Mesh } from "babylonjs/Meshes/mesh";
  48425. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  48426. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  48427. /**
  48428. * Used to show the physics impostor around the specific mesh
  48429. */
  48430. export class PhysicsViewer {
  48431. /** @hidden */
  48432. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  48433. /** @hidden */
  48434. protected _meshes: Array<Nullable<AbstractMesh>>;
  48435. /** @hidden */
  48436. protected _scene: Nullable<Scene>;
  48437. /** @hidden */
  48438. protected _numMeshes: number;
  48439. /** @hidden */
  48440. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  48441. private _renderFunction;
  48442. private _utilityLayer;
  48443. private _debugBoxMesh;
  48444. private _debugSphereMesh;
  48445. private _debugCylinderMesh;
  48446. private _debugMaterial;
  48447. private _debugMeshMeshes;
  48448. /**
  48449. * Creates a new PhysicsViewer
  48450. * @param scene defines the hosting scene
  48451. */
  48452. constructor(scene: Scene);
  48453. /** @hidden */
  48454. protected _updateDebugMeshes(): void;
  48455. /**
  48456. * Renders a specified physic impostor
  48457. * @param impostor defines the impostor to render
  48458. * @param targetMesh defines the mesh represented by the impostor
  48459. * @returns the new debug mesh used to render the impostor
  48460. */
  48461. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  48462. /**
  48463. * Hides a specified physic impostor
  48464. * @param impostor defines the impostor to hide
  48465. */
  48466. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  48467. private _getDebugMaterial;
  48468. private _getDebugBoxMesh;
  48469. private _getDebugSphereMesh;
  48470. private _getDebugCylinderMesh;
  48471. private _getDebugMeshMesh;
  48472. private _getDebugMesh;
  48473. /** Releases all resources */
  48474. dispose(): void;
  48475. }
  48476. }
  48477. declare module "babylonjs/Debug/rayHelper" {
  48478. import { Nullable } from "babylonjs/types";
  48479. import { Ray } from "babylonjs/Culling/ray";
  48480. import { Vector3 } from "babylonjs/Maths/math.vector";
  48481. import { Color3 } from "babylonjs/Maths/math.color";
  48482. import { Scene } from "babylonjs/scene";
  48483. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48484. import "babylonjs/Meshes/Builders/linesBuilder";
  48485. /**
  48486. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48487. * in order to better appreciate the issue one might have.
  48488. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48489. */
  48490. export class RayHelper {
  48491. /**
  48492. * Defines the ray we are currently tryin to visualize.
  48493. */
  48494. ray: Nullable<Ray>;
  48495. private _renderPoints;
  48496. private _renderLine;
  48497. private _renderFunction;
  48498. private _scene;
  48499. private _updateToMeshFunction;
  48500. private _attachedToMesh;
  48501. private _meshSpaceDirection;
  48502. private _meshSpaceOrigin;
  48503. /**
  48504. * Helper function to create a colored helper in a scene in one line.
  48505. * @param ray Defines the ray we are currently tryin to visualize
  48506. * @param scene Defines the scene the ray is used in
  48507. * @param color Defines the color we want to see the ray in
  48508. * @returns The newly created ray helper.
  48509. */
  48510. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  48511. /**
  48512. * Instantiate a new ray helper.
  48513. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  48514. * in order to better appreciate the issue one might have.
  48515. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  48516. * @param ray Defines the ray we are currently tryin to visualize
  48517. */
  48518. constructor(ray: Ray);
  48519. /**
  48520. * Shows the ray we are willing to debug.
  48521. * @param scene Defines the scene the ray needs to be rendered in
  48522. * @param color Defines the color the ray needs to be rendered in
  48523. */
  48524. show(scene: Scene, color?: Color3): void;
  48525. /**
  48526. * Hides the ray we are debugging.
  48527. */
  48528. hide(): void;
  48529. private _render;
  48530. /**
  48531. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  48532. * @param mesh Defines the mesh we want the helper attached to
  48533. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  48534. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  48535. * @param length Defines the length of the ray
  48536. */
  48537. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  48538. /**
  48539. * Detach the ray helper from the mesh it has previously been attached to.
  48540. */
  48541. detachFromMesh(): void;
  48542. private _updateToMesh;
  48543. /**
  48544. * Dispose the helper and release its associated resources.
  48545. */
  48546. dispose(): void;
  48547. }
  48548. }
  48549. declare module "babylonjs/Debug/skeletonViewer" {
  48550. import { Color3 } from "babylonjs/Maths/math.color";
  48551. import { Scene } from "babylonjs/scene";
  48552. import { Nullable } from "babylonjs/types";
  48553. import { Skeleton } from "babylonjs/Bones/skeleton";
  48554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48555. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  48556. /**
  48557. * Class used to render a debug view of a given skeleton
  48558. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  48559. */
  48560. export class SkeletonViewer {
  48561. /** defines the skeleton to render */
  48562. skeleton: Skeleton;
  48563. /** defines the mesh attached to the skeleton */
  48564. mesh: AbstractMesh;
  48565. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48566. autoUpdateBonesMatrices: boolean;
  48567. /** defines the rendering group id to use with the viewer */
  48568. renderingGroupId: number;
  48569. /** Gets or sets the color used to render the skeleton */
  48570. color: Color3;
  48571. private _scene;
  48572. private _debugLines;
  48573. private _debugMesh;
  48574. private _isEnabled;
  48575. private _renderFunction;
  48576. private _utilityLayer;
  48577. /**
  48578. * Returns the mesh used to render the bones
  48579. */
  48580. get debugMesh(): Nullable<LinesMesh>;
  48581. /**
  48582. * Creates a new SkeletonViewer
  48583. * @param skeleton defines the skeleton to render
  48584. * @param mesh defines the mesh attached to the skeleton
  48585. * @param scene defines the hosting scene
  48586. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  48587. * @param renderingGroupId defines the rendering group id to use with the viewer
  48588. */
  48589. constructor(
  48590. /** defines the skeleton to render */
  48591. skeleton: Skeleton,
  48592. /** defines the mesh attached to the skeleton */
  48593. mesh: AbstractMesh, scene: Scene,
  48594. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  48595. autoUpdateBonesMatrices?: boolean,
  48596. /** defines the rendering group id to use with the viewer */
  48597. renderingGroupId?: number);
  48598. /** Gets or sets a boolean indicating if the viewer is enabled */
  48599. set isEnabled(value: boolean);
  48600. get isEnabled(): boolean;
  48601. private _getBonePosition;
  48602. private _getLinesForBonesWithLength;
  48603. private _getLinesForBonesNoLength;
  48604. /** Update the viewer to sync with current skeleton state */
  48605. update(): void;
  48606. /** Release associated resources */
  48607. dispose(): void;
  48608. }
  48609. }
  48610. declare module "babylonjs/Debug/index" {
  48611. export * from "babylonjs/Debug/axesViewer";
  48612. export * from "babylonjs/Debug/boneAxesViewer";
  48613. export * from "babylonjs/Debug/debugLayer";
  48614. export * from "babylonjs/Debug/physicsViewer";
  48615. export * from "babylonjs/Debug/rayHelper";
  48616. export * from "babylonjs/Debug/skeletonViewer";
  48617. }
  48618. declare module "babylonjs/Engines/nullEngine" {
  48619. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  48620. import { Engine } from "babylonjs/Engines/engine";
  48621. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  48622. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  48623. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  48624. import { Effect } from "babylonjs/Materials/effect";
  48625. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  48626. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  48627. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  48628. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  48629. /**
  48630. * Options to create the null engine
  48631. */
  48632. export class NullEngineOptions {
  48633. /**
  48634. * Render width (Default: 512)
  48635. */
  48636. renderWidth: number;
  48637. /**
  48638. * Render height (Default: 256)
  48639. */
  48640. renderHeight: number;
  48641. /**
  48642. * Texture size (Default: 512)
  48643. */
  48644. textureSize: number;
  48645. /**
  48646. * If delta time between frames should be constant
  48647. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48648. */
  48649. deterministicLockstep: boolean;
  48650. /**
  48651. * Maximum about of steps between frames (Default: 4)
  48652. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48653. */
  48654. lockstepMaxSteps: number;
  48655. }
  48656. /**
  48657. * The null engine class provides support for headless version of babylon.js.
  48658. * This can be used in server side scenario or for testing purposes
  48659. */
  48660. export class NullEngine extends Engine {
  48661. private _options;
  48662. /**
  48663. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  48664. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48665. * @returns true if engine is in deterministic lock step mode
  48666. */
  48667. isDeterministicLockStep(): boolean;
  48668. /**
  48669. * Gets the max steps when engine is running in deterministic lock step
  48670. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  48671. * @returns the max steps
  48672. */
  48673. getLockstepMaxSteps(): number;
  48674. /**
  48675. * Gets the current hardware scaling level.
  48676. * By default the hardware scaling level is computed from the window device ratio.
  48677. * 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.
  48678. * @returns a number indicating the current hardware scaling level
  48679. */
  48680. getHardwareScalingLevel(): number;
  48681. constructor(options?: NullEngineOptions);
  48682. /**
  48683. * Creates a vertex buffer
  48684. * @param vertices the data for the vertex buffer
  48685. * @returns the new WebGL static buffer
  48686. */
  48687. createVertexBuffer(vertices: FloatArray): DataBuffer;
  48688. /**
  48689. * Creates a new index buffer
  48690. * @param indices defines the content of the index buffer
  48691. * @param updatable defines if the index buffer must be updatable
  48692. * @returns a new webGL buffer
  48693. */
  48694. createIndexBuffer(indices: IndicesArray): DataBuffer;
  48695. /**
  48696. * Clear the current render buffer or the current render target (if any is set up)
  48697. * @param color defines the color to use
  48698. * @param backBuffer defines if the back buffer must be cleared
  48699. * @param depth defines if the depth buffer must be cleared
  48700. * @param stencil defines if the stencil buffer must be cleared
  48701. */
  48702. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  48703. /**
  48704. * Gets the current render width
  48705. * @param useScreen defines if screen size must be used (or the current render target if any)
  48706. * @returns a number defining the current render width
  48707. */
  48708. getRenderWidth(useScreen?: boolean): number;
  48709. /**
  48710. * Gets the current render height
  48711. * @param useScreen defines if screen size must be used (or the current render target if any)
  48712. * @returns a number defining the current render height
  48713. */
  48714. getRenderHeight(useScreen?: boolean): number;
  48715. /**
  48716. * Set the WebGL's viewport
  48717. * @param viewport defines the viewport element to be used
  48718. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  48719. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  48720. */
  48721. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  48722. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  48723. /**
  48724. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  48725. * @param pipelineContext defines the pipeline context to use
  48726. * @param uniformsNames defines the list of uniform names
  48727. * @returns an array of webGL uniform locations
  48728. */
  48729. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  48730. /**
  48731. * Gets the lsit of active attributes for a given webGL program
  48732. * @param pipelineContext defines the pipeline context to use
  48733. * @param attributesNames defines the list of attribute names to get
  48734. * @returns an array of indices indicating the offset of each attribute
  48735. */
  48736. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  48737. /**
  48738. * Binds an effect to the webGL context
  48739. * @param effect defines the effect to bind
  48740. */
  48741. bindSamplers(effect: Effect): void;
  48742. /**
  48743. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  48744. * @param effect defines the effect to activate
  48745. */
  48746. enableEffect(effect: Effect): void;
  48747. /**
  48748. * Set various states to the webGL context
  48749. * @param culling defines backface culling state
  48750. * @param zOffset defines the value to apply to zOffset (0 by default)
  48751. * @param force defines if states must be applied even if cache is up to date
  48752. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  48753. */
  48754. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  48755. /**
  48756. * Set the value of an uniform to an array of int32
  48757. * @param uniform defines the webGL uniform location where to store the value
  48758. * @param array defines the array of int32 to store
  48759. */
  48760. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  48761. /**
  48762. * Set the value of an uniform to an array of int32 (stored as vec2)
  48763. * @param uniform defines the webGL uniform location where to store the value
  48764. * @param array defines the array of int32 to store
  48765. */
  48766. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  48767. /**
  48768. * Set the value of an uniform to an array of int32 (stored as vec3)
  48769. * @param uniform defines the webGL uniform location where to store the value
  48770. * @param array defines the array of int32 to store
  48771. */
  48772. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  48773. /**
  48774. * Set the value of an uniform to an array of int32 (stored as vec4)
  48775. * @param uniform defines the webGL uniform location where to store the value
  48776. * @param array defines the array of int32 to store
  48777. */
  48778. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  48779. /**
  48780. * Set the value of an uniform to an array of float32
  48781. * @param uniform defines the webGL uniform location where to store the value
  48782. * @param array defines the array of float32 to store
  48783. */
  48784. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  48785. /**
  48786. * Set the value of an uniform to an array of float32 (stored as vec2)
  48787. * @param uniform defines the webGL uniform location where to store the value
  48788. * @param array defines the array of float32 to store
  48789. */
  48790. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  48791. /**
  48792. * Set the value of an uniform to an array of float32 (stored as vec3)
  48793. * @param uniform defines the webGL uniform location where to store the value
  48794. * @param array defines the array of float32 to store
  48795. */
  48796. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  48797. /**
  48798. * Set the value of an uniform to an array of float32 (stored as vec4)
  48799. * @param uniform defines the webGL uniform location where to store the value
  48800. * @param array defines the array of float32 to store
  48801. */
  48802. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  48803. /**
  48804. * Set the value of an uniform to an array of number
  48805. * @param uniform defines the webGL uniform location where to store the value
  48806. * @param array defines the array of number to store
  48807. */
  48808. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  48809. /**
  48810. * Set the value of an uniform to an array of number (stored as vec2)
  48811. * @param uniform defines the webGL uniform location where to store the value
  48812. * @param array defines the array of number to store
  48813. */
  48814. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  48815. /**
  48816. * Set the value of an uniform to an array of number (stored as vec3)
  48817. * @param uniform defines the webGL uniform location where to store the value
  48818. * @param array defines the array of number to store
  48819. */
  48820. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  48821. /**
  48822. * Set the value of an uniform to an array of number (stored as vec4)
  48823. * @param uniform defines the webGL uniform location where to store the value
  48824. * @param array defines the array of number to store
  48825. */
  48826. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  48827. /**
  48828. * Set the value of an uniform to an array of float32 (stored as matrices)
  48829. * @param uniform defines the webGL uniform location where to store the value
  48830. * @param matrices defines the array of float32 to store
  48831. */
  48832. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  48833. /**
  48834. * Set the value of an uniform to a matrix (3x3)
  48835. * @param uniform defines the webGL uniform location where to store the value
  48836. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  48837. */
  48838. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48839. /**
  48840. * Set the value of an uniform to a matrix (2x2)
  48841. * @param uniform defines the webGL uniform location where to store the value
  48842. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  48843. */
  48844. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  48845. /**
  48846. * Set the value of an uniform to a number (float)
  48847. * @param uniform defines the webGL uniform location where to store the value
  48848. * @param value defines the float number to store
  48849. */
  48850. setFloat(uniform: WebGLUniformLocation, value: number): void;
  48851. /**
  48852. * Set the value of an uniform to a vec2
  48853. * @param uniform defines the webGL uniform location where to store the value
  48854. * @param x defines the 1st component of the value
  48855. * @param y defines the 2nd component of the value
  48856. */
  48857. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  48858. /**
  48859. * Set the value of an uniform to a vec3
  48860. * @param uniform defines the webGL uniform location where to store the value
  48861. * @param x defines the 1st component of the value
  48862. * @param y defines the 2nd component of the value
  48863. * @param z defines the 3rd component of the value
  48864. */
  48865. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  48866. /**
  48867. * Set the value of an uniform to a boolean
  48868. * @param uniform defines the webGL uniform location where to store the value
  48869. * @param bool defines the boolean to store
  48870. */
  48871. setBool(uniform: WebGLUniformLocation, bool: number): void;
  48872. /**
  48873. * Set the value of an uniform to a vec4
  48874. * @param uniform defines the webGL uniform location where to store the value
  48875. * @param x defines the 1st component of the value
  48876. * @param y defines the 2nd component of the value
  48877. * @param z defines the 3rd component of the value
  48878. * @param w defines the 4th component of the value
  48879. */
  48880. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  48881. /**
  48882. * Sets the current alpha mode
  48883. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  48884. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  48885. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  48886. */
  48887. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  48888. /**
  48889. * Bind webGl buffers directly to the webGL context
  48890. * @param vertexBuffers defines the vertex buffer to bind
  48891. * @param indexBuffer defines the index buffer to bind
  48892. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  48893. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  48894. * @param effect defines the effect associated with the vertex buffer
  48895. */
  48896. bindBuffers(vertexBuffers: {
  48897. [key: string]: VertexBuffer;
  48898. }, indexBuffer: DataBuffer, effect: Effect): void;
  48899. /**
  48900. * Force the entire cache to be cleared
  48901. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  48902. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  48903. */
  48904. wipeCaches(bruteForce?: boolean): void;
  48905. /**
  48906. * Send a draw order
  48907. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  48908. * @param indexStart defines the starting index
  48909. * @param indexCount defines the number of index to draw
  48910. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48911. */
  48912. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  48913. /**
  48914. * Draw a list of indexed primitives
  48915. * @param fillMode defines the primitive to use
  48916. * @param indexStart defines the starting index
  48917. * @param indexCount defines the number of index to draw
  48918. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48919. */
  48920. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  48921. /**
  48922. * Draw a list of unindexed primitives
  48923. * @param fillMode defines the primitive to use
  48924. * @param verticesStart defines the index of first vertex to draw
  48925. * @param verticesCount defines the count of vertices to draw
  48926. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  48927. */
  48928. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  48929. /** @hidden */
  48930. _createTexture(): WebGLTexture;
  48931. /** @hidden */
  48932. _releaseTexture(texture: InternalTexture): void;
  48933. /**
  48934. * Usually called from Texture.ts.
  48935. * Passed information to create a WebGLTexture
  48936. * @param urlArg defines a value which contains one of the following:
  48937. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  48938. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  48939. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  48940. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  48941. * @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)
  48942. * @param scene needed for loading to the correct scene
  48943. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  48944. * @param onLoad optional callback to be called upon successful completion
  48945. * @param onError optional callback to be called upon failure
  48946. * @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
  48947. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  48948. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  48949. * @param forcedExtension defines the extension to use to pick the right loader
  48950. * @param mimeType defines an optional mime type
  48951. * @returns a InternalTexture for assignment back into BABYLON.Texture
  48952. */
  48953. 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;
  48954. /**
  48955. * Creates a new render target texture
  48956. * @param size defines the size of the texture
  48957. * @param options defines the options used to create the texture
  48958. * @returns a new render target texture stored in an InternalTexture
  48959. */
  48960. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  48961. /**
  48962. * Update the sampling mode of a given texture
  48963. * @param samplingMode defines the required sampling mode
  48964. * @param texture defines the texture to update
  48965. */
  48966. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  48967. /**
  48968. * Binds the frame buffer to the specified texture.
  48969. * @param texture The texture to render to or null for the default canvas
  48970. * @param faceIndex The face of the texture to render to in case of cube texture
  48971. * @param requiredWidth The width of the target to render to
  48972. * @param requiredHeight The height of the target to render to
  48973. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  48974. * @param lodLevel defines le lod level to bind to the frame buffer
  48975. */
  48976. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  48977. /**
  48978. * Unbind the current render target texture from the webGL context
  48979. * @param texture defines the render target texture to unbind
  48980. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  48981. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  48982. */
  48983. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  48984. /**
  48985. * Creates a dynamic vertex buffer
  48986. * @param vertices the data for the dynamic vertex buffer
  48987. * @returns the new WebGL dynamic buffer
  48988. */
  48989. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  48990. /**
  48991. * Update the content of a dynamic texture
  48992. * @param texture defines the texture to update
  48993. * @param canvas defines the canvas containing the source
  48994. * @param invertY defines if data must be stored with Y axis inverted
  48995. * @param premulAlpha defines if alpha is stored as premultiplied
  48996. * @param format defines the format of the data
  48997. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  48998. */
  48999. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  49000. /**
  49001. * Gets a boolean indicating if all created effects are ready
  49002. * @returns true if all effects are ready
  49003. */
  49004. areAllEffectsReady(): boolean;
  49005. /**
  49006. * @hidden
  49007. * Get the current error code of the webGL context
  49008. * @returns the error code
  49009. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  49010. */
  49011. getError(): number;
  49012. /** @hidden */
  49013. _getUnpackAlignement(): number;
  49014. /** @hidden */
  49015. _unpackFlipY(value: boolean): void;
  49016. /**
  49017. * Update a dynamic index buffer
  49018. * @param indexBuffer defines the target index buffer
  49019. * @param indices defines the data to update
  49020. * @param offset defines the offset in the target index buffer where update should start
  49021. */
  49022. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  49023. /**
  49024. * Updates a dynamic vertex buffer.
  49025. * @param vertexBuffer the vertex buffer to update
  49026. * @param vertices the data used to update the vertex buffer
  49027. * @param byteOffset the byte offset of the data (optional)
  49028. * @param byteLength the byte length of the data (optional)
  49029. */
  49030. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  49031. /** @hidden */
  49032. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  49033. /** @hidden */
  49034. _bindTexture(channel: number, texture: InternalTexture): void;
  49035. protected _deleteBuffer(buffer: WebGLBuffer): void;
  49036. /**
  49037. * 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
  49038. */
  49039. releaseEffects(): void;
  49040. displayLoadingUI(): void;
  49041. hideLoadingUI(): void;
  49042. /** @hidden */
  49043. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49044. /** @hidden */
  49045. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49046. /** @hidden */
  49047. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  49048. /** @hidden */
  49049. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  49050. }
  49051. }
  49052. declare module "babylonjs/Instrumentation/timeToken" {
  49053. import { Nullable } from "babylonjs/types";
  49054. /**
  49055. * @hidden
  49056. **/
  49057. export class _TimeToken {
  49058. _startTimeQuery: Nullable<WebGLQuery>;
  49059. _endTimeQuery: Nullable<WebGLQuery>;
  49060. _timeElapsedQuery: Nullable<WebGLQuery>;
  49061. _timeElapsedQueryEnded: boolean;
  49062. }
  49063. }
  49064. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  49065. import { Nullable, int } from "babylonjs/types";
  49066. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  49067. /** @hidden */
  49068. export class _OcclusionDataStorage {
  49069. /** @hidden */
  49070. occlusionInternalRetryCounter: number;
  49071. /** @hidden */
  49072. isOcclusionQueryInProgress: boolean;
  49073. /** @hidden */
  49074. isOccluded: boolean;
  49075. /** @hidden */
  49076. occlusionRetryCount: number;
  49077. /** @hidden */
  49078. occlusionType: number;
  49079. /** @hidden */
  49080. occlusionQueryAlgorithmType: number;
  49081. }
  49082. module "babylonjs/Engines/engine" {
  49083. interface Engine {
  49084. /**
  49085. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  49086. * @return the new query
  49087. */
  49088. createQuery(): WebGLQuery;
  49089. /**
  49090. * Delete and release a webGL query
  49091. * @param query defines the query to delete
  49092. * @return the current engine
  49093. */
  49094. deleteQuery(query: WebGLQuery): Engine;
  49095. /**
  49096. * Check if a given query has resolved and got its value
  49097. * @param query defines the query to check
  49098. * @returns true if the query got its value
  49099. */
  49100. isQueryResultAvailable(query: WebGLQuery): boolean;
  49101. /**
  49102. * Gets the value of a given query
  49103. * @param query defines the query to check
  49104. * @returns the value of the query
  49105. */
  49106. getQueryResult(query: WebGLQuery): number;
  49107. /**
  49108. * Initiates an occlusion query
  49109. * @param algorithmType defines the algorithm to use
  49110. * @param query defines the query to use
  49111. * @returns the current engine
  49112. * @see http://doc.babylonjs.com/features/occlusionquery
  49113. */
  49114. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  49115. /**
  49116. * Ends an occlusion query
  49117. * @see http://doc.babylonjs.com/features/occlusionquery
  49118. * @param algorithmType defines the algorithm to use
  49119. * @returns the current engine
  49120. */
  49121. endOcclusionQuery(algorithmType: number): Engine;
  49122. /**
  49123. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  49124. * Please note that only one query can be issued at a time
  49125. * @returns a time token used to track the time span
  49126. */
  49127. startTimeQuery(): Nullable<_TimeToken>;
  49128. /**
  49129. * Ends a time query
  49130. * @param token defines the token used to measure the time span
  49131. * @returns the time spent (in ns)
  49132. */
  49133. endTimeQuery(token: _TimeToken): int;
  49134. /** @hidden */
  49135. _currentNonTimestampToken: Nullable<_TimeToken>;
  49136. /** @hidden */
  49137. _createTimeQuery(): WebGLQuery;
  49138. /** @hidden */
  49139. _deleteTimeQuery(query: WebGLQuery): void;
  49140. /** @hidden */
  49141. _getGlAlgorithmType(algorithmType: number): number;
  49142. /** @hidden */
  49143. _getTimeQueryResult(query: WebGLQuery): any;
  49144. /** @hidden */
  49145. _getTimeQueryAvailability(query: WebGLQuery): any;
  49146. }
  49147. }
  49148. module "babylonjs/Meshes/abstractMesh" {
  49149. interface AbstractMesh {
  49150. /**
  49151. * Backing filed
  49152. * @hidden
  49153. */
  49154. __occlusionDataStorage: _OcclusionDataStorage;
  49155. /**
  49156. * Access property
  49157. * @hidden
  49158. */
  49159. _occlusionDataStorage: _OcclusionDataStorage;
  49160. /**
  49161. * 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.
  49162. * The default value is -1 which means don't break the query and wait till the result
  49163. * @see http://doc.babylonjs.com/features/occlusionquery
  49164. */
  49165. occlusionRetryCount: number;
  49166. /**
  49167. * 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:
  49168. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  49169. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  49170. * * 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.
  49171. * @see http://doc.babylonjs.com/features/occlusionquery
  49172. */
  49173. occlusionType: number;
  49174. /**
  49175. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  49176. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  49177. * * 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.
  49178. * @see http://doc.babylonjs.com/features/occlusionquery
  49179. */
  49180. occlusionQueryAlgorithmType: number;
  49181. /**
  49182. * 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
  49183. * @see http://doc.babylonjs.com/features/occlusionquery
  49184. */
  49185. isOccluded: boolean;
  49186. /**
  49187. * Flag to check the progress status of the query
  49188. * @see http://doc.babylonjs.com/features/occlusionquery
  49189. */
  49190. isOcclusionQueryInProgress: boolean;
  49191. }
  49192. }
  49193. }
  49194. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  49195. import { Nullable } from "babylonjs/types";
  49196. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49197. /** @hidden */
  49198. export var _forceTransformFeedbackToBundle: boolean;
  49199. module "babylonjs/Engines/engine" {
  49200. interface Engine {
  49201. /**
  49202. * Creates a webGL transform feedback object
  49203. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  49204. * @returns the webGL transform feedback object
  49205. */
  49206. createTransformFeedback(): WebGLTransformFeedback;
  49207. /**
  49208. * Delete a webGL transform feedback object
  49209. * @param value defines the webGL transform feedback object to delete
  49210. */
  49211. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  49212. /**
  49213. * Bind a webGL transform feedback object to the webgl context
  49214. * @param value defines the webGL transform feedback object to bind
  49215. */
  49216. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  49217. /**
  49218. * Begins a transform feedback operation
  49219. * @param usePoints defines if points or triangles must be used
  49220. */
  49221. beginTransformFeedback(usePoints: boolean): void;
  49222. /**
  49223. * Ends a transform feedback operation
  49224. */
  49225. endTransformFeedback(): void;
  49226. /**
  49227. * Specify the varyings to use with transform feedback
  49228. * @param program defines the associated webGL program
  49229. * @param value defines the list of strings representing the varying names
  49230. */
  49231. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  49232. /**
  49233. * Bind a webGL buffer for a transform feedback operation
  49234. * @param value defines the webGL buffer to bind
  49235. */
  49236. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  49237. }
  49238. }
  49239. }
  49240. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  49241. import { Scene } from "babylonjs/scene";
  49242. import { Engine } from "babylonjs/Engines/engine";
  49243. import { Texture } from "babylonjs/Materials/Textures/texture";
  49244. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  49245. import "babylonjs/Engines/Extensions/engine.multiRender";
  49246. /**
  49247. * Creation options of the multi render target texture.
  49248. */
  49249. export interface IMultiRenderTargetOptions {
  49250. /**
  49251. * Define if the texture needs to create mip maps after render.
  49252. */
  49253. generateMipMaps?: boolean;
  49254. /**
  49255. * Define the types of all the draw buffers we want to create
  49256. */
  49257. types?: number[];
  49258. /**
  49259. * Define the sampling modes of all the draw buffers we want to create
  49260. */
  49261. samplingModes?: number[];
  49262. /**
  49263. * Define if a depth buffer is required
  49264. */
  49265. generateDepthBuffer?: boolean;
  49266. /**
  49267. * Define if a stencil buffer is required
  49268. */
  49269. generateStencilBuffer?: boolean;
  49270. /**
  49271. * Define if a depth texture is required instead of a depth buffer
  49272. */
  49273. generateDepthTexture?: boolean;
  49274. /**
  49275. * Define the number of desired draw buffers
  49276. */
  49277. textureCount?: number;
  49278. /**
  49279. * Define if aspect ratio should be adapted to the texture or stay the scene one
  49280. */
  49281. doNotChangeAspectRatio?: boolean;
  49282. /**
  49283. * Define the default type of the buffers we are creating
  49284. */
  49285. defaultType?: number;
  49286. }
  49287. /**
  49288. * A multi render target, like a render target provides the ability to render to a texture.
  49289. * Unlike the render target, it can render to several draw buffers in one draw.
  49290. * This is specially interesting in deferred rendering or for any effects requiring more than
  49291. * just one color from a single pass.
  49292. */
  49293. export class MultiRenderTarget extends RenderTargetTexture {
  49294. private _internalTextures;
  49295. private _textures;
  49296. private _multiRenderTargetOptions;
  49297. /**
  49298. * Get if draw buffers are currently supported by the used hardware and browser.
  49299. */
  49300. get isSupported(): boolean;
  49301. /**
  49302. * Get the list of textures generated by the multi render target.
  49303. */
  49304. get textures(): Texture[];
  49305. /**
  49306. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  49307. */
  49308. get depthTexture(): Texture;
  49309. /**
  49310. * Set the wrapping mode on U of all the textures we are rendering to.
  49311. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49312. */
  49313. set wrapU(wrap: number);
  49314. /**
  49315. * Set the wrapping mode on V of all the textures we are rendering to.
  49316. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  49317. */
  49318. set wrapV(wrap: number);
  49319. /**
  49320. * Instantiate a new multi render target texture.
  49321. * A multi render target, like a render target provides the ability to render to a texture.
  49322. * Unlike the render target, it can render to several draw buffers in one draw.
  49323. * This is specially interesting in deferred rendering or for any effects requiring more than
  49324. * just one color from a single pass.
  49325. * @param name Define the name of the texture
  49326. * @param size Define the size of the buffers to render to
  49327. * @param count Define the number of target we are rendering into
  49328. * @param scene Define the scene the texture belongs to
  49329. * @param options Define the options used to create the multi render target
  49330. */
  49331. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  49332. /** @hidden */
  49333. _rebuild(): void;
  49334. private _createInternalTextures;
  49335. private _createTextures;
  49336. /**
  49337. * Define the number of samples used if MSAA is enabled.
  49338. */
  49339. get samples(): number;
  49340. set samples(value: number);
  49341. /**
  49342. * Resize all the textures in the multi render target.
  49343. * Be carrefull as it will recreate all the data in the new texture.
  49344. * @param size Define the new size
  49345. */
  49346. resize(size: any): void;
  49347. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  49348. /**
  49349. * Dispose the render targets and their associated resources
  49350. */
  49351. dispose(): void;
  49352. /**
  49353. * Release all the underlying texture used as draw buffers.
  49354. */
  49355. releaseInternalTextures(): void;
  49356. }
  49357. }
  49358. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  49359. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49360. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  49361. import { Nullable } from "babylonjs/types";
  49362. module "babylonjs/Engines/thinEngine" {
  49363. interface ThinEngine {
  49364. /**
  49365. * Unbind a list of render target textures from the webGL context
  49366. * This is used only when drawBuffer extension or webGL2 are active
  49367. * @param textures defines the render target textures to unbind
  49368. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  49369. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  49370. */
  49371. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  49372. /**
  49373. * Create a multi render target texture
  49374. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  49375. * @param size defines the size of the texture
  49376. * @param options defines the creation options
  49377. * @returns the cube texture as an InternalTexture
  49378. */
  49379. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  49380. /**
  49381. * Update the sample count for a given multiple render target texture
  49382. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  49383. * @param textures defines the textures to update
  49384. * @param samples defines the sample count to set
  49385. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  49386. */
  49387. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  49388. }
  49389. }
  49390. }
  49391. declare module "babylonjs/Engines/Extensions/engine.views" {
  49392. import { Camera } from "babylonjs/Cameras/camera";
  49393. import { Nullable } from "babylonjs/types";
  49394. /**
  49395. * Class used to define an additional view for the engine
  49396. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49397. */
  49398. export class EngineView {
  49399. /** Defines the canvas where to render the view */
  49400. target: HTMLCanvasElement;
  49401. /** Defines an optional camera used to render the view (will use active camera else) */
  49402. camera?: Camera;
  49403. }
  49404. module "babylonjs/Engines/engine" {
  49405. interface Engine {
  49406. /**
  49407. * Gets or sets the HTML element to use for attaching events
  49408. */
  49409. inputElement: Nullable<HTMLElement>;
  49410. /**
  49411. * Gets the current engine view
  49412. * @see https://doc.babylonjs.com/how_to/multi_canvases
  49413. */
  49414. activeView: Nullable<EngineView>;
  49415. /** Gets or sets the list of views */
  49416. views: EngineView[];
  49417. /**
  49418. * Register a new child canvas
  49419. * @param canvas defines the canvas to register
  49420. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  49421. * @returns the associated view
  49422. */
  49423. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  49424. /**
  49425. * Remove a registered child canvas
  49426. * @param canvas defines the canvas to remove
  49427. * @returns the current engine
  49428. */
  49429. unRegisterView(canvas: HTMLCanvasElement): Engine;
  49430. }
  49431. }
  49432. }
  49433. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  49434. import { Nullable } from "babylonjs/types";
  49435. module "babylonjs/Engines/engine" {
  49436. interface Engine {
  49437. /** @hidden */
  49438. _excludedCompressedTextures: string[];
  49439. /** @hidden */
  49440. _textureFormatInUse: string;
  49441. /**
  49442. * Gets the list of texture formats supported
  49443. */
  49444. readonly texturesSupported: Array<string>;
  49445. /**
  49446. * Gets the texture format in use
  49447. */
  49448. readonly textureFormatInUse: Nullable<string>;
  49449. /**
  49450. * Set the compressed texture extensions or file names to skip.
  49451. *
  49452. * @param skippedFiles defines the list of those texture files you want to skip
  49453. * Example: [".dds", ".env", "myfile.png"]
  49454. */
  49455. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  49456. /**
  49457. * Set the compressed texture format to use, based on the formats you have, and the formats
  49458. * supported by the hardware / browser.
  49459. *
  49460. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  49461. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  49462. * to API arguments needed to compressed textures. This puts the burden on the container
  49463. * generator to house the arcane code for determining these for current & future formats.
  49464. *
  49465. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  49466. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  49467. *
  49468. * Note: The result of this call is not taken into account when a texture is base64.
  49469. *
  49470. * @param formatsAvailable defines the list of those format families you have created
  49471. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  49472. *
  49473. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  49474. * @returns The extension selected.
  49475. */
  49476. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  49477. }
  49478. }
  49479. }
  49480. declare module "babylonjs/Engines/Extensions/index" {
  49481. export * from "babylonjs/Engines/Extensions/engine.alpha";
  49482. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  49483. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  49484. export * from "babylonjs/Engines/Extensions/engine.multiview";
  49485. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  49486. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  49487. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  49488. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  49489. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  49490. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  49491. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49492. export * from "babylonjs/Engines/Extensions/engine.webVR";
  49493. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  49494. export * from "babylonjs/Engines/Extensions/engine.views";
  49495. import "babylonjs/Engines/Extensions/engine.textureSelector";
  49496. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  49497. }
  49498. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  49499. import { Nullable } from "babylonjs/types";
  49500. /**
  49501. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  49502. */
  49503. export interface CubeMapInfo {
  49504. /**
  49505. * The pixel array for the front face.
  49506. * This is stored in format, left to right, up to down format.
  49507. */
  49508. front: Nullable<ArrayBufferView>;
  49509. /**
  49510. * The pixel array for the back face.
  49511. * This is stored in format, left to right, up to down format.
  49512. */
  49513. back: Nullable<ArrayBufferView>;
  49514. /**
  49515. * The pixel array for the left face.
  49516. * This is stored in format, left to right, up to down format.
  49517. */
  49518. left: Nullable<ArrayBufferView>;
  49519. /**
  49520. * The pixel array for the right face.
  49521. * This is stored in format, left to right, up to down format.
  49522. */
  49523. right: Nullable<ArrayBufferView>;
  49524. /**
  49525. * The pixel array for the up face.
  49526. * This is stored in format, left to right, up to down format.
  49527. */
  49528. up: Nullable<ArrayBufferView>;
  49529. /**
  49530. * The pixel array for the down face.
  49531. * This is stored in format, left to right, up to down format.
  49532. */
  49533. down: Nullable<ArrayBufferView>;
  49534. /**
  49535. * The size of the cubemap stored.
  49536. *
  49537. * Each faces will be size * size pixels.
  49538. */
  49539. size: number;
  49540. /**
  49541. * The format of the texture.
  49542. *
  49543. * RGBA, RGB.
  49544. */
  49545. format: number;
  49546. /**
  49547. * The type of the texture data.
  49548. *
  49549. * UNSIGNED_INT, FLOAT.
  49550. */
  49551. type: number;
  49552. /**
  49553. * Specifies whether the texture is in gamma space.
  49554. */
  49555. gammaSpace: boolean;
  49556. }
  49557. /**
  49558. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  49559. */
  49560. export class PanoramaToCubeMapTools {
  49561. private static FACE_FRONT;
  49562. private static FACE_BACK;
  49563. private static FACE_RIGHT;
  49564. private static FACE_LEFT;
  49565. private static FACE_DOWN;
  49566. private static FACE_UP;
  49567. /**
  49568. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  49569. *
  49570. * @param float32Array The source data.
  49571. * @param inputWidth The width of the input panorama.
  49572. * @param inputHeight The height of the input panorama.
  49573. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  49574. * @return The cubemap data
  49575. */
  49576. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  49577. private static CreateCubemapTexture;
  49578. private static CalcProjectionSpherical;
  49579. }
  49580. }
  49581. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  49582. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49584. import { Nullable } from "babylonjs/types";
  49585. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49586. /**
  49587. * Helper class dealing with the extraction of spherical polynomial dataArray
  49588. * from a cube map.
  49589. */
  49590. export class CubeMapToSphericalPolynomialTools {
  49591. private static FileFaces;
  49592. /**
  49593. * Converts a texture to the according Spherical Polynomial data.
  49594. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49595. *
  49596. * @param texture The texture to extract the information from.
  49597. * @return The Spherical Polynomial data.
  49598. */
  49599. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  49600. /**
  49601. * Converts a cubemap to the according Spherical Polynomial data.
  49602. * This extracts the first 3 orders only as they are the only one used in the lighting.
  49603. *
  49604. * @param cubeInfo The Cube map to extract the information from.
  49605. * @return The Spherical Polynomial data.
  49606. */
  49607. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  49608. }
  49609. }
  49610. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  49611. import { Nullable } from "babylonjs/types";
  49612. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49613. module "babylonjs/Materials/Textures/baseTexture" {
  49614. interface BaseTexture {
  49615. /**
  49616. * Get the polynomial representation of the texture data.
  49617. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  49618. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  49619. */
  49620. sphericalPolynomial: Nullable<SphericalPolynomial>;
  49621. }
  49622. }
  49623. }
  49624. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  49625. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49626. /** @hidden */
  49627. export var rgbdEncodePixelShader: {
  49628. name: string;
  49629. shader: string;
  49630. };
  49631. }
  49632. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  49633. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  49634. /** @hidden */
  49635. export var rgbdDecodePixelShader: {
  49636. name: string;
  49637. shader: string;
  49638. };
  49639. }
  49640. declare module "babylonjs/Misc/environmentTextureTools" {
  49641. import { Nullable } from "babylonjs/types";
  49642. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  49643. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49644. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  49645. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  49646. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  49647. import "babylonjs/Shaders/rgbdEncode.fragment";
  49648. import "babylonjs/Shaders/rgbdDecode.fragment";
  49649. /**
  49650. * Raw texture data and descriptor sufficient for WebGL texture upload
  49651. */
  49652. export interface EnvironmentTextureInfo {
  49653. /**
  49654. * Version of the environment map
  49655. */
  49656. version: number;
  49657. /**
  49658. * Width of image
  49659. */
  49660. width: number;
  49661. /**
  49662. * Irradiance information stored in the file.
  49663. */
  49664. irradiance: any;
  49665. /**
  49666. * Specular information stored in the file.
  49667. */
  49668. specular: any;
  49669. }
  49670. /**
  49671. * Defines One Image in the file. It requires only the position in the file
  49672. * as well as the length.
  49673. */
  49674. interface BufferImageData {
  49675. /**
  49676. * Length of the image data.
  49677. */
  49678. length: number;
  49679. /**
  49680. * Position of the data from the null terminator delimiting the end of the JSON.
  49681. */
  49682. position: number;
  49683. }
  49684. /**
  49685. * Defines the specular data enclosed in the file.
  49686. * This corresponds to the version 1 of the data.
  49687. */
  49688. export interface EnvironmentTextureSpecularInfoV1 {
  49689. /**
  49690. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  49691. */
  49692. specularDataPosition?: number;
  49693. /**
  49694. * This contains all the images data needed to reconstruct the cubemap.
  49695. */
  49696. mipmaps: Array<BufferImageData>;
  49697. /**
  49698. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  49699. */
  49700. lodGenerationScale: number;
  49701. }
  49702. /**
  49703. * Sets of helpers addressing the serialization and deserialization of environment texture
  49704. * stored in a BabylonJS env file.
  49705. * Those files are usually stored as .env files.
  49706. */
  49707. export class EnvironmentTextureTools {
  49708. /**
  49709. * Magic number identifying the env file.
  49710. */
  49711. private static _MagicBytes;
  49712. /**
  49713. * Gets the environment info from an env file.
  49714. * @param data The array buffer containing the .env bytes.
  49715. * @returns the environment file info (the json header) if successfully parsed.
  49716. */
  49717. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  49718. /**
  49719. * Creates an environment texture from a loaded cube texture.
  49720. * @param texture defines the cube texture to convert in env file
  49721. * @return a promise containing the environment data if succesfull.
  49722. */
  49723. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  49724. /**
  49725. * Creates a JSON representation of the spherical data.
  49726. * @param texture defines the texture containing the polynomials
  49727. * @return the JSON representation of the spherical info
  49728. */
  49729. private static _CreateEnvTextureIrradiance;
  49730. /**
  49731. * Creates the ArrayBufferViews used for initializing environment texture image data.
  49732. * @param data the image data
  49733. * @param info parameters that determine what views will be created for accessing the underlying buffer
  49734. * @return the views described by info providing access to the underlying buffer
  49735. */
  49736. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  49737. /**
  49738. * Uploads the texture info contained in the env file to the GPU.
  49739. * @param texture defines the internal texture to upload to
  49740. * @param data defines the data to load
  49741. * @param info defines the texture info retrieved through the GetEnvInfo method
  49742. * @returns a promise
  49743. */
  49744. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  49745. private static _OnImageReadyAsync;
  49746. /**
  49747. * Uploads the levels of image data to the GPU.
  49748. * @param texture defines the internal texture to upload to
  49749. * @param imageData defines the array buffer views of image data [mipmap][face]
  49750. * @returns a promise
  49751. */
  49752. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  49753. /**
  49754. * Uploads spherical polynomials information to the texture.
  49755. * @param texture defines the texture we are trying to upload the information to
  49756. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  49757. */
  49758. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  49759. /** @hidden */
  49760. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  49761. }
  49762. }
  49763. declare module "babylonjs/Maths/math.vertexFormat" {
  49764. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  49765. /**
  49766. * Contains position and normal vectors for a vertex
  49767. */
  49768. export class PositionNormalVertex {
  49769. /** the position of the vertex (defaut: 0,0,0) */
  49770. position: Vector3;
  49771. /** the normal of the vertex (defaut: 0,1,0) */
  49772. normal: Vector3;
  49773. /**
  49774. * Creates a PositionNormalVertex
  49775. * @param position the position of the vertex (defaut: 0,0,0)
  49776. * @param normal the normal of the vertex (defaut: 0,1,0)
  49777. */
  49778. constructor(
  49779. /** the position of the vertex (defaut: 0,0,0) */
  49780. position?: Vector3,
  49781. /** the normal of the vertex (defaut: 0,1,0) */
  49782. normal?: Vector3);
  49783. /**
  49784. * Clones the PositionNormalVertex
  49785. * @returns the cloned PositionNormalVertex
  49786. */
  49787. clone(): PositionNormalVertex;
  49788. }
  49789. /**
  49790. * Contains position, normal and uv vectors for a vertex
  49791. */
  49792. export class PositionNormalTextureVertex {
  49793. /** the position of the vertex (defaut: 0,0,0) */
  49794. position: Vector3;
  49795. /** the normal of the vertex (defaut: 0,1,0) */
  49796. normal: Vector3;
  49797. /** the uv of the vertex (default: 0,0) */
  49798. uv: Vector2;
  49799. /**
  49800. * Creates a PositionNormalTextureVertex
  49801. * @param position the position of the vertex (defaut: 0,0,0)
  49802. * @param normal the normal of the vertex (defaut: 0,1,0)
  49803. * @param uv the uv of the vertex (default: 0,0)
  49804. */
  49805. constructor(
  49806. /** the position of the vertex (defaut: 0,0,0) */
  49807. position?: Vector3,
  49808. /** the normal of the vertex (defaut: 0,1,0) */
  49809. normal?: Vector3,
  49810. /** the uv of the vertex (default: 0,0) */
  49811. uv?: Vector2);
  49812. /**
  49813. * Clones the PositionNormalTextureVertex
  49814. * @returns the cloned PositionNormalTextureVertex
  49815. */
  49816. clone(): PositionNormalTextureVertex;
  49817. }
  49818. }
  49819. declare module "babylonjs/Maths/math" {
  49820. export * from "babylonjs/Maths/math.axis";
  49821. export * from "babylonjs/Maths/math.color";
  49822. export * from "babylonjs/Maths/math.constants";
  49823. export * from "babylonjs/Maths/math.frustum";
  49824. export * from "babylonjs/Maths/math.path";
  49825. export * from "babylonjs/Maths/math.plane";
  49826. export * from "babylonjs/Maths/math.size";
  49827. export * from "babylonjs/Maths/math.vector";
  49828. export * from "babylonjs/Maths/math.vertexFormat";
  49829. export * from "babylonjs/Maths/math.viewport";
  49830. }
  49831. declare module "babylonjs/Engines/Native/nativeShaderProcessor" {
  49832. import { WebGL2ShaderProcessor } from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  49833. /** @hidden */
  49834. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  49835. private _genericAttributeLocation;
  49836. private _varyingLocationCount;
  49837. private _varyingLocationMap;
  49838. private _replacements;
  49839. private _textureCount;
  49840. private _uniforms;
  49841. lineProcessor(line: string): string;
  49842. attributeProcessor(attribute: string): string;
  49843. varyingProcessor(varying: string, isFragment: boolean): string;
  49844. uniformProcessor(uniform: string): string;
  49845. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  49846. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  49847. }
  49848. }
  49849. declare module "babylonjs/Engines/nativeEngine" {
  49850. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  49851. import { Engine } from "babylonjs/Engines/engine";
  49852. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  49853. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  49854. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49855. import { Effect } from "babylonjs/Materials/effect";
  49856. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  49857. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  49858. import { IColor4Like } from "babylonjs/Maths/math.like";
  49859. import { Scene } from "babylonjs/scene";
  49860. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  49861. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  49862. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  49863. /**
  49864. * Container for accessors for natively-stored mesh data buffers.
  49865. */
  49866. class NativeDataBuffer extends DataBuffer {
  49867. /**
  49868. * Accessor value used to identify/retrieve a natively-stored index buffer.
  49869. */
  49870. nativeIndexBuffer?: any;
  49871. /**
  49872. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  49873. */
  49874. nativeVertexBuffer?: any;
  49875. }
  49876. /** @hidden */
  49877. class NativeTexture extends InternalTexture {
  49878. getInternalTexture(): InternalTexture;
  49879. getViewCount(): number;
  49880. }
  49881. /** @hidden */
  49882. export class NativeEngine extends Engine {
  49883. private readonly _native;
  49884. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  49885. private readonly INVALID_HANDLE;
  49886. getHardwareScalingLevel(): number;
  49887. constructor();
  49888. dispose(): void;
  49889. /**
  49890. * Can be used to override the current requestAnimationFrame requester.
  49891. * @hidden
  49892. */
  49893. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  49894. /**
  49895. * Override default engine behavior.
  49896. * @param color
  49897. * @param backBuffer
  49898. * @param depth
  49899. * @param stencil
  49900. */
  49901. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  49902. /**
  49903. * Gets host document
  49904. * @returns the host document object
  49905. */
  49906. getHostDocument(): Nullable<Document>;
  49907. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  49908. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  49909. createVertexBuffer(data: DataArray): NativeDataBuffer;
  49910. recordVertexArrayObject(vertexBuffers: {
  49911. [key: string]: VertexBuffer;
  49912. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  49913. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49914. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  49915. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  49916. /**
  49917. * Draw a list of indexed primitives
  49918. * @param fillMode defines the primitive to use
  49919. * @param indexStart defines the starting index
  49920. * @param indexCount defines the number of index to draw
  49921. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49922. */
  49923. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  49924. /**
  49925. * Draw a list of unindexed primitives
  49926. * @param fillMode defines the primitive to use
  49927. * @param verticesStart defines the index of first vertex to draw
  49928. * @param verticesCount defines the count of vertices to draw
  49929. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  49930. */
  49931. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  49932. createPipelineContext(): IPipelineContext;
  49933. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  49934. /** @hidden */
  49935. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  49936. /** @hidden */
  49937. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  49938. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49939. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  49940. protected _setProgram(program: WebGLProgram): void;
  49941. _releaseEffect(effect: Effect): void;
  49942. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  49943. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  49944. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  49945. bindSamplers(effect: Effect): void;
  49946. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  49947. getRenderWidth(useScreen?: boolean): number;
  49948. getRenderHeight(useScreen?: boolean): number;
  49949. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  49950. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  49951. /**
  49952. * Set the z offset to apply to current rendering
  49953. * @param value defines the offset to apply
  49954. */
  49955. setZOffset(value: number): void;
  49956. /**
  49957. * Gets the current value of the zOffset
  49958. * @returns the current zOffset state
  49959. */
  49960. getZOffset(): number;
  49961. /**
  49962. * Enable or disable depth buffering
  49963. * @param enable defines the state to set
  49964. */
  49965. setDepthBuffer(enable: boolean): void;
  49966. /**
  49967. * Gets a boolean indicating if depth writing is enabled
  49968. * @returns the current depth writing state
  49969. */
  49970. getDepthWrite(): boolean;
  49971. /**
  49972. * Enable or disable depth writing
  49973. * @param enable defines the state to set
  49974. */
  49975. setDepthWrite(enable: boolean): void;
  49976. /**
  49977. * Enable or disable color writing
  49978. * @param enable defines the state to set
  49979. */
  49980. setColorWrite(enable: boolean): void;
  49981. /**
  49982. * Gets a boolean indicating if color writing is enabled
  49983. * @returns the current color writing state
  49984. */
  49985. getColorWrite(): boolean;
  49986. /**
  49987. * Sets alpha constants used by some alpha blending modes
  49988. * @param r defines the red component
  49989. * @param g defines the green component
  49990. * @param b defines the blue component
  49991. * @param a defines the alpha component
  49992. */
  49993. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  49994. /**
  49995. * Sets the current alpha mode
  49996. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  49997. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  49998. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  49999. */
  50000. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  50001. /**
  50002. * Gets the current alpha mode
  50003. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  50004. * @returns the current alpha mode
  50005. */
  50006. getAlphaMode(): number;
  50007. setInt(uniform: WebGLUniformLocation, int: number): void;
  50008. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  50009. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  50010. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  50011. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  50012. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  50013. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  50014. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  50015. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  50016. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  50017. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  50018. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  50019. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  50020. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  50021. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50022. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  50023. setFloat(uniform: WebGLUniformLocation, value: number): void;
  50024. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  50025. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  50026. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  50027. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  50028. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  50029. wipeCaches(bruteForce?: boolean): void;
  50030. _createTexture(): WebGLTexture;
  50031. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  50032. /**
  50033. * Usually called from Texture.ts.
  50034. * Passed information to create a WebGLTexture
  50035. * @param url defines a value which contains one of the following:
  50036. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  50037. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  50038. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  50039. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  50040. * @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)
  50041. * @param scene needed for loading to the correct scene
  50042. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  50043. * @param onLoad optional callback to be called upon successful completion
  50044. * @param onError optional callback to be called upon failure
  50045. * @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
  50046. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  50047. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  50048. * @param forcedExtension defines the extension to use to pick the right loader
  50049. * @param mimeType defines an optional mime type
  50050. * @returns a InternalTexture for assignment back into BABYLON.Texture
  50051. */
  50052. 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;
  50053. /**
  50054. * Creates a cube texture
  50055. * @param rootUrl defines the url where the files to load is located
  50056. * @param scene defines the current scene
  50057. * @param files defines the list of files to load (1 per face)
  50058. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  50059. * @param onLoad defines an optional callback raised when the texture is loaded
  50060. * @param onError defines an optional callback raised if there is an issue to load the texture
  50061. * @param format defines the format of the data
  50062. * @param forcedExtension defines the extension to use to pick the right loader
  50063. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  50064. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  50065. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  50066. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  50067. * @returns the cube texture as an InternalTexture
  50068. */
  50069. 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;
  50070. private _getSamplingFilter;
  50071. private static _GetNativeTextureFormat;
  50072. createRenderTargetTexture(size: number | {
  50073. width: number;
  50074. height: number;
  50075. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  50076. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  50077. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  50078. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  50079. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  50080. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  50081. /**
  50082. * Updates a dynamic vertex buffer.
  50083. * @param vertexBuffer the vertex buffer to update
  50084. * @param data the data used to update the vertex buffer
  50085. * @param byteOffset the byte offset of the data (optional)
  50086. * @param byteLength the byte length of the data (optional)
  50087. */
  50088. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  50089. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  50090. private _updateAnisotropicLevel;
  50091. private _getAddressMode;
  50092. /** @hidden */
  50093. _bindTexture(channel: number, texture: InternalTexture): void;
  50094. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  50095. releaseEffects(): void;
  50096. /** @hidden */
  50097. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50098. /** @hidden */
  50099. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50100. /** @hidden */
  50101. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  50102. /** @hidden */
  50103. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  50104. }
  50105. }
  50106. declare module "babylonjs/Engines/index" {
  50107. export * from "babylonjs/Engines/constants";
  50108. export * from "babylonjs/Engines/engineCapabilities";
  50109. export * from "babylonjs/Engines/instancingAttributeInfo";
  50110. export * from "babylonjs/Engines/thinEngine";
  50111. export * from "babylonjs/Engines/engine";
  50112. export * from "babylonjs/Engines/engineStore";
  50113. export * from "babylonjs/Engines/nullEngine";
  50114. export * from "babylonjs/Engines/Extensions/index";
  50115. export * from "babylonjs/Engines/IPipelineContext";
  50116. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  50117. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  50118. export * from "babylonjs/Engines/nativeEngine";
  50119. }
  50120. declare module "babylonjs/Events/clipboardEvents" {
  50121. /**
  50122. * Gather the list of clipboard event types as constants.
  50123. */
  50124. export class ClipboardEventTypes {
  50125. /**
  50126. * The clipboard event is fired when a copy command is active (pressed).
  50127. */
  50128. static readonly COPY: number;
  50129. /**
  50130. * The clipboard event is fired when a cut command is active (pressed).
  50131. */
  50132. static readonly CUT: number;
  50133. /**
  50134. * The clipboard event is fired when a paste command is active (pressed).
  50135. */
  50136. static readonly PASTE: number;
  50137. }
  50138. /**
  50139. * This class is used to store clipboard related info for the onClipboardObservable event.
  50140. */
  50141. export class ClipboardInfo {
  50142. /**
  50143. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50144. */
  50145. type: number;
  50146. /**
  50147. * Defines the related dom event
  50148. */
  50149. event: ClipboardEvent;
  50150. /**
  50151. *Creates an instance of ClipboardInfo.
  50152. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  50153. * @param event Defines the related dom event
  50154. */
  50155. constructor(
  50156. /**
  50157. * Defines the type of event (BABYLON.ClipboardEventTypes)
  50158. */
  50159. type: number,
  50160. /**
  50161. * Defines the related dom event
  50162. */
  50163. event: ClipboardEvent);
  50164. /**
  50165. * Get the clipboard event's type from the keycode.
  50166. * @param keyCode Defines the keyCode for the current keyboard event.
  50167. * @return {number}
  50168. */
  50169. static GetTypeFromCharacter(keyCode: number): number;
  50170. }
  50171. }
  50172. declare module "babylonjs/Events/index" {
  50173. export * from "babylonjs/Events/keyboardEvents";
  50174. export * from "babylonjs/Events/pointerEvents";
  50175. export * from "babylonjs/Events/clipboardEvents";
  50176. }
  50177. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  50178. import { Scene } from "babylonjs/scene";
  50179. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50180. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50181. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50182. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50183. /**
  50184. * Google Daydream controller
  50185. */
  50186. export class DaydreamController extends WebVRController {
  50187. /**
  50188. * Base Url for the controller model.
  50189. */
  50190. static MODEL_BASE_URL: string;
  50191. /**
  50192. * File name for the controller model.
  50193. */
  50194. static MODEL_FILENAME: string;
  50195. /**
  50196. * Gamepad Id prefix used to identify Daydream Controller.
  50197. */
  50198. static readonly GAMEPAD_ID_PREFIX: string;
  50199. /**
  50200. * Creates a new DaydreamController from a gamepad
  50201. * @param vrGamepad the gamepad that the controller should be created from
  50202. */
  50203. constructor(vrGamepad: any);
  50204. /**
  50205. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50206. * @param scene scene in which to add meshes
  50207. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50208. */
  50209. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50210. /**
  50211. * Called once for each button that changed state since the last frame
  50212. * @param buttonIdx Which button index changed
  50213. * @param state New state of the button
  50214. * @param changes Which properties on the state changed since last frame
  50215. */
  50216. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50217. }
  50218. }
  50219. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  50220. import { Scene } from "babylonjs/scene";
  50221. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50222. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50223. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50224. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50225. /**
  50226. * Gear VR Controller
  50227. */
  50228. export class GearVRController extends WebVRController {
  50229. /**
  50230. * Base Url for the controller model.
  50231. */
  50232. static MODEL_BASE_URL: string;
  50233. /**
  50234. * File name for the controller model.
  50235. */
  50236. static MODEL_FILENAME: string;
  50237. /**
  50238. * Gamepad Id prefix used to identify this controller.
  50239. */
  50240. static readonly GAMEPAD_ID_PREFIX: string;
  50241. private readonly _buttonIndexToObservableNameMap;
  50242. /**
  50243. * Creates a new GearVRController from a gamepad
  50244. * @param vrGamepad the gamepad that the controller should be created from
  50245. */
  50246. constructor(vrGamepad: any);
  50247. /**
  50248. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50249. * @param scene scene in which to add meshes
  50250. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50251. */
  50252. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50253. /**
  50254. * Called once for each button that changed state since the last frame
  50255. * @param buttonIdx Which button index changed
  50256. * @param state New state of the button
  50257. * @param changes Which properties on the state changed since last frame
  50258. */
  50259. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50260. }
  50261. }
  50262. declare module "babylonjs/Gamepads/Controllers/genericController" {
  50263. import { Scene } from "babylonjs/scene";
  50264. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50265. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50266. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50267. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50268. /**
  50269. * Generic Controller
  50270. */
  50271. export class GenericController extends WebVRController {
  50272. /**
  50273. * Base Url for the controller model.
  50274. */
  50275. static readonly MODEL_BASE_URL: string;
  50276. /**
  50277. * File name for the controller model.
  50278. */
  50279. static readonly MODEL_FILENAME: string;
  50280. /**
  50281. * Creates a new GenericController from a gamepad
  50282. * @param vrGamepad the gamepad that the controller should be created from
  50283. */
  50284. constructor(vrGamepad: any);
  50285. /**
  50286. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50287. * @param scene scene in which to add meshes
  50288. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50289. */
  50290. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50291. /**
  50292. * Called once for each button that changed state since the last frame
  50293. * @param buttonIdx Which button index changed
  50294. * @param state New state of the button
  50295. * @param changes Which properties on the state changed since last frame
  50296. */
  50297. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50298. }
  50299. }
  50300. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  50301. import { Observable } from "babylonjs/Misc/observable";
  50302. import { Scene } from "babylonjs/scene";
  50303. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50304. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50305. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50306. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50307. /**
  50308. * Oculus Touch Controller
  50309. */
  50310. export class OculusTouchController extends WebVRController {
  50311. /**
  50312. * Base Url for the controller model.
  50313. */
  50314. static MODEL_BASE_URL: string;
  50315. /**
  50316. * File name for the left controller model.
  50317. */
  50318. static MODEL_LEFT_FILENAME: string;
  50319. /**
  50320. * File name for the right controller model.
  50321. */
  50322. static MODEL_RIGHT_FILENAME: string;
  50323. /**
  50324. * Base Url for the Quest controller model.
  50325. */
  50326. static QUEST_MODEL_BASE_URL: string;
  50327. /**
  50328. * @hidden
  50329. * If the controllers are running on a device that needs the updated Quest controller models
  50330. */
  50331. static _IsQuest: boolean;
  50332. /**
  50333. * Fired when the secondary trigger on this controller is modified
  50334. */
  50335. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  50336. /**
  50337. * Fired when the thumb rest on this controller is modified
  50338. */
  50339. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  50340. /**
  50341. * Creates a new OculusTouchController from a gamepad
  50342. * @param vrGamepad the gamepad that the controller should be created from
  50343. */
  50344. constructor(vrGamepad: any);
  50345. /**
  50346. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50347. * @param scene scene in which to add meshes
  50348. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50349. */
  50350. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50351. /**
  50352. * Fired when the A button on this controller is modified
  50353. */
  50354. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50355. /**
  50356. * Fired when the B button on this controller is modified
  50357. */
  50358. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50359. /**
  50360. * Fired when the X button on this controller is modified
  50361. */
  50362. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50363. /**
  50364. * Fired when the Y button on this controller is modified
  50365. */
  50366. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50367. /**
  50368. * Called once for each button that changed state since the last frame
  50369. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  50370. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  50371. * 2) secondary trigger (same)
  50372. * 3) A (right) X (left), touch, pressed = value
  50373. * 4) B / Y
  50374. * 5) thumb rest
  50375. * @param buttonIdx Which button index changed
  50376. * @param state New state of the button
  50377. * @param changes Which properties on the state changed since last frame
  50378. */
  50379. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50380. }
  50381. }
  50382. declare module "babylonjs/Gamepads/Controllers/viveController" {
  50383. import { Scene } from "babylonjs/scene";
  50384. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50385. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50386. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50387. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50388. import { Observable } from "babylonjs/Misc/observable";
  50389. /**
  50390. * Vive Controller
  50391. */
  50392. export class ViveController extends WebVRController {
  50393. /**
  50394. * Base Url for the controller model.
  50395. */
  50396. static MODEL_BASE_URL: string;
  50397. /**
  50398. * File name for the controller model.
  50399. */
  50400. static MODEL_FILENAME: string;
  50401. /**
  50402. * Creates a new ViveController from a gamepad
  50403. * @param vrGamepad the gamepad that the controller should be created from
  50404. */
  50405. constructor(vrGamepad: any);
  50406. /**
  50407. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50408. * @param scene scene in which to add meshes
  50409. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50410. */
  50411. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  50412. /**
  50413. * Fired when the left button on this controller is modified
  50414. */
  50415. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50416. /**
  50417. * Fired when the right button on this controller is modified
  50418. */
  50419. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50420. /**
  50421. * Fired when the menu button on this controller is modified
  50422. */
  50423. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50424. /**
  50425. * Called once for each button that changed state since the last frame
  50426. * Vive mapping:
  50427. * 0: touchpad
  50428. * 1: trigger
  50429. * 2: left AND right buttons
  50430. * 3: menu button
  50431. * @param buttonIdx Which button index changed
  50432. * @param state New state of the button
  50433. * @param changes Which properties on the state changed since last frame
  50434. */
  50435. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50436. }
  50437. }
  50438. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  50439. import { Observable } from "babylonjs/Misc/observable";
  50440. import { Scene } from "babylonjs/scene";
  50441. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50442. import { Ray } from "babylonjs/Culling/ray";
  50443. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  50444. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50445. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  50446. /**
  50447. * Defines the WindowsMotionController object that the state of the windows motion controller
  50448. */
  50449. export class WindowsMotionController extends WebVRController {
  50450. /**
  50451. * The base url used to load the left and right controller models
  50452. */
  50453. static MODEL_BASE_URL: string;
  50454. /**
  50455. * The name of the left controller model file
  50456. */
  50457. static MODEL_LEFT_FILENAME: string;
  50458. /**
  50459. * The name of the right controller model file
  50460. */
  50461. static MODEL_RIGHT_FILENAME: string;
  50462. /**
  50463. * The controller name prefix for this controller type
  50464. */
  50465. static readonly GAMEPAD_ID_PREFIX: string;
  50466. /**
  50467. * The controller id pattern for this controller type
  50468. */
  50469. private static readonly GAMEPAD_ID_PATTERN;
  50470. private _loadedMeshInfo;
  50471. protected readonly _mapping: {
  50472. buttons: string[];
  50473. buttonMeshNames: {
  50474. trigger: string;
  50475. menu: string;
  50476. grip: string;
  50477. thumbstick: string;
  50478. trackpad: string;
  50479. };
  50480. buttonObservableNames: {
  50481. trigger: string;
  50482. menu: string;
  50483. grip: string;
  50484. thumbstick: string;
  50485. trackpad: string;
  50486. };
  50487. axisMeshNames: string[];
  50488. pointingPoseMeshName: string;
  50489. };
  50490. /**
  50491. * Fired when the trackpad on this controller is clicked
  50492. */
  50493. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50494. /**
  50495. * Fired when the trackpad on this controller is modified
  50496. */
  50497. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50498. /**
  50499. * The current x and y values of this controller's trackpad
  50500. */
  50501. trackpad: StickValues;
  50502. /**
  50503. * Creates a new WindowsMotionController from a gamepad
  50504. * @param vrGamepad the gamepad that the controller should be created from
  50505. */
  50506. constructor(vrGamepad: any);
  50507. /**
  50508. * Fired when the trigger on this controller is modified
  50509. */
  50510. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50511. /**
  50512. * Fired when the menu button on this controller is modified
  50513. */
  50514. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50515. /**
  50516. * Fired when the grip button on this controller is modified
  50517. */
  50518. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50519. /**
  50520. * Fired when the thumbstick button on this controller is modified
  50521. */
  50522. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50523. /**
  50524. * Fired when the touchpad button on this controller is modified
  50525. */
  50526. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50527. /**
  50528. * Fired when the touchpad values on this controller are modified
  50529. */
  50530. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  50531. protected _updateTrackpad(): void;
  50532. /**
  50533. * Called once per frame by the engine.
  50534. */
  50535. update(): void;
  50536. /**
  50537. * Called once for each button that changed state since the last frame
  50538. * @param buttonIdx Which button index changed
  50539. * @param state New state of the button
  50540. * @param changes Which properties on the state changed since last frame
  50541. */
  50542. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  50543. /**
  50544. * Moves the buttons on the controller mesh based on their current state
  50545. * @param buttonName the name of the button to move
  50546. * @param buttonValue the value of the button which determines the buttons new position
  50547. */
  50548. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  50549. /**
  50550. * Moves the axis on the controller mesh based on its current state
  50551. * @param axis the index of the axis
  50552. * @param axisValue the value of the axis which determines the meshes new position
  50553. * @hidden
  50554. */
  50555. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  50556. /**
  50557. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  50558. * @param scene scene in which to add meshes
  50559. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  50560. */
  50561. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  50562. /**
  50563. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  50564. * can be transformed by button presses and axes values, based on this._mapping.
  50565. *
  50566. * @param scene scene in which the meshes exist
  50567. * @param meshes list of meshes that make up the controller model to process
  50568. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  50569. */
  50570. private processModel;
  50571. private createMeshInfo;
  50572. /**
  50573. * Gets the ray of the controller in the direction the controller is pointing
  50574. * @param length the length the resulting ray should be
  50575. * @returns a ray in the direction the controller is pointing
  50576. */
  50577. getForwardRay(length?: number): Ray;
  50578. /**
  50579. * Disposes of the controller
  50580. */
  50581. dispose(): void;
  50582. }
  50583. /**
  50584. * This class represents a new windows motion controller in XR.
  50585. */
  50586. export class XRWindowsMotionController extends WindowsMotionController {
  50587. /**
  50588. * Changing the original WIndowsMotionController mapping to fir the new mapping
  50589. */
  50590. protected readonly _mapping: {
  50591. buttons: string[];
  50592. buttonMeshNames: {
  50593. trigger: string;
  50594. menu: string;
  50595. grip: string;
  50596. thumbstick: string;
  50597. trackpad: string;
  50598. };
  50599. buttonObservableNames: {
  50600. trigger: string;
  50601. menu: string;
  50602. grip: string;
  50603. thumbstick: string;
  50604. trackpad: string;
  50605. };
  50606. axisMeshNames: string[];
  50607. pointingPoseMeshName: string;
  50608. };
  50609. /**
  50610. * Construct a new XR-Based windows motion controller
  50611. *
  50612. * @param gamepadInfo the gamepad object from the browser
  50613. */
  50614. constructor(gamepadInfo: any);
  50615. /**
  50616. * holds the thumbstick values (X,Y)
  50617. */
  50618. thumbstickValues: StickValues;
  50619. /**
  50620. * Fired when the thumbstick on this controller is clicked
  50621. */
  50622. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  50623. /**
  50624. * Fired when the thumbstick on this controller is modified
  50625. */
  50626. onThumbstickValuesChangedObservable: Observable<StickValues>;
  50627. /**
  50628. * Fired when the touchpad button on this controller is modified
  50629. */
  50630. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  50631. /**
  50632. * Fired when the touchpad values on this controller are modified
  50633. */
  50634. onTrackpadValuesChangedObservable: Observable<StickValues>;
  50635. /**
  50636. * Fired when the thumbstick button on this controller is modified
  50637. * here to prevent breaking changes
  50638. */
  50639. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  50640. /**
  50641. * updating the thumbstick(!) and not the trackpad.
  50642. * This is named this way due to the difference between WebVR and XR and to avoid
  50643. * changing the parent class.
  50644. */
  50645. protected _updateTrackpad(): void;
  50646. /**
  50647. * Disposes the class with joy
  50648. */
  50649. dispose(): void;
  50650. }
  50651. }
  50652. declare module "babylonjs/Gamepads/Controllers/index" {
  50653. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  50654. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  50655. export * from "babylonjs/Gamepads/Controllers/genericController";
  50656. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  50657. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  50658. export * from "babylonjs/Gamepads/Controllers/viveController";
  50659. export * from "babylonjs/Gamepads/Controllers/webVRController";
  50660. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  50661. }
  50662. declare module "babylonjs/Gamepads/index" {
  50663. export * from "babylonjs/Gamepads/Controllers/index";
  50664. export * from "babylonjs/Gamepads/gamepad";
  50665. export * from "babylonjs/Gamepads/gamepadManager";
  50666. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  50667. export * from "babylonjs/Gamepads/xboxGamepad";
  50668. export * from "babylonjs/Gamepads/dualShockGamepad";
  50669. }
  50670. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  50671. import { Scene } from "babylonjs/scene";
  50672. import { Vector4 } from "babylonjs/Maths/math.vector";
  50673. import { Color4 } from "babylonjs/Maths/math.color";
  50674. import { Mesh } from "babylonjs/Meshes/mesh";
  50675. import { Nullable } from "babylonjs/types";
  50676. /**
  50677. * Class containing static functions to help procedurally build meshes
  50678. */
  50679. export class PolyhedronBuilder {
  50680. /**
  50681. * Creates a polyhedron mesh
  50682. * * 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
  50683. * * The parameter `size` (positive float, default 1) sets the polygon size
  50684. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  50685. * * 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`
  50686. * * 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
  50687. * * 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)`)
  50688. * * 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
  50689. * * 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
  50690. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50691. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50692. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50693. * @param name defines the name of the mesh
  50694. * @param options defines the options used to create the mesh
  50695. * @param scene defines the hosting scene
  50696. * @returns the polyhedron mesh
  50697. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  50698. */
  50699. static CreatePolyhedron(name: string, options: {
  50700. type?: number;
  50701. size?: number;
  50702. sizeX?: number;
  50703. sizeY?: number;
  50704. sizeZ?: number;
  50705. custom?: any;
  50706. faceUV?: Vector4[];
  50707. faceColors?: Color4[];
  50708. flat?: boolean;
  50709. updatable?: boolean;
  50710. sideOrientation?: number;
  50711. frontUVs?: Vector4;
  50712. backUVs?: Vector4;
  50713. }, scene?: Nullable<Scene>): Mesh;
  50714. }
  50715. }
  50716. declare module "babylonjs/Gizmos/scaleGizmo" {
  50717. import { Observable } from "babylonjs/Misc/observable";
  50718. import { Nullable } from "babylonjs/types";
  50719. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50720. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50721. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  50722. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50723. /**
  50724. * Gizmo that enables scaling a mesh along 3 axis
  50725. */
  50726. export class ScaleGizmo extends Gizmo {
  50727. /**
  50728. * Internal gizmo used for interactions on the x axis
  50729. */
  50730. xGizmo: AxisScaleGizmo;
  50731. /**
  50732. * Internal gizmo used for interactions on the y axis
  50733. */
  50734. yGizmo: AxisScaleGizmo;
  50735. /**
  50736. * Internal gizmo used for interactions on the z axis
  50737. */
  50738. zGizmo: AxisScaleGizmo;
  50739. /**
  50740. * Internal gizmo used to scale all axis equally
  50741. */
  50742. uniformScaleGizmo: AxisScaleGizmo;
  50743. private _meshAttached;
  50744. private _updateGizmoRotationToMatchAttachedMesh;
  50745. private _snapDistance;
  50746. private _scaleRatio;
  50747. private _uniformScalingMesh;
  50748. private _octahedron;
  50749. private _sensitivity;
  50750. /** Fires an event when any of it's sub gizmos are dragged */
  50751. onDragStartObservable: Observable<unknown>;
  50752. /** Fires an event when any of it's sub gizmos are released from dragging */
  50753. onDragEndObservable: Observable<unknown>;
  50754. get attachedMesh(): Nullable<AbstractMesh>;
  50755. set attachedMesh(mesh: Nullable<AbstractMesh>);
  50756. /**
  50757. * Creates a ScaleGizmo
  50758. * @param gizmoLayer The utility layer the gizmo will be added to
  50759. */
  50760. constructor(gizmoLayer?: UtilityLayerRenderer);
  50761. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  50762. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  50763. /**
  50764. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50765. */
  50766. set snapDistance(value: number);
  50767. get snapDistance(): number;
  50768. /**
  50769. * Ratio for the scale of the gizmo (Default: 1)
  50770. */
  50771. set scaleRatio(value: number);
  50772. get scaleRatio(): number;
  50773. /**
  50774. * Sensitivity factor for dragging (Default: 1)
  50775. */
  50776. set sensitivity(value: number);
  50777. get sensitivity(): number;
  50778. /**
  50779. * Disposes of the gizmo
  50780. */
  50781. dispose(): void;
  50782. }
  50783. }
  50784. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  50785. import { Observable } from "babylonjs/Misc/observable";
  50786. import { Nullable } from "babylonjs/types";
  50787. import { Vector3 } from "babylonjs/Maths/math.vector";
  50788. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50789. import { Mesh } from "babylonjs/Meshes/mesh";
  50790. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50791. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50792. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50793. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  50794. import { Color3 } from "babylonjs/Maths/math.color";
  50795. /**
  50796. * Single axis scale gizmo
  50797. */
  50798. export class AxisScaleGizmo extends Gizmo {
  50799. /**
  50800. * Drag behavior responsible for the gizmos dragging interactions
  50801. */
  50802. dragBehavior: PointerDragBehavior;
  50803. private _pointerObserver;
  50804. /**
  50805. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  50806. */
  50807. snapDistance: number;
  50808. /**
  50809. * Event that fires each time the gizmo snaps to a new location.
  50810. * * snapDistance is the the change in distance
  50811. */
  50812. onSnapObservable: Observable<{
  50813. snapDistance: number;
  50814. }>;
  50815. /**
  50816. * If the scaling operation should be done on all axis (default: false)
  50817. */
  50818. uniformScaling: boolean;
  50819. /**
  50820. * Custom sensitivity value for the drag strength
  50821. */
  50822. sensitivity: number;
  50823. private _isEnabled;
  50824. private _parent;
  50825. private _arrow;
  50826. private _coloredMaterial;
  50827. private _hoverMaterial;
  50828. /**
  50829. * Creates an AxisScaleGizmo
  50830. * @param gizmoLayer The utility layer the gizmo will be added to
  50831. * @param dragAxis The axis which the gizmo will be able to scale on
  50832. * @param color The color of the gizmo
  50833. */
  50834. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  50835. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50836. /**
  50837. * If the gizmo is enabled
  50838. */
  50839. set isEnabled(value: boolean);
  50840. get isEnabled(): boolean;
  50841. /**
  50842. * Disposes of the gizmo
  50843. */
  50844. dispose(): void;
  50845. /**
  50846. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  50847. * @param mesh The mesh to replace the default mesh of the gizmo
  50848. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  50849. */
  50850. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  50851. }
  50852. }
  50853. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  50854. import { Observable } from "babylonjs/Misc/observable";
  50855. import { Nullable } from "babylonjs/types";
  50856. import { Vector3 } from "babylonjs/Maths/math.vector";
  50857. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50858. import { Mesh } from "babylonjs/Meshes/mesh";
  50859. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50860. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50861. import { Color3 } from "babylonjs/Maths/math.color";
  50862. import "babylonjs/Meshes/Builders/boxBuilder";
  50863. /**
  50864. * Bounding box gizmo
  50865. */
  50866. export class BoundingBoxGizmo extends Gizmo {
  50867. private _lineBoundingBox;
  50868. private _rotateSpheresParent;
  50869. private _scaleBoxesParent;
  50870. private _boundingDimensions;
  50871. private _renderObserver;
  50872. private _pointerObserver;
  50873. private _scaleDragSpeed;
  50874. private _tmpQuaternion;
  50875. private _tmpVector;
  50876. private _tmpRotationMatrix;
  50877. /**
  50878. * 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)
  50879. */
  50880. ignoreChildren: boolean;
  50881. /**
  50882. * 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)
  50883. */
  50884. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  50885. /**
  50886. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  50887. */
  50888. rotationSphereSize: number;
  50889. /**
  50890. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  50891. */
  50892. scaleBoxSize: number;
  50893. /**
  50894. * 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)
  50895. */
  50896. fixedDragMeshScreenSize: boolean;
  50897. /**
  50898. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  50899. */
  50900. fixedDragMeshScreenSizeDistanceFactor: number;
  50901. /**
  50902. * Fired when a rotation sphere or scale box is dragged
  50903. */
  50904. onDragStartObservable: Observable<{}>;
  50905. /**
  50906. * Fired when a scale box is dragged
  50907. */
  50908. onScaleBoxDragObservable: Observable<{}>;
  50909. /**
  50910. * Fired when a scale box drag is ended
  50911. */
  50912. onScaleBoxDragEndObservable: Observable<{}>;
  50913. /**
  50914. * Fired when a rotation sphere is dragged
  50915. */
  50916. onRotationSphereDragObservable: Observable<{}>;
  50917. /**
  50918. * Fired when a rotation sphere drag is ended
  50919. */
  50920. onRotationSphereDragEndObservable: Observable<{}>;
  50921. /**
  50922. * 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)
  50923. */
  50924. scalePivot: Nullable<Vector3>;
  50925. /**
  50926. * Mesh used as a pivot to rotate the attached mesh
  50927. */
  50928. private _anchorMesh;
  50929. private _existingMeshScale;
  50930. private _dragMesh;
  50931. private pointerDragBehavior;
  50932. private coloredMaterial;
  50933. private hoverColoredMaterial;
  50934. /**
  50935. * Sets the color of the bounding box gizmo
  50936. * @param color the color to set
  50937. */
  50938. setColor(color: Color3): void;
  50939. /**
  50940. * Creates an BoundingBoxGizmo
  50941. * @param gizmoLayer The utility layer the gizmo will be added to
  50942. * @param color The color of the gizmo
  50943. */
  50944. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  50945. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  50946. private _selectNode;
  50947. /**
  50948. * Updates the bounding box information for the Gizmo
  50949. */
  50950. updateBoundingBox(): void;
  50951. private _updateRotationSpheres;
  50952. private _updateScaleBoxes;
  50953. /**
  50954. * Enables rotation on the specified axis and disables rotation on the others
  50955. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  50956. */
  50957. setEnabledRotationAxis(axis: string): void;
  50958. /**
  50959. * Enables/disables scaling
  50960. * @param enable if scaling should be enabled
  50961. * @param homogeneousScaling defines if scaling should only be homogeneous
  50962. */
  50963. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  50964. private _updateDummy;
  50965. /**
  50966. * Enables a pointer drag behavior on the bounding box of the gizmo
  50967. */
  50968. enableDragBehavior(): void;
  50969. /**
  50970. * Disposes of the gizmo
  50971. */
  50972. dispose(): void;
  50973. /**
  50974. * 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)
  50975. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  50976. * @returns the bounding box mesh with the passed in mesh as a child
  50977. */
  50978. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  50979. /**
  50980. * CustomMeshes are not supported by this gizmo
  50981. * @param mesh The mesh to replace the default mesh of the gizmo
  50982. */
  50983. setCustomMesh(mesh: Mesh): void;
  50984. }
  50985. }
  50986. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  50987. import { Observable } from "babylonjs/Misc/observable";
  50988. import { Nullable } from "babylonjs/types";
  50989. import { Vector3 } from "babylonjs/Maths/math.vector";
  50990. import { Color3 } from "babylonjs/Maths/math.color";
  50991. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50992. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  50993. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  50994. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  50995. import "babylonjs/Meshes/Builders/linesBuilder";
  50996. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  50997. /**
  50998. * Single plane rotation gizmo
  50999. */
  51000. export class PlaneRotationGizmo extends Gizmo {
  51001. /**
  51002. * Drag behavior responsible for the gizmos dragging interactions
  51003. */
  51004. dragBehavior: PointerDragBehavior;
  51005. private _pointerObserver;
  51006. /**
  51007. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  51008. */
  51009. snapDistance: number;
  51010. /**
  51011. * Event that fires each time the gizmo snaps to a new location.
  51012. * * snapDistance is the the change in distance
  51013. */
  51014. onSnapObservable: Observable<{
  51015. snapDistance: number;
  51016. }>;
  51017. private _isEnabled;
  51018. private _parent;
  51019. /**
  51020. * Creates a PlaneRotationGizmo
  51021. * @param gizmoLayer The utility layer the gizmo will be added to
  51022. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  51023. * @param color The color of the gizmo
  51024. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51025. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51026. */
  51027. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  51028. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  51029. /**
  51030. * If the gizmo is enabled
  51031. */
  51032. set isEnabled(value: boolean);
  51033. get isEnabled(): boolean;
  51034. /**
  51035. * Disposes of the gizmo
  51036. */
  51037. dispose(): void;
  51038. }
  51039. }
  51040. declare module "babylonjs/Gizmos/rotationGizmo" {
  51041. import { Observable } from "babylonjs/Misc/observable";
  51042. import { Nullable } from "babylonjs/types";
  51043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51044. import { Mesh } from "babylonjs/Meshes/mesh";
  51045. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51046. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  51047. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51048. /**
  51049. * Gizmo that enables rotating a mesh along 3 axis
  51050. */
  51051. export class RotationGizmo extends Gizmo {
  51052. /**
  51053. * Internal gizmo used for interactions on the x axis
  51054. */
  51055. xGizmo: PlaneRotationGizmo;
  51056. /**
  51057. * Internal gizmo used for interactions on the y axis
  51058. */
  51059. yGizmo: PlaneRotationGizmo;
  51060. /**
  51061. * Internal gizmo used for interactions on the z axis
  51062. */
  51063. zGizmo: PlaneRotationGizmo;
  51064. /** Fires an event when any of it's sub gizmos are dragged */
  51065. onDragStartObservable: Observable<unknown>;
  51066. /** Fires an event when any of it's sub gizmos are released from dragging */
  51067. onDragEndObservable: Observable<unknown>;
  51068. private _meshAttached;
  51069. get attachedMesh(): Nullable<AbstractMesh>;
  51070. set attachedMesh(mesh: Nullable<AbstractMesh>);
  51071. /**
  51072. * Creates a RotationGizmo
  51073. * @param gizmoLayer The utility layer the gizmo will be added to
  51074. * @param tessellation Amount of tessellation to be used when creating rotation circles
  51075. * @param useEulerRotation Use and update Euler angle instead of quaternion
  51076. */
  51077. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  51078. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  51079. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  51080. /**
  51081. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  51082. */
  51083. set snapDistance(value: number);
  51084. get snapDistance(): number;
  51085. /**
  51086. * Ratio for the scale of the gizmo (Default: 1)
  51087. */
  51088. set scaleRatio(value: number);
  51089. get scaleRatio(): number;
  51090. /**
  51091. * Disposes of the gizmo
  51092. */
  51093. dispose(): void;
  51094. /**
  51095. * CustomMeshes are not supported by this gizmo
  51096. * @param mesh The mesh to replace the default mesh of the gizmo
  51097. */
  51098. setCustomMesh(mesh: Mesh): void;
  51099. }
  51100. }
  51101. declare module "babylonjs/Gizmos/gizmoManager" {
  51102. import { Observable } from "babylonjs/Misc/observable";
  51103. import { Nullable } from "babylonjs/types";
  51104. import { Scene, IDisposable } from "babylonjs/scene";
  51105. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51106. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51107. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  51108. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  51109. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  51110. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  51111. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  51112. /**
  51113. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  51114. */
  51115. export class GizmoManager implements IDisposable {
  51116. private scene;
  51117. /**
  51118. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  51119. */
  51120. gizmos: {
  51121. positionGizmo: Nullable<PositionGizmo>;
  51122. rotationGizmo: Nullable<RotationGizmo>;
  51123. scaleGizmo: Nullable<ScaleGizmo>;
  51124. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  51125. };
  51126. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  51127. clearGizmoOnEmptyPointerEvent: boolean;
  51128. /** Fires an event when the manager is attached to a mesh */
  51129. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  51130. private _gizmosEnabled;
  51131. private _pointerObserver;
  51132. private _attachedMesh;
  51133. private _boundingBoxColor;
  51134. private _defaultUtilityLayer;
  51135. private _defaultKeepDepthUtilityLayer;
  51136. /**
  51137. * When bounding box gizmo is enabled, this can be used to track drag/end events
  51138. */
  51139. boundingBoxDragBehavior: SixDofDragBehavior;
  51140. /**
  51141. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  51142. */
  51143. attachableMeshes: Nullable<Array<AbstractMesh>>;
  51144. /**
  51145. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  51146. */
  51147. usePointerToAttachGizmos: boolean;
  51148. /**
  51149. * Utility layer that the bounding box gizmo belongs to
  51150. */
  51151. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  51152. /**
  51153. * Utility layer that all gizmos besides bounding box belong to
  51154. */
  51155. get utilityLayer(): UtilityLayerRenderer;
  51156. /**
  51157. * Instatiates a gizmo manager
  51158. * @param scene the scene to overlay the gizmos on top of
  51159. */
  51160. constructor(scene: Scene);
  51161. /**
  51162. * Attaches a set of gizmos to the specified mesh
  51163. * @param mesh The mesh the gizmo's should be attached to
  51164. */
  51165. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  51166. /**
  51167. * If the position gizmo is enabled
  51168. */
  51169. set positionGizmoEnabled(value: boolean);
  51170. get positionGizmoEnabled(): boolean;
  51171. /**
  51172. * If the rotation gizmo is enabled
  51173. */
  51174. set rotationGizmoEnabled(value: boolean);
  51175. get rotationGizmoEnabled(): boolean;
  51176. /**
  51177. * If the scale gizmo is enabled
  51178. */
  51179. set scaleGizmoEnabled(value: boolean);
  51180. get scaleGizmoEnabled(): boolean;
  51181. /**
  51182. * If the boundingBox gizmo is enabled
  51183. */
  51184. set boundingBoxGizmoEnabled(value: boolean);
  51185. get boundingBoxGizmoEnabled(): boolean;
  51186. /**
  51187. * Disposes of the gizmo manager
  51188. */
  51189. dispose(): void;
  51190. }
  51191. }
  51192. declare module "babylonjs/Lights/directionalLight" {
  51193. import { Camera } from "babylonjs/Cameras/camera";
  51194. import { Scene } from "babylonjs/scene";
  51195. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51196. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51197. import { Light } from "babylonjs/Lights/light";
  51198. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51199. import { Effect } from "babylonjs/Materials/effect";
  51200. /**
  51201. * A directional light is defined by a direction (what a surprise!).
  51202. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  51203. * 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.
  51204. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51205. */
  51206. export class DirectionalLight extends ShadowLight {
  51207. private _shadowFrustumSize;
  51208. /**
  51209. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  51210. */
  51211. get shadowFrustumSize(): number;
  51212. /**
  51213. * Specifies a fix frustum size for the shadow generation.
  51214. */
  51215. set shadowFrustumSize(value: number);
  51216. private _shadowOrthoScale;
  51217. /**
  51218. * Gets the shadow projection scale against the optimal computed one.
  51219. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51220. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51221. */
  51222. get shadowOrthoScale(): number;
  51223. /**
  51224. * Sets the shadow projection scale against the optimal computed one.
  51225. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  51226. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  51227. */
  51228. set shadowOrthoScale(value: number);
  51229. /**
  51230. * Automatically compute the projection matrix to best fit (including all the casters)
  51231. * on each frame.
  51232. */
  51233. autoUpdateExtends: boolean;
  51234. /**
  51235. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  51236. * on each frame. autoUpdateExtends must be set to true for this to work
  51237. */
  51238. autoCalcShadowZBounds: boolean;
  51239. private _orthoLeft;
  51240. private _orthoRight;
  51241. private _orthoTop;
  51242. private _orthoBottom;
  51243. /**
  51244. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  51245. * The directional light is emitted from everywhere in the given direction.
  51246. * It can cast shadows.
  51247. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51248. * @param name The friendly name of the light
  51249. * @param direction The direction of the light
  51250. * @param scene The scene the light belongs to
  51251. */
  51252. constructor(name: string, direction: Vector3, scene: Scene);
  51253. /**
  51254. * Returns the string "DirectionalLight".
  51255. * @return The class name
  51256. */
  51257. getClassName(): string;
  51258. /**
  51259. * Returns the integer 1.
  51260. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51261. */
  51262. getTypeID(): number;
  51263. /**
  51264. * Sets the passed matrix "matrix" as 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 _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51268. /**
  51269. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  51270. * Returns the DirectionalLight Shadow projection matrix.
  51271. */
  51272. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  51273. /**
  51274. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  51275. * Returns the DirectionalLight Shadow projection matrix.
  51276. */
  51277. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51278. protected _buildUniformLayout(): void;
  51279. /**
  51280. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  51281. * @param effect The effect to update
  51282. * @param lightIndex The index of the light in the effect to update
  51283. * @returns The directional light
  51284. */
  51285. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  51286. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  51287. /**
  51288. * Gets the minZ used for shadow according to both the scene and the light.
  51289. *
  51290. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51291. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51292. * @param activeCamera The camera we are returning the min for
  51293. * @returns the depth min z
  51294. */
  51295. getDepthMinZ(activeCamera: Camera): number;
  51296. /**
  51297. * Gets the maxZ used for shadow according to both the scene and the light.
  51298. *
  51299. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  51300. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  51301. * @param activeCamera The camera we are returning the max for
  51302. * @returns the depth max z
  51303. */
  51304. getDepthMaxZ(activeCamera: Camera): number;
  51305. /**
  51306. * Prepares the list of defines specific to the light type.
  51307. * @param defines the list of defines
  51308. * @param lightIndex defines the index of the light for the effect
  51309. */
  51310. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51311. }
  51312. }
  51313. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  51314. import { Mesh } from "babylonjs/Meshes/mesh";
  51315. /**
  51316. * Class containing static functions to help procedurally build meshes
  51317. */
  51318. export class HemisphereBuilder {
  51319. /**
  51320. * Creates a hemisphere mesh
  51321. * @param name defines the name of the mesh
  51322. * @param options defines the options used to create the mesh
  51323. * @param scene defines the hosting scene
  51324. * @returns the hemisphere mesh
  51325. */
  51326. static CreateHemisphere(name: string, options: {
  51327. segments?: number;
  51328. diameter?: number;
  51329. sideOrientation?: number;
  51330. }, scene: any): Mesh;
  51331. }
  51332. }
  51333. declare module "babylonjs/Lights/spotLight" {
  51334. import { Nullable } from "babylonjs/types";
  51335. import { Scene } from "babylonjs/scene";
  51336. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51337. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51338. import { Effect } from "babylonjs/Materials/effect";
  51339. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51340. import { Light } from "babylonjs/Lights/light";
  51341. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  51342. /**
  51343. * A spot light is defined by a position, a direction, an angle, and an exponent.
  51344. * These values define a cone of light starting from the position, emitting toward the direction.
  51345. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  51346. * and the exponent defines the speed of the decay of the light with distance (reach).
  51347. * Documentation: https://doc.babylonjs.com/babylon101/lights
  51348. */
  51349. export class SpotLight extends ShadowLight {
  51350. private _angle;
  51351. private _innerAngle;
  51352. private _cosHalfAngle;
  51353. private _lightAngleScale;
  51354. private _lightAngleOffset;
  51355. /**
  51356. * Gets the cone angle of the spot light in Radians.
  51357. */
  51358. get angle(): number;
  51359. /**
  51360. * Sets the cone angle of the spot light in Radians.
  51361. */
  51362. set angle(value: number);
  51363. /**
  51364. * Only used in gltf falloff mode, this defines the angle where
  51365. * the directional falloff will start before cutting at angle which could be seen
  51366. * as outer angle.
  51367. */
  51368. get innerAngle(): number;
  51369. /**
  51370. * Only used in gltf falloff mode, this defines the angle where
  51371. * the directional falloff will start before cutting at angle which could be seen
  51372. * as outer angle.
  51373. */
  51374. set innerAngle(value: number);
  51375. private _shadowAngleScale;
  51376. /**
  51377. * Allows scaling the angle of the light for shadow generation only.
  51378. */
  51379. get shadowAngleScale(): number;
  51380. /**
  51381. * Allows scaling the angle of the light for shadow generation only.
  51382. */
  51383. set shadowAngleScale(value: number);
  51384. /**
  51385. * The light decay speed with the distance from the emission spot.
  51386. */
  51387. exponent: number;
  51388. private _projectionTextureMatrix;
  51389. /**
  51390. * Allows reading the projecton texture
  51391. */
  51392. get projectionTextureMatrix(): Matrix;
  51393. protected _projectionTextureLightNear: number;
  51394. /**
  51395. * Gets the near clip of the Spotlight for texture projection.
  51396. */
  51397. get projectionTextureLightNear(): number;
  51398. /**
  51399. * Sets the near clip of the Spotlight for texture projection.
  51400. */
  51401. set projectionTextureLightNear(value: number);
  51402. protected _projectionTextureLightFar: number;
  51403. /**
  51404. * Gets the far clip of the Spotlight for texture projection.
  51405. */
  51406. get projectionTextureLightFar(): number;
  51407. /**
  51408. * Sets the far clip of the Spotlight for texture projection.
  51409. */
  51410. set projectionTextureLightFar(value: number);
  51411. protected _projectionTextureUpDirection: Vector3;
  51412. /**
  51413. * Gets the Up vector of the Spotlight for texture projection.
  51414. */
  51415. get projectionTextureUpDirection(): Vector3;
  51416. /**
  51417. * Sets the Up vector of the Spotlight for texture projection.
  51418. */
  51419. set projectionTextureUpDirection(value: Vector3);
  51420. private _projectionTexture;
  51421. /**
  51422. * Gets the projection texture of the light.
  51423. */
  51424. get projectionTexture(): Nullable<BaseTexture>;
  51425. /**
  51426. * Sets the projection texture of the light.
  51427. */
  51428. set projectionTexture(value: Nullable<BaseTexture>);
  51429. private _projectionTextureViewLightDirty;
  51430. private _projectionTextureProjectionLightDirty;
  51431. private _projectionTextureDirty;
  51432. private _projectionTextureViewTargetVector;
  51433. private _projectionTextureViewLightMatrix;
  51434. private _projectionTextureProjectionLightMatrix;
  51435. private _projectionTextureScalingMatrix;
  51436. /**
  51437. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  51438. * It can cast shadows.
  51439. * Documentation : https://doc.babylonjs.com/babylon101/lights
  51440. * @param name The light friendly name
  51441. * @param position The position of the spot light in the scene
  51442. * @param direction The direction of the light in the scene
  51443. * @param angle The cone angle of the light in Radians
  51444. * @param exponent The light decay speed with the distance from the emission spot
  51445. * @param scene The scene the lights belongs to
  51446. */
  51447. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  51448. /**
  51449. * Returns the string "SpotLight".
  51450. * @returns the class name
  51451. */
  51452. getClassName(): string;
  51453. /**
  51454. * Returns the integer 2.
  51455. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  51456. */
  51457. getTypeID(): number;
  51458. /**
  51459. * Overrides the direction setter to recompute the projection texture view light Matrix.
  51460. */
  51461. protected _setDirection(value: Vector3): void;
  51462. /**
  51463. * Overrides the position setter to recompute the projection texture view light Matrix.
  51464. */
  51465. protected _setPosition(value: Vector3): void;
  51466. /**
  51467. * 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.
  51468. * Returns the SpotLight.
  51469. */
  51470. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  51471. protected _computeProjectionTextureViewLightMatrix(): void;
  51472. protected _computeProjectionTextureProjectionLightMatrix(): void;
  51473. /**
  51474. * Main function for light texture projection matrix computing.
  51475. */
  51476. protected _computeProjectionTextureMatrix(): void;
  51477. protected _buildUniformLayout(): void;
  51478. private _computeAngleValues;
  51479. /**
  51480. * Sets the passed Effect "effect" with the Light textures.
  51481. * @param effect The effect to update
  51482. * @param lightIndex The index of the light in the effect to update
  51483. * @returns The light
  51484. */
  51485. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  51486. /**
  51487. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  51488. * @param effect The effect to update
  51489. * @param lightIndex The index of the light in the effect to update
  51490. * @returns The spot light
  51491. */
  51492. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  51493. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  51494. /**
  51495. * Disposes the light and the associated resources.
  51496. */
  51497. dispose(): void;
  51498. /**
  51499. * Prepares the list of defines specific to the light type.
  51500. * @param defines the list of defines
  51501. * @param lightIndex defines the index of the light for the effect
  51502. */
  51503. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  51504. }
  51505. }
  51506. declare module "babylonjs/Gizmos/lightGizmo" {
  51507. import { Nullable } from "babylonjs/types";
  51508. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  51509. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  51510. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  51511. import { Light } from "babylonjs/Lights/light";
  51512. /**
  51513. * Gizmo that enables viewing a light
  51514. */
  51515. export class LightGizmo extends Gizmo {
  51516. private _lightMesh;
  51517. private _material;
  51518. private _cachedPosition;
  51519. private _cachedForward;
  51520. private _attachedMeshParent;
  51521. /**
  51522. * Creates a LightGizmo
  51523. * @param gizmoLayer The utility layer the gizmo will be added to
  51524. */
  51525. constructor(gizmoLayer?: UtilityLayerRenderer);
  51526. private _light;
  51527. /**
  51528. * The light that the gizmo is attached to
  51529. */
  51530. set light(light: Nullable<Light>);
  51531. get light(): Nullable<Light>;
  51532. /**
  51533. * Gets the material used to render the light gizmo
  51534. */
  51535. get material(): StandardMaterial;
  51536. /**
  51537. * @hidden
  51538. * Updates the gizmo to match the attached mesh's position/rotation
  51539. */
  51540. protected _update(): void;
  51541. private static _Scale;
  51542. /**
  51543. * Creates the lines for a light mesh
  51544. */
  51545. private static _CreateLightLines;
  51546. /**
  51547. * Disposes of the light gizmo
  51548. */
  51549. dispose(): void;
  51550. private static _CreateHemisphericLightMesh;
  51551. private static _CreatePointLightMesh;
  51552. private static _CreateSpotLightMesh;
  51553. private static _CreateDirectionalLightMesh;
  51554. }
  51555. }
  51556. declare module "babylonjs/Gizmos/index" {
  51557. export * from "babylonjs/Gizmos/axisDragGizmo";
  51558. export * from "babylonjs/Gizmos/axisScaleGizmo";
  51559. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  51560. export * from "babylonjs/Gizmos/gizmo";
  51561. export * from "babylonjs/Gizmos/gizmoManager";
  51562. export * from "babylonjs/Gizmos/planeRotationGizmo";
  51563. export * from "babylonjs/Gizmos/positionGizmo";
  51564. export * from "babylonjs/Gizmos/rotationGizmo";
  51565. export * from "babylonjs/Gizmos/scaleGizmo";
  51566. export * from "babylonjs/Gizmos/lightGizmo";
  51567. export * from "babylonjs/Gizmos/planeDragGizmo";
  51568. }
  51569. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  51570. /** @hidden */
  51571. export var backgroundFragmentDeclaration: {
  51572. name: string;
  51573. shader: string;
  51574. };
  51575. }
  51576. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  51577. /** @hidden */
  51578. export var backgroundUboDeclaration: {
  51579. name: string;
  51580. shader: string;
  51581. };
  51582. }
  51583. declare module "babylonjs/Shaders/background.fragment" {
  51584. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  51585. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51586. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  51587. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  51588. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51589. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51590. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51591. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  51592. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  51593. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  51594. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  51595. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  51596. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  51597. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  51598. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  51599. /** @hidden */
  51600. export var backgroundPixelShader: {
  51601. name: string;
  51602. shader: string;
  51603. };
  51604. }
  51605. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  51606. /** @hidden */
  51607. export var backgroundVertexDeclaration: {
  51608. name: string;
  51609. shader: string;
  51610. };
  51611. }
  51612. declare module "babylonjs/Shaders/background.vertex" {
  51613. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  51614. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  51615. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  51616. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  51617. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  51618. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  51619. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  51620. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  51621. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  51622. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  51623. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  51624. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  51625. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  51626. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  51627. /** @hidden */
  51628. export var backgroundVertexShader: {
  51629. name: string;
  51630. shader: string;
  51631. };
  51632. }
  51633. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  51634. import { Nullable, int, float } from "babylonjs/types";
  51635. import { Scene } from "babylonjs/scene";
  51636. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  51637. import { SubMesh } from "babylonjs/Meshes/subMesh";
  51638. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51639. import { Mesh } from "babylonjs/Meshes/mesh";
  51640. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  51641. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  51642. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  51643. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51644. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  51645. import { Color3 } from "babylonjs/Maths/math.color";
  51646. import "babylonjs/Shaders/background.fragment";
  51647. import "babylonjs/Shaders/background.vertex";
  51648. /**
  51649. * Background material used to create an efficient environement around your scene.
  51650. */
  51651. export class BackgroundMaterial extends PushMaterial {
  51652. /**
  51653. * Standard reflectance value at parallel view angle.
  51654. */
  51655. static StandardReflectance0: number;
  51656. /**
  51657. * Standard reflectance value at grazing angle.
  51658. */
  51659. static StandardReflectance90: number;
  51660. protected _primaryColor: Color3;
  51661. /**
  51662. * Key light Color (multiply against the environement texture)
  51663. */
  51664. primaryColor: Color3;
  51665. protected __perceptualColor: Nullable<Color3>;
  51666. /**
  51667. * Experimental Internal Use Only.
  51668. *
  51669. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  51670. * This acts as a helper to set the primary color to a more "human friendly" value.
  51671. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  51672. * output color as close as possible from the chosen value.
  51673. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  51674. * part of lighting setup.)
  51675. */
  51676. get _perceptualColor(): Nullable<Color3>;
  51677. set _perceptualColor(value: Nullable<Color3>);
  51678. protected _primaryColorShadowLevel: float;
  51679. /**
  51680. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  51681. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  51682. */
  51683. get primaryColorShadowLevel(): float;
  51684. set primaryColorShadowLevel(value: float);
  51685. protected _primaryColorHighlightLevel: float;
  51686. /**
  51687. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  51688. * The primary color is used at the level chosen to define what the white area would look.
  51689. */
  51690. get primaryColorHighlightLevel(): float;
  51691. set primaryColorHighlightLevel(value: float);
  51692. protected _reflectionTexture: Nullable<BaseTexture>;
  51693. /**
  51694. * Reflection Texture used in the material.
  51695. * Should be author in a specific way for the best result (refer to the documentation).
  51696. */
  51697. reflectionTexture: Nullable<BaseTexture>;
  51698. protected _reflectionBlur: float;
  51699. /**
  51700. * Reflection Texture level of blur.
  51701. *
  51702. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  51703. * texture twice.
  51704. */
  51705. reflectionBlur: float;
  51706. protected _diffuseTexture: Nullable<BaseTexture>;
  51707. /**
  51708. * Diffuse Texture used in the material.
  51709. * Should be author in a specific way for the best result (refer to the documentation).
  51710. */
  51711. diffuseTexture: Nullable<BaseTexture>;
  51712. protected _shadowLights: Nullable<IShadowLight[]>;
  51713. /**
  51714. * Specify the list of lights casting shadow on the material.
  51715. * All scene shadow lights will be included if null.
  51716. */
  51717. shadowLights: Nullable<IShadowLight[]>;
  51718. protected _shadowLevel: float;
  51719. /**
  51720. * Helps adjusting the shadow to a softer level if required.
  51721. * 0 means black shadows and 1 means no shadows.
  51722. */
  51723. shadowLevel: float;
  51724. protected _sceneCenter: Vector3;
  51725. /**
  51726. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  51727. * It is usually zero but might be interesting to modify according to your setup.
  51728. */
  51729. sceneCenter: Vector3;
  51730. protected _opacityFresnel: boolean;
  51731. /**
  51732. * This helps specifying that the material is falling off to the sky box at grazing angle.
  51733. * This helps ensuring a nice transition when the camera goes under the ground.
  51734. */
  51735. opacityFresnel: boolean;
  51736. protected _reflectionFresnel: boolean;
  51737. /**
  51738. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  51739. * This helps adding a mirror texture on the ground.
  51740. */
  51741. reflectionFresnel: boolean;
  51742. protected _reflectionFalloffDistance: number;
  51743. /**
  51744. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  51745. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  51746. */
  51747. reflectionFalloffDistance: number;
  51748. protected _reflectionAmount: number;
  51749. /**
  51750. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  51751. */
  51752. reflectionAmount: number;
  51753. protected _reflectionReflectance0: number;
  51754. /**
  51755. * This specifies the weight of the reflection at grazing angle.
  51756. */
  51757. reflectionReflectance0: number;
  51758. protected _reflectionReflectance90: number;
  51759. /**
  51760. * This specifies the weight of the reflection at a perpendicular point of view.
  51761. */
  51762. reflectionReflectance90: number;
  51763. /**
  51764. * Sets the reflection reflectance fresnel values according to the default standard
  51765. * empirically know to work well :-)
  51766. */
  51767. set reflectionStandardFresnelWeight(value: number);
  51768. protected _useRGBColor: boolean;
  51769. /**
  51770. * Helps to directly use the maps channels instead of their level.
  51771. */
  51772. useRGBColor: boolean;
  51773. protected _enableNoise: boolean;
  51774. /**
  51775. * This helps reducing the banding effect that could occur on the background.
  51776. */
  51777. enableNoise: boolean;
  51778. /**
  51779. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  51780. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  51781. * Recommended to be keep at 1.0 except for special cases.
  51782. */
  51783. get fovMultiplier(): number;
  51784. set fovMultiplier(value: number);
  51785. private _fovMultiplier;
  51786. /**
  51787. * Enable the FOV adjustment feature controlled by fovMultiplier.
  51788. */
  51789. useEquirectangularFOV: boolean;
  51790. private _maxSimultaneousLights;
  51791. /**
  51792. * Number of Simultaneous lights allowed on the material.
  51793. */
  51794. maxSimultaneousLights: int;
  51795. /**
  51796. * Default configuration related to image processing available in the Background Material.
  51797. */
  51798. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  51799. /**
  51800. * Keep track of the image processing observer to allow dispose and replace.
  51801. */
  51802. private _imageProcessingObserver;
  51803. /**
  51804. * Attaches a new image processing configuration to the PBR Material.
  51805. * @param configuration (if null the scene configuration will be use)
  51806. */
  51807. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  51808. /**
  51809. * Gets the image processing configuration used either in this material.
  51810. */
  51811. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  51812. /**
  51813. * Sets the Default image processing configuration used either in the this material.
  51814. *
  51815. * If sets to null, the scene one is in use.
  51816. */
  51817. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  51818. /**
  51819. * Gets wether the color curves effect is enabled.
  51820. */
  51821. get cameraColorCurvesEnabled(): boolean;
  51822. /**
  51823. * Sets wether the color curves effect is enabled.
  51824. */
  51825. set cameraColorCurvesEnabled(value: boolean);
  51826. /**
  51827. * Gets wether the color grading effect is enabled.
  51828. */
  51829. get cameraColorGradingEnabled(): boolean;
  51830. /**
  51831. * Gets wether the color grading effect is enabled.
  51832. */
  51833. set cameraColorGradingEnabled(value: boolean);
  51834. /**
  51835. * Gets wether tonemapping is enabled or not.
  51836. */
  51837. get cameraToneMappingEnabled(): boolean;
  51838. /**
  51839. * Sets wether tonemapping is enabled or not
  51840. */
  51841. set cameraToneMappingEnabled(value: boolean);
  51842. /**
  51843. * The camera exposure used on this material.
  51844. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51845. * This corresponds to a photographic exposure.
  51846. */
  51847. get cameraExposure(): float;
  51848. /**
  51849. * The camera exposure used on this material.
  51850. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  51851. * This corresponds to a photographic exposure.
  51852. */
  51853. set cameraExposure(value: float);
  51854. /**
  51855. * Gets The camera contrast used on this material.
  51856. */
  51857. get cameraContrast(): float;
  51858. /**
  51859. * Sets The camera contrast used on this material.
  51860. */
  51861. set cameraContrast(value: float);
  51862. /**
  51863. * Gets the Color Grading 2D Lookup Texture.
  51864. */
  51865. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  51866. /**
  51867. * Sets the Color Grading 2D Lookup Texture.
  51868. */
  51869. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  51870. /**
  51871. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51872. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51873. * 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;
  51874. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51875. */
  51876. get cameraColorCurves(): Nullable<ColorCurves>;
  51877. /**
  51878. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  51879. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  51880. * 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;
  51881. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  51882. */
  51883. set cameraColorCurves(value: Nullable<ColorCurves>);
  51884. /**
  51885. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  51886. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  51887. */
  51888. switchToBGR: boolean;
  51889. private _renderTargets;
  51890. private _reflectionControls;
  51891. private _white;
  51892. private _primaryShadowColor;
  51893. private _primaryHighlightColor;
  51894. /**
  51895. * Instantiates a Background Material in the given scene
  51896. * @param name The friendly name of the material
  51897. * @param scene The scene to add the material to
  51898. */
  51899. constructor(name: string, scene: Scene);
  51900. /**
  51901. * Gets a boolean indicating that current material needs to register RTT
  51902. */
  51903. get hasRenderTargetTextures(): boolean;
  51904. /**
  51905. * The entire material has been created in order to prevent overdraw.
  51906. * @returns false
  51907. */
  51908. needAlphaTesting(): boolean;
  51909. /**
  51910. * The entire material has been created in order to prevent overdraw.
  51911. * @returns true if blending is enable
  51912. */
  51913. needAlphaBlending(): boolean;
  51914. /**
  51915. * Checks wether the material is ready to be rendered for a given mesh.
  51916. * @param mesh The mesh to render
  51917. * @param subMesh The submesh to check against
  51918. * @param useInstances Specify wether or not the material is used with instances
  51919. * @returns true if all the dependencies are ready (Textures, Effects...)
  51920. */
  51921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  51922. /**
  51923. * Compute the primary color according to the chosen perceptual color.
  51924. */
  51925. private _computePrimaryColorFromPerceptualColor;
  51926. /**
  51927. * Compute the highlights and shadow colors according to their chosen levels.
  51928. */
  51929. private _computePrimaryColors;
  51930. /**
  51931. * Build the uniform buffer used in the material.
  51932. */
  51933. buildUniformLayout(): void;
  51934. /**
  51935. * Unbind the material.
  51936. */
  51937. unbind(): void;
  51938. /**
  51939. * Bind only the world matrix to the material.
  51940. * @param world The world matrix to bind.
  51941. */
  51942. bindOnlyWorldMatrix(world: Matrix): void;
  51943. /**
  51944. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  51945. * @param world The world matrix to bind.
  51946. * @param subMesh The submesh to bind for.
  51947. */
  51948. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  51949. /**
  51950. * Checks to see if a texture is used in the material.
  51951. * @param texture - Base texture to use.
  51952. * @returns - Boolean specifying if a texture is used in the material.
  51953. */
  51954. hasTexture(texture: BaseTexture): boolean;
  51955. /**
  51956. * Dispose the material.
  51957. * @param forceDisposeEffect Force disposal of the associated effect.
  51958. * @param forceDisposeTextures Force disposal of the associated textures.
  51959. */
  51960. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  51961. /**
  51962. * Clones the material.
  51963. * @param name The cloned name.
  51964. * @returns The cloned material.
  51965. */
  51966. clone(name: string): BackgroundMaterial;
  51967. /**
  51968. * Serializes the current material to its JSON representation.
  51969. * @returns The JSON representation.
  51970. */
  51971. serialize(): any;
  51972. /**
  51973. * Gets the class name of the material
  51974. * @returns "BackgroundMaterial"
  51975. */
  51976. getClassName(): string;
  51977. /**
  51978. * Parse a JSON input to create back a background material.
  51979. * @param source The JSON data to parse
  51980. * @param scene The scene to create the parsed material in
  51981. * @param rootUrl The root url of the assets the material depends upon
  51982. * @returns the instantiated BackgroundMaterial.
  51983. */
  51984. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  51985. }
  51986. }
  51987. declare module "babylonjs/Helpers/environmentHelper" {
  51988. import { Observable } from "babylonjs/Misc/observable";
  51989. import { Nullable } from "babylonjs/types";
  51990. import { Scene } from "babylonjs/scene";
  51991. import { Vector3 } from "babylonjs/Maths/math.vector";
  51992. import { Color3 } from "babylonjs/Maths/math.color";
  51993. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51994. import { Mesh } from "babylonjs/Meshes/mesh";
  51995. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51996. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  51997. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  51998. import "babylonjs/Meshes/Builders/planeBuilder";
  51999. import "babylonjs/Meshes/Builders/boxBuilder";
  52000. /**
  52001. * Represents the different options available during the creation of
  52002. * a Environment helper.
  52003. *
  52004. * This can control the default ground, skybox and image processing setup of your scene.
  52005. */
  52006. export interface IEnvironmentHelperOptions {
  52007. /**
  52008. * Specifies whether or not to create a ground.
  52009. * True by default.
  52010. */
  52011. createGround: boolean;
  52012. /**
  52013. * Specifies the ground size.
  52014. * 15 by default.
  52015. */
  52016. groundSize: number;
  52017. /**
  52018. * The texture used on the ground for the main color.
  52019. * Comes from the BabylonJS CDN by default.
  52020. *
  52021. * Remarks: Can be either a texture or a url.
  52022. */
  52023. groundTexture: string | BaseTexture;
  52024. /**
  52025. * The color mixed in the ground texture by default.
  52026. * BabylonJS clearColor by default.
  52027. */
  52028. groundColor: Color3;
  52029. /**
  52030. * Specifies the ground opacity.
  52031. * 1 by default.
  52032. */
  52033. groundOpacity: number;
  52034. /**
  52035. * Enables the ground to receive shadows.
  52036. * True by default.
  52037. */
  52038. enableGroundShadow: boolean;
  52039. /**
  52040. * Helps preventing the shadow to be fully black on the ground.
  52041. * 0.5 by default.
  52042. */
  52043. groundShadowLevel: number;
  52044. /**
  52045. * Creates a mirror texture attach to the ground.
  52046. * false by default.
  52047. */
  52048. enableGroundMirror: boolean;
  52049. /**
  52050. * Specifies the ground mirror size ratio.
  52051. * 0.3 by default as the default kernel is 64.
  52052. */
  52053. groundMirrorSizeRatio: number;
  52054. /**
  52055. * Specifies the ground mirror blur kernel size.
  52056. * 64 by default.
  52057. */
  52058. groundMirrorBlurKernel: number;
  52059. /**
  52060. * Specifies the ground mirror visibility amount.
  52061. * 1 by default
  52062. */
  52063. groundMirrorAmount: number;
  52064. /**
  52065. * Specifies the ground mirror reflectance weight.
  52066. * This uses the standard weight of the background material to setup the fresnel effect
  52067. * of the mirror.
  52068. * 1 by default.
  52069. */
  52070. groundMirrorFresnelWeight: number;
  52071. /**
  52072. * Specifies the ground mirror Falloff distance.
  52073. * This can helps reducing the size of the reflection.
  52074. * 0 by Default.
  52075. */
  52076. groundMirrorFallOffDistance: number;
  52077. /**
  52078. * Specifies the ground mirror texture type.
  52079. * Unsigned Int by Default.
  52080. */
  52081. groundMirrorTextureType: number;
  52082. /**
  52083. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  52084. * the shown objects.
  52085. */
  52086. groundYBias: number;
  52087. /**
  52088. * Specifies whether or not to create a skybox.
  52089. * True by default.
  52090. */
  52091. createSkybox: boolean;
  52092. /**
  52093. * Specifies the skybox size.
  52094. * 20 by default.
  52095. */
  52096. skyboxSize: number;
  52097. /**
  52098. * The texture used on the skybox for the main color.
  52099. * Comes from the BabylonJS CDN by default.
  52100. *
  52101. * Remarks: Can be either a texture or a url.
  52102. */
  52103. skyboxTexture: string | BaseTexture;
  52104. /**
  52105. * The color mixed in the skybox texture by default.
  52106. * BabylonJS clearColor by default.
  52107. */
  52108. skyboxColor: Color3;
  52109. /**
  52110. * The background rotation around the Y axis of the scene.
  52111. * This helps aligning the key lights of your scene with the background.
  52112. * 0 by default.
  52113. */
  52114. backgroundYRotation: number;
  52115. /**
  52116. * Compute automatically the size of the elements to best fit with the scene.
  52117. */
  52118. sizeAuto: boolean;
  52119. /**
  52120. * Default position of the rootMesh if autoSize is not true.
  52121. */
  52122. rootPosition: Vector3;
  52123. /**
  52124. * Sets up the image processing in the scene.
  52125. * true by default.
  52126. */
  52127. setupImageProcessing: boolean;
  52128. /**
  52129. * The texture used as your environment texture in the scene.
  52130. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  52131. *
  52132. * Remarks: Can be either a texture or a url.
  52133. */
  52134. environmentTexture: string | BaseTexture;
  52135. /**
  52136. * The value of the exposure to apply to the scene.
  52137. * 0.6 by default if setupImageProcessing is true.
  52138. */
  52139. cameraExposure: number;
  52140. /**
  52141. * The value of the contrast to apply to the scene.
  52142. * 1.6 by default if setupImageProcessing is true.
  52143. */
  52144. cameraContrast: number;
  52145. /**
  52146. * Specifies whether or not tonemapping should be enabled in the scene.
  52147. * true by default if setupImageProcessing is true.
  52148. */
  52149. toneMappingEnabled: boolean;
  52150. }
  52151. /**
  52152. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  52153. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  52154. * It also helps with the default setup of your imageProcessing configuration.
  52155. */
  52156. export class EnvironmentHelper {
  52157. /**
  52158. * Default ground texture URL.
  52159. */
  52160. private static _groundTextureCDNUrl;
  52161. /**
  52162. * Default skybox texture URL.
  52163. */
  52164. private static _skyboxTextureCDNUrl;
  52165. /**
  52166. * Default environment texture URL.
  52167. */
  52168. private static _environmentTextureCDNUrl;
  52169. /**
  52170. * Creates the default options for the helper.
  52171. */
  52172. private static _getDefaultOptions;
  52173. private _rootMesh;
  52174. /**
  52175. * Gets the root mesh created by the helper.
  52176. */
  52177. get rootMesh(): Mesh;
  52178. private _skybox;
  52179. /**
  52180. * Gets the skybox created by the helper.
  52181. */
  52182. get skybox(): Nullable<Mesh>;
  52183. private _skyboxTexture;
  52184. /**
  52185. * Gets the skybox texture created by the helper.
  52186. */
  52187. get skyboxTexture(): Nullable<BaseTexture>;
  52188. private _skyboxMaterial;
  52189. /**
  52190. * Gets the skybox material created by the helper.
  52191. */
  52192. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  52193. private _ground;
  52194. /**
  52195. * Gets the ground mesh created by the helper.
  52196. */
  52197. get ground(): Nullable<Mesh>;
  52198. private _groundTexture;
  52199. /**
  52200. * Gets the ground texture created by the helper.
  52201. */
  52202. get groundTexture(): Nullable<BaseTexture>;
  52203. private _groundMirror;
  52204. /**
  52205. * Gets the ground mirror created by the helper.
  52206. */
  52207. get groundMirror(): Nullable<MirrorTexture>;
  52208. /**
  52209. * Gets the ground mirror render list to helps pushing the meshes
  52210. * you wish in the ground reflection.
  52211. */
  52212. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  52213. private _groundMaterial;
  52214. /**
  52215. * Gets the ground material created by the helper.
  52216. */
  52217. get groundMaterial(): Nullable<BackgroundMaterial>;
  52218. /**
  52219. * Stores the creation options.
  52220. */
  52221. private readonly _scene;
  52222. private _options;
  52223. /**
  52224. * This observable will be notified with any error during the creation of the environment,
  52225. * mainly texture creation errors.
  52226. */
  52227. onErrorObservable: Observable<{
  52228. message?: string;
  52229. exception?: any;
  52230. }>;
  52231. /**
  52232. * constructor
  52233. * @param options Defines the options we want to customize the helper
  52234. * @param scene The scene to add the material to
  52235. */
  52236. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  52237. /**
  52238. * Updates the background according to the new options
  52239. * @param options
  52240. */
  52241. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  52242. /**
  52243. * Sets the primary color of all the available elements.
  52244. * @param color the main color to affect to the ground and the background
  52245. */
  52246. setMainColor(color: Color3): void;
  52247. /**
  52248. * Setup the image processing according to the specified options.
  52249. */
  52250. private _setupImageProcessing;
  52251. /**
  52252. * Setup the environment texture according to the specified options.
  52253. */
  52254. private _setupEnvironmentTexture;
  52255. /**
  52256. * Setup the background according to the specified options.
  52257. */
  52258. private _setupBackground;
  52259. /**
  52260. * Get the scene sizes according to the setup.
  52261. */
  52262. private _getSceneSize;
  52263. /**
  52264. * Setup the ground according to the specified options.
  52265. */
  52266. private _setupGround;
  52267. /**
  52268. * Setup the ground material according to the specified options.
  52269. */
  52270. private _setupGroundMaterial;
  52271. /**
  52272. * Setup the ground diffuse texture according to the specified options.
  52273. */
  52274. private _setupGroundDiffuseTexture;
  52275. /**
  52276. * Setup the ground mirror texture according to the specified options.
  52277. */
  52278. private _setupGroundMirrorTexture;
  52279. /**
  52280. * Setup the ground to receive the mirror texture.
  52281. */
  52282. private _setupMirrorInGroundMaterial;
  52283. /**
  52284. * Setup the skybox according to the specified options.
  52285. */
  52286. private _setupSkybox;
  52287. /**
  52288. * Setup the skybox material according to the specified options.
  52289. */
  52290. private _setupSkyboxMaterial;
  52291. /**
  52292. * Setup the skybox reflection texture according to the specified options.
  52293. */
  52294. private _setupSkyboxReflectionTexture;
  52295. private _errorHandler;
  52296. /**
  52297. * Dispose all the elements created by the Helper.
  52298. */
  52299. dispose(): void;
  52300. }
  52301. }
  52302. declare module "babylonjs/Helpers/photoDome" {
  52303. import { Observable } from "babylonjs/Misc/observable";
  52304. import { Nullable } from "babylonjs/types";
  52305. import { Scene } from "babylonjs/scene";
  52306. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52307. import { Mesh } from "babylonjs/Meshes/mesh";
  52308. import { Texture } from "babylonjs/Materials/Textures/texture";
  52309. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  52310. import "babylonjs/Meshes/Builders/sphereBuilder";
  52311. /**
  52312. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  52313. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  52314. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  52315. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  52316. */
  52317. export class PhotoDome extends TransformNode {
  52318. /**
  52319. * Define the image as a Monoscopic panoramic 360 image.
  52320. */
  52321. static readonly MODE_MONOSCOPIC: number;
  52322. /**
  52323. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52324. */
  52325. static readonly MODE_TOPBOTTOM: number;
  52326. /**
  52327. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52328. */
  52329. static readonly MODE_SIDEBYSIDE: number;
  52330. private _useDirectMapping;
  52331. /**
  52332. * The texture being displayed on the sphere
  52333. */
  52334. protected _photoTexture: Texture;
  52335. /**
  52336. * Gets or sets the texture being displayed on the sphere
  52337. */
  52338. get photoTexture(): Texture;
  52339. set photoTexture(value: Texture);
  52340. /**
  52341. * Observable raised when an error occured while loading the 360 image
  52342. */
  52343. onLoadErrorObservable: Observable<string>;
  52344. /**
  52345. * The skybox material
  52346. */
  52347. protected _material: BackgroundMaterial;
  52348. /**
  52349. * The surface used for the skybox
  52350. */
  52351. protected _mesh: Mesh;
  52352. /**
  52353. * Gets the mesh used for the skybox.
  52354. */
  52355. get mesh(): Mesh;
  52356. /**
  52357. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  52358. * Also see the options.resolution property.
  52359. */
  52360. get fovMultiplier(): number;
  52361. set fovMultiplier(value: number);
  52362. private _imageMode;
  52363. /**
  52364. * Gets or set the current video mode for the video. It can be:
  52365. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  52366. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  52367. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  52368. */
  52369. get imageMode(): number;
  52370. set imageMode(value: number);
  52371. /**
  52372. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  52373. * @param name Element's name, child elements will append suffixes for their own names.
  52374. * @param urlsOfPhoto defines the url of the photo to display
  52375. * @param options defines an object containing optional or exposed sub element properties
  52376. * @param onError defines a callback called when an error occured while loading the texture
  52377. */
  52378. constructor(name: string, urlOfPhoto: string, options: {
  52379. resolution?: number;
  52380. size?: number;
  52381. useDirectMapping?: boolean;
  52382. faceForward?: boolean;
  52383. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  52384. private _onBeforeCameraRenderObserver;
  52385. private _changeImageMode;
  52386. /**
  52387. * Releases resources associated with this node.
  52388. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  52389. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  52390. */
  52391. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  52392. }
  52393. }
  52394. declare module "babylonjs/Misc/rgbdTextureTools" {
  52395. import "babylonjs/Shaders/rgbdDecode.fragment";
  52396. import "babylonjs/Engines/Extensions/engine.renderTarget";
  52397. import { Texture } from "babylonjs/Materials/Textures/texture";
  52398. /**
  52399. * Class used to host RGBD texture specific utilities
  52400. */
  52401. export class RGBDTextureTools {
  52402. /**
  52403. * Expand the RGBD Texture from RGBD to Half Float if possible.
  52404. * @param texture the texture to expand.
  52405. */
  52406. static ExpandRGBDTexture(texture: Texture): void;
  52407. }
  52408. }
  52409. declare module "babylonjs/Misc/brdfTextureTools" {
  52410. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52411. import { Scene } from "babylonjs/scene";
  52412. /**
  52413. * Class used to host texture specific utilities
  52414. */
  52415. export class BRDFTextureTools {
  52416. /**
  52417. * Prevents texture cache collision
  52418. */
  52419. private static _instanceNumber;
  52420. /**
  52421. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  52422. * @param scene defines the hosting scene
  52423. * @returns the environment BRDF texture
  52424. */
  52425. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  52426. private static _environmentBRDFBase64Texture;
  52427. }
  52428. }
  52429. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  52430. import { Nullable } from "babylonjs/types";
  52431. import { Color3 } from "babylonjs/Maths/math.color";
  52432. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52433. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52434. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52435. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52436. import { Engine } from "babylonjs/Engines/engine";
  52437. import { Scene } from "babylonjs/scene";
  52438. /**
  52439. * @hidden
  52440. */
  52441. export interface IMaterialClearCoatDefines {
  52442. CLEARCOAT: boolean;
  52443. CLEARCOAT_DEFAULTIOR: boolean;
  52444. CLEARCOAT_TEXTURE: boolean;
  52445. CLEARCOAT_TEXTUREDIRECTUV: number;
  52446. CLEARCOAT_BUMP: boolean;
  52447. CLEARCOAT_BUMPDIRECTUV: number;
  52448. CLEARCOAT_TINT: boolean;
  52449. CLEARCOAT_TINT_TEXTURE: boolean;
  52450. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  52451. /** @hidden */
  52452. _areTexturesDirty: boolean;
  52453. }
  52454. /**
  52455. * Define the code related to the clear coat parameters of the pbr material.
  52456. */
  52457. export class PBRClearCoatConfiguration {
  52458. /**
  52459. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52460. * The default fits with a polyurethane material.
  52461. */
  52462. private static readonly _DefaultIndexOfRefraction;
  52463. private _isEnabled;
  52464. /**
  52465. * Defines if the clear coat is enabled in the material.
  52466. */
  52467. isEnabled: boolean;
  52468. /**
  52469. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52470. */
  52471. intensity: number;
  52472. /**
  52473. * Defines the clear coat layer roughness.
  52474. */
  52475. roughness: number;
  52476. private _indexOfRefraction;
  52477. /**
  52478. * Defines the index of refraction of the clear coat.
  52479. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  52480. * The default fits with a polyurethane material.
  52481. * Changing the default value is more performance intensive.
  52482. */
  52483. indexOfRefraction: number;
  52484. private _texture;
  52485. /**
  52486. * Stores the clear coat values in a texture.
  52487. */
  52488. texture: Nullable<BaseTexture>;
  52489. private _bumpTexture;
  52490. /**
  52491. * Define the clear coat specific bump texture.
  52492. */
  52493. bumpTexture: Nullable<BaseTexture>;
  52494. private _isTintEnabled;
  52495. /**
  52496. * Defines if the clear coat tint is enabled in the material.
  52497. */
  52498. isTintEnabled: boolean;
  52499. /**
  52500. * Defines the clear coat tint of the material.
  52501. * This is only use if tint is enabled
  52502. */
  52503. tintColor: Color3;
  52504. /**
  52505. * Defines the distance at which the tint color should be found in the
  52506. * clear coat media.
  52507. * This is only use if tint is enabled
  52508. */
  52509. tintColorAtDistance: number;
  52510. /**
  52511. * Defines the clear coat layer thickness.
  52512. * This is only use if tint is enabled
  52513. */
  52514. tintThickness: number;
  52515. private _tintTexture;
  52516. /**
  52517. * Stores the clear tint values in a texture.
  52518. * rgb is tint
  52519. * a is a thickness factor
  52520. */
  52521. tintTexture: Nullable<BaseTexture>;
  52522. /** @hidden */
  52523. private _internalMarkAllSubMeshesAsTexturesDirty;
  52524. /** @hidden */
  52525. _markAllSubMeshesAsTexturesDirty(): void;
  52526. /**
  52527. * Instantiate a new istance of clear coat configuration.
  52528. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52529. */
  52530. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52531. /**
  52532. * Gets wehter the submesh is ready to be used or not.
  52533. * @param defines the list of "defines" to update.
  52534. * @param scene defines the scene the material belongs to.
  52535. * @param engine defines the engine the material belongs to.
  52536. * @param disableBumpMap defines wether the material disables bump or not.
  52537. * @returns - boolean indicating that the submesh is ready or not.
  52538. */
  52539. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  52540. /**
  52541. * Checks to see if a texture is used in the material.
  52542. * @param defines the list of "defines" to update.
  52543. * @param scene defines the scene to the material belongs to.
  52544. */
  52545. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  52546. /**
  52547. * Binds the material data.
  52548. * @param uniformBuffer defines the Uniform buffer to fill in.
  52549. * @param scene defines the scene the material belongs to.
  52550. * @param engine defines the engine the material belongs to.
  52551. * @param disableBumpMap defines wether the material disables bump or not.
  52552. * @param isFrozen defines wether the material is frozen or not.
  52553. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52554. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52555. */
  52556. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  52557. /**
  52558. * Checks to see if a texture is used in the material.
  52559. * @param texture - Base texture to use.
  52560. * @returns - Boolean specifying if a texture is used in the material.
  52561. */
  52562. hasTexture(texture: BaseTexture): boolean;
  52563. /**
  52564. * Returns an array of the actively used textures.
  52565. * @param activeTextures Array of BaseTextures
  52566. */
  52567. getActiveTextures(activeTextures: BaseTexture[]): void;
  52568. /**
  52569. * Returns the animatable textures.
  52570. * @param animatables Array of animatable textures.
  52571. */
  52572. getAnimatables(animatables: IAnimatable[]): void;
  52573. /**
  52574. * Disposes the resources of the material.
  52575. * @param forceDisposeTextures - Forces the disposal of all textures.
  52576. */
  52577. dispose(forceDisposeTextures?: boolean): void;
  52578. /**
  52579. * Get the current class name of the texture useful for serialization or dynamic coding.
  52580. * @returns "PBRClearCoatConfiguration"
  52581. */
  52582. getClassName(): string;
  52583. /**
  52584. * Add fallbacks to the effect fallbacks list.
  52585. * @param defines defines the Base texture to use.
  52586. * @param fallbacks defines the current fallback list.
  52587. * @param currentRank defines the current fallback rank.
  52588. * @returns the new fallback rank.
  52589. */
  52590. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52591. /**
  52592. * Add the required uniforms to the current list.
  52593. * @param uniforms defines the current uniform list.
  52594. */
  52595. static AddUniforms(uniforms: string[]): void;
  52596. /**
  52597. * Add the required samplers to the current list.
  52598. * @param samplers defines the current sampler list.
  52599. */
  52600. static AddSamplers(samplers: string[]): void;
  52601. /**
  52602. * Add the required uniforms to the current buffer.
  52603. * @param uniformBuffer defines the current uniform buffer.
  52604. */
  52605. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52606. /**
  52607. * Makes a duplicate of the current configuration into another one.
  52608. * @param clearCoatConfiguration define the config where to copy the info
  52609. */
  52610. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  52611. /**
  52612. * Serializes this clear coat configuration.
  52613. * @returns - An object with the serialized config.
  52614. */
  52615. serialize(): any;
  52616. /**
  52617. * Parses a anisotropy Configuration from a serialized object.
  52618. * @param source - Serialized object.
  52619. * @param scene Defines the scene we are parsing for
  52620. * @param rootUrl Defines the rootUrl to load from
  52621. */
  52622. parse(source: any, scene: Scene, rootUrl: string): void;
  52623. }
  52624. }
  52625. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  52626. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52627. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52628. import { Vector2 } from "babylonjs/Maths/math.vector";
  52629. import { Scene } from "babylonjs/scene";
  52630. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52631. import { Nullable } from "babylonjs/types";
  52632. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52633. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52634. /**
  52635. * @hidden
  52636. */
  52637. export interface IMaterialAnisotropicDefines {
  52638. ANISOTROPIC: boolean;
  52639. ANISOTROPIC_TEXTURE: boolean;
  52640. ANISOTROPIC_TEXTUREDIRECTUV: number;
  52641. MAINUV1: boolean;
  52642. _areTexturesDirty: boolean;
  52643. _needUVs: boolean;
  52644. }
  52645. /**
  52646. * Define the code related to the anisotropic parameters of the pbr material.
  52647. */
  52648. export class PBRAnisotropicConfiguration {
  52649. private _isEnabled;
  52650. /**
  52651. * Defines if the anisotropy is enabled in the material.
  52652. */
  52653. isEnabled: boolean;
  52654. /**
  52655. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  52656. */
  52657. intensity: number;
  52658. /**
  52659. * Defines if the effect is along the tangents, bitangents or in between.
  52660. * By default, the effect is "strectching" the highlights along the tangents.
  52661. */
  52662. direction: Vector2;
  52663. private _texture;
  52664. /**
  52665. * Stores the anisotropy values in a texture.
  52666. * rg is direction (like normal from -1 to 1)
  52667. * b is a intensity
  52668. */
  52669. texture: Nullable<BaseTexture>;
  52670. /** @hidden */
  52671. private _internalMarkAllSubMeshesAsTexturesDirty;
  52672. /** @hidden */
  52673. _markAllSubMeshesAsTexturesDirty(): void;
  52674. /**
  52675. * Instantiate a new istance of anisotropy configuration.
  52676. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52677. */
  52678. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52679. /**
  52680. * Specifies that the submesh is ready to be used.
  52681. * @param defines the list of "defines" to update.
  52682. * @param scene defines the scene the material belongs to.
  52683. * @returns - boolean indicating that the submesh is ready or not.
  52684. */
  52685. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  52686. /**
  52687. * Checks to see if a texture is used in the material.
  52688. * @param defines the list of "defines" to update.
  52689. * @param mesh the mesh we are preparing the defines for.
  52690. * @param scene defines the scene the material belongs to.
  52691. */
  52692. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  52693. /**
  52694. * Binds the material data.
  52695. * @param uniformBuffer defines the Uniform buffer to fill in.
  52696. * @param scene defines the scene the material belongs to.
  52697. * @param isFrozen defines wether the material is frozen or not.
  52698. */
  52699. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52700. /**
  52701. * Checks to see if a texture is used in the material.
  52702. * @param texture - Base texture to use.
  52703. * @returns - Boolean specifying if a texture is used in the material.
  52704. */
  52705. hasTexture(texture: BaseTexture): boolean;
  52706. /**
  52707. * Returns an array of the actively used textures.
  52708. * @param activeTextures Array of BaseTextures
  52709. */
  52710. getActiveTextures(activeTextures: BaseTexture[]): void;
  52711. /**
  52712. * Returns the animatable textures.
  52713. * @param animatables Array of animatable textures.
  52714. */
  52715. getAnimatables(animatables: IAnimatable[]): void;
  52716. /**
  52717. * Disposes the resources of the material.
  52718. * @param forceDisposeTextures - Forces the disposal of all textures.
  52719. */
  52720. dispose(forceDisposeTextures?: boolean): void;
  52721. /**
  52722. * Get the current class name of the texture useful for serialization or dynamic coding.
  52723. * @returns "PBRAnisotropicConfiguration"
  52724. */
  52725. getClassName(): string;
  52726. /**
  52727. * Add fallbacks to the effect fallbacks list.
  52728. * @param defines defines the Base texture to use.
  52729. * @param fallbacks defines the current fallback list.
  52730. * @param currentRank defines the current fallback rank.
  52731. * @returns the new fallback rank.
  52732. */
  52733. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  52734. /**
  52735. * Add the required uniforms to the current list.
  52736. * @param uniforms defines the current uniform list.
  52737. */
  52738. static AddUniforms(uniforms: string[]): void;
  52739. /**
  52740. * Add the required uniforms to the current buffer.
  52741. * @param uniformBuffer defines the current uniform buffer.
  52742. */
  52743. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  52744. /**
  52745. * Add the required samplers to the current list.
  52746. * @param samplers defines the current sampler list.
  52747. */
  52748. static AddSamplers(samplers: string[]): void;
  52749. /**
  52750. * Makes a duplicate of the current configuration into another one.
  52751. * @param anisotropicConfiguration define the config where to copy the info
  52752. */
  52753. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  52754. /**
  52755. * Serializes this anisotropy configuration.
  52756. * @returns - An object with the serialized config.
  52757. */
  52758. serialize(): any;
  52759. /**
  52760. * Parses a anisotropy Configuration from a serialized object.
  52761. * @param source - Serialized object.
  52762. * @param scene Defines the scene we are parsing for
  52763. * @param rootUrl Defines the rootUrl to load from
  52764. */
  52765. parse(source: any, scene: Scene, rootUrl: string): void;
  52766. }
  52767. }
  52768. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  52769. import { Scene } from "babylonjs/scene";
  52770. /**
  52771. * @hidden
  52772. */
  52773. export interface IMaterialBRDFDefines {
  52774. BRDF_V_HEIGHT_CORRELATED: boolean;
  52775. MS_BRDF_ENERGY_CONSERVATION: boolean;
  52776. SPHERICAL_HARMONICS: boolean;
  52777. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  52778. /** @hidden */
  52779. _areMiscDirty: boolean;
  52780. }
  52781. /**
  52782. * Define the code related to the BRDF parameters of the pbr material.
  52783. */
  52784. export class PBRBRDFConfiguration {
  52785. /**
  52786. * Default value used for the energy conservation.
  52787. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52788. */
  52789. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  52790. /**
  52791. * Default value used for the Smith Visibility Height Correlated mode.
  52792. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  52793. */
  52794. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  52795. /**
  52796. * Default value used for the IBL diffuse part.
  52797. * This can help switching back to the polynomials mode globally which is a tiny bit
  52798. * less GPU intensive at the drawback of a lower quality.
  52799. */
  52800. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  52801. /**
  52802. * Default value used for activating energy conservation for the specular workflow.
  52803. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52804. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52805. */
  52806. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  52807. private _useEnergyConservation;
  52808. /**
  52809. * Defines if the material uses energy conservation.
  52810. */
  52811. useEnergyConservation: boolean;
  52812. private _useSmithVisibilityHeightCorrelated;
  52813. /**
  52814. * LEGACY Mode set to false
  52815. * Defines if the material uses height smith correlated visibility term.
  52816. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  52817. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  52818. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  52819. * Not relying on height correlated will also disable energy conservation.
  52820. */
  52821. useSmithVisibilityHeightCorrelated: boolean;
  52822. private _useSphericalHarmonics;
  52823. /**
  52824. * LEGACY Mode set to false
  52825. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  52826. * diffuse part of the IBL.
  52827. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  52828. * to the ground truth.
  52829. */
  52830. useSphericalHarmonics: boolean;
  52831. private _useSpecularGlossinessInputEnergyConservation;
  52832. /**
  52833. * Defines if the material uses energy conservation, when the specular workflow is active.
  52834. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  52835. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  52836. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  52837. */
  52838. useSpecularGlossinessInputEnergyConservation: boolean;
  52839. /** @hidden */
  52840. private _internalMarkAllSubMeshesAsMiscDirty;
  52841. /** @hidden */
  52842. _markAllSubMeshesAsMiscDirty(): void;
  52843. /**
  52844. * Instantiate a new istance of clear coat configuration.
  52845. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  52846. */
  52847. constructor(markAllSubMeshesAsMiscDirty: () => void);
  52848. /**
  52849. * Checks to see if a texture is used in the material.
  52850. * @param defines the list of "defines" to update.
  52851. */
  52852. prepareDefines(defines: IMaterialBRDFDefines): void;
  52853. /**
  52854. * Get the current class name of the texture useful for serialization or dynamic coding.
  52855. * @returns "PBRClearCoatConfiguration"
  52856. */
  52857. getClassName(): string;
  52858. /**
  52859. * Makes a duplicate of the current configuration into another one.
  52860. * @param brdfConfiguration define the config where to copy the info
  52861. */
  52862. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  52863. /**
  52864. * Serializes this BRDF configuration.
  52865. * @returns - An object with the serialized config.
  52866. */
  52867. serialize(): any;
  52868. /**
  52869. * Parses a anisotropy Configuration from a serialized object.
  52870. * @param source - Serialized object.
  52871. * @param scene Defines the scene we are parsing for
  52872. * @param rootUrl Defines the rootUrl to load from
  52873. */
  52874. parse(source: any, scene: Scene, rootUrl: string): void;
  52875. }
  52876. }
  52877. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  52878. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  52879. import { Color3 } from "babylonjs/Maths/math.color";
  52880. import { Scene } from "babylonjs/scene";
  52881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  52882. import { Nullable } from "babylonjs/types";
  52883. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  52884. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  52885. /**
  52886. * @hidden
  52887. */
  52888. export interface IMaterialSheenDefines {
  52889. SHEEN: boolean;
  52890. SHEEN_TEXTURE: boolean;
  52891. SHEEN_TEXTUREDIRECTUV: number;
  52892. SHEEN_LINKWITHALBEDO: boolean;
  52893. SHEEN_ROUGHNESS: boolean;
  52894. SHEEN_ALBEDOSCALING: boolean;
  52895. /** @hidden */
  52896. _areTexturesDirty: boolean;
  52897. }
  52898. /**
  52899. * Define the code related to the Sheen parameters of the pbr material.
  52900. */
  52901. export class PBRSheenConfiguration {
  52902. private _isEnabled;
  52903. /**
  52904. * Defines if the material uses sheen.
  52905. */
  52906. isEnabled: boolean;
  52907. private _linkSheenWithAlbedo;
  52908. /**
  52909. * Defines if the sheen is linked to the sheen color.
  52910. */
  52911. linkSheenWithAlbedo: boolean;
  52912. /**
  52913. * Defines the sheen intensity.
  52914. */
  52915. intensity: number;
  52916. /**
  52917. * Defines the sheen color.
  52918. */
  52919. color: Color3;
  52920. private _texture;
  52921. /**
  52922. * Stores the sheen tint values in a texture.
  52923. * rgb is tint
  52924. * a is a intensity
  52925. */
  52926. texture: Nullable<BaseTexture>;
  52927. private _roughness;
  52928. /**
  52929. * Defines the sheen roughness.
  52930. * It is not taken into account if linkSheenWithAlbedo is true.
  52931. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  52932. */
  52933. roughness: Nullable<number>;
  52934. private _albedoScaling;
  52935. /**
  52936. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  52937. * It allows the strength of the sheen effect to not depend on the base color of the material,
  52938. * making it easier to setup and tweak the effect
  52939. */
  52940. albedoScaling: boolean;
  52941. /** @hidden */
  52942. private _internalMarkAllSubMeshesAsTexturesDirty;
  52943. /** @hidden */
  52944. _markAllSubMeshesAsTexturesDirty(): void;
  52945. /**
  52946. * Instantiate a new istance of clear coat configuration.
  52947. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52948. */
  52949. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  52950. /**
  52951. * Specifies that the submesh is ready to be used.
  52952. * @param defines the list of "defines" to update.
  52953. * @param scene defines the scene the material belongs to.
  52954. * @returns - boolean indicating that the submesh is ready or not.
  52955. */
  52956. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  52957. /**
  52958. * Checks to see if a texture is used in the material.
  52959. * @param defines the list of "defines" to update.
  52960. * @param scene defines the scene the material belongs to.
  52961. */
  52962. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  52963. /**
  52964. * Binds the material data.
  52965. * @param uniformBuffer defines the Uniform buffer to fill in.
  52966. * @param scene defines the scene the material belongs to.
  52967. * @param isFrozen defines wether the material is frozen or not.
  52968. */
  52969. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  52970. /**
  52971. * Checks to see if a texture is used in the material.
  52972. * @param texture - Base texture to use.
  52973. * @returns - Boolean specifying if a texture is used in the material.
  52974. */
  52975. hasTexture(texture: BaseTexture): boolean;
  52976. /**
  52977. * Returns an array of the actively used textures.
  52978. * @param activeTextures Array of BaseTextures
  52979. */
  52980. getActiveTextures(activeTextures: BaseTexture[]): void;
  52981. /**
  52982. * Returns the animatable textures.
  52983. * @param animatables Array of animatable textures.
  52984. */
  52985. getAnimatables(animatables: IAnimatable[]): void;
  52986. /**
  52987. * Disposes the resources of the material.
  52988. * @param forceDisposeTextures - Forces the disposal of all textures.
  52989. */
  52990. dispose(forceDisposeTextures?: boolean): void;
  52991. /**
  52992. * Get the current class name of the texture useful for serialization or dynamic coding.
  52993. * @returns "PBRSheenConfiguration"
  52994. */
  52995. getClassName(): string;
  52996. /**
  52997. * Add fallbacks to the effect fallbacks list.
  52998. * @param defines defines the Base texture to use.
  52999. * @param fallbacks defines the current fallback list.
  53000. * @param currentRank defines the current fallback rank.
  53001. * @returns the new fallback rank.
  53002. */
  53003. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53004. /**
  53005. * Add the required uniforms to the current list.
  53006. * @param uniforms defines the current uniform list.
  53007. */
  53008. static AddUniforms(uniforms: string[]): void;
  53009. /**
  53010. * Add the required uniforms to the current buffer.
  53011. * @param uniformBuffer defines the current uniform buffer.
  53012. */
  53013. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53014. /**
  53015. * Add the required samplers to the current list.
  53016. * @param samplers defines the current sampler list.
  53017. */
  53018. static AddSamplers(samplers: string[]): void;
  53019. /**
  53020. * Makes a duplicate of the current configuration into another one.
  53021. * @param sheenConfiguration define the config where to copy the info
  53022. */
  53023. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  53024. /**
  53025. * Serializes this BRDF configuration.
  53026. * @returns - An object with the serialized config.
  53027. */
  53028. serialize(): any;
  53029. /**
  53030. * Parses a anisotropy Configuration from a serialized object.
  53031. * @param source - Serialized object.
  53032. * @param scene Defines the scene we are parsing for
  53033. * @param rootUrl Defines the rootUrl to load from
  53034. */
  53035. parse(source: any, scene: Scene, rootUrl: string): void;
  53036. }
  53037. }
  53038. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  53039. import { Nullable } from "babylonjs/types";
  53040. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53041. import { Color3 } from "babylonjs/Maths/math.color";
  53042. import { SmartArray } from "babylonjs/Misc/smartArray";
  53043. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53044. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  53045. import { Effect } from "babylonjs/Materials/effect";
  53046. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  53047. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  53048. import { Engine } from "babylonjs/Engines/engine";
  53049. import { Scene } from "babylonjs/scene";
  53050. /**
  53051. * @hidden
  53052. */
  53053. export interface IMaterialSubSurfaceDefines {
  53054. SUBSURFACE: boolean;
  53055. SS_REFRACTION: boolean;
  53056. SS_TRANSLUCENCY: boolean;
  53057. SS_SCATERRING: boolean;
  53058. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53059. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53060. SS_REFRACTIONMAP_3D: boolean;
  53061. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53062. SS_LODINREFRACTIONALPHA: boolean;
  53063. SS_GAMMAREFRACTION: boolean;
  53064. SS_RGBDREFRACTION: boolean;
  53065. SS_LINEARSPECULARREFRACTION: boolean;
  53066. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53067. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53068. /** @hidden */
  53069. _areTexturesDirty: boolean;
  53070. }
  53071. /**
  53072. * Define the code related to the sub surface parameters of the pbr material.
  53073. */
  53074. export class PBRSubSurfaceConfiguration {
  53075. private _isRefractionEnabled;
  53076. /**
  53077. * Defines if the refraction is enabled in the material.
  53078. */
  53079. isRefractionEnabled: boolean;
  53080. private _isTranslucencyEnabled;
  53081. /**
  53082. * Defines if the translucency is enabled in the material.
  53083. */
  53084. isTranslucencyEnabled: boolean;
  53085. private _isScatteringEnabled;
  53086. /**
  53087. * Defines the refraction intensity of the material.
  53088. * The refraction when enabled replaces the Diffuse part of the material.
  53089. * The intensity helps transitionning between diffuse and refraction.
  53090. */
  53091. refractionIntensity: number;
  53092. /**
  53093. * Defines the translucency intensity of the material.
  53094. * When translucency has been enabled, this defines how much of the "translucency"
  53095. * is addded to the diffuse part of the material.
  53096. */
  53097. translucencyIntensity: number;
  53098. /**
  53099. * Defines the scattering intensity of the material.
  53100. * When scattering has been enabled, this defines how much of the "scattered light"
  53101. * is addded to the diffuse part of the material.
  53102. */
  53103. scatteringIntensity: number;
  53104. private _thicknessTexture;
  53105. /**
  53106. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  53107. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  53108. * 0 would mean minimumThickness
  53109. * 1 would mean maximumThickness
  53110. * The other channels might be use as a mask to vary the different effects intensity.
  53111. */
  53112. thicknessTexture: Nullable<BaseTexture>;
  53113. private _refractionTexture;
  53114. /**
  53115. * Defines the texture to use for refraction.
  53116. */
  53117. refractionTexture: Nullable<BaseTexture>;
  53118. private _indexOfRefraction;
  53119. /**
  53120. * Defines the index of refraction used in the material.
  53121. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  53122. */
  53123. indexOfRefraction: number;
  53124. private _invertRefractionY;
  53125. /**
  53126. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  53127. */
  53128. invertRefractionY: boolean;
  53129. private _linkRefractionWithTransparency;
  53130. /**
  53131. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  53132. * Materials half opaque for instance using refraction could benefit from this control.
  53133. */
  53134. linkRefractionWithTransparency: boolean;
  53135. /**
  53136. * Defines the minimum thickness stored in the thickness map.
  53137. * If no thickness map is defined, this value will be used to simulate thickness.
  53138. */
  53139. minimumThickness: number;
  53140. /**
  53141. * Defines the maximum thickness stored in the thickness map.
  53142. */
  53143. maximumThickness: number;
  53144. /**
  53145. * Defines the volume tint of the material.
  53146. * This is used for both translucency and scattering.
  53147. */
  53148. tintColor: Color3;
  53149. /**
  53150. * Defines the distance at which the tint color should be found in the media.
  53151. * This is used for refraction only.
  53152. */
  53153. tintColorAtDistance: number;
  53154. /**
  53155. * Defines how far each channel transmit through the media.
  53156. * It is defined as a color to simplify it selection.
  53157. */
  53158. diffusionDistance: Color3;
  53159. private _useMaskFromThicknessTexture;
  53160. /**
  53161. * Stores the intensity of the different subsurface effects in the thickness texture.
  53162. * * the green channel is the translucency intensity.
  53163. * * the blue channel is the scattering intensity.
  53164. * * the alpha channel is the refraction intensity.
  53165. */
  53166. useMaskFromThicknessTexture: boolean;
  53167. /** @hidden */
  53168. private _internalMarkAllSubMeshesAsTexturesDirty;
  53169. /** @hidden */
  53170. _markAllSubMeshesAsTexturesDirty(): void;
  53171. /**
  53172. * Instantiate a new istance of sub surface configuration.
  53173. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  53174. */
  53175. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  53176. /**
  53177. * Gets wehter the submesh is ready to be used or not.
  53178. * @param defines the list of "defines" to update.
  53179. * @param scene defines the scene the material belongs to.
  53180. * @returns - boolean indicating that the submesh is ready or not.
  53181. */
  53182. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  53183. /**
  53184. * Checks to see if a texture is used in the material.
  53185. * @param defines the list of "defines" to update.
  53186. * @param scene defines the scene to the material belongs to.
  53187. */
  53188. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  53189. /**
  53190. * Binds the material data.
  53191. * @param uniformBuffer defines the Uniform buffer to fill in.
  53192. * @param scene defines the scene the material belongs to.
  53193. * @param engine defines the engine the material belongs to.
  53194. * @param isFrozen defines wether the material is frozen or not.
  53195. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  53196. */
  53197. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  53198. /**
  53199. * Unbinds the material from the mesh.
  53200. * @param activeEffect defines the effect that should be unbound from.
  53201. * @returns true if unbound, otherwise false
  53202. */
  53203. unbind(activeEffect: Effect): boolean;
  53204. /**
  53205. * Returns the texture used for refraction or null if none is used.
  53206. * @param scene defines the scene the material belongs to.
  53207. * @returns - Refraction texture if present. If no refraction texture and refraction
  53208. * is linked with transparency, returns environment texture. Otherwise, returns null.
  53209. */
  53210. private _getRefractionTexture;
  53211. /**
  53212. * Returns true if alpha blending should be disabled.
  53213. */
  53214. get disableAlphaBlending(): boolean;
  53215. /**
  53216. * Fills the list of render target textures.
  53217. * @param renderTargets the list of render targets to update
  53218. */
  53219. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  53220. /**
  53221. * Checks to see if a texture is used in the material.
  53222. * @param texture - Base texture to use.
  53223. * @returns - Boolean specifying if a texture is used in the material.
  53224. */
  53225. hasTexture(texture: BaseTexture): boolean;
  53226. /**
  53227. * Gets a boolean indicating that current material needs to register RTT
  53228. * @returns true if this uses a render target otherwise false.
  53229. */
  53230. hasRenderTargetTextures(): boolean;
  53231. /**
  53232. * Returns an array of the actively used textures.
  53233. * @param activeTextures Array of BaseTextures
  53234. */
  53235. getActiveTextures(activeTextures: BaseTexture[]): void;
  53236. /**
  53237. * Returns the animatable textures.
  53238. * @param animatables Array of animatable textures.
  53239. */
  53240. getAnimatables(animatables: IAnimatable[]): void;
  53241. /**
  53242. * Disposes the resources of the material.
  53243. * @param forceDisposeTextures - Forces the disposal of all textures.
  53244. */
  53245. dispose(forceDisposeTextures?: boolean): void;
  53246. /**
  53247. * Get the current class name of the texture useful for serialization or dynamic coding.
  53248. * @returns "PBRSubSurfaceConfiguration"
  53249. */
  53250. getClassName(): string;
  53251. /**
  53252. * Add fallbacks to the effect fallbacks list.
  53253. * @param defines defines the Base texture to use.
  53254. * @param fallbacks defines the current fallback list.
  53255. * @param currentRank defines the current fallback rank.
  53256. * @returns the new fallback rank.
  53257. */
  53258. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  53259. /**
  53260. * Add the required uniforms to the current list.
  53261. * @param uniforms defines the current uniform list.
  53262. */
  53263. static AddUniforms(uniforms: string[]): void;
  53264. /**
  53265. * Add the required samplers to the current list.
  53266. * @param samplers defines the current sampler list.
  53267. */
  53268. static AddSamplers(samplers: string[]): void;
  53269. /**
  53270. * Add the required uniforms to the current buffer.
  53271. * @param uniformBuffer defines the current uniform buffer.
  53272. */
  53273. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  53274. /**
  53275. * Makes a duplicate of the current configuration into another one.
  53276. * @param configuration define the config where to copy the info
  53277. */
  53278. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  53279. /**
  53280. * Serializes this Sub Surface configuration.
  53281. * @returns - An object with the serialized config.
  53282. */
  53283. serialize(): any;
  53284. /**
  53285. * Parses a anisotropy Configuration from a serialized object.
  53286. * @param source - Serialized object.
  53287. * @param scene Defines the scene we are parsing for
  53288. * @param rootUrl Defines the rootUrl to load from
  53289. */
  53290. parse(source: any, scene: Scene, rootUrl: string): void;
  53291. }
  53292. }
  53293. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  53294. /** @hidden */
  53295. export var pbrFragmentDeclaration: {
  53296. name: string;
  53297. shader: string;
  53298. };
  53299. }
  53300. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  53301. /** @hidden */
  53302. export var pbrUboDeclaration: {
  53303. name: string;
  53304. shader: string;
  53305. };
  53306. }
  53307. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  53308. /** @hidden */
  53309. export var pbrFragmentExtraDeclaration: {
  53310. name: string;
  53311. shader: string;
  53312. };
  53313. }
  53314. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  53315. /** @hidden */
  53316. export var pbrFragmentSamplersDeclaration: {
  53317. name: string;
  53318. shader: string;
  53319. };
  53320. }
  53321. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  53322. /** @hidden */
  53323. export var pbrHelperFunctions: {
  53324. name: string;
  53325. shader: string;
  53326. };
  53327. }
  53328. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  53329. /** @hidden */
  53330. export var harmonicsFunctions: {
  53331. name: string;
  53332. shader: string;
  53333. };
  53334. }
  53335. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  53336. /** @hidden */
  53337. export var pbrDirectLightingSetupFunctions: {
  53338. name: string;
  53339. shader: string;
  53340. };
  53341. }
  53342. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  53343. /** @hidden */
  53344. export var pbrDirectLightingFalloffFunctions: {
  53345. name: string;
  53346. shader: string;
  53347. };
  53348. }
  53349. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  53350. /** @hidden */
  53351. export var pbrBRDFFunctions: {
  53352. name: string;
  53353. shader: string;
  53354. };
  53355. }
  53356. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  53357. /** @hidden */
  53358. export var pbrDirectLightingFunctions: {
  53359. name: string;
  53360. shader: string;
  53361. };
  53362. }
  53363. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  53364. /** @hidden */
  53365. export var pbrIBLFunctions: {
  53366. name: string;
  53367. shader: string;
  53368. };
  53369. }
  53370. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  53371. /** @hidden */
  53372. export var pbrBlockAlbedoOpacity: {
  53373. name: string;
  53374. shader: string;
  53375. };
  53376. }
  53377. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  53378. /** @hidden */
  53379. export var pbrBlockReflectivity: {
  53380. name: string;
  53381. shader: string;
  53382. };
  53383. }
  53384. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  53385. /** @hidden */
  53386. export var pbrBlockAmbientOcclusion: {
  53387. name: string;
  53388. shader: string;
  53389. };
  53390. }
  53391. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  53392. /** @hidden */
  53393. export var pbrBlockAlphaFresnel: {
  53394. name: string;
  53395. shader: string;
  53396. };
  53397. }
  53398. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  53399. /** @hidden */
  53400. export var pbrBlockAnisotropic: {
  53401. name: string;
  53402. shader: string;
  53403. };
  53404. }
  53405. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  53406. /** @hidden */
  53407. export var pbrBlockReflection: {
  53408. name: string;
  53409. shader: string;
  53410. };
  53411. }
  53412. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  53413. /** @hidden */
  53414. export var pbrBlockSheen: {
  53415. name: string;
  53416. shader: string;
  53417. };
  53418. }
  53419. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  53420. /** @hidden */
  53421. export var pbrBlockClearcoat: {
  53422. name: string;
  53423. shader: string;
  53424. };
  53425. }
  53426. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  53427. /** @hidden */
  53428. export var pbrBlockSubSurface: {
  53429. name: string;
  53430. shader: string;
  53431. };
  53432. }
  53433. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  53434. /** @hidden */
  53435. export var pbrBlockNormalGeometric: {
  53436. name: string;
  53437. shader: string;
  53438. };
  53439. }
  53440. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  53441. /** @hidden */
  53442. export var pbrBlockNormalFinal: {
  53443. name: string;
  53444. shader: string;
  53445. };
  53446. }
  53447. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  53448. /** @hidden */
  53449. export var pbrBlockGeometryInfo: {
  53450. name: string;
  53451. shader: string;
  53452. };
  53453. }
  53454. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  53455. /** @hidden */
  53456. export var pbrBlockReflectance0: {
  53457. name: string;
  53458. shader: string;
  53459. };
  53460. }
  53461. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  53462. /** @hidden */
  53463. export var pbrBlockReflectance: {
  53464. name: string;
  53465. shader: string;
  53466. };
  53467. }
  53468. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  53469. /** @hidden */
  53470. export var pbrBlockDirectLighting: {
  53471. name: string;
  53472. shader: string;
  53473. };
  53474. }
  53475. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  53476. /** @hidden */
  53477. export var pbrBlockFinalLitComponents: {
  53478. name: string;
  53479. shader: string;
  53480. };
  53481. }
  53482. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  53483. /** @hidden */
  53484. export var pbrBlockFinalUnlitComponents: {
  53485. name: string;
  53486. shader: string;
  53487. };
  53488. }
  53489. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  53490. /** @hidden */
  53491. export var pbrBlockFinalColorComposition: {
  53492. name: string;
  53493. shader: string;
  53494. };
  53495. }
  53496. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  53497. /** @hidden */
  53498. export var pbrBlockImageProcessing: {
  53499. name: string;
  53500. shader: string;
  53501. };
  53502. }
  53503. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  53504. /** @hidden */
  53505. export var pbrDebug: {
  53506. name: string;
  53507. shader: string;
  53508. };
  53509. }
  53510. declare module "babylonjs/Shaders/pbr.fragment" {
  53511. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  53512. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53513. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  53514. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53515. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53516. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  53517. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53518. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  53519. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53520. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  53521. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53522. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  53523. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53524. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  53525. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53526. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  53527. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  53528. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  53529. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  53530. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  53531. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  53532. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  53533. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  53534. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  53535. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  53536. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  53537. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  53538. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  53539. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  53540. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  53541. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  53542. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53543. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  53544. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  53545. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  53546. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  53547. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  53548. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  53549. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  53550. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  53551. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  53552. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  53553. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  53554. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  53555. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  53556. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  53557. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  53558. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  53559. /** @hidden */
  53560. export var pbrPixelShader: {
  53561. name: string;
  53562. shader: string;
  53563. };
  53564. }
  53565. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  53566. /** @hidden */
  53567. export var pbrVertexDeclaration: {
  53568. name: string;
  53569. shader: string;
  53570. };
  53571. }
  53572. declare module "babylonjs/Shaders/pbr.vertex" {
  53573. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  53574. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  53575. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53576. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  53577. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  53578. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  53579. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  53580. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  53581. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  53582. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  53583. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  53584. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  53585. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  53586. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  53587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  53588. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  53589. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  53590. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  53591. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53592. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  53593. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  53594. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  53595. /** @hidden */
  53596. export var pbrVertexShader: {
  53597. name: string;
  53598. shader: string;
  53599. };
  53600. }
  53601. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  53602. import { Nullable } from "babylonjs/types";
  53603. import { Scene } from "babylonjs/scene";
  53604. import { Matrix } from "babylonjs/Maths/math.vector";
  53605. import { SubMesh } from "babylonjs/Meshes/subMesh";
  53606. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53607. import { Mesh } from "babylonjs/Meshes/mesh";
  53608. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  53609. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  53610. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  53611. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  53612. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  53613. import { Color3 } from "babylonjs/Maths/math.color";
  53614. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  53615. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  53616. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  53617. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  53618. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  53619. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  53620. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  53621. import "babylonjs/Shaders/pbr.fragment";
  53622. import "babylonjs/Shaders/pbr.vertex";
  53623. /**
  53624. * Manages the defines for the PBR Material.
  53625. * @hidden
  53626. */
  53627. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  53628. PBR: boolean;
  53629. MAINUV1: boolean;
  53630. MAINUV2: boolean;
  53631. UV1: boolean;
  53632. UV2: boolean;
  53633. ALBEDO: boolean;
  53634. GAMMAALBEDO: boolean;
  53635. ALBEDODIRECTUV: number;
  53636. VERTEXCOLOR: boolean;
  53637. AMBIENT: boolean;
  53638. AMBIENTDIRECTUV: number;
  53639. AMBIENTINGRAYSCALE: boolean;
  53640. OPACITY: boolean;
  53641. VERTEXALPHA: boolean;
  53642. OPACITYDIRECTUV: number;
  53643. OPACITYRGB: boolean;
  53644. ALPHATEST: boolean;
  53645. DEPTHPREPASS: boolean;
  53646. ALPHABLEND: boolean;
  53647. ALPHAFROMALBEDO: boolean;
  53648. ALPHATESTVALUE: string;
  53649. SPECULAROVERALPHA: boolean;
  53650. RADIANCEOVERALPHA: boolean;
  53651. ALPHAFRESNEL: boolean;
  53652. LINEARALPHAFRESNEL: boolean;
  53653. PREMULTIPLYALPHA: boolean;
  53654. EMISSIVE: boolean;
  53655. EMISSIVEDIRECTUV: number;
  53656. REFLECTIVITY: boolean;
  53657. REFLECTIVITYDIRECTUV: number;
  53658. SPECULARTERM: boolean;
  53659. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  53660. MICROSURFACEAUTOMATIC: boolean;
  53661. LODBASEDMICROSFURACE: boolean;
  53662. MICROSURFACEMAP: boolean;
  53663. MICROSURFACEMAPDIRECTUV: number;
  53664. METALLICWORKFLOW: boolean;
  53665. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  53666. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  53667. METALLNESSSTOREINMETALMAPBLUE: boolean;
  53668. AOSTOREINMETALMAPRED: boolean;
  53669. METALLICF0FACTORFROMMETALLICMAP: boolean;
  53670. ENVIRONMENTBRDF: boolean;
  53671. ENVIRONMENTBRDF_RGBD: boolean;
  53672. NORMAL: boolean;
  53673. TANGENT: boolean;
  53674. BUMP: boolean;
  53675. BUMPDIRECTUV: number;
  53676. OBJECTSPACE_NORMALMAP: boolean;
  53677. PARALLAX: boolean;
  53678. PARALLAXOCCLUSION: boolean;
  53679. NORMALXYSCALE: boolean;
  53680. LIGHTMAP: boolean;
  53681. LIGHTMAPDIRECTUV: number;
  53682. USELIGHTMAPASSHADOWMAP: boolean;
  53683. GAMMALIGHTMAP: boolean;
  53684. RGBDLIGHTMAP: boolean;
  53685. REFLECTION: boolean;
  53686. REFLECTIONMAP_3D: boolean;
  53687. REFLECTIONMAP_SPHERICAL: boolean;
  53688. REFLECTIONMAP_PLANAR: boolean;
  53689. REFLECTIONMAP_CUBIC: boolean;
  53690. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  53691. REFLECTIONMAP_PROJECTION: boolean;
  53692. REFLECTIONMAP_SKYBOX: boolean;
  53693. REFLECTIONMAP_EXPLICIT: boolean;
  53694. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  53695. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  53696. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  53697. INVERTCUBICMAP: boolean;
  53698. USESPHERICALFROMREFLECTIONMAP: boolean;
  53699. USEIRRADIANCEMAP: boolean;
  53700. SPHERICAL_HARMONICS: boolean;
  53701. USESPHERICALINVERTEX: boolean;
  53702. REFLECTIONMAP_OPPOSITEZ: boolean;
  53703. LODINREFLECTIONALPHA: boolean;
  53704. GAMMAREFLECTION: boolean;
  53705. RGBDREFLECTION: boolean;
  53706. LINEARSPECULARREFLECTION: boolean;
  53707. RADIANCEOCCLUSION: boolean;
  53708. HORIZONOCCLUSION: boolean;
  53709. INSTANCES: boolean;
  53710. NUM_BONE_INFLUENCERS: number;
  53711. BonesPerMesh: number;
  53712. BONETEXTURE: boolean;
  53713. NONUNIFORMSCALING: boolean;
  53714. MORPHTARGETS: boolean;
  53715. MORPHTARGETS_NORMAL: boolean;
  53716. MORPHTARGETS_TANGENT: boolean;
  53717. MORPHTARGETS_UV: boolean;
  53718. NUM_MORPH_INFLUENCERS: number;
  53719. IMAGEPROCESSING: boolean;
  53720. VIGNETTE: boolean;
  53721. VIGNETTEBLENDMODEMULTIPLY: boolean;
  53722. VIGNETTEBLENDMODEOPAQUE: boolean;
  53723. TONEMAPPING: boolean;
  53724. TONEMAPPING_ACES: boolean;
  53725. CONTRAST: boolean;
  53726. COLORCURVES: boolean;
  53727. COLORGRADING: boolean;
  53728. COLORGRADING3D: boolean;
  53729. SAMPLER3DGREENDEPTH: boolean;
  53730. SAMPLER3DBGRMAP: boolean;
  53731. IMAGEPROCESSINGPOSTPROCESS: boolean;
  53732. EXPOSURE: boolean;
  53733. MULTIVIEW: boolean;
  53734. USEPHYSICALLIGHTFALLOFF: boolean;
  53735. USEGLTFLIGHTFALLOFF: boolean;
  53736. TWOSIDEDLIGHTING: boolean;
  53737. SHADOWFLOAT: boolean;
  53738. CLIPPLANE: boolean;
  53739. CLIPPLANE2: boolean;
  53740. CLIPPLANE3: boolean;
  53741. CLIPPLANE4: boolean;
  53742. CLIPPLANE5: boolean;
  53743. CLIPPLANE6: boolean;
  53744. POINTSIZE: boolean;
  53745. FOG: boolean;
  53746. LOGARITHMICDEPTH: boolean;
  53747. FORCENORMALFORWARD: boolean;
  53748. SPECULARAA: boolean;
  53749. CLEARCOAT: boolean;
  53750. CLEARCOAT_DEFAULTIOR: boolean;
  53751. CLEARCOAT_TEXTURE: boolean;
  53752. CLEARCOAT_TEXTUREDIRECTUV: number;
  53753. CLEARCOAT_BUMP: boolean;
  53754. CLEARCOAT_BUMPDIRECTUV: number;
  53755. CLEARCOAT_TINT: boolean;
  53756. CLEARCOAT_TINT_TEXTURE: boolean;
  53757. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  53758. ANISOTROPIC: boolean;
  53759. ANISOTROPIC_TEXTURE: boolean;
  53760. ANISOTROPIC_TEXTUREDIRECTUV: number;
  53761. BRDF_V_HEIGHT_CORRELATED: boolean;
  53762. MS_BRDF_ENERGY_CONSERVATION: boolean;
  53763. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  53764. SHEEN: boolean;
  53765. SHEEN_TEXTURE: boolean;
  53766. SHEEN_TEXTUREDIRECTUV: number;
  53767. SHEEN_LINKWITHALBEDO: boolean;
  53768. SHEEN_ROUGHNESS: boolean;
  53769. SHEEN_ALBEDOSCALING: boolean;
  53770. SUBSURFACE: boolean;
  53771. SS_REFRACTION: boolean;
  53772. SS_TRANSLUCENCY: boolean;
  53773. SS_SCATERRING: boolean;
  53774. SS_THICKNESSANDMASK_TEXTURE: boolean;
  53775. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  53776. SS_REFRACTIONMAP_3D: boolean;
  53777. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  53778. SS_LODINREFRACTIONALPHA: boolean;
  53779. SS_GAMMAREFRACTION: boolean;
  53780. SS_RGBDREFRACTION: boolean;
  53781. SS_LINEARSPECULARREFRACTION: boolean;
  53782. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  53783. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  53784. UNLIT: boolean;
  53785. DEBUGMODE: number;
  53786. /**
  53787. * Initializes the PBR Material defines.
  53788. */
  53789. constructor();
  53790. /**
  53791. * Resets the PBR Material defines.
  53792. */
  53793. reset(): void;
  53794. }
  53795. /**
  53796. * The Physically based material base class of BJS.
  53797. *
  53798. * This offers the main features of a standard PBR material.
  53799. * For more information, please refer to the documentation :
  53800. * https://doc.babylonjs.com/how_to/physically_based_rendering
  53801. */
  53802. export abstract class PBRBaseMaterial extends PushMaterial {
  53803. /**
  53804. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53805. */
  53806. static readonly PBRMATERIAL_OPAQUE: number;
  53807. /**
  53808. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53809. */
  53810. static readonly PBRMATERIAL_ALPHATEST: number;
  53811. /**
  53812. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53813. */
  53814. static readonly PBRMATERIAL_ALPHABLEND: number;
  53815. /**
  53816. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53817. * They are also discarded below the alpha cutoff threshold to improve performances.
  53818. */
  53819. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  53820. /**
  53821. * Defines the default value of how much AO map is occluding the analytical lights
  53822. * (point spot...).
  53823. */
  53824. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  53825. /**
  53826. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  53827. */
  53828. static readonly LIGHTFALLOFF_PHYSICAL: number;
  53829. /**
  53830. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  53831. * to enhance interoperability with other engines.
  53832. */
  53833. static readonly LIGHTFALLOFF_GLTF: number;
  53834. /**
  53835. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  53836. * to enhance interoperability with other materials.
  53837. */
  53838. static readonly LIGHTFALLOFF_STANDARD: number;
  53839. /**
  53840. * Intensity of the direct lights e.g. the four lights available in your scene.
  53841. * This impacts both the direct diffuse and specular highlights.
  53842. */
  53843. protected _directIntensity: number;
  53844. /**
  53845. * Intensity of the emissive part of the material.
  53846. * This helps controlling the emissive effect without modifying the emissive color.
  53847. */
  53848. protected _emissiveIntensity: number;
  53849. /**
  53850. * Intensity of the environment e.g. how much the environment will light the object
  53851. * either through harmonics for rough material or through the refelction for shiny ones.
  53852. */
  53853. protected _environmentIntensity: number;
  53854. /**
  53855. * This is a special control allowing the reduction of the specular highlights coming from the
  53856. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  53857. */
  53858. protected _specularIntensity: number;
  53859. /**
  53860. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  53861. */
  53862. private _lightingInfos;
  53863. /**
  53864. * Debug Control allowing disabling the bump map on this material.
  53865. */
  53866. protected _disableBumpMap: boolean;
  53867. /**
  53868. * AKA Diffuse Texture in standard nomenclature.
  53869. */
  53870. protected _albedoTexture: Nullable<BaseTexture>;
  53871. /**
  53872. * AKA Occlusion Texture in other nomenclature.
  53873. */
  53874. protected _ambientTexture: Nullable<BaseTexture>;
  53875. /**
  53876. * AKA Occlusion Texture Intensity in other nomenclature.
  53877. */
  53878. protected _ambientTextureStrength: number;
  53879. /**
  53880. * Defines how much the AO map is occluding the analytical lights (point spot...).
  53881. * 1 means it completely occludes it
  53882. * 0 mean it has no impact
  53883. */
  53884. protected _ambientTextureImpactOnAnalyticalLights: number;
  53885. /**
  53886. * Stores the alpha values in a texture.
  53887. */
  53888. protected _opacityTexture: Nullable<BaseTexture>;
  53889. /**
  53890. * Stores the reflection values in a texture.
  53891. */
  53892. protected _reflectionTexture: Nullable<BaseTexture>;
  53893. /**
  53894. * Stores the emissive values in a texture.
  53895. */
  53896. protected _emissiveTexture: Nullable<BaseTexture>;
  53897. /**
  53898. * AKA Specular texture in other nomenclature.
  53899. */
  53900. protected _reflectivityTexture: Nullable<BaseTexture>;
  53901. /**
  53902. * Used to switch from specular/glossiness to metallic/roughness workflow.
  53903. */
  53904. protected _metallicTexture: Nullable<BaseTexture>;
  53905. /**
  53906. * Specifies the metallic scalar of the metallic/roughness workflow.
  53907. * Can also be used to scale the metalness values of the metallic texture.
  53908. */
  53909. protected _metallic: Nullable<number>;
  53910. /**
  53911. * Specifies the roughness scalar of the metallic/roughness workflow.
  53912. * Can also be used to scale the roughness values of the metallic texture.
  53913. */
  53914. protected _roughness: Nullable<number>;
  53915. /**
  53916. * Specifies the an F0 factor to help configuring the material F0.
  53917. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  53918. * to 0.5 the previously hard coded value stays the same.
  53919. * Can also be used to scale the F0 values of the metallic texture.
  53920. */
  53921. protected _metallicF0Factor: number;
  53922. /**
  53923. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  53924. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  53925. * your expectation as it multiplies with the texture data.
  53926. */
  53927. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  53928. /**
  53929. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  53930. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  53931. */
  53932. protected _microSurfaceTexture: Nullable<BaseTexture>;
  53933. /**
  53934. * Stores surface normal data used to displace a mesh in a texture.
  53935. */
  53936. protected _bumpTexture: Nullable<BaseTexture>;
  53937. /**
  53938. * Stores the pre-calculated light information of a mesh in a texture.
  53939. */
  53940. protected _lightmapTexture: Nullable<BaseTexture>;
  53941. /**
  53942. * The color of a material in ambient lighting.
  53943. */
  53944. protected _ambientColor: Color3;
  53945. /**
  53946. * AKA Diffuse Color in other nomenclature.
  53947. */
  53948. protected _albedoColor: Color3;
  53949. /**
  53950. * AKA Specular Color in other nomenclature.
  53951. */
  53952. protected _reflectivityColor: Color3;
  53953. /**
  53954. * The color applied when light is reflected from a material.
  53955. */
  53956. protected _reflectionColor: Color3;
  53957. /**
  53958. * The color applied when light is emitted from a material.
  53959. */
  53960. protected _emissiveColor: Color3;
  53961. /**
  53962. * AKA Glossiness in other nomenclature.
  53963. */
  53964. protected _microSurface: number;
  53965. /**
  53966. * Specifies that the material will use the light map as a show map.
  53967. */
  53968. protected _useLightmapAsShadowmap: boolean;
  53969. /**
  53970. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  53971. * makes the reflect vector face the model (under horizon).
  53972. */
  53973. protected _useHorizonOcclusion: boolean;
  53974. /**
  53975. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  53976. * too much the area relying on ambient texture to define their ambient occlusion.
  53977. */
  53978. protected _useRadianceOcclusion: boolean;
  53979. /**
  53980. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  53981. */
  53982. protected _useAlphaFromAlbedoTexture: boolean;
  53983. /**
  53984. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  53985. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  53986. */
  53987. protected _useSpecularOverAlpha: boolean;
  53988. /**
  53989. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  53990. */
  53991. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  53992. /**
  53993. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  53994. */
  53995. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  53996. /**
  53997. * Specifies if the metallic texture contains the roughness information in its green channel.
  53998. */
  53999. protected _useRoughnessFromMetallicTextureGreen: boolean;
  54000. /**
  54001. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54002. */
  54003. protected _useMetallnessFromMetallicTextureBlue: boolean;
  54004. /**
  54005. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54006. */
  54007. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  54008. /**
  54009. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54010. */
  54011. protected _useAmbientInGrayScale: boolean;
  54012. /**
  54013. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54014. * The material will try to infer what glossiness each pixel should be.
  54015. */
  54016. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  54017. /**
  54018. * Defines the falloff type used in this material.
  54019. * It by default is Physical.
  54020. */
  54021. protected _lightFalloff: number;
  54022. /**
  54023. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54024. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54025. */
  54026. protected _useRadianceOverAlpha: boolean;
  54027. /**
  54028. * Allows using an object space normal map (instead of tangent space).
  54029. */
  54030. protected _useObjectSpaceNormalMap: boolean;
  54031. /**
  54032. * Allows using the bump map in parallax mode.
  54033. */
  54034. protected _useParallax: boolean;
  54035. /**
  54036. * Allows using the bump map in parallax occlusion mode.
  54037. */
  54038. protected _useParallaxOcclusion: boolean;
  54039. /**
  54040. * Controls the scale bias of the parallax mode.
  54041. */
  54042. protected _parallaxScaleBias: number;
  54043. /**
  54044. * If sets to true, disables all the lights affecting the material.
  54045. */
  54046. protected _disableLighting: boolean;
  54047. /**
  54048. * Number of Simultaneous lights allowed on the material.
  54049. */
  54050. protected _maxSimultaneousLights: number;
  54051. /**
  54052. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  54053. */
  54054. protected _invertNormalMapX: boolean;
  54055. /**
  54056. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  54057. */
  54058. protected _invertNormalMapY: boolean;
  54059. /**
  54060. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54061. */
  54062. protected _twoSidedLighting: boolean;
  54063. /**
  54064. * Defines the alpha limits in alpha test mode.
  54065. */
  54066. protected _alphaCutOff: number;
  54067. /**
  54068. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54069. */
  54070. protected _forceAlphaTest: boolean;
  54071. /**
  54072. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54073. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54074. */
  54075. protected _useAlphaFresnel: boolean;
  54076. /**
  54077. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54078. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54079. */
  54080. protected _useLinearAlphaFresnel: boolean;
  54081. /**
  54082. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  54083. * from cos thetav and roughness:
  54084. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  54085. */
  54086. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  54087. /**
  54088. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54089. */
  54090. protected _forceIrradianceInFragment: boolean;
  54091. /**
  54092. * Force normal to face away from face.
  54093. */
  54094. protected _forceNormalForward: boolean;
  54095. /**
  54096. * Enables specular anti aliasing in the PBR shader.
  54097. * It will both interacts on the Geometry for analytical and IBL lighting.
  54098. * It also prefilter the roughness map based on the bump values.
  54099. */
  54100. protected _enableSpecularAntiAliasing: boolean;
  54101. /**
  54102. * Default configuration related to image processing available in the PBR Material.
  54103. */
  54104. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  54105. /**
  54106. * Keep track of the image processing observer to allow dispose and replace.
  54107. */
  54108. private _imageProcessingObserver;
  54109. /**
  54110. * Attaches a new image processing configuration to the PBR Material.
  54111. * @param configuration
  54112. */
  54113. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  54114. /**
  54115. * Stores the available render targets.
  54116. */
  54117. private _renderTargets;
  54118. /**
  54119. * Sets the global ambient color for the material used in lighting calculations.
  54120. */
  54121. private _globalAmbientColor;
  54122. /**
  54123. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  54124. */
  54125. private _useLogarithmicDepth;
  54126. /**
  54127. * If set to true, no lighting calculations will be applied.
  54128. */
  54129. private _unlit;
  54130. private _debugMode;
  54131. /**
  54132. * @hidden
  54133. * This is reserved for the inspector.
  54134. * Defines the material debug mode.
  54135. * It helps seeing only some components of the material while troubleshooting.
  54136. */
  54137. debugMode: number;
  54138. /**
  54139. * @hidden
  54140. * This is reserved for the inspector.
  54141. * Specify from where on screen the debug mode should start.
  54142. * The value goes from -1 (full screen) to 1 (not visible)
  54143. * It helps with side by side comparison against the final render
  54144. * This defaults to -1
  54145. */
  54146. private debugLimit;
  54147. /**
  54148. * @hidden
  54149. * This is reserved for the inspector.
  54150. * As the default viewing range might not be enough (if the ambient is really small for instance)
  54151. * You can use the factor to better multiply the final value.
  54152. */
  54153. private debugFactor;
  54154. /**
  54155. * Defines the clear coat layer parameters for the material.
  54156. */
  54157. readonly clearCoat: PBRClearCoatConfiguration;
  54158. /**
  54159. * Defines the anisotropic parameters for the material.
  54160. */
  54161. readonly anisotropy: PBRAnisotropicConfiguration;
  54162. /**
  54163. * Defines the BRDF parameters for the material.
  54164. */
  54165. readonly brdf: PBRBRDFConfiguration;
  54166. /**
  54167. * Defines the Sheen parameters for the material.
  54168. */
  54169. readonly sheen: PBRSheenConfiguration;
  54170. /**
  54171. * Defines the SubSurface parameters for the material.
  54172. */
  54173. readonly subSurface: PBRSubSurfaceConfiguration;
  54174. /**
  54175. * Custom callback helping to override the default shader used in the material.
  54176. */
  54177. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  54178. protected _rebuildInParallel: boolean;
  54179. /**
  54180. * Instantiates a new PBRMaterial instance.
  54181. *
  54182. * @param name The material name
  54183. * @param scene The scene the material will be use in.
  54184. */
  54185. constructor(name: string, scene: Scene);
  54186. /**
  54187. * Gets a boolean indicating that current material needs to register RTT
  54188. */
  54189. get hasRenderTargetTextures(): boolean;
  54190. /**
  54191. * Gets the name of the material class.
  54192. */
  54193. getClassName(): string;
  54194. /**
  54195. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54196. */
  54197. get useLogarithmicDepth(): boolean;
  54198. /**
  54199. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  54200. */
  54201. set useLogarithmicDepth(value: boolean);
  54202. /**
  54203. * Returns true if alpha blending should be disabled.
  54204. */
  54205. protected get _disableAlphaBlending(): boolean;
  54206. /**
  54207. * Specifies whether or not this material should be rendered in alpha blend mode.
  54208. */
  54209. needAlphaBlending(): boolean;
  54210. /**
  54211. * Specifies whether or not this material should be rendered in alpha test mode.
  54212. */
  54213. needAlphaTesting(): boolean;
  54214. /**
  54215. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  54216. */
  54217. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  54218. /**
  54219. * Gets the texture used for the alpha test.
  54220. */
  54221. getAlphaTestTexture(): Nullable<BaseTexture>;
  54222. /**
  54223. * Specifies that the submesh is ready to be used.
  54224. * @param mesh - BJS mesh.
  54225. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  54226. * @param useInstances - Specifies that instances should be used.
  54227. * @returns - boolean indicating that the submesh is ready or not.
  54228. */
  54229. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  54230. /**
  54231. * Specifies if the material uses metallic roughness workflow.
  54232. * @returns boolean specifiying if the material uses metallic roughness workflow.
  54233. */
  54234. isMetallicWorkflow(): boolean;
  54235. private _prepareEffect;
  54236. private _prepareDefines;
  54237. /**
  54238. * Force shader compilation
  54239. */
  54240. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  54241. /**
  54242. * Initializes the uniform buffer layout for the shader.
  54243. */
  54244. buildUniformLayout(): void;
  54245. /**
  54246. * Unbinds the material from the mesh
  54247. */
  54248. unbind(): void;
  54249. /**
  54250. * Binds the submesh data.
  54251. * @param world - The world matrix.
  54252. * @param mesh - The BJS mesh.
  54253. * @param subMesh - A submesh of the BJS mesh.
  54254. */
  54255. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  54256. /**
  54257. * Returns the animatable textures.
  54258. * @returns - Array of animatable textures.
  54259. */
  54260. getAnimatables(): IAnimatable[];
  54261. /**
  54262. * Returns the texture used for reflections.
  54263. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  54264. */
  54265. private _getReflectionTexture;
  54266. /**
  54267. * Returns an array of the actively used textures.
  54268. * @returns - Array of BaseTextures
  54269. */
  54270. getActiveTextures(): BaseTexture[];
  54271. /**
  54272. * Checks to see if a texture is used in the material.
  54273. * @param texture - Base texture to use.
  54274. * @returns - Boolean specifying if a texture is used in the material.
  54275. */
  54276. hasTexture(texture: BaseTexture): boolean;
  54277. /**
  54278. * Disposes the resources of the material.
  54279. * @param forceDisposeEffect - Forces the disposal of effects.
  54280. * @param forceDisposeTextures - Forces the disposal of all textures.
  54281. */
  54282. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  54283. }
  54284. }
  54285. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  54286. import { Nullable } from "babylonjs/types";
  54287. import { Scene } from "babylonjs/scene";
  54288. import { Color3 } from "babylonjs/Maths/math.color";
  54289. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  54290. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  54291. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54292. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  54293. /**
  54294. * The Physically based material of BJS.
  54295. *
  54296. * This offers the main features of a standard PBR material.
  54297. * For more information, please refer to the documentation :
  54298. * https://doc.babylonjs.com/how_to/physically_based_rendering
  54299. */
  54300. export class PBRMaterial extends PBRBaseMaterial {
  54301. /**
  54302. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  54303. */
  54304. static readonly PBRMATERIAL_OPAQUE: number;
  54305. /**
  54306. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  54307. */
  54308. static readonly PBRMATERIAL_ALPHATEST: number;
  54309. /**
  54310. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54311. */
  54312. static readonly PBRMATERIAL_ALPHABLEND: number;
  54313. /**
  54314. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  54315. * They are also discarded below the alpha cutoff threshold to improve performances.
  54316. */
  54317. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  54318. /**
  54319. * Defines the default value of how much AO map is occluding the analytical lights
  54320. * (point spot...).
  54321. */
  54322. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  54323. /**
  54324. * Intensity of the direct lights e.g. the four lights available in your scene.
  54325. * This impacts both the direct diffuse and specular highlights.
  54326. */
  54327. directIntensity: number;
  54328. /**
  54329. * Intensity of the emissive part of the material.
  54330. * This helps controlling the emissive effect without modifying the emissive color.
  54331. */
  54332. emissiveIntensity: number;
  54333. /**
  54334. * Intensity of the environment e.g. how much the environment will light the object
  54335. * either through harmonics for rough material or through the refelction for shiny ones.
  54336. */
  54337. environmentIntensity: number;
  54338. /**
  54339. * This is a special control allowing the reduction of the specular highlights coming from the
  54340. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  54341. */
  54342. specularIntensity: number;
  54343. /**
  54344. * Debug Control allowing disabling the bump map on this material.
  54345. */
  54346. disableBumpMap: boolean;
  54347. /**
  54348. * AKA Diffuse Texture in standard nomenclature.
  54349. */
  54350. albedoTexture: BaseTexture;
  54351. /**
  54352. * AKA Occlusion Texture in other nomenclature.
  54353. */
  54354. ambientTexture: BaseTexture;
  54355. /**
  54356. * AKA Occlusion Texture Intensity in other nomenclature.
  54357. */
  54358. ambientTextureStrength: number;
  54359. /**
  54360. * Defines how much the AO map is occluding the analytical lights (point spot...).
  54361. * 1 means it completely occludes it
  54362. * 0 mean it has no impact
  54363. */
  54364. ambientTextureImpactOnAnalyticalLights: number;
  54365. /**
  54366. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  54367. */
  54368. opacityTexture: BaseTexture;
  54369. /**
  54370. * Stores the reflection values in a texture.
  54371. */
  54372. reflectionTexture: Nullable<BaseTexture>;
  54373. /**
  54374. * Stores the emissive values in a texture.
  54375. */
  54376. emissiveTexture: BaseTexture;
  54377. /**
  54378. * AKA Specular texture in other nomenclature.
  54379. */
  54380. reflectivityTexture: BaseTexture;
  54381. /**
  54382. * Used to switch from specular/glossiness to metallic/roughness workflow.
  54383. */
  54384. metallicTexture: BaseTexture;
  54385. /**
  54386. * Specifies the metallic scalar of the metallic/roughness workflow.
  54387. * Can also be used to scale the metalness values of the metallic texture.
  54388. */
  54389. metallic: Nullable<number>;
  54390. /**
  54391. * Specifies the roughness scalar of the metallic/roughness workflow.
  54392. * Can also be used to scale the roughness values of the metallic texture.
  54393. */
  54394. roughness: Nullable<number>;
  54395. /**
  54396. * Specifies the an F0 factor to help configuring the material F0.
  54397. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  54398. * to 0.5 the previously hard coded value stays the same.
  54399. * Can also be used to scale the F0 values of the metallic texture.
  54400. */
  54401. metallicF0Factor: number;
  54402. /**
  54403. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  54404. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  54405. * your expectation as it multiplies with the texture data.
  54406. */
  54407. useMetallicF0FactorFromMetallicTexture: boolean;
  54408. /**
  54409. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  54410. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  54411. */
  54412. microSurfaceTexture: BaseTexture;
  54413. /**
  54414. * Stores surface normal data used to displace a mesh in a texture.
  54415. */
  54416. bumpTexture: BaseTexture;
  54417. /**
  54418. * Stores the pre-calculated light information of a mesh in a texture.
  54419. */
  54420. lightmapTexture: BaseTexture;
  54421. /**
  54422. * Stores the refracted light information in a texture.
  54423. */
  54424. get refractionTexture(): Nullable<BaseTexture>;
  54425. set refractionTexture(value: Nullable<BaseTexture>);
  54426. /**
  54427. * The color of a material in ambient lighting.
  54428. */
  54429. ambientColor: Color3;
  54430. /**
  54431. * AKA Diffuse Color in other nomenclature.
  54432. */
  54433. albedoColor: Color3;
  54434. /**
  54435. * AKA Specular Color in other nomenclature.
  54436. */
  54437. reflectivityColor: Color3;
  54438. /**
  54439. * The color reflected from the material.
  54440. */
  54441. reflectionColor: Color3;
  54442. /**
  54443. * The color emitted from the material.
  54444. */
  54445. emissiveColor: Color3;
  54446. /**
  54447. * AKA Glossiness in other nomenclature.
  54448. */
  54449. microSurface: number;
  54450. /**
  54451. * source material index of refraction (IOR)' / 'destination material IOR.
  54452. */
  54453. get indexOfRefraction(): number;
  54454. set indexOfRefraction(value: number);
  54455. /**
  54456. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  54457. */
  54458. get invertRefractionY(): boolean;
  54459. set invertRefractionY(value: boolean);
  54460. /**
  54461. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  54462. * Materials half opaque for instance using refraction could benefit from this control.
  54463. */
  54464. get linkRefractionWithTransparency(): boolean;
  54465. set linkRefractionWithTransparency(value: boolean);
  54466. /**
  54467. * If true, the light map contains occlusion information instead of lighting info.
  54468. */
  54469. useLightmapAsShadowmap: boolean;
  54470. /**
  54471. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  54472. */
  54473. useAlphaFromAlbedoTexture: boolean;
  54474. /**
  54475. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  54476. */
  54477. forceAlphaTest: boolean;
  54478. /**
  54479. * Defines the alpha limits in alpha test mode.
  54480. */
  54481. alphaCutOff: number;
  54482. /**
  54483. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  54484. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  54485. */
  54486. useSpecularOverAlpha: boolean;
  54487. /**
  54488. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  54489. */
  54490. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  54491. /**
  54492. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  54493. */
  54494. useRoughnessFromMetallicTextureAlpha: boolean;
  54495. /**
  54496. * Specifies if the metallic texture contains the roughness information in its green channel.
  54497. */
  54498. useRoughnessFromMetallicTextureGreen: boolean;
  54499. /**
  54500. * Specifies if the metallic texture contains the metallness information in its blue channel.
  54501. */
  54502. useMetallnessFromMetallicTextureBlue: boolean;
  54503. /**
  54504. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  54505. */
  54506. useAmbientOcclusionFromMetallicTextureRed: boolean;
  54507. /**
  54508. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  54509. */
  54510. useAmbientInGrayScale: boolean;
  54511. /**
  54512. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  54513. * The material will try to infer what glossiness each pixel should be.
  54514. */
  54515. useAutoMicroSurfaceFromReflectivityMap: boolean;
  54516. /**
  54517. * BJS is using an harcoded light falloff based on a manually sets up range.
  54518. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54519. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54520. */
  54521. get usePhysicalLightFalloff(): boolean;
  54522. /**
  54523. * BJS is using an harcoded light falloff based on a manually sets up range.
  54524. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  54525. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  54526. */
  54527. set usePhysicalLightFalloff(value: boolean);
  54528. /**
  54529. * In order to support the falloff compatibility with gltf, a special mode has been added
  54530. * to reproduce the gltf light falloff.
  54531. */
  54532. get useGLTFLightFalloff(): boolean;
  54533. /**
  54534. * In order to support the falloff compatibility with gltf, a special mode has been added
  54535. * to reproduce the gltf light falloff.
  54536. */
  54537. set useGLTFLightFalloff(value: boolean);
  54538. /**
  54539. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  54540. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  54541. */
  54542. useRadianceOverAlpha: boolean;
  54543. /**
  54544. * Allows using an object space normal map (instead of tangent space).
  54545. */
  54546. useObjectSpaceNormalMap: boolean;
  54547. /**
  54548. * Allows using the bump map in parallax mode.
  54549. */
  54550. useParallax: boolean;
  54551. /**
  54552. * Allows using the bump map in parallax occlusion mode.
  54553. */
  54554. useParallaxOcclusion: boolean;
  54555. /**
  54556. * Controls the scale bias of the parallax mode.
  54557. */
  54558. parallaxScaleBias: number;
  54559. /**
  54560. * If sets to true, disables all the lights affecting the material.
  54561. */
  54562. disableLighting: boolean;
  54563. /**
  54564. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  54565. */
  54566. forceIrradianceInFragment: boolean;
  54567. /**
  54568. * Number of Simultaneous lights allowed on the material.
  54569. */
  54570. maxSimultaneousLights: number;
  54571. /**
  54572. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  54573. */
  54574. invertNormalMapX: boolean;
  54575. /**
  54576. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  54577. */
  54578. invertNormalMapY: boolean;
  54579. /**
  54580. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  54581. */
  54582. twoSidedLighting: boolean;
  54583. /**
  54584. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54585. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  54586. */
  54587. useAlphaFresnel: boolean;
  54588. /**
  54589. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  54590. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  54591. */
  54592. useLinearAlphaFresnel: boolean;
  54593. /**
  54594. * Let user defines the brdf lookup texture used for IBL.
  54595. * A default 8bit version is embedded but you could point at :
  54596. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  54597. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  54598. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  54599. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  54600. */
  54601. environmentBRDFTexture: Nullable<BaseTexture>;
  54602. /**
  54603. * Force normal to face away from face.
  54604. */
  54605. forceNormalForward: boolean;
  54606. /**
  54607. * Enables specular anti aliasing in the PBR shader.
  54608. * It will both interacts on the Geometry for analytical and IBL lighting.
  54609. * It also prefilter the roughness map based on the bump values.
  54610. */
  54611. enableSpecularAntiAliasing: boolean;
  54612. /**
  54613. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  54614. * makes the reflect vector face the model (under horizon).
  54615. */
  54616. useHorizonOcclusion: boolean;
  54617. /**
  54618. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  54619. * too much the area relying on ambient texture to define their ambient occlusion.
  54620. */
  54621. useRadianceOcclusion: boolean;
  54622. /**
  54623. * If set to true, no lighting calculations will be applied.
  54624. */
  54625. unlit: boolean;
  54626. /**
  54627. * Gets the image processing configuration used either in this material.
  54628. */
  54629. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  54630. /**
  54631. * Sets the Default image processing configuration used either in the this material.
  54632. *
  54633. * If sets to null, the scene one is in use.
  54634. */
  54635. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  54636. /**
  54637. * Gets wether the color curves effect is enabled.
  54638. */
  54639. get cameraColorCurvesEnabled(): boolean;
  54640. /**
  54641. * Sets wether the color curves effect is enabled.
  54642. */
  54643. set cameraColorCurvesEnabled(value: boolean);
  54644. /**
  54645. * Gets wether the color grading effect is enabled.
  54646. */
  54647. get cameraColorGradingEnabled(): boolean;
  54648. /**
  54649. * Gets wether the color grading effect is enabled.
  54650. */
  54651. set cameraColorGradingEnabled(value: boolean);
  54652. /**
  54653. * Gets wether tonemapping is enabled or not.
  54654. */
  54655. get cameraToneMappingEnabled(): boolean;
  54656. /**
  54657. * Sets wether tonemapping is enabled or not
  54658. */
  54659. set cameraToneMappingEnabled(value: boolean);
  54660. /**
  54661. * The camera exposure used on this material.
  54662. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54663. * This corresponds to a photographic exposure.
  54664. */
  54665. get cameraExposure(): number;
  54666. /**
  54667. * The camera exposure used on this material.
  54668. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  54669. * This corresponds to a photographic exposure.
  54670. */
  54671. set cameraExposure(value: number);
  54672. /**
  54673. * Gets The camera contrast used on this material.
  54674. */
  54675. get cameraContrast(): number;
  54676. /**
  54677. * Sets The camera contrast used on this material.
  54678. */
  54679. set cameraContrast(value: number);
  54680. /**
  54681. * Gets the Color Grading 2D Lookup Texture.
  54682. */
  54683. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  54684. /**
  54685. * Sets the Color Grading 2D Lookup Texture.
  54686. */
  54687. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  54688. /**
  54689. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54690. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54691. * 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;
  54692. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54693. */
  54694. get cameraColorCurves(): Nullable<ColorCurves>;
  54695. /**
  54696. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  54697. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  54698. * 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;
  54699. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  54700. */
  54701. set cameraColorCurves(value: Nullable<ColorCurves>);
  54702. /**
  54703. * Instantiates a new PBRMaterial instance.
  54704. *
  54705. * @param name The material name
  54706. * @param scene The scene the material will be use in.
  54707. */
  54708. constructor(name: string, scene: Scene);
  54709. /**
  54710. * Returns the name of this material class.
  54711. */
  54712. getClassName(): string;
  54713. /**
  54714. * Makes a duplicate of the current material.
  54715. * @param name - name to use for the new material.
  54716. */
  54717. clone(name: string): PBRMaterial;
  54718. /**
  54719. * Serializes this PBR Material.
  54720. * @returns - An object with the serialized material.
  54721. */
  54722. serialize(): any;
  54723. /**
  54724. * Parses a PBR Material from a serialized object.
  54725. * @param source - Serialized object.
  54726. * @param scene - BJS scene instance.
  54727. * @param rootUrl - url for the scene object
  54728. * @returns - PBRMaterial
  54729. */
  54730. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  54731. }
  54732. }
  54733. declare module "babylonjs/Misc/dds" {
  54734. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54735. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54736. import { Nullable } from "babylonjs/types";
  54737. import { Scene } from "babylonjs/scene";
  54738. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  54739. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  54740. /**
  54741. * Direct draw surface info
  54742. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  54743. */
  54744. export interface DDSInfo {
  54745. /**
  54746. * Width of the texture
  54747. */
  54748. width: number;
  54749. /**
  54750. * Width of the texture
  54751. */
  54752. height: number;
  54753. /**
  54754. * Number of Mipmaps for the texture
  54755. * @see https://en.wikipedia.org/wiki/Mipmap
  54756. */
  54757. mipmapCount: number;
  54758. /**
  54759. * If the textures format is a known fourCC format
  54760. * @see https://www.fourcc.org/
  54761. */
  54762. isFourCC: boolean;
  54763. /**
  54764. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  54765. */
  54766. isRGB: boolean;
  54767. /**
  54768. * If the texture is a lumincance format
  54769. */
  54770. isLuminance: boolean;
  54771. /**
  54772. * If this is a cube texture
  54773. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  54774. */
  54775. isCube: boolean;
  54776. /**
  54777. * If the texture is a compressed format eg. FOURCC_DXT1
  54778. */
  54779. isCompressed: boolean;
  54780. /**
  54781. * The dxgiFormat of the texture
  54782. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  54783. */
  54784. dxgiFormat: number;
  54785. /**
  54786. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  54787. */
  54788. textureType: number;
  54789. /**
  54790. * Sphericle polynomial created for the dds texture
  54791. */
  54792. sphericalPolynomial?: SphericalPolynomial;
  54793. }
  54794. /**
  54795. * Class used to provide DDS decompression tools
  54796. */
  54797. export class DDSTools {
  54798. /**
  54799. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  54800. */
  54801. static StoreLODInAlphaChannel: boolean;
  54802. /**
  54803. * Gets DDS information from an array buffer
  54804. * @param data defines the array buffer view to read data from
  54805. * @returns the DDS information
  54806. */
  54807. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  54808. private static _FloatView;
  54809. private static _Int32View;
  54810. private static _ToHalfFloat;
  54811. private static _FromHalfFloat;
  54812. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  54813. private static _GetHalfFloatRGBAArrayBuffer;
  54814. private static _GetFloatRGBAArrayBuffer;
  54815. private static _GetFloatAsUIntRGBAArrayBuffer;
  54816. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  54817. private static _GetRGBAArrayBuffer;
  54818. private static _ExtractLongWordOrder;
  54819. private static _GetRGBArrayBuffer;
  54820. private static _GetLuminanceArrayBuffer;
  54821. /**
  54822. * Uploads DDS Levels to a Babylon Texture
  54823. * @hidden
  54824. */
  54825. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  54826. }
  54827. module "babylonjs/Engines/thinEngine" {
  54828. interface ThinEngine {
  54829. /**
  54830. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  54831. * @param rootUrl defines the url where the file to load is located
  54832. * @param scene defines the current scene
  54833. * @param lodScale defines scale to apply to the mip map selection
  54834. * @param lodOffset defines offset to apply to the mip map selection
  54835. * @param onLoad defines an optional callback raised when the texture is loaded
  54836. * @param onError defines an optional callback raised if there is an issue to load the texture
  54837. * @param format defines the format of the data
  54838. * @param forcedExtension defines the extension to use to pick the right loader
  54839. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  54840. * @returns the cube texture as an InternalTexture
  54841. */
  54842. 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;
  54843. }
  54844. }
  54845. }
  54846. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  54847. import { Nullable } from "babylonjs/types";
  54848. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54849. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54850. /**
  54851. * Implementation of the DDS Texture Loader.
  54852. * @hidden
  54853. */
  54854. export class _DDSTextureLoader implements IInternalTextureLoader {
  54855. /**
  54856. * Defines wether the loader supports cascade loading the different faces.
  54857. */
  54858. readonly supportCascades: boolean;
  54859. /**
  54860. * This returns if the loader support the current file information.
  54861. * @param extension defines the file extension of the file being loaded
  54862. * @returns true if the loader can load the specified file
  54863. */
  54864. canLoad(extension: string): boolean;
  54865. /**
  54866. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54867. * @param data contains the texture data
  54868. * @param texture defines the BabylonJS internal texture
  54869. * @param createPolynomials will be true if polynomials have been requested
  54870. * @param onLoad defines the callback to trigger once the texture is ready
  54871. * @param onError defines the callback to trigger in case of error
  54872. */
  54873. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54874. /**
  54875. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54876. * @param data contains the texture data
  54877. * @param texture defines the BabylonJS internal texture
  54878. * @param callback defines the method to call once ready to upload
  54879. */
  54880. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54881. }
  54882. }
  54883. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  54884. import { Nullable } from "babylonjs/types";
  54885. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54886. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  54887. /**
  54888. * Implementation of the ENV Texture Loader.
  54889. * @hidden
  54890. */
  54891. export class _ENVTextureLoader implements IInternalTextureLoader {
  54892. /**
  54893. * Defines wether the loader supports cascade loading the different faces.
  54894. */
  54895. readonly supportCascades: boolean;
  54896. /**
  54897. * This returns if the loader support the current file information.
  54898. * @param extension defines the file extension of the file being loaded
  54899. * @returns true if the loader can load the specified file
  54900. */
  54901. canLoad(extension: string): boolean;
  54902. /**
  54903. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  54904. * @param data contains the texture data
  54905. * @param texture defines the BabylonJS internal texture
  54906. * @param createPolynomials will be true if polynomials have been requested
  54907. * @param onLoad defines the callback to trigger once the texture is ready
  54908. * @param onError defines the callback to trigger in case of error
  54909. */
  54910. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  54911. /**
  54912. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  54913. * @param data contains the texture data
  54914. * @param texture defines the BabylonJS internal texture
  54915. * @param callback defines the method to call once ready to upload
  54916. */
  54917. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  54918. }
  54919. }
  54920. declare module "babylonjs/Misc/khronosTextureContainer" {
  54921. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54922. /**
  54923. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54924. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54925. */
  54926. export class KhronosTextureContainer {
  54927. /** contents of the KTX container file */
  54928. data: ArrayBufferView;
  54929. private static HEADER_LEN;
  54930. private static COMPRESSED_2D;
  54931. private static COMPRESSED_3D;
  54932. private static TEX_2D;
  54933. private static TEX_3D;
  54934. /**
  54935. * Gets the openGL type
  54936. */
  54937. glType: number;
  54938. /**
  54939. * Gets the openGL type size
  54940. */
  54941. glTypeSize: number;
  54942. /**
  54943. * Gets the openGL format
  54944. */
  54945. glFormat: number;
  54946. /**
  54947. * Gets the openGL internal format
  54948. */
  54949. glInternalFormat: number;
  54950. /**
  54951. * Gets the base internal format
  54952. */
  54953. glBaseInternalFormat: number;
  54954. /**
  54955. * Gets image width in pixel
  54956. */
  54957. pixelWidth: number;
  54958. /**
  54959. * Gets image height in pixel
  54960. */
  54961. pixelHeight: number;
  54962. /**
  54963. * Gets image depth in pixels
  54964. */
  54965. pixelDepth: number;
  54966. /**
  54967. * Gets the number of array elements
  54968. */
  54969. numberOfArrayElements: number;
  54970. /**
  54971. * Gets the number of faces
  54972. */
  54973. numberOfFaces: number;
  54974. /**
  54975. * Gets the number of mipmap levels
  54976. */
  54977. numberOfMipmapLevels: number;
  54978. /**
  54979. * Gets the bytes of key value data
  54980. */
  54981. bytesOfKeyValueData: number;
  54982. /**
  54983. * Gets the load type
  54984. */
  54985. loadType: number;
  54986. /**
  54987. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  54988. */
  54989. isInvalid: boolean;
  54990. /**
  54991. * Creates a new KhronosTextureContainer
  54992. * @param data contents of the KTX container file
  54993. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  54994. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  54995. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  54996. */
  54997. constructor(
  54998. /** contents of the KTX container file */
  54999. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  55000. /**
  55001. * Uploads KTX content to a Babylon Texture.
  55002. * It is assumed that the texture has already been created & is currently bound
  55003. * @hidden
  55004. */
  55005. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  55006. private _upload2DCompressedLevels;
  55007. /**
  55008. * Checks if the given data starts with a KTX file identifier.
  55009. * @param data the data to check
  55010. * @returns true if the data is a KTX file or false otherwise
  55011. */
  55012. static IsValid(data: ArrayBufferView): boolean;
  55013. }
  55014. }
  55015. declare module "babylonjs/Misc/khronosTextureContainer2" {
  55016. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55017. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  55018. /**
  55019. * Class for loading KTX2 files
  55020. * !!! Experimental Extension Subject to Changes !!!
  55021. * @hidden
  55022. */
  55023. export class KhronosTextureContainer2 {
  55024. private static _ModulePromise;
  55025. private static _TranscodeFormat;
  55026. constructor(engine: ThinEngine);
  55027. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  55028. private _determineTranscodeFormat;
  55029. /**
  55030. * Checks if the given data starts with a KTX2 file identifier.
  55031. * @param data the data to check
  55032. * @returns true if the data is a KTX2 file or false otherwise
  55033. */
  55034. static IsValid(data: ArrayBufferView): boolean;
  55035. }
  55036. }
  55037. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  55038. import { Nullable } from "babylonjs/types";
  55039. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55040. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  55041. /**
  55042. * Implementation of the KTX Texture Loader.
  55043. * @hidden
  55044. */
  55045. export class _KTXTextureLoader implements IInternalTextureLoader {
  55046. /**
  55047. * Defines wether the loader supports cascade loading the different faces.
  55048. */
  55049. readonly supportCascades: boolean;
  55050. /**
  55051. * This returns if the loader support the current file information.
  55052. * @param extension defines the file extension of the file being loaded
  55053. * @returns true if the loader can load the specified file
  55054. */
  55055. canLoad(extension: string): boolean;
  55056. /**
  55057. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  55058. * @param data contains the texture data
  55059. * @param texture defines the BabylonJS internal texture
  55060. * @param createPolynomials will be true if polynomials have been requested
  55061. * @param onLoad defines the callback to trigger once the texture is ready
  55062. * @param onError defines the callback to trigger in case of error
  55063. */
  55064. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  55065. /**
  55066. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  55067. * @param data contains the texture data
  55068. * @param texture defines the BabylonJS internal texture
  55069. * @param callback defines the method to call once ready to upload
  55070. */
  55071. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  55072. }
  55073. }
  55074. declare module "babylonjs/Helpers/sceneHelpers" {
  55075. import { Nullable } from "babylonjs/types";
  55076. import { Mesh } from "babylonjs/Meshes/mesh";
  55077. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55078. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  55079. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  55080. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  55081. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  55082. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  55083. import "babylonjs/Meshes/Builders/boxBuilder";
  55084. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  55085. /** @hidden */
  55086. export var _forceSceneHelpersToBundle: boolean;
  55087. module "babylonjs/scene" {
  55088. interface Scene {
  55089. /**
  55090. * Creates a default light for the scene.
  55091. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  55092. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  55093. */
  55094. createDefaultLight(replace?: boolean): void;
  55095. /**
  55096. * Creates a default camera for the scene.
  55097. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  55098. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55099. * @param replace has default false, when true replaces the active camera in the scene
  55100. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  55101. */
  55102. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55103. /**
  55104. * Creates a default camera and a default light.
  55105. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  55106. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  55107. * @param replace has the default false, when true replaces the active camera/light in the scene
  55108. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  55109. */
  55110. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  55111. /**
  55112. * Creates a new sky box
  55113. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  55114. * @param environmentTexture defines the texture to use as environment texture
  55115. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  55116. * @param scale defines the overall scale of the skybox
  55117. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  55118. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  55119. * @returns a new mesh holding the sky box
  55120. */
  55121. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  55122. /**
  55123. * Creates a new environment
  55124. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  55125. * @param options defines the options you can use to configure the environment
  55126. * @returns the new EnvironmentHelper
  55127. */
  55128. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  55129. /**
  55130. * Creates a new VREXperienceHelper
  55131. * @see http://doc.babylonjs.com/how_to/webvr_helper
  55132. * @param webVROptions defines the options used to create the new VREXperienceHelper
  55133. * @returns a new VREXperienceHelper
  55134. */
  55135. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  55136. /**
  55137. * Creates a new WebXRDefaultExperience
  55138. * @see http://doc.babylonjs.com/how_to/webxr
  55139. * @param options experience options
  55140. * @returns a promise for a new WebXRDefaultExperience
  55141. */
  55142. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  55143. }
  55144. }
  55145. }
  55146. declare module "babylonjs/Helpers/videoDome" {
  55147. import { Scene } from "babylonjs/scene";
  55148. import { TransformNode } from "babylonjs/Meshes/transformNode";
  55149. import { Mesh } from "babylonjs/Meshes/mesh";
  55150. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  55151. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  55152. import "babylonjs/Meshes/Builders/sphereBuilder";
  55153. /**
  55154. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  55155. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  55156. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  55157. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  55158. */
  55159. export class VideoDome extends TransformNode {
  55160. /**
  55161. * Define the video source as a Monoscopic panoramic 360 video.
  55162. */
  55163. static readonly MODE_MONOSCOPIC: number;
  55164. /**
  55165. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55166. */
  55167. static readonly MODE_TOPBOTTOM: number;
  55168. /**
  55169. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55170. */
  55171. static readonly MODE_SIDEBYSIDE: number;
  55172. private _halfDome;
  55173. private _useDirectMapping;
  55174. /**
  55175. * The video texture being displayed on the sphere
  55176. */
  55177. protected _videoTexture: VideoTexture;
  55178. /**
  55179. * Gets the video texture being displayed on the sphere
  55180. */
  55181. get videoTexture(): VideoTexture;
  55182. /**
  55183. * The skybox material
  55184. */
  55185. protected _material: BackgroundMaterial;
  55186. /**
  55187. * The surface used for the skybox
  55188. */
  55189. protected _mesh: Mesh;
  55190. /**
  55191. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  55192. */
  55193. private _halfDomeMask;
  55194. /**
  55195. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  55196. * Also see the options.resolution property.
  55197. */
  55198. get fovMultiplier(): number;
  55199. set fovMultiplier(value: number);
  55200. private _videoMode;
  55201. /**
  55202. * Gets or set the current video mode for the video. It can be:
  55203. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  55204. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  55205. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  55206. */
  55207. get videoMode(): number;
  55208. set videoMode(value: number);
  55209. /**
  55210. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  55211. *
  55212. */
  55213. get halfDome(): boolean;
  55214. /**
  55215. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  55216. */
  55217. set halfDome(enabled: boolean);
  55218. /**
  55219. * Oberserver used in Stereoscopic VR Mode.
  55220. */
  55221. private _onBeforeCameraRenderObserver;
  55222. /**
  55223. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  55224. * @param name Element's name, child elements will append suffixes for their own names.
  55225. * @param urlsOrVideo defines the url(s) or the video element to use
  55226. * @param options An object containing optional or exposed sub element properties
  55227. */
  55228. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  55229. resolution?: number;
  55230. clickToPlay?: boolean;
  55231. autoPlay?: boolean;
  55232. loop?: boolean;
  55233. size?: number;
  55234. poster?: string;
  55235. faceForward?: boolean;
  55236. useDirectMapping?: boolean;
  55237. halfDomeMode?: boolean;
  55238. }, scene: Scene);
  55239. private _changeVideoMode;
  55240. /**
  55241. * Releases resources associated with this node.
  55242. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  55243. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  55244. */
  55245. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  55246. }
  55247. }
  55248. declare module "babylonjs/Helpers/index" {
  55249. export * from "babylonjs/Helpers/environmentHelper";
  55250. export * from "babylonjs/Helpers/photoDome";
  55251. export * from "babylonjs/Helpers/sceneHelpers";
  55252. export * from "babylonjs/Helpers/videoDome";
  55253. }
  55254. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  55255. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55256. import { IDisposable } from "babylonjs/scene";
  55257. import { Engine } from "babylonjs/Engines/engine";
  55258. /**
  55259. * This class can be used to get instrumentation data from a Babylon engine
  55260. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55261. */
  55262. export class EngineInstrumentation implements IDisposable {
  55263. /**
  55264. * Define the instrumented engine.
  55265. */
  55266. engine: Engine;
  55267. private _captureGPUFrameTime;
  55268. private _gpuFrameTimeToken;
  55269. private _gpuFrameTime;
  55270. private _captureShaderCompilationTime;
  55271. private _shaderCompilationTime;
  55272. private _onBeginFrameObserver;
  55273. private _onEndFrameObserver;
  55274. private _onBeforeShaderCompilationObserver;
  55275. private _onAfterShaderCompilationObserver;
  55276. /**
  55277. * Gets the perf counter used for GPU frame time
  55278. */
  55279. get gpuFrameTimeCounter(): PerfCounter;
  55280. /**
  55281. * Gets the GPU frame time capture status
  55282. */
  55283. get captureGPUFrameTime(): boolean;
  55284. /**
  55285. * Enable or disable the GPU frame time capture
  55286. */
  55287. set captureGPUFrameTime(value: boolean);
  55288. /**
  55289. * Gets the perf counter used for shader compilation time
  55290. */
  55291. get shaderCompilationTimeCounter(): PerfCounter;
  55292. /**
  55293. * Gets the shader compilation time capture status
  55294. */
  55295. get captureShaderCompilationTime(): boolean;
  55296. /**
  55297. * Enable or disable the shader compilation time capture
  55298. */
  55299. set captureShaderCompilationTime(value: boolean);
  55300. /**
  55301. * Instantiates a new engine instrumentation.
  55302. * This class can be used to get instrumentation data from a Babylon engine
  55303. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  55304. * @param engine Defines the engine to instrument
  55305. */
  55306. constructor(
  55307. /**
  55308. * Define the instrumented engine.
  55309. */
  55310. engine: Engine);
  55311. /**
  55312. * Dispose and release associated resources.
  55313. */
  55314. dispose(): void;
  55315. }
  55316. }
  55317. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  55318. import { Scene, IDisposable } from "babylonjs/scene";
  55319. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  55320. /**
  55321. * This class can be used to get instrumentation data from a Babylon engine
  55322. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55323. */
  55324. export class SceneInstrumentation implements IDisposable {
  55325. /**
  55326. * Defines the scene to instrument
  55327. */
  55328. scene: Scene;
  55329. private _captureActiveMeshesEvaluationTime;
  55330. private _activeMeshesEvaluationTime;
  55331. private _captureRenderTargetsRenderTime;
  55332. private _renderTargetsRenderTime;
  55333. private _captureFrameTime;
  55334. private _frameTime;
  55335. private _captureRenderTime;
  55336. private _renderTime;
  55337. private _captureInterFrameTime;
  55338. private _interFrameTime;
  55339. private _captureParticlesRenderTime;
  55340. private _particlesRenderTime;
  55341. private _captureSpritesRenderTime;
  55342. private _spritesRenderTime;
  55343. private _capturePhysicsTime;
  55344. private _physicsTime;
  55345. private _captureAnimationsTime;
  55346. private _animationsTime;
  55347. private _captureCameraRenderTime;
  55348. private _cameraRenderTime;
  55349. private _onBeforeActiveMeshesEvaluationObserver;
  55350. private _onAfterActiveMeshesEvaluationObserver;
  55351. private _onBeforeRenderTargetsRenderObserver;
  55352. private _onAfterRenderTargetsRenderObserver;
  55353. private _onAfterRenderObserver;
  55354. private _onBeforeDrawPhaseObserver;
  55355. private _onAfterDrawPhaseObserver;
  55356. private _onBeforeAnimationsObserver;
  55357. private _onBeforeParticlesRenderingObserver;
  55358. private _onAfterParticlesRenderingObserver;
  55359. private _onBeforeSpritesRenderingObserver;
  55360. private _onAfterSpritesRenderingObserver;
  55361. private _onBeforePhysicsObserver;
  55362. private _onAfterPhysicsObserver;
  55363. private _onAfterAnimationsObserver;
  55364. private _onBeforeCameraRenderObserver;
  55365. private _onAfterCameraRenderObserver;
  55366. /**
  55367. * Gets the perf counter used for active meshes evaluation time
  55368. */
  55369. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  55370. /**
  55371. * Gets the active meshes evaluation time capture status
  55372. */
  55373. get captureActiveMeshesEvaluationTime(): boolean;
  55374. /**
  55375. * Enable or disable the active meshes evaluation time capture
  55376. */
  55377. set captureActiveMeshesEvaluationTime(value: boolean);
  55378. /**
  55379. * Gets the perf counter used for render targets render time
  55380. */
  55381. get renderTargetsRenderTimeCounter(): PerfCounter;
  55382. /**
  55383. * Gets the render targets render time capture status
  55384. */
  55385. get captureRenderTargetsRenderTime(): boolean;
  55386. /**
  55387. * Enable or disable the render targets render time capture
  55388. */
  55389. set captureRenderTargetsRenderTime(value: boolean);
  55390. /**
  55391. * Gets the perf counter used for particles render time
  55392. */
  55393. get particlesRenderTimeCounter(): PerfCounter;
  55394. /**
  55395. * Gets the particles render time capture status
  55396. */
  55397. get captureParticlesRenderTime(): boolean;
  55398. /**
  55399. * Enable or disable the particles render time capture
  55400. */
  55401. set captureParticlesRenderTime(value: boolean);
  55402. /**
  55403. * Gets the perf counter used for sprites render time
  55404. */
  55405. get spritesRenderTimeCounter(): PerfCounter;
  55406. /**
  55407. * Gets the sprites render time capture status
  55408. */
  55409. get captureSpritesRenderTime(): boolean;
  55410. /**
  55411. * Enable or disable the sprites render time capture
  55412. */
  55413. set captureSpritesRenderTime(value: boolean);
  55414. /**
  55415. * Gets the perf counter used for physics time
  55416. */
  55417. get physicsTimeCounter(): PerfCounter;
  55418. /**
  55419. * Gets the physics time capture status
  55420. */
  55421. get capturePhysicsTime(): boolean;
  55422. /**
  55423. * Enable or disable the physics time capture
  55424. */
  55425. set capturePhysicsTime(value: boolean);
  55426. /**
  55427. * Gets the perf counter used for animations time
  55428. */
  55429. get animationsTimeCounter(): PerfCounter;
  55430. /**
  55431. * Gets the animations time capture status
  55432. */
  55433. get captureAnimationsTime(): boolean;
  55434. /**
  55435. * Enable or disable the animations time capture
  55436. */
  55437. set captureAnimationsTime(value: boolean);
  55438. /**
  55439. * Gets the perf counter used for frame time capture
  55440. */
  55441. get frameTimeCounter(): PerfCounter;
  55442. /**
  55443. * Gets the frame time capture status
  55444. */
  55445. get captureFrameTime(): boolean;
  55446. /**
  55447. * Enable or disable the frame time capture
  55448. */
  55449. set captureFrameTime(value: boolean);
  55450. /**
  55451. * Gets the perf counter used for inter-frames time capture
  55452. */
  55453. get interFrameTimeCounter(): PerfCounter;
  55454. /**
  55455. * Gets the inter-frames time capture status
  55456. */
  55457. get captureInterFrameTime(): boolean;
  55458. /**
  55459. * Enable or disable the inter-frames time capture
  55460. */
  55461. set captureInterFrameTime(value: boolean);
  55462. /**
  55463. * Gets the perf counter used for render time capture
  55464. */
  55465. get renderTimeCounter(): PerfCounter;
  55466. /**
  55467. * Gets the render time capture status
  55468. */
  55469. get captureRenderTime(): boolean;
  55470. /**
  55471. * Enable or disable the render time capture
  55472. */
  55473. set captureRenderTime(value: boolean);
  55474. /**
  55475. * Gets the perf counter used for camera render time capture
  55476. */
  55477. get cameraRenderTimeCounter(): PerfCounter;
  55478. /**
  55479. * Gets the camera render time capture status
  55480. */
  55481. get captureCameraRenderTime(): boolean;
  55482. /**
  55483. * Enable or disable the camera render time capture
  55484. */
  55485. set captureCameraRenderTime(value: boolean);
  55486. /**
  55487. * Gets the perf counter used for draw calls
  55488. */
  55489. get drawCallsCounter(): PerfCounter;
  55490. /**
  55491. * Instantiates a new scene instrumentation.
  55492. * This class can be used to get instrumentation data from a Babylon engine
  55493. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  55494. * @param scene Defines the scene to instrument
  55495. */
  55496. constructor(
  55497. /**
  55498. * Defines the scene to instrument
  55499. */
  55500. scene: Scene);
  55501. /**
  55502. * Dispose and release associated resources.
  55503. */
  55504. dispose(): void;
  55505. }
  55506. }
  55507. declare module "babylonjs/Instrumentation/index" {
  55508. export * from "babylonjs/Instrumentation/engineInstrumentation";
  55509. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  55510. export * from "babylonjs/Instrumentation/timeToken";
  55511. }
  55512. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  55513. /** @hidden */
  55514. export var glowMapGenerationPixelShader: {
  55515. name: string;
  55516. shader: string;
  55517. };
  55518. }
  55519. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  55520. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55521. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  55522. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  55523. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55524. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  55525. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55526. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55527. /** @hidden */
  55528. export var glowMapGenerationVertexShader: {
  55529. name: string;
  55530. shader: string;
  55531. };
  55532. }
  55533. declare module "babylonjs/Layers/effectLayer" {
  55534. import { Observable } from "babylonjs/Misc/observable";
  55535. import { Nullable } from "babylonjs/types";
  55536. import { Camera } from "babylonjs/Cameras/camera";
  55537. import { Scene } from "babylonjs/scene";
  55538. import { ISize } from "babylonjs/Maths/math.size";
  55539. import { Color4 } from "babylonjs/Maths/math.color";
  55540. import { Engine } from "babylonjs/Engines/engine";
  55541. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55542. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55543. import { Mesh } from "babylonjs/Meshes/mesh";
  55544. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  55545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  55547. import { Effect } from "babylonjs/Materials/effect";
  55548. import { Material } from "babylonjs/Materials/material";
  55549. import "babylonjs/Shaders/glowMapGeneration.fragment";
  55550. import "babylonjs/Shaders/glowMapGeneration.vertex";
  55551. /**
  55552. * Effect layer options. This helps customizing the behaviour
  55553. * of the effect layer.
  55554. */
  55555. export interface IEffectLayerOptions {
  55556. /**
  55557. * Multiplication factor apply to the canvas size to compute the render target size
  55558. * used to generated the objects (the smaller the faster).
  55559. */
  55560. mainTextureRatio: number;
  55561. /**
  55562. * Enforces a fixed size texture to ensure effect stability across devices.
  55563. */
  55564. mainTextureFixedSize?: number;
  55565. /**
  55566. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  55567. */
  55568. alphaBlendingMode: number;
  55569. /**
  55570. * The camera attached to the layer.
  55571. */
  55572. camera: Nullable<Camera>;
  55573. /**
  55574. * The rendering group to draw the layer in.
  55575. */
  55576. renderingGroupId: number;
  55577. }
  55578. /**
  55579. * The effect layer Helps adding post process effect blended with the main pass.
  55580. *
  55581. * This can be for instance use to generate glow or higlight effects on the scene.
  55582. *
  55583. * The effect layer class can not be used directly and is intented to inherited from to be
  55584. * customized per effects.
  55585. */
  55586. export abstract class EffectLayer {
  55587. private _vertexBuffers;
  55588. private _indexBuffer;
  55589. private _cachedDefines;
  55590. private _effectLayerMapGenerationEffect;
  55591. private _effectLayerOptions;
  55592. private _mergeEffect;
  55593. protected _scene: Scene;
  55594. protected _engine: Engine;
  55595. protected _maxSize: number;
  55596. protected _mainTextureDesiredSize: ISize;
  55597. protected _mainTexture: RenderTargetTexture;
  55598. protected _shouldRender: boolean;
  55599. protected _postProcesses: PostProcess[];
  55600. protected _textures: BaseTexture[];
  55601. protected _emissiveTextureAndColor: {
  55602. texture: Nullable<BaseTexture>;
  55603. color: Color4;
  55604. };
  55605. /**
  55606. * The name of the layer
  55607. */
  55608. name: string;
  55609. /**
  55610. * The clear color of the texture used to generate the glow map.
  55611. */
  55612. neutralColor: Color4;
  55613. /**
  55614. * Specifies whether the highlight layer is enabled or not.
  55615. */
  55616. isEnabled: boolean;
  55617. /**
  55618. * Gets the camera attached to the layer.
  55619. */
  55620. get camera(): Nullable<Camera>;
  55621. /**
  55622. * Gets the rendering group id the layer should render in.
  55623. */
  55624. get renderingGroupId(): number;
  55625. set renderingGroupId(renderingGroupId: number);
  55626. /**
  55627. * An event triggered when the effect layer has been disposed.
  55628. */
  55629. onDisposeObservable: Observable<EffectLayer>;
  55630. /**
  55631. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  55632. */
  55633. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  55634. /**
  55635. * An event triggered when the generated texture is being merged in the scene.
  55636. */
  55637. onBeforeComposeObservable: Observable<EffectLayer>;
  55638. /**
  55639. * An event triggered when the mesh is rendered into the effect render target.
  55640. */
  55641. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  55642. /**
  55643. * An event triggered after the mesh has been rendered into the effect render target.
  55644. */
  55645. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  55646. /**
  55647. * An event triggered when the generated texture has been merged in the scene.
  55648. */
  55649. onAfterComposeObservable: Observable<EffectLayer>;
  55650. /**
  55651. * An event triggered when the efffect layer changes its size.
  55652. */
  55653. onSizeChangedObservable: Observable<EffectLayer>;
  55654. /** @hidden */
  55655. static _SceneComponentInitialization: (scene: Scene) => void;
  55656. /**
  55657. * Instantiates a new effect Layer and references it in the scene.
  55658. * @param name The name of the layer
  55659. * @param scene The scene to use the layer in
  55660. */
  55661. constructor(
  55662. /** The Friendly of the effect in the scene */
  55663. name: string, scene: Scene);
  55664. /**
  55665. * Get the effect name of the layer.
  55666. * @return The effect name
  55667. */
  55668. abstract getEffectName(): string;
  55669. /**
  55670. * Checks for the readiness of the element composing the layer.
  55671. * @param subMesh the mesh to check for
  55672. * @param useInstances specify whether or not to use instances to render the mesh
  55673. * @return true if ready otherwise, false
  55674. */
  55675. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55676. /**
  55677. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  55678. * @returns true if the effect requires stencil during the main canvas render pass.
  55679. */
  55680. abstract needStencil(): boolean;
  55681. /**
  55682. * Create the merge effect. This is the shader use to blit the information back
  55683. * to the main canvas at the end of the scene rendering.
  55684. * @returns The effect containing the shader used to merge the effect on the main canvas
  55685. */
  55686. protected abstract _createMergeEffect(): Effect;
  55687. /**
  55688. * Creates the render target textures and post processes used in the effect layer.
  55689. */
  55690. protected abstract _createTextureAndPostProcesses(): void;
  55691. /**
  55692. * Implementation specific of rendering the generating effect on the main canvas.
  55693. * @param effect The effect used to render through
  55694. */
  55695. protected abstract _internalRender(effect: Effect): void;
  55696. /**
  55697. * Sets the required values for both the emissive texture and and the main color.
  55698. */
  55699. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  55700. /**
  55701. * Free any resources and references associated to a mesh.
  55702. * Internal use
  55703. * @param mesh The mesh to free.
  55704. */
  55705. abstract _disposeMesh(mesh: Mesh): void;
  55706. /**
  55707. * Serializes this layer (Glow or Highlight for example)
  55708. * @returns a serialized layer object
  55709. */
  55710. abstract serialize?(): any;
  55711. /**
  55712. * Initializes the effect layer with the required options.
  55713. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  55714. */
  55715. protected _init(options: Partial<IEffectLayerOptions>): void;
  55716. /**
  55717. * Generates the index buffer of the full screen quad blending to the main canvas.
  55718. */
  55719. private _generateIndexBuffer;
  55720. /**
  55721. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  55722. */
  55723. private _generateVertexBuffer;
  55724. /**
  55725. * Sets the main texture desired size which is the closest power of two
  55726. * of the engine canvas size.
  55727. */
  55728. private _setMainTextureSize;
  55729. /**
  55730. * Creates the main texture for the effect layer.
  55731. */
  55732. protected _createMainTexture(): void;
  55733. /**
  55734. * Adds specific effects defines.
  55735. * @param defines The defines to add specifics to.
  55736. */
  55737. protected _addCustomEffectDefines(defines: string[]): void;
  55738. /**
  55739. * Checks for the readiness of the element composing the layer.
  55740. * @param subMesh the mesh to check for
  55741. * @param useInstances specify whether or not to use instances to render the mesh
  55742. * @param emissiveTexture the associated emissive texture used to generate the glow
  55743. * @return true if ready otherwise, false
  55744. */
  55745. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  55746. /**
  55747. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  55748. */
  55749. render(): void;
  55750. /**
  55751. * Determine if a given mesh will be used in the current effect.
  55752. * @param mesh mesh to test
  55753. * @returns true if the mesh will be used
  55754. */
  55755. hasMesh(mesh: AbstractMesh): boolean;
  55756. /**
  55757. * Returns true if the layer contains information to display, otherwise false.
  55758. * @returns true if the glow layer should be rendered
  55759. */
  55760. shouldRender(): boolean;
  55761. /**
  55762. * Returns true if the mesh should render, otherwise false.
  55763. * @param mesh The mesh to render
  55764. * @returns true if it should render otherwise false
  55765. */
  55766. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  55767. /**
  55768. * Returns true if the mesh can be rendered, otherwise false.
  55769. * @param mesh The mesh to render
  55770. * @param material The material used on the mesh
  55771. * @returns true if it can be rendered otherwise false
  55772. */
  55773. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  55774. /**
  55775. * Returns true if the mesh should render, otherwise false.
  55776. * @param mesh The mesh to render
  55777. * @returns true if it should render otherwise false
  55778. */
  55779. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  55780. /**
  55781. * Renders the submesh passed in parameter to the generation map.
  55782. */
  55783. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  55784. /**
  55785. * Defines whether the current material of the mesh should be use to render the effect.
  55786. * @param mesh defines the current mesh to render
  55787. */
  55788. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  55789. /**
  55790. * Rebuild the required buffers.
  55791. * @hidden Internal use only.
  55792. */
  55793. _rebuild(): void;
  55794. /**
  55795. * Dispose only the render target textures and post process.
  55796. */
  55797. private _disposeTextureAndPostProcesses;
  55798. /**
  55799. * Dispose the highlight layer and free resources.
  55800. */
  55801. dispose(): void;
  55802. /**
  55803. * Gets the class name of the effect layer
  55804. * @returns the string with the class name of the effect layer
  55805. */
  55806. getClassName(): string;
  55807. /**
  55808. * Creates an effect layer from parsed effect layer data
  55809. * @param parsedEffectLayer defines effect layer data
  55810. * @param scene defines the current scene
  55811. * @param rootUrl defines the root URL containing the effect layer information
  55812. * @returns a parsed effect Layer
  55813. */
  55814. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  55815. }
  55816. }
  55817. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  55818. import { Scene } from "babylonjs/scene";
  55819. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  55820. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55821. import { AbstractScene } from "babylonjs/abstractScene";
  55822. module "babylonjs/abstractScene" {
  55823. interface AbstractScene {
  55824. /**
  55825. * The list of effect layers (highlights/glow) added to the scene
  55826. * @see http://doc.babylonjs.com/how_to/highlight_layer
  55827. * @see http://doc.babylonjs.com/how_to/glow_layer
  55828. */
  55829. effectLayers: Array<EffectLayer>;
  55830. /**
  55831. * Removes the given effect layer from this scene.
  55832. * @param toRemove defines the effect layer to remove
  55833. * @returns the index of the removed effect layer
  55834. */
  55835. removeEffectLayer(toRemove: EffectLayer): number;
  55836. /**
  55837. * Adds the given effect layer to this scene
  55838. * @param newEffectLayer defines the effect layer to add
  55839. */
  55840. addEffectLayer(newEffectLayer: EffectLayer): void;
  55841. }
  55842. }
  55843. /**
  55844. * Defines the layer scene component responsible to manage any effect layers
  55845. * in a given scene.
  55846. */
  55847. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  55848. /**
  55849. * The component name helpfull to identify the component in the list of scene components.
  55850. */
  55851. readonly name: string;
  55852. /**
  55853. * The scene the component belongs to.
  55854. */
  55855. scene: Scene;
  55856. private _engine;
  55857. private _renderEffects;
  55858. private _needStencil;
  55859. private _previousStencilState;
  55860. /**
  55861. * Creates a new instance of the component for the given scene
  55862. * @param scene Defines the scene to register the component in
  55863. */
  55864. constructor(scene: Scene);
  55865. /**
  55866. * Registers the component in a given scene
  55867. */
  55868. register(): void;
  55869. /**
  55870. * Rebuilds the elements related to this component in case of
  55871. * context lost for instance.
  55872. */
  55873. rebuild(): void;
  55874. /**
  55875. * Serializes the component data to the specified json object
  55876. * @param serializationObject The object to serialize to
  55877. */
  55878. serialize(serializationObject: any): void;
  55879. /**
  55880. * Adds all the elements from the container to the scene
  55881. * @param container the container holding the elements
  55882. */
  55883. addFromContainer(container: AbstractScene): void;
  55884. /**
  55885. * Removes all the elements in the container from the scene
  55886. * @param container contains the elements to remove
  55887. * @param dispose if the removed element should be disposed (default: false)
  55888. */
  55889. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  55890. /**
  55891. * Disposes the component and the associated ressources.
  55892. */
  55893. dispose(): void;
  55894. private _isReadyForMesh;
  55895. private _renderMainTexture;
  55896. private _setStencil;
  55897. private _setStencilBack;
  55898. private _draw;
  55899. private _drawCamera;
  55900. private _drawRenderingGroup;
  55901. }
  55902. }
  55903. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  55904. /** @hidden */
  55905. export var glowMapMergePixelShader: {
  55906. name: string;
  55907. shader: string;
  55908. };
  55909. }
  55910. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  55911. /** @hidden */
  55912. export var glowMapMergeVertexShader: {
  55913. name: string;
  55914. shader: string;
  55915. };
  55916. }
  55917. declare module "babylonjs/Layers/glowLayer" {
  55918. import { Nullable } from "babylonjs/types";
  55919. import { Camera } from "babylonjs/Cameras/camera";
  55920. import { Scene } from "babylonjs/scene";
  55921. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55922. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55923. import { Mesh } from "babylonjs/Meshes/mesh";
  55924. import { Texture } from "babylonjs/Materials/Textures/texture";
  55925. import { Effect } from "babylonjs/Materials/effect";
  55926. import { Material } from "babylonjs/Materials/material";
  55927. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  55928. import { Color4 } from "babylonjs/Maths/math.color";
  55929. import "babylonjs/Shaders/glowMapMerge.fragment";
  55930. import "babylonjs/Shaders/glowMapMerge.vertex";
  55931. import "babylonjs/Layers/effectLayerSceneComponent";
  55932. module "babylonjs/abstractScene" {
  55933. interface AbstractScene {
  55934. /**
  55935. * Return a the first highlight layer of the scene with a given name.
  55936. * @param name The name of the highlight layer to look for.
  55937. * @return The highlight layer if found otherwise null.
  55938. */
  55939. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  55940. }
  55941. }
  55942. /**
  55943. * Glow layer options. This helps customizing the behaviour
  55944. * of the glow layer.
  55945. */
  55946. export interface IGlowLayerOptions {
  55947. /**
  55948. * Multiplication factor apply to the canvas size to compute the render target size
  55949. * used to generated the glowing objects (the smaller the faster).
  55950. */
  55951. mainTextureRatio: number;
  55952. /**
  55953. * Enforces a fixed size texture to ensure resize independant blur.
  55954. */
  55955. mainTextureFixedSize?: number;
  55956. /**
  55957. * How big is the kernel of the blur texture.
  55958. */
  55959. blurKernelSize: number;
  55960. /**
  55961. * The camera attached to the layer.
  55962. */
  55963. camera: Nullable<Camera>;
  55964. /**
  55965. * Enable MSAA by chosing the number of samples.
  55966. */
  55967. mainTextureSamples?: number;
  55968. /**
  55969. * The rendering group to draw the layer in.
  55970. */
  55971. renderingGroupId: number;
  55972. }
  55973. /**
  55974. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  55975. *
  55976. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  55977. *
  55978. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  55979. */
  55980. export class GlowLayer extends EffectLayer {
  55981. /**
  55982. * Effect Name of the layer.
  55983. */
  55984. static readonly EffectName: string;
  55985. /**
  55986. * The default blur kernel size used for the glow.
  55987. */
  55988. static DefaultBlurKernelSize: number;
  55989. /**
  55990. * The default texture size ratio used for the glow.
  55991. */
  55992. static DefaultTextureRatio: number;
  55993. /**
  55994. * Sets the kernel size of the blur.
  55995. */
  55996. set blurKernelSize(value: number);
  55997. /**
  55998. * Gets the kernel size of the blur.
  55999. */
  56000. get blurKernelSize(): number;
  56001. /**
  56002. * Sets the glow intensity.
  56003. */
  56004. set intensity(value: number);
  56005. /**
  56006. * Gets the glow intensity.
  56007. */
  56008. get intensity(): number;
  56009. private _options;
  56010. private _intensity;
  56011. private _horizontalBlurPostprocess1;
  56012. private _verticalBlurPostprocess1;
  56013. private _horizontalBlurPostprocess2;
  56014. private _verticalBlurPostprocess2;
  56015. private _blurTexture1;
  56016. private _blurTexture2;
  56017. private _postProcesses1;
  56018. private _postProcesses2;
  56019. private _includedOnlyMeshes;
  56020. private _excludedMeshes;
  56021. private _meshesUsingTheirOwnMaterials;
  56022. /**
  56023. * Callback used to let the user override the color selection on a per mesh basis
  56024. */
  56025. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  56026. /**
  56027. * Callback used to let the user override the texture selection on a per mesh basis
  56028. */
  56029. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  56030. /**
  56031. * Instantiates a new glow Layer and references it to the scene.
  56032. * @param name The name of the layer
  56033. * @param scene The scene to use the layer in
  56034. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  56035. */
  56036. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  56037. /**
  56038. * Get the effect name of the layer.
  56039. * @return The effect name
  56040. */
  56041. getEffectName(): string;
  56042. /**
  56043. * Create the merge effect. This is the shader use to blit the information back
  56044. * to the main canvas at the end of the scene rendering.
  56045. */
  56046. protected _createMergeEffect(): Effect;
  56047. /**
  56048. * Creates the render target textures and post processes used in the glow layer.
  56049. */
  56050. protected _createTextureAndPostProcesses(): void;
  56051. /**
  56052. * Checks for the readiness of the element composing the layer.
  56053. * @param subMesh the mesh to check for
  56054. * @param useInstances specify wether or not to use instances to render the mesh
  56055. * @param emissiveTexture the associated emissive texture used to generate the glow
  56056. * @return true if ready otherwise, false
  56057. */
  56058. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56059. /**
  56060. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  56061. */
  56062. needStencil(): boolean;
  56063. /**
  56064. * Returns true if the mesh can be rendered, otherwise false.
  56065. * @param mesh The mesh to render
  56066. * @param material The material used on the mesh
  56067. * @returns true if it can be rendered otherwise false
  56068. */
  56069. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  56070. /**
  56071. * Implementation specific of rendering the generating effect on the main canvas.
  56072. * @param effect The effect used to render through
  56073. */
  56074. protected _internalRender(effect: Effect): void;
  56075. /**
  56076. * Sets the required values for both the emissive texture and and the main color.
  56077. */
  56078. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56079. /**
  56080. * Returns true if the mesh should render, otherwise false.
  56081. * @param mesh The mesh to render
  56082. * @returns true if it should render otherwise false
  56083. */
  56084. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56085. /**
  56086. * Adds specific effects defines.
  56087. * @param defines The defines to add specifics to.
  56088. */
  56089. protected _addCustomEffectDefines(defines: string[]): void;
  56090. /**
  56091. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  56092. * @param mesh The mesh to exclude from the glow layer
  56093. */
  56094. addExcludedMesh(mesh: Mesh): void;
  56095. /**
  56096. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  56097. * @param mesh The mesh to remove
  56098. */
  56099. removeExcludedMesh(mesh: Mesh): void;
  56100. /**
  56101. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  56102. * @param mesh The mesh to include in the glow layer
  56103. */
  56104. addIncludedOnlyMesh(mesh: Mesh): void;
  56105. /**
  56106. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  56107. * @param mesh The mesh to remove
  56108. */
  56109. removeIncludedOnlyMesh(mesh: Mesh): void;
  56110. /**
  56111. * Determine if a given mesh will be used in the glow layer
  56112. * @param mesh The mesh to test
  56113. * @returns true if the mesh will be highlighted by the current glow layer
  56114. */
  56115. hasMesh(mesh: AbstractMesh): boolean;
  56116. /**
  56117. * Defines whether the current material of the mesh should be use to render the effect.
  56118. * @param mesh defines the current mesh to render
  56119. */
  56120. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  56121. /**
  56122. * Add a mesh to be rendered through its own material and not with emissive only.
  56123. * @param mesh The mesh for which we need to use its material
  56124. */
  56125. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  56126. /**
  56127. * Remove a mesh from being rendered through its own material and not with emissive only.
  56128. * @param mesh The mesh for which we need to not use its material
  56129. */
  56130. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  56131. /**
  56132. * Free any resources and references associated to a mesh.
  56133. * Internal use
  56134. * @param mesh The mesh to free.
  56135. * @hidden
  56136. */
  56137. _disposeMesh(mesh: Mesh): void;
  56138. /**
  56139. * Gets the class name of the effect layer
  56140. * @returns the string with the class name of the effect layer
  56141. */
  56142. getClassName(): string;
  56143. /**
  56144. * Serializes this glow layer
  56145. * @returns a serialized glow layer object
  56146. */
  56147. serialize(): any;
  56148. /**
  56149. * Creates a Glow Layer from parsed glow layer data
  56150. * @param parsedGlowLayer defines glow layer data
  56151. * @param scene defines the current scene
  56152. * @param rootUrl defines the root URL containing the glow layer information
  56153. * @returns a parsed Glow Layer
  56154. */
  56155. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  56156. }
  56157. }
  56158. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  56159. /** @hidden */
  56160. export var glowBlurPostProcessPixelShader: {
  56161. name: string;
  56162. shader: string;
  56163. };
  56164. }
  56165. declare module "babylonjs/Layers/highlightLayer" {
  56166. import { Observable } from "babylonjs/Misc/observable";
  56167. import { Nullable } from "babylonjs/types";
  56168. import { Camera } from "babylonjs/Cameras/camera";
  56169. import { Scene } from "babylonjs/scene";
  56170. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56171. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56172. import { Mesh } from "babylonjs/Meshes/mesh";
  56173. import { Effect } from "babylonjs/Materials/effect";
  56174. import { Material } from "babylonjs/Materials/material";
  56175. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  56176. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  56177. import "babylonjs/Shaders/glowMapMerge.fragment";
  56178. import "babylonjs/Shaders/glowMapMerge.vertex";
  56179. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  56180. module "babylonjs/abstractScene" {
  56181. interface AbstractScene {
  56182. /**
  56183. * Return a the first highlight layer of the scene with a given name.
  56184. * @param name The name of the highlight layer to look for.
  56185. * @return The highlight layer if found otherwise null.
  56186. */
  56187. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  56188. }
  56189. }
  56190. /**
  56191. * Highlight layer options. This helps customizing the behaviour
  56192. * of the highlight layer.
  56193. */
  56194. export interface IHighlightLayerOptions {
  56195. /**
  56196. * Multiplication factor apply to the canvas size to compute the render target size
  56197. * used to generated the glowing objects (the smaller the faster).
  56198. */
  56199. mainTextureRatio: number;
  56200. /**
  56201. * Enforces a fixed size texture to ensure resize independant blur.
  56202. */
  56203. mainTextureFixedSize?: number;
  56204. /**
  56205. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  56206. * of the picture to blur (the smaller the faster).
  56207. */
  56208. blurTextureSizeRatio: number;
  56209. /**
  56210. * How big in texel of the blur texture is the vertical blur.
  56211. */
  56212. blurVerticalSize: number;
  56213. /**
  56214. * How big in texel of the blur texture is the horizontal blur.
  56215. */
  56216. blurHorizontalSize: number;
  56217. /**
  56218. * Alpha blending mode used to apply the blur. Default is combine.
  56219. */
  56220. alphaBlendingMode: number;
  56221. /**
  56222. * The camera attached to the layer.
  56223. */
  56224. camera: Nullable<Camera>;
  56225. /**
  56226. * Should we display highlight as a solid stroke?
  56227. */
  56228. isStroke?: boolean;
  56229. /**
  56230. * The rendering group to draw the layer in.
  56231. */
  56232. renderingGroupId: number;
  56233. }
  56234. /**
  56235. * The highlight layer Helps adding a glow effect around a mesh.
  56236. *
  56237. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  56238. * glowy meshes to your scene.
  56239. *
  56240. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  56241. */
  56242. export class HighlightLayer extends EffectLayer {
  56243. name: string;
  56244. /**
  56245. * Effect Name of the highlight layer.
  56246. */
  56247. static readonly EffectName: string;
  56248. /**
  56249. * The neutral color used during the preparation of the glow effect.
  56250. * This is black by default as the blend operation is a blend operation.
  56251. */
  56252. static NeutralColor: Color4;
  56253. /**
  56254. * Stencil value used for glowing meshes.
  56255. */
  56256. static GlowingMeshStencilReference: number;
  56257. /**
  56258. * Stencil value used for the other meshes in the scene.
  56259. */
  56260. static NormalMeshStencilReference: number;
  56261. /**
  56262. * Specifies whether or not the inner glow is ACTIVE in the layer.
  56263. */
  56264. innerGlow: boolean;
  56265. /**
  56266. * Specifies whether or not the outer glow is ACTIVE in the layer.
  56267. */
  56268. outerGlow: boolean;
  56269. /**
  56270. * Specifies the horizontal size of the blur.
  56271. */
  56272. set blurHorizontalSize(value: number);
  56273. /**
  56274. * Specifies the vertical size of the blur.
  56275. */
  56276. set blurVerticalSize(value: number);
  56277. /**
  56278. * Gets the horizontal size of the blur.
  56279. */
  56280. get blurHorizontalSize(): number;
  56281. /**
  56282. * Gets the vertical size of the blur.
  56283. */
  56284. get blurVerticalSize(): number;
  56285. /**
  56286. * An event triggered when the highlight layer is being blurred.
  56287. */
  56288. onBeforeBlurObservable: Observable<HighlightLayer>;
  56289. /**
  56290. * An event triggered when the highlight layer has been blurred.
  56291. */
  56292. onAfterBlurObservable: Observable<HighlightLayer>;
  56293. private _instanceGlowingMeshStencilReference;
  56294. private _options;
  56295. private _downSamplePostprocess;
  56296. private _horizontalBlurPostprocess;
  56297. private _verticalBlurPostprocess;
  56298. private _blurTexture;
  56299. private _meshes;
  56300. private _excludedMeshes;
  56301. /**
  56302. * Instantiates a new highlight Layer and references it to the scene..
  56303. * @param name The name of the layer
  56304. * @param scene The scene to use the layer in
  56305. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  56306. */
  56307. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  56308. /**
  56309. * Get the effect name of the layer.
  56310. * @return The effect name
  56311. */
  56312. getEffectName(): string;
  56313. /**
  56314. * Create the merge effect. This is the shader use to blit the information back
  56315. * to the main canvas at the end of the scene rendering.
  56316. */
  56317. protected _createMergeEffect(): Effect;
  56318. /**
  56319. * Creates the render target textures and post processes used in the highlight layer.
  56320. */
  56321. protected _createTextureAndPostProcesses(): void;
  56322. /**
  56323. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  56324. */
  56325. needStencil(): boolean;
  56326. /**
  56327. * Checks for the readiness of the element composing the layer.
  56328. * @param subMesh the mesh to check for
  56329. * @param useInstances specify wether or not to use instances to render the mesh
  56330. * @param emissiveTexture the associated emissive texture used to generate the glow
  56331. * @return true if ready otherwise, false
  56332. */
  56333. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  56334. /**
  56335. * Implementation specific of rendering the generating effect on the main canvas.
  56336. * @param effect The effect used to render through
  56337. */
  56338. protected _internalRender(effect: Effect): void;
  56339. /**
  56340. * Returns true if the layer contains information to display, otherwise false.
  56341. */
  56342. shouldRender(): boolean;
  56343. /**
  56344. * Returns true if the mesh should render, otherwise false.
  56345. * @param mesh The mesh to render
  56346. * @returns true if it should render otherwise false
  56347. */
  56348. protected _shouldRenderMesh(mesh: Mesh): boolean;
  56349. /**
  56350. * Adds specific effects defines.
  56351. * @param defines The defines to add specifics to.
  56352. */
  56353. protected _addCustomEffectDefines(defines: string[]): void;
  56354. /**
  56355. * Sets the required values for both the emissive texture and and the main color.
  56356. */
  56357. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  56358. /**
  56359. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  56360. * @param mesh The mesh to exclude from the highlight layer
  56361. */
  56362. addExcludedMesh(mesh: Mesh): void;
  56363. /**
  56364. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  56365. * @param mesh The mesh to highlight
  56366. */
  56367. removeExcludedMesh(mesh: Mesh): void;
  56368. /**
  56369. * Determine if a given mesh will be highlighted by the current HighlightLayer
  56370. * @param mesh mesh to test
  56371. * @returns true if the mesh will be highlighted by the current HighlightLayer
  56372. */
  56373. hasMesh(mesh: AbstractMesh): boolean;
  56374. /**
  56375. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  56376. * @param mesh The mesh to highlight
  56377. * @param color The color of the highlight
  56378. * @param glowEmissiveOnly Extract the glow from the emissive texture
  56379. */
  56380. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  56381. /**
  56382. * Remove a mesh from the highlight layer in order to make it stop glowing.
  56383. * @param mesh The mesh to highlight
  56384. */
  56385. removeMesh(mesh: Mesh): void;
  56386. /**
  56387. * Remove all the meshes currently referenced in the highlight layer
  56388. */
  56389. removeAllMeshes(): void;
  56390. /**
  56391. * Force the stencil to the normal expected value for none glowing parts
  56392. */
  56393. private _defaultStencilReference;
  56394. /**
  56395. * Free any resources and references associated to a mesh.
  56396. * Internal use
  56397. * @param mesh The mesh to free.
  56398. * @hidden
  56399. */
  56400. _disposeMesh(mesh: Mesh): void;
  56401. /**
  56402. * Dispose the highlight layer and free resources.
  56403. */
  56404. dispose(): void;
  56405. /**
  56406. * Gets the class name of the effect layer
  56407. * @returns the string with the class name of the effect layer
  56408. */
  56409. getClassName(): string;
  56410. /**
  56411. * Serializes this Highlight layer
  56412. * @returns a serialized Highlight layer object
  56413. */
  56414. serialize(): any;
  56415. /**
  56416. * Creates a Highlight layer from parsed Highlight layer data
  56417. * @param parsedHightlightLayer defines the Highlight layer data
  56418. * @param scene defines the current scene
  56419. * @param rootUrl defines the root URL containing the Highlight layer information
  56420. * @returns a parsed Highlight layer
  56421. */
  56422. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  56423. }
  56424. }
  56425. declare module "babylonjs/Layers/layerSceneComponent" {
  56426. import { Scene } from "babylonjs/scene";
  56427. import { ISceneComponent } from "babylonjs/sceneComponent";
  56428. import { Layer } from "babylonjs/Layers/layer";
  56429. import { AbstractScene } from "babylonjs/abstractScene";
  56430. module "babylonjs/abstractScene" {
  56431. interface AbstractScene {
  56432. /**
  56433. * The list of layers (background and foreground) of the scene
  56434. */
  56435. layers: Array<Layer>;
  56436. }
  56437. }
  56438. /**
  56439. * Defines the layer scene component responsible to manage any layers
  56440. * in a given scene.
  56441. */
  56442. export class LayerSceneComponent implements ISceneComponent {
  56443. /**
  56444. * The component name helpfull to identify the component in the list of scene components.
  56445. */
  56446. readonly name: string;
  56447. /**
  56448. * The scene the component belongs to.
  56449. */
  56450. scene: Scene;
  56451. private _engine;
  56452. /**
  56453. * Creates a new instance of the component for the given scene
  56454. * @param scene Defines the scene to register the component in
  56455. */
  56456. constructor(scene: Scene);
  56457. /**
  56458. * Registers the component in a given scene
  56459. */
  56460. register(): void;
  56461. /**
  56462. * Rebuilds the elements related to this component in case of
  56463. * context lost for instance.
  56464. */
  56465. rebuild(): void;
  56466. /**
  56467. * Disposes the component and the associated ressources.
  56468. */
  56469. dispose(): void;
  56470. private _draw;
  56471. private _drawCameraPredicate;
  56472. private _drawCameraBackground;
  56473. private _drawCameraForeground;
  56474. private _drawRenderTargetPredicate;
  56475. private _drawRenderTargetBackground;
  56476. private _drawRenderTargetForeground;
  56477. /**
  56478. * Adds all the elements from the container to the scene
  56479. * @param container the container holding the elements
  56480. */
  56481. addFromContainer(container: AbstractScene): void;
  56482. /**
  56483. * Removes all the elements in the container from the scene
  56484. * @param container contains the elements to remove
  56485. * @param dispose if the removed element should be disposed (default: false)
  56486. */
  56487. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56488. }
  56489. }
  56490. declare module "babylonjs/Shaders/layer.fragment" {
  56491. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  56492. /** @hidden */
  56493. export var layerPixelShader: {
  56494. name: string;
  56495. shader: string;
  56496. };
  56497. }
  56498. declare module "babylonjs/Shaders/layer.vertex" {
  56499. /** @hidden */
  56500. export var layerVertexShader: {
  56501. name: string;
  56502. shader: string;
  56503. };
  56504. }
  56505. declare module "babylonjs/Layers/layer" {
  56506. import { Observable } from "babylonjs/Misc/observable";
  56507. import { Nullable } from "babylonjs/types";
  56508. import { Scene } from "babylonjs/scene";
  56509. import { Vector2 } from "babylonjs/Maths/math.vector";
  56510. import { Color4 } from "babylonjs/Maths/math.color";
  56511. import { Texture } from "babylonjs/Materials/Textures/texture";
  56512. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56513. import "babylonjs/Shaders/layer.fragment";
  56514. import "babylonjs/Shaders/layer.vertex";
  56515. /**
  56516. * This represents a full screen 2d layer.
  56517. * This can be useful to display a picture in the background of your scene for instance.
  56518. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56519. */
  56520. export class Layer {
  56521. /**
  56522. * Define the name of the layer.
  56523. */
  56524. name: string;
  56525. /**
  56526. * Define the texture the layer should display.
  56527. */
  56528. texture: Nullable<Texture>;
  56529. /**
  56530. * Is the layer in background or foreground.
  56531. */
  56532. isBackground: boolean;
  56533. /**
  56534. * Define the color of the layer (instead of texture).
  56535. */
  56536. color: Color4;
  56537. /**
  56538. * Define the scale of the layer in order to zoom in out of the texture.
  56539. */
  56540. scale: Vector2;
  56541. /**
  56542. * Define an offset for the layer in order to shift the texture.
  56543. */
  56544. offset: Vector2;
  56545. /**
  56546. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  56547. */
  56548. alphaBlendingMode: number;
  56549. /**
  56550. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  56551. * Alpha test will not mix with the background color in case of transparency.
  56552. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  56553. */
  56554. alphaTest: boolean;
  56555. /**
  56556. * Define a mask to restrict the layer to only some of the scene cameras.
  56557. */
  56558. layerMask: number;
  56559. /**
  56560. * Define the list of render target the layer is visible into.
  56561. */
  56562. renderTargetTextures: RenderTargetTexture[];
  56563. /**
  56564. * Define if the layer is only used in renderTarget or if it also
  56565. * renders in the main frame buffer of the canvas.
  56566. */
  56567. renderOnlyInRenderTargetTextures: boolean;
  56568. private _scene;
  56569. private _vertexBuffers;
  56570. private _indexBuffer;
  56571. private _effect;
  56572. private _previousDefines;
  56573. /**
  56574. * An event triggered when the layer is disposed.
  56575. */
  56576. onDisposeObservable: Observable<Layer>;
  56577. private _onDisposeObserver;
  56578. /**
  56579. * Back compatibility with callback before the onDisposeObservable existed.
  56580. * The set callback will be triggered when the layer has been disposed.
  56581. */
  56582. set onDispose(callback: () => void);
  56583. /**
  56584. * An event triggered before rendering the scene
  56585. */
  56586. onBeforeRenderObservable: Observable<Layer>;
  56587. private _onBeforeRenderObserver;
  56588. /**
  56589. * Back compatibility with callback before the onBeforeRenderObservable existed.
  56590. * The set callback will be triggered just before rendering the layer.
  56591. */
  56592. set onBeforeRender(callback: () => void);
  56593. /**
  56594. * An event triggered after rendering the scene
  56595. */
  56596. onAfterRenderObservable: Observable<Layer>;
  56597. private _onAfterRenderObserver;
  56598. /**
  56599. * Back compatibility with callback before the onAfterRenderObservable existed.
  56600. * The set callback will be triggered just after rendering the layer.
  56601. */
  56602. set onAfterRender(callback: () => void);
  56603. /**
  56604. * Instantiates a new layer.
  56605. * This represents a full screen 2d layer.
  56606. * This can be useful to display a picture in the background of your scene for instance.
  56607. * @see https://www.babylonjs-playground.com/#08A2BS#1
  56608. * @param name Define the name of the layer in the scene
  56609. * @param imgUrl Define the url of the texture to display in the layer
  56610. * @param scene Define the scene the layer belongs to
  56611. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  56612. * @param color Defines a color for the layer
  56613. */
  56614. constructor(
  56615. /**
  56616. * Define the name of the layer.
  56617. */
  56618. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  56619. private _createIndexBuffer;
  56620. /** @hidden */
  56621. _rebuild(): void;
  56622. /**
  56623. * Renders the layer in the scene.
  56624. */
  56625. render(): void;
  56626. /**
  56627. * Disposes and releases the associated ressources.
  56628. */
  56629. dispose(): void;
  56630. }
  56631. }
  56632. declare module "babylonjs/Layers/index" {
  56633. export * from "babylonjs/Layers/effectLayer";
  56634. export * from "babylonjs/Layers/effectLayerSceneComponent";
  56635. export * from "babylonjs/Layers/glowLayer";
  56636. export * from "babylonjs/Layers/highlightLayer";
  56637. export * from "babylonjs/Layers/layer";
  56638. export * from "babylonjs/Layers/layerSceneComponent";
  56639. }
  56640. declare module "babylonjs/Shaders/lensFlare.fragment" {
  56641. /** @hidden */
  56642. export var lensFlarePixelShader: {
  56643. name: string;
  56644. shader: string;
  56645. };
  56646. }
  56647. declare module "babylonjs/Shaders/lensFlare.vertex" {
  56648. /** @hidden */
  56649. export var lensFlareVertexShader: {
  56650. name: string;
  56651. shader: string;
  56652. };
  56653. }
  56654. declare module "babylonjs/LensFlares/lensFlareSystem" {
  56655. import { Scene } from "babylonjs/scene";
  56656. import { Vector3 } from "babylonjs/Maths/math.vector";
  56657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56658. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  56659. import "babylonjs/Shaders/lensFlare.fragment";
  56660. import "babylonjs/Shaders/lensFlare.vertex";
  56661. import { Viewport } from "babylonjs/Maths/math.viewport";
  56662. /**
  56663. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56664. * It is usually composed of several `lensFlare`.
  56665. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56666. */
  56667. export class LensFlareSystem {
  56668. /**
  56669. * Define the name of the lens flare system
  56670. */
  56671. name: string;
  56672. /**
  56673. * List of lens flares used in this system.
  56674. */
  56675. lensFlares: LensFlare[];
  56676. /**
  56677. * Define a limit from the border the lens flare can be visible.
  56678. */
  56679. borderLimit: number;
  56680. /**
  56681. * Define a viewport border we do not want to see the lens flare in.
  56682. */
  56683. viewportBorder: number;
  56684. /**
  56685. * Define a predicate which could limit the list of meshes able to occlude the effect.
  56686. */
  56687. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  56688. /**
  56689. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  56690. */
  56691. layerMask: number;
  56692. /**
  56693. * Define the id of the lens flare system in the scene.
  56694. * (equal to name by default)
  56695. */
  56696. id: string;
  56697. private _scene;
  56698. private _emitter;
  56699. private _vertexBuffers;
  56700. private _indexBuffer;
  56701. private _effect;
  56702. private _positionX;
  56703. private _positionY;
  56704. private _isEnabled;
  56705. /** @hidden */
  56706. static _SceneComponentInitialization: (scene: Scene) => void;
  56707. /**
  56708. * Instantiates a lens flare system.
  56709. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  56710. * It is usually composed of several `lensFlare`.
  56711. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56712. * @param name Define the name of the lens flare system in the scene
  56713. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  56714. * @param scene Define the scene the lens flare system belongs to
  56715. */
  56716. constructor(
  56717. /**
  56718. * Define the name of the lens flare system
  56719. */
  56720. name: string, emitter: any, scene: Scene);
  56721. /**
  56722. * Define if the lens flare system is enabled.
  56723. */
  56724. get isEnabled(): boolean;
  56725. set isEnabled(value: boolean);
  56726. /**
  56727. * Get the scene the effects belongs to.
  56728. * @returns the scene holding the lens flare system
  56729. */
  56730. getScene(): Scene;
  56731. /**
  56732. * Get the emitter of the lens flare system.
  56733. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56734. * @returns the emitter of the lens flare system
  56735. */
  56736. getEmitter(): any;
  56737. /**
  56738. * Set the emitter of the lens flare system.
  56739. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  56740. * @param newEmitter Define the new emitter of the system
  56741. */
  56742. setEmitter(newEmitter: any): void;
  56743. /**
  56744. * Get the lens flare system emitter position.
  56745. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  56746. * @returns the position
  56747. */
  56748. getEmitterPosition(): Vector3;
  56749. /**
  56750. * @hidden
  56751. */
  56752. computeEffectivePosition(globalViewport: Viewport): boolean;
  56753. /** @hidden */
  56754. _isVisible(): boolean;
  56755. /**
  56756. * @hidden
  56757. */
  56758. render(): boolean;
  56759. /**
  56760. * Dispose and release the lens flare with its associated resources.
  56761. */
  56762. dispose(): void;
  56763. /**
  56764. * Parse a lens flare system from a JSON repressentation
  56765. * @param parsedLensFlareSystem Define the JSON to parse
  56766. * @param scene Define the scene the parsed system should be instantiated in
  56767. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  56768. * @returns the parsed system
  56769. */
  56770. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  56771. /**
  56772. * Serialize the current Lens Flare System into a JSON representation.
  56773. * @returns the serialized JSON
  56774. */
  56775. serialize(): any;
  56776. }
  56777. }
  56778. declare module "babylonjs/LensFlares/lensFlare" {
  56779. import { Nullable } from "babylonjs/types";
  56780. import { Color3 } from "babylonjs/Maths/math.color";
  56781. import { Texture } from "babylonjs/Materials/Textures/texture";
  56782. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56783. /**
  56784. * This represents one of the lens effect in a `lensFlareSystem`.
  56785. * It controls one of the indiviual texture used in the effect.
  56786. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56787. */
  56788. export class LensFlare {
  56789. /**
  56790. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56791. */
  56792. size: number;
  56793. /**
  56794. * 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.
  56795. */
  56796. position: number;
  56797. /**
  56798. * Define the lens color.
  56799. */
  56800. color: Color3;
  56801. /**
  56802. * Define the lens texture.
  56803. */
  56804. texture: Nullable<Texture>;
  56805. /**
  56806. * Define the alpha mode to render this particular lens.
  56807. */
  56808. alphaMode: number;
  56809. private _system;
  56810. /**
  56811. * Creates a new Lens Flare.
  56812. * This represents one of the lens effect in a `lensFlareSystem`.
  56813. * It controls one of the indiviual texture used in the effect.
  56814. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56815. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  56816. * @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.
  56817. * @param color Define the lens color
  56818. * @param imgUrl Define the lens texture url
  56819. * @param system Define the `lensFlareSystem` this flare is part of
  56820. * @returns The newly created Lens Flare
  56821. */
  56822. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  56823. /**
  56824. * Instantiates a new Lens Flare.
  56825. * This represents one of the lens effect in a `lensFlareSystem`.
  56826. * It controls one of the indiviual texture used in the effect.
  56827. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56828. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  56829. * @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.
  56830. * @param color Define the lens color
  56831. * @param imgUrl Define the lens texture url
  56832. * @param system Define the `lensFlareSystem` this flare is part of
  56833. */
  56834. constructor(
  56835. /**
  56836. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  56837. */
  56838. size: number,
  56839. /**
  56840. * 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.
  56841. */
  56842. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  56843. /**
  56844. * Dispose and release the lens flare with its associated resources.
  56845. */
  56846. dispose(): void;
  56847. }
  56848. }
  56849. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  56850. import { Nullable } from "babylonjs/types";
  56851. import { Scene } from "babylonjs/scene";
  56852. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  56853. import { AbstractScene } from "babylonjs/abstractScene";
  56854. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  56855. module "babylonjs/abstractScene" {
  56856. interface AbstractScene {
  56857. /**
  56858. * The list of lens flare system added to the scene
  56859. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  56860. */
  56861. lensFlareSystems: Array<LensFlareSystem>;
  56862. /**
  56863. * Removes the given lens flare system from this scene.
  56864. * @param toRemove The lens flare system to remove
  56865. * @returns The index of the removed lens flare system
  56866. */
  56867. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  56868. /**
  56869. * Adds the given lens flare system to this scene
  56870. * @param newLensFlareSystem The lens flare system to add
  56871. */
  56872. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  56873. /**
  56874. * Gets a lens flare system using its name
  56875. * @param name defines the name to look for
  56876. * @returns the lens flare system or null if not found
  56877. */
  56878. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  56879. /**
  56880. * Gets a lens flare system using its id
  56881. * @param id defines the id to look for
  56882. * @returns the lens flare system or null if not found
  56883. */
  56884. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  56885. }
  56886. }
  56887. /**
  56888. * Defines the lens flare scene component responsible to manage any lens flares
  56889. * in a given scene.
  56890. */
  56891. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  56892. /**
  56893. * The component name helpfull to identify the component in the list of scene components.
  56894. */
  56895. readonly name: string;
  56896. /**
  56897. * The scene the component belongs to.
  56898. */
  56899. scene: Scene;
  56900. /**
  56901. * Creates a new instance of the component for the given scene
  56902. * @param scene Defines the scene to register the component in
  56903. */
  56904. constructor(scene: Scene);
  56905. /**
  56906. * Registers the component in a given scene
  56907. */
  56908. register(): void;
  56909. /**
  56910. * Rebuilds the elements related to this component in case of
  56911. * context lost for instance.
  56912. */
  56913. rebuild(): void;
  56914. /**
  56915. * Adds all the elements from the container to the scene
  56916. * @param container the container holding the elements
  56917. */
  56918. addFromContainer(container: AbstractScene): void;
  56919. /**
  56920. * Removes all the elements in the container from the scene
  56921. * @param container contains the elements to remove
  56922. * @param dispose if the removed element should be disposed (default: false)
  56923. */
  56924. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  56925. /**
  56926. * Serializes the component data to the specified json object
  56927. * @param serializationObject The object to serialize to
  56928. */
  56929. serialize(serializationObject: any): void;
  56930. /**
  56931. * Disposes the component and the associated ressources.
  56932. */
  56933. dispose(): void;
  56934. private _draw;
  56935. }
  56936. }
  56937. declare module "babylonjs/LensFlares/index" {
  56938. export * from "babylonjs/LensFlares/lensFlare";
  56939. export * from "babylonjs/LensFlares/lensFlareSystem";
  56940. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  56941. }
  56942. declare module "babylonjs/Shaders/depth.fragment" {
  56943. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  56944. /** @hidden */
  56945. export var depthPixelShader: {
  56946. name: string;
  56947. shader: string;
  56948. };
  56949. }
  56950. declare module "babylonjs/Shaders/depth.vertex" {
  56951. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56952. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  56953. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  56954. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56955. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  56956. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56957. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56958. /** @hidden */
  56959. export var depthVertexShader: {
  56960. name: string;
  56961. shader: string;
  56962. };
  56963. }
  56964. declare module "babylonjs/Rendering/depthRenderer" {
  56965. import { Nullable } from "babylonjs/types";
  56966. import { SubMesh } from "babylonjs/Meshes/subMesh";
  56967. import { Scene } from "babylonjs/scene";
  56968. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56969. import { Camera } from "babylonjs/Cameras/camera";
  56970. import "babylonjs/Shaders/depth.fragment";
  56971. import "babylonjs/Shaders/depth.vertex";
  56972. /**
  56973. * This represents a depth renderer in Babylon.
  56974. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  56975. */
  56976. export class DepthRenderer {
  56977. private _scene;
  56978. private _depthMap;
  56979. private _effect;
  56980. private readonly _storeNonLinearDepth;
  56981. private readonly _clearColor;
  56982. /** Get if the depth renderer is using packed depth or not */
  56983. readonly isPacked: boolean;
  56984. private _cachedDefines;
  56985. private _camera;
  56986. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  56987. enabled: boolean;
  56988. /**
  56989. * Specifiess that the depth renderer will only be used within
  56990. * the camera it is created for.
  56991. * This can help forcing its rendering during the camera processing.
  56992. */
  56993. useOnlyInActiveCamera: boolean;
  56994. /** @hidden */
  56995. static _SceneComponentInitialization: (scene: Scene) => void;
  56996. /**
  56997. * Instantiates a depth renderer
  56998. * @param scene The scene the renderer belongs to
  56999. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57000. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57001. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  57002. */
  57003. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  57004. /**
  57005. * Creates the depth rendering effect and checks if the effect is ready.
  57006. * @param subMesh The submesh to be used to render the depth map of
  57007. * @param useInstances If multiple world instances should be used
  57008. * @returns if the depth renderer is ready to render the depth map
  57009. */
  57010. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57011. /**
  57012. * Gets the texture which the depth map will be written to.
  57013. * @returns The depth map texture
  57014. */
  57015. getDepthMap(): RenderTargetTexture;
  57016. /**
  57017. * Disposes of the depth renderer.
  57018. */
  57019. dispose(): void;
  57020. }
  57021. }
  57022. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  57023. /** @hidden */
  57024. export var minmaxReduxPixelShader: {
  57025. name: string;
  57026. shader: string;
  57027. };
  57028. }
  57029. declare module "babylonjs/Misc/minMaxReducer" {
  57030. import { Nullable } from "babylonjs/types";
  57031. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57032. import { Camera } from "babylonjs/Cameras/camera";
  57033. import { Observer } from "babylonjs/Misc/observable";
  57034. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  57035. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  57036. import { Observable } from "babylonjs/Misc/observable";
  57037. import "babylonjs/Shaders/minmaxRedux.fragment";
  57038. /**
  57039. * This class computes a min/max reduction from a texture: it means it computes the minimum
  57040. * and maximum values from all values of the texture.
  57041. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  57042. * The source values are read from the red channel of the texture.
  57043. */
  57044. export class MinMaxReducer {
  57045. /**
  57046. * Observable triggered when the computation has been performed
  57047. */
  57048. onAfterReductionPerformed: Observable<{
  57049. min: number;
  57050. max: number;
  57051. }>;
  57052. protected _camera: Camera;
  57053. protected _sourceTexture: Nullable<RenderTargetTexture>;
  57054. protected _reductionSteps: Nullable<Array<PostProcess>>;
  57055. protected _postProcessManager: PostProcessManager;
  57056. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  57057. protected _forceFullscreenViewport: boolean;
  57058. /**
  57059. * Creates a min/max reducer
  57060. * @param camera The camera to use for the post processes
  57061. */
  57062. constructor(camera: Camera);
  57063. /**
  57064. * Gets the texture used to read the values from.
  57065. */
  57066. get sourceTexture(): Nullable<RenderTargetTexture>;
  57067. /**
  57068. * Sets the source texture to read the values from.
  57069. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  57070. * because in such textures '1' value must not be taken into account to compute the maximum
  57071. * as this value is used to clear the texture.
  57072. * Note that the computation is not activated by calling this function, you must call activate() for that!
  57073. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  57074. * @param depthRedux Indicates if the texture is a depth texture or not
  57075. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  57076. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57077. */
  57078. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57079. /**
  57080. * Defines the refresh rate of the computation.
  57081. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57082. */
  57083. get refreshRate(): number;
  57084. set refreshRate(value: number);
  57085. protected _activated: boolean;
  57086. /**
  57087. * Gets the activation status of the reducer
  57088. */
  57089. get activated(): boolean;
  57090. /**
  57091. * Activates the reduction computation.
  57092. * When activated, the observers registered in onAfterReductionPerformed are
  57093. * called after the compuation is performed
  57094. */
  57095. activate(): void;
  57096. /**
  57097. * Deactivates the reduction computation.
  57098. */
  57099. deactivate(): void;
  57100. /**
  57101. * Disposes the min/max reducer
  57102. * @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.
  57103. */
  57104. dispose(disposeAll?: boolean): void;
  57105. }
  57106. }
  57107. declare module "babylonjs/Misc/depthReducer" {
  57108. import { Nullable } from "babylonjs/types";
  57109. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57110. import { Camera } from "babylonjs/Cameras/camera";
  57111. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57112. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  57113. /**
  57114. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  57115. */
  57116. export class DepthReducer extends MinMaxReducer {
  57117. private _depthRenderer;
  57118. private _depthRendererId;
  57119. /**
  57120. * Gets the depth renderer used for the computation.
  57121. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  57122. */
  57123. get depthRenderer(): Nullable<DepthRenderer>;
  57124. /**
  57125. * Creates a depth reducer
  57126. * @param camera The camera used to render the depth texture
  57127. */
  57128. constructor(camera: Camera);
  57129. /**
  57130. * Sets the depth renderer to use to generate the depth map
  57131. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  57132. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  57133. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  57134. */
  57135. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  57136. /** @hidden */
  57137. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  57138. /**
  57139. * Activates the reduction computation.
  57140. * When activated, the observers registered in onAfterReductionPerformed are
  57141. * called after the compuation is performed
  57142. */
  57143. activate(): void;
  57144. /**
  57145. * Deactivates the reduction computation.
  57146. */
  57147. deactivate(): void;
  57148. /**
  57149. * Disposes the depth reducer
  57150. * @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.
  57151. */
  57152. dispose(disposeAll?: boolean): void;
  57153. }
  57154. }
  57155. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  57156. import { Nullable } from "babylonjs/types";
  57157. import { Scene } from "babylonjs/scene";
  57158. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57159. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57160. import { Effect } from "babylonjs/Materials/effect";
  57161. import "babylonjs/Shaders/shadowMap.fragment";
  57162. import "babylonjs/Shaders/shadowMap.vertex";
  57163. import "babylonjs/Shaders/depthBoxBlur.fragment";
  57164. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  57165. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  57166. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  57167. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57168. /**
  57169. * A CSM implementation allowing casting shadows on large scenes.
  57170. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57171. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  57172. */
  57173. export class CascadedShadowGenerator extends ShadowGenerator {
  57174. private static readonly frustumCornersNDCSpace;
  57175. /**
  57176. * Name of the CSM class
  57177. */
  57178. static CLASSNAME: string;
  57179. /**
  57180. * Defines the default number of cascades used by the CSM.
  57181. */
  57182. static readonly DEFAULT_CASCADES_COUNT: number;
  57183. /**
  57184. * Defines the minimum number of cascades used by the CSM.
  57185. */
  57186. static readonly MIN_CASCADES_COUNT: number;
  57187. /**
  57188. * Defines the maximum number of cascades used by the CSM.
  57189. */
  57190. static readonly MAX_CASCADES_COUNT: number;
  57191. protected _validateFilter(filter: number): number;
  57192. /**
  57193. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  57194. */
  57195. penumbraDarkness: number;
  57196. private _numCascades;
  57197. /**
  57198. * Gets or set the number of cascades used by the CSM.
  57199. */
  57200. get numCascades(): number;
  57201. set numCascades(value: number);
  57202. /**
  57203. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  57204. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  57205. */
  57206. stabilizeCascades: boolean;
  57207. private _freezeShadowCastersBoundingInfo;
  57208. private _freezeShadowCastersBoundingInfoObservable;
  57209. /**
  57210. * Enables or disables the shadow casters bounding info computation.
  57211. * If your shadow casters don't move, you can disable this feature.
  57212. * If it is enabled, the bounding box computation is done every frame.
  57213. */
  57214. get freezeShadowCastersBoundingInfo(): boolean;
  57215. set freezeShadowCastersBoundingInfo(freeze: boolean);
  57216. private _scbiMin;
  57217. private _scbiMax;
  57218. protected _computeShadowCastersBoundingInfo(): void;
  57219. protected _shadowCastersBoundingInfo: BoundingInfo;
  57220. /**
  57221. * Gets or sets the shadow casters bounding info.
  57222. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  57223. * so that the system won't overwrite the bounds you provide
  57224. */
  57225. get shadowCastersBoundingInfo(): BoundingInfo;
  57226. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  57227. protected _breaksAreDirty: boolean;
  57228. protected _minDistance: number;
  57229. protected _maxDistance: number;
  57230. /**
  57231. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  57232. *
  57233. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  57234. * If you don't know these values, simply leave them to their defaults and don't call this function.
  57235. * @param min minimal distance for the breaks (default to 0.)
  57236. * @param max maximal distance for the breaks (default to 1.)
  57237. */
  57238. setMinMaxDistance(min: number, max: number): void;
  57239. /** Gets the minimal distance used in the cascade break computation */
  57240. get minDistance(): number;
  57241. /** Gets the maximal distance used in the cascade break computation */
  57242. get maxDistance(): number;
  57243. /**
  57244. * Gets the class name of that object
  57245. * @returns "CascadedShadowGenerator"
  57246. */
  57247. getClassName(): string;
  57248. private _cascadeMinExtents;
  57249. private _cascadeMaxExtents;
  57250. /**
  57251. * Gets a cascade minimum extents
  57252. * @param cascadeIndex index of the cascade
  57253. * @returns the minimum cascade extents
  57254. */
  57255. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  57256. /**
  57257. * Gets a cascade maximum extents
  57258. * @param cascadeIndex index of the cascade
  57259. * @returns the maximum cascade extents
  57260. */
  57261. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  57262. private _cascades;
  57263. private _currentLayer;
  57264. private _viewSpaceFrustumsZ;
  57265. private _viewMatrices;
  57266. private _projectionMatrices;
  57267. private _transformMatrices;
  57268. private _transformMatricesAsArray;
  57269. private _frustumLengths;
  57270. private _lightSizeUVCorrection;
  57271. private _depthCorrection;
  57272. private _frustumCornersWorldSpace;
  57273. private _frustumCenter;
  57274. private _shadowCameraPos;
  57275. private _shadowMaxZ;
  57276. /**
  57277. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  57278. * It defaults to camera.maxZ
  57279. */
  57280. get shadowMaxZ(): number;
  57281. /**
  57282. * Sets the shadow max z distance.
  57283. */
  57284. set shadowMaxZ(value: number);
  57285. protected _debug: boolean;
  57286. /**
  57287. * Gets or sets the debug flag.
  57288. * When enabled, the cascades are materialized by different colors on the screen.
  57289. */
  57290. get debug(): boolean;
  57291. set debug(dbg: boolean);
  57292. private _depthClamp;
  57293. /**
  57294. * Gets or sets the depth clamping value.
  57295. *
  57296. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  57297. * to account for the shadow casters far away.
  57298. *
  57299. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  57300. */
  57301. get depthClamp(): boolean;
  57302. set depthClamp(value: boolean);
  57303. private _cascadeBlendPercentage;
  57304. /**
  57305. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  57306. * It defaults to 0.1 (10% blending).
  57307. */
  57308. get cascadeBlendPercentage(): number;
  57309. set cascadeBlendPercentage(value: number);
  57310. private _lambda;
  57311. /**
  57312. * Gets or set the lambda parameter.
  57313. * This parameter is used to split the camera frustum and create the cascades.
  57314. * 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.
  57315. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  57316. */
  57317. get lambda(): number;
  57318. set lambda(value: number);
  57319. /**
  57320. * Gets the view matrix corresponding to a given cascade
  57321. * @param cascadeNum cascade to retrieve the view matrix from
  57322. * @returns the cascade view matrix
  57323. */
  57324. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  57325. /**
  57326. * Gets the projection matrix corresponding to a given cascade
  57327. * @param cascadeNum cascade to retrieve the projection matrix from
  57328. * @returns the cascade projection matrix
  57329. */
  57330. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  57331. /**
  57332. * Gets the transformation matrix corresponding to a given cascade
  57333. * @param cascadeNum cascade to retrieve the transformation matrix from
  57334. * @returns the cascade transformation matrix
  57335. */
  57336. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  57337. private _depthRenderer;
  57338. /**
  57339. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  57340. *
  57341. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  57342. *
  57343. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  57344. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  57345. * @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
  57346. */
  57347. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  57348. private _depthReducer;
  57349. private _autoCalcDepthBounds;
  57350. /**
  57351. * Gets or sets the autoCalcDepthBounds property.
  57352. *
  57353. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  57354. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  57355. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  57356. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  57357. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  57358. */
  57359. get autoCalcDepthBounds(): boolean;
  57360. set autoCalcDepthBounds(value: boolean);
  57361. /**
  57362. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  57363. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  57364. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  57365. * for setting the refresh rate on the renderer yourself!
  57366. */
  57367. get autoCalcDepthBoundsRefreshRate(): number;
  57368. set autoCalcDepthBoundsRefreshRate(value: number);
  57369. /**
  57370. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  57371. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  57372. * you change the camera near/far planes!
  57373. */
  57374. splitFrustum(): void;
  57375. private _splitFrustum;
  57376. private _computeMatrices;
  57377. private _computeFrustumInWorldSpace;
  57378. private _computeCascadeFrustum;
  57379. /**
  57380. * Support test.
  57381. */
  57382. static get IsSupported(): boolean;
  57383. /** @hidden */
  57384. static _SceneComponentInitialization: (scene: Scene) => void;
  57385. /**
  57386. * Creates a Cascaded Shadow Generator object.
  57387. * A ShadowGenerator is the required tool to use the shadows.
  57388. * Each directional light casting shadows needs to use its own ShadowGenerator.
  57389. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  57390. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  57391. * @param light The directional light object generating the shadows.
  57392. * @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.
  57393. */
  57394. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  57395. protected _initializeGenerator(): void;
  57396. protected _createTargetRenderTexture(): void;
  57397. protected _initializeShadowMap(): void;
  57398. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  57399. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  57400. /**
  57401. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  57402. * @param defines Defines of the material we want to update
  57403. * @param lightIndex Index of the light in the enabled light list of the material
  57404. */
  57405. prepareDefines(defines: any, lightIndex: number): void;
  57406. /**
  57407. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  57408. * defined in the generator but impacting the effect).
  57409. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  57410. * @param effect The effect we are binfing the information for
  57411. */
  57412. bindShadowLight(lightIndex: string, effect: Effect): void;
  57413. /**
  57414. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  57415. * (eq to view projection * shadow projection matrices)
  57416. * @returns The transform matrix used to create the shadow map
  57417. */
  57418. getTransformMatrix(): Matrix;
  57419. /**
  57420. * Disposes the ShadowGenerator.
  57421. * Returns nothing.
  57422. */
  57423. dispose(): void;
  57424. /**
  57425. * Serializes the shadow generator setup to a json object.
  57426. * @returns The serialized JSON object
  57427. */
  57428. serialize(): any;
  57429. /**
  57430. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  57431. * @param parsedShadowGenerator The JSON object to parse
  57432. * @param scene The scene to create the shadow map for
  57433. * @returns The parsed shadow generator
  57434. */
  57435. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  57436. }
  57437. }
  57438. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  57439. import { Scene } from "babylonjs/scene";
  57440. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  57441. import { AbstractScene } from "babylonjs/abstractScene";
  57442. /**
  57443. * Defines the shadow generator component responsible to manage any shadow generators
  57444. * in a given scene.
  57445. */
  57446. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  57447. /**
  57448. * The component name helpfull to identify the component in the list of scene components.
  57449. */
  57450. readonly name: string;
  57451. /**
  57452. * The scene the component belongs to.
  57453. */
  57454. scene: Scene;
  57455. /**
  57456. * Creates a new instance of the component for the given scene
  57457. * @param scene Defines the scene to register the component in
  57458. */
  57459. constructor(scene: Scene);
  57460. /**
  57461. * Registers the component in a given scene
  57462. */
  57463. register(): void;
  57464. /**
  57465. * Rebuilds the elements related to this component in case of
  57466. * context lost for instance.
  57467. */
  57468. rebuild(): void;
  57469. /**
  57470. * Serializes the component data to the specified json object
  57471. * @param serializationObject The object to serialize to
  57472. */
  57473. serialize(serializationObject: any): void;
  57474. /**
  57475. * Adds all the elements from the container to the scene
  57476. * @param container the container holding the elements
  57477. */
  57478. addFromContainer(container: AbstractScene): void;
  57479. /**
  57480. * Removes all the elements in the container from the scene
  57481. * @param container contains the elements to remove
  57482. * @param dispose if the removed element should be disposed (default: false)
  57483. */
  57484. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  57485. /**
  57486. * Rebuilds the elements related to this component in case of
  57487. * context lost for instance.
  57488. */
  57489. dispose(): void;
  57490. private _gatherRenderTargets;
  57491. }
  57492. }
  57493. declare module "babylonjs/Lights/Shadows/index" {
  57494. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  57495. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  57496. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  57497. }
  57498. declare module "babylonjs/Lights/pointLight" {
  57499. import { Scene } from "babylonjs/scene";
  57500. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57501. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57502. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  57503. import { Effect } from "babylonjs/Materials/effect";
  57504. /**
  57505. * A point light is a light defined by an unique point in world space.
  57506. * The light is emitted in every direction from this point.
  57507. * A good example of a point light is a standard light bulb.
  57508. * Documentation: https://doc.babylonjs.com/babylon101/lights
  57509. */
  57510. export class PointLight extends ShadowLight {
  57511. private _shadowAngle;
  57512. /**
  57513. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57514. * This specifies what angle the shadow will use to be created.
  57515. *
  57516. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57517. */
  57518. get shadowAngle(): number;
  57519. /**
  57520. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57521. * This specifies what angle the shadow will use to be created.
  57522. *
  57523. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  57524. */
  57525. set shadowAngle(value: number);
  57526. /**
  57527. * Gets the direction if it has been set.
  57528. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57529. */
  57530. get direction(): Vector3;
  57531. /**
  57532. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  57533. */
  57534. set direction(value: Vector3);
  57535. /**
  57536. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  57537. * A PointLight emits the light in every direction.
  57538. * It can cast shadows.
  57539. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  57540. * ```javascript
  57541. * var pointLight = new PointLight("pl", camera.position, scene);
  57542. * ```
  57543. * Documentation : https://doc.babylonjs.com/babylon101/lights
  57544. * @param name The light friendly name
  57545. * @param position The position of the point light in the scene
  57546. * @param scene The scene the lights belongs to
  57547. */
  57548. constructor(name: string, position: Vector3, scene: Scene);
  57549. /**
  57550. * Returns the string "PointLight"
  57551. * @returns the class name
  57552. */
  57553. getClassName(): string;
  57554. /**
  57555. * Returns the integer 0.
  57556. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  57557. */
  57558. getTypeID(): number;
  57559. /**
  57560. * Specifies wether or not the shadowmap should be a cube texture.
  57561. * @returns true if the shadowmap needs to be a cube texture.
  57562. */
  57563. needCube(): boolean;
  57564. /**
  57565. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  57566. * @param faceIndex The index of the face we are computed the direction to generate shadow
  57567. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  57568. */
  57569. getShadowDirection(faceIndex?: number): Vector3;
  57570. /**
  57571. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  57572. * - fov = PI / 2
  57573. * - aspect ratio : 1.0
  57574. * - z-near and far equal to the active camera minZ and maxZ.
  57575. * Returns the PointLight.
  57576. */
  57577. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  57578. protected _buildUniformLayout(): void;
  57579. /**
  57580. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  57581. * @param effect The effect to update
  57582. * @param lightIndex The index of the light in the effect to update
  57583. * @returns The point light
  57584. */
  57585. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  57586. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  57587. /**
  57588. * Prepares the list of defines specific to the light type.
  57589. * @param defines the list of defines
  57590. * @param lightIndex defines the index of the light for the effect
  57591. */
  57592. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  57593. }
  57594. }
  57595. declare module "babylonjs/Lights/index" {
  57596. export * from "babylonjs/Lights/light";
  57597. export * from "babylonjs/Lights/shadowLight";
  57598. export * from "babylonjs/Lights/Shadows/index";
  57599. export * from "babylonjs/Lights/directionalLight";
  57600. export * from "babylonjs/Lights/hemisphericLight";
  57601. export * from "babylonjs/Lights/pointLight";
  57602. export * from "babylonjs/Lights/spotLight";
  57603. }
  57604. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  57605. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  57606. /**
  57607. * Header information of HDR texture files.
  57608. */
  57609. export interface HDRInfo {
  57610. /**
  57611. * The height of the texture in pixels.
  57612. */
  57613. height: number;
  57614. /**
  57615. * The width of the texture in pixels.
  57616. */
  57617. width: number;
  57618. /**
  57619. * The index of the beginning of the data in the binary file.
  57620. */
  57621. dataPosition: number;
  57622. }
  57623. /**
  57624. * This groups tools to convert HDR texture to native colors array.
  57625. */
  57626. export class HDRTools {
  57627. private static Ldexp;
  57628. private static Rgbe2float;
  57629. private static readStringLine;
  57630. /**
  57631. * Reads header information from an RGBE texture stored in a native array.
  57632. * More information on this format are available here:
  57633. * https://en.wikipedia.org/wiki/RGBE_image_format
  57634. *
  57635. * @param uint8array The binary file stored in native array.
  57636. * @return The header information.
  57637. */
  57638. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  57639. /**
  57640. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  57641. * This RGBE texture needs to store the information as a panorama.
  57642. *
  57643. * More information on this format are available here:
  57644. * https://en.wikipedia.org/wiki/RGBE_image_format
  57645. *
  57646. * @param buffer The binary file stored in an array buffer.
  57647. * @param size The expected size of the extracted cubemap.
  57648. * @return The Cube Map information.
  57649. */
  57650. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  57651. /**
  57652. * Returns the pixels data extracted from an RGBE texture.
  57653. * This pixels will be stored left to right up to down in the R G B order in one array.
  57654. *
  57655. * More information on this format are available here:
  57656. * https://en.wikipedia.org/wiki/RGBE_image_format
  57657. *
  57658. * @param uint8array The binary file stored in an array buffer.
  57659. * @param hdrInfo The header information of the file.
  57660. * @return The pixels data in RGB right to left up to down order.
  57661. */
  57662. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  57663. private static RGBE_ReadPixels_RLE;
  57664. }
  57665. }
  57666. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  57667. import { Nullable } from "babylonjs/types";
  57668. import { Scene } from "babylonjs/scene";
  57669. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57670. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57671. import "babylonjs/Engines/Extensions/engine.rawTexture";
  57672. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  57673. /**
  57674. * This represents a texture coming from an HDR input.
  57675. *
  57676. * The only supported format is currently panorama picture stored in RGBE format.
  57677. * Example of such files can be found on HDRLib: http://hdrlib.com/
  57678. */
  57679. export class HDRCubeTexture extends BaseTexture {
  57680. private static _facesMapping;
  57681. private _generateHarmonics;
  57682. private _noMipmap;
  57683. private _textureMatrix;
  57684. private _size;
  57685. private _onLoad;
  57686. private _onError;
  57687. /**
  57688. * The texture URL.
  57689. */
  57690. url: string;
  57691. /**
  57692. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  57693. */
  57694. coordinatesMode: number;
  57695. protected _isBlocking: boolean;
  57696. /**
  57697. * Sets wether or not the texture is blocking during loading.
  57698. */
  57699. set isBlocking(value: boolean);
  57700. /**
  57701. * Gets wether or not the texture is blocking during loading.
  57702. */
  57703. get isBlocking(): boolean;
  57704. protected _rotationY: number;
  57705. /**
  57706. * Sets texture matrix rotation angle around Y axis in radians.
  57707. */
  57708. set rotationY(value: number);
  57709. /**
  57710. * Gets texture matrix rotation angle around Y axis radians.
  57711. */
  57712. get rotationY(): number;
  57713. /**
  57714. * Gets or sets the center of the bounding box associated with the cube texture
  57715. * It must define where the camera used to render the texture was set
  57716. */
  57717. boundingBoxPosition: Vector3;
  57718. private _boundingBoxSize;
  57719. /**
  57720. * Gets or sets the size of the bounding box associated with the cube texture
  57721. * When defined, the cubemap will switch to local mode
  57722. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  57723. * @example https://www.babylonjs-playground.com/#RNASML
  57724. */
  57725. set boundingBoxSize(value: Vector3);
  57726. get boundingBoxSize(): Vector3;
  57727. /**
  57728. * Instantiates an HDRTexture from the following parameters.
  57729. *
  57730. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  57731. * @param scene The scene the texture will be used in
  57732. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  57733. * @param noMipmap Forces to not generate the mipmap if true
  57734. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  57735. * @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)
  57736. * @param reserved Reserved flag for internal use.
  57737. */
  57738. 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>);
  57739. /**
  57740. * Get the current class name of the texture useful for serialization or dynamic coding.
  57741. * @returns "HDRCubeTexture"
  57742. */
  57743. getClassName(): string;
  57744. /**
  57745. * Occurs when the file is raw .hdr file.
  57746. */
  57747. private loadTexture;
  57748. clone(): HDRCubeTexture;
  57749. delayLoad(): void;
  57750. /**
  57751. * Get the texture reflection matrix used to rotate/transform the reflection.
  57752. * @returns the reflection matrix
  57753. */
  57754. getReflectionTextureMatrix(): Matrix;
  57755. /**
  57756. * Set the texture reflection matrix used to rotate/transform the reflection.
  57757. * @param value Define the reflection matrix to set
  57758. */
  57759. setReflectionTextureMatrix(value: Matrix): void;
  57760. /**
  57761. * Parses a JSON representation of an HDR Texture in order to create the texture
  57762. * @param parsedTexture Define the JSON representation
  57763. * @param scene Define the scene the texture should be created in
  57764. * @param rootUrl Define the root url in case we need to load relative dependencies
  57765. * @returns the newly created texture after parsing
  57766. */
  57767. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  57768. serialize(): any;
  57769. }
  57770. }
  57771. declare module "babylonjs/Physics/physicsEngine" {
  57772. import { Nullable } from "babylonjs/types";
  57773. import { Vector3 } from "babylonjs/Maths/math.vector";
  57774. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  57775. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  57776. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  57777. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57778. /**
  57779. * Class used to control physics engine
  57780. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  57781. */
  57782. export class PhysicsEngine implements IPhysicsEngine {
  57783. private _physicsPlugin;
  57784. /**
  57785. * Global value used to control the smallest number supported by the simulation
  57786. */
  57787. static Epsilon: number;
  57788. private _impostors;
  57789. private _joints;
  57790. private _subTimeStep;
  57791. /**
  57792. * Gets the gravity vector used by the simulation
  57793. */
  57794. gravity: Vector3;
  57795. /**
  57796. * Factory used to create the default physics plugin.
  57797. * @returns The default physics plugin
  57798. */
  57799. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  57800. /**
  57801. * Creates a new Physics Engine
  57802. * @param gravity defines the gravity vector used by the simulation
  57803. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  57804. */
  57805. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  57806. /**
  57807. * Sets the gravity vector used by the simulation
  57808. * @param gravity defines the gravity vector to use
  57809. */
  57810. setGravity(gravity: Vector3): void;
  57811. /**
  57812. * Set the time step of the physics engine.
  57813. * Default is 1/60.
  57814. * To slow it down, enter 1/600 for example.
  57815. * To speed it up, 1/30
  57816. * @param newTimeStep defines the new timestep to apply to this world.
  57817. */
  57818. setTimeStep(newTimeStep?: number): void;
  57819. /**
  57820. * Get the time step of the physics engine.
  57821. * @returns the current time step
  57822. */
  57823. getTimeStep(): number;
  57824. /**
  57825. * Set the sub time step of the physics engine.
  57826. * Default is 0 meaning there is no sub steps
  57827. * To increase physics resolution precision, set a small value (like 1 ms)
  57828. * @param subTimeStep defines the new sub timestep used for physics resolution.
  57829. */
  57830. setSubTimeStep(subTimeStep?: number): void;
  57831. /**
  57832. * Get the sub time step of the physics engine.
  57833. * @returns the current sub time step
  57834. */
  57835. getSubTimeStep(): number;
  57836. /**
  57837. * Release all resources
  57838. */
  57839. dispose(): void;
  57840. /**
  57841. * Gets the name of the current physics plugin
  57842. * @returns the name of the plugin
  57843. */
  57844. getPhysicsPluginName(): string;
  57845. /**
  57846. * Adding a new impostor for the impostor tracking.
  57847. * This will be done by the impostor itself.
  57848. * @param impostor the impostor to add
  57849. */
  57850. addImpostor(impostor: PhysicsImpostor): void;
  57851. /**
  57852. * Remove an impostor from the engine.
  57853. * This impostor and its mesh will not longer be updated by the physics engine.
  57854. * @param impostor the impostor to remove
  57855. */
  57856. removeImpostor(impostor: PhysicsImpostor): void;
  57857. /**
  57858. * Add a joint to the physics engine
  57859. * @param mainImpostor defines the main impostor to which the joint is added.
  57860. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  57861. * @param joint defines the joint that will connect both impostors.
  57862. */
  57863. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57864. /**
  57865. * Removes a joint from the simulation
  57866. * @param mainImpostor defines the impostor used with the joint
  57867. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  57868. * @param joint defines the joint to remove
  57869. */
  57870. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  57871. /**
  57872. * Called by the scene. No need to call it.
  57873. * @param delta defines the timespam between frames
  57874. */
  57875. _step(delta: number): void;
  57876. /**
  57877. * Gets the current plugin used to run the simulation
  57878. * @returns current plugin
  57879. */
  57880. getPhysicsPlugin(): IPhysicsEnginePlugin;
  57881. /**
  57882. * Gets the list of physic impostors
  57883. * @returns an array of PhysicsImpostor
  57884. */
  57885. getImpostors(): Array<PhysicsImpostor>;
  57886. /**
  57887. * Gets the impostor for a physics enabled object
  57888. * @param object defines the object impersonated by the impostor
  57889. * @returns the PhysicsImpostor or null if not found
  57890. */
  57891. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  57892. /**
  57893. * Gets the impostor for a physics body object
  57894. * @param body defines physics body used by the impostor
  57895. * @returns the PhysicsImpostor or null if not found
  57896. */
  57897. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  57898. /**
  57899. * Does a raycast in the physics world
  57900. * @param from when should the ray start?
  57901. * @param to when should the ray end?
  57902. * @returns PhysicsRaycastResult
  57903. */
  57904. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57905. }
  57906. }
  57907. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  57908. import { Nullable } from "babylonjs/types";
  57909. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57910. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57911. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57912. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57913. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57914. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57915. /** @hidden */
  57916. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  57917. private _useDeltaForWorldStep;
  57918. world: any;
  57919. name: string;
  57920. private _physicsMaterials;
  57921. private _fixedTimeStep;
  57922. private _cannonRaycastResult;
  57923. private _raycastResult;
  57924. private _physicsBodysToRemoveAfterStep;
  57925. BJSCANNON: any;
  57926. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  57927. setGravity(gravity: Vector3): void;
  57928. setTimeStep(timeStep: number): void;
  57929. getTimeStep(): number;
  57930. executeStep(delta: number): void;
  57931. private _removeMarkedPhysicsBodiesFromWorld;
  57932. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57933. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  57934. generatePhysicsBody(impostor: PhysicsImpostor): void;
  57935. private _processChildMeshes;
  57936. removePhysicsBody(impostor: PhysicsImpostor): void;
  57937. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  57938. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  57939. private _addMaterial;
  57940. private _checkWithEpsilon;
  57941. private _createShape;
  57942. private _createHeightmap;
  57943. private _minus90X;
  57944. private _plus90X;
  57945. private _tmpPosition;
  57946. private _tmpDeltaPosition;
  57947. private _tmpUnityRotation;
  57948. private _updatePhysicsBodyTransformation;
  57949. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  57950. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  57951. isSupported(): boolean;
  57952. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57953. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  57954. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57955. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  57956. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  57957. getBodyMass(impostor: PhysicsImpostor): number;
  57958. getBodyFriction(impostor: PhysicsImpostor): number;
  57959. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  57960. getBodyRestitution(impostor: PhysicsImpostor): number;
  57961. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  57962. sleepBody(impostor: PhysicsImpostor): void;
  57963. wakeUpBody(impostor: PhysicsImpostor): void;
  57964. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  57965. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  57966. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  57967. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  57968. getRadius(impostor: PhysicsImpostor): number;
  57969. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  57970. dispose(): void;
  57971. private _extendNamespace;
  57972. /**
  57973. * Does a raycast in the physics world
  57974. * @param from when should the ray start?
  57975. * @param to when should the ray end?
  57976. * @returns PhysicsRaycastResult
  57977. */
  57978. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  57979. }
  57980. }
  57981. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  57982. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  57983. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  57984. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  57985. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57986. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  57987. import { Nullable } from "babylonjs/types";
  57988. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  57989. /** @hidden */
  57990. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  57991. world: any;
  57992. name: string;
  57993. BJSOIMO: any;
  57994. private _raycastResult;
  57995. constructor(iterations?: number, oimoInjection?: any);
  57996. setGravity(gravity: Vector3): void;
  57997. setTimeStep(timeStep: number): void;
  57998. getTimeStep(): number;
  57999. private _tmpImpostorsArray;
  58000. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58001. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58002. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58003. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58004. private _tmpPositionVector;
  58005. removePhysicsBody(impostor: PhysicsImpostor): void;
  58006. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58007. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58008. isSupported(): boolean;
  58009. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58010. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58011. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58012. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58013. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58014. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58015. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58016. getBodyMass(impostor: PhysicsImpostor): number;
  58017. getBodyFriction(impostor: PhysicsImpostor): number;
  58018. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58019. getBodyRestitution(impostor: PhysicsImpostor): number;
  58020. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58021. sleepBody(impostor: PhysicsImpostor): void;
  58022. wakeUpBody(impostor: PhysicsImpostor): void;
  58023. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58024. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  58025. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  58026. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58027. getRadius(impostor: PhysicsImpostor): number;
  58028. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58029. dispose(): void;
  58030. /**
  58031. * Does a raycast in the physics world
  58032. * @param from when should the ray start?
  58033. * @param to when should the ray end?
  58034. * @returns PhysicsRaycastResult
  58035. */
  58036. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58037. }
  58038. }
  58039. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  58040. import { Nullable } from "babylonjs/types";
  58041. import { Scene } from "babylonjs/scene";
  58042. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  58043. import { Color4 } from "babylonjs/Maths/math.color";
  58044. import { Mesh } from "babylonjs/Meshes/mesh";
  58045. /**
  58046. * Class containing static functions to help procedurally build meshes
  58047. */
  58048. export class RibbonBuilder {
  58049. /**
  58050. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  58051. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  58052. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  58053. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  58054. * * 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
  58055. * * 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
  58056. * * 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
  58057. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58058. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58059. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58060. * * 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
  58061. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  58062. * * 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
  58063. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  58064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58065. * @param name defines the name of the mesh
  58066. * @param options defines the options used to create the mesh
  58067. * @param scene defines the hosting scene
  58068. * @returns the ribbon mesh
  58069. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  58070. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58071. */
  58072. static CreateRibbon(name: string, options: {
  58073. pathArray: Vector3[][];
  58074. closeArray?: boolean;
  58075. closePath?: boolean;
  58076. offset?: number;
  58077. updatable?: boolean;
  58078. sideOrientation?: number;
  58079. frontUVs?: Vector4;
  58080. backUVs?: Vector4;
  58081. instance?: Mesh;
  58082. invertUV?: boolean;
  58083. uvs?: Vector2[];
  58084. colors?: Color4[];
  58085. }, scene?: Nullable<Scene>): Mesh;
  58086. }
  58087. }
  58088. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  58089. import { Nullable } from "babylonjs/types";
  58090. import { Scene } from "babylonjs/scene";
  58091. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  58092. import { Mesh } from "babylonjs/Meshes/mesh";
  58093. /**
  58094. * Class containing static functions to help procedurally build meshes
  58095. */
  58096. export class ShapeBuilder {
  58097. /**
  58098. * 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.
  58099. * * 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.
  58100. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58101. * * 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.
  58102. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  58103. * * 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
  58104. * * 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
  58105. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  58106. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58107. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58108. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  58109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  58110. * @param name defines the name of the mesh
  58111. * @param options defines the options used to create the mesh
  58112. * @param scene defines the hosting scene
  58113. * @returns the extruded shape mesh
  58114. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58115. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58116. */
  58117. static ExtrudeShape(name: string, options: {
  58118. shape: Vector3[];
  58119. path: Vector3[];
  58120. scale?: number;
  58121. rotation?: number;
  58122. cap?: number;
  58123. updatable?: boolean;
  58124. sideOrientation?: number;
  58125. frontUVs?: Vector4;
  58126. backUVs?: Vector4;
  58127. instance?: Mesh;
  58128. invertUV?: boolean;
  58129. }, scene?: Nullable<Scene>): Mesh;
  58130. /**
  58131. * Creates an custom extruded shape mesh.
  58132. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  58133. * * 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.
  58134. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  58135. * * 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
  58136. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  58137. * * 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
  58138. * * It must returns a float value that will be the scale value applied to the shape on each path point
  58139. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  58140. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  58141. * * 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
  58142. * * 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
  58143. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  58144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  58145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  58146. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  58147. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  58148. * @param name defines the name of the mesh
  58149. * @param options defines the options used to create the mesh
  58150. * @param scene defines the hosting scene
  58151. * @returns the custom extruded shape mesh
  58152. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  58153. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  58154. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  58155. */
  58156. static ExtrudeShapeCustom(name: string, options: {
  58157. shape: Vector3[];
  58158. path: Vector3[];
  58159. scaleFunction?: any;
  58160. rotationFunction?: any;
  58161. ribbonCloseArray?: boolean;
  58162. ribbonClosePath?: boolean;
  58163. cap?: number;
  58164. updatable?: boolean;
  58165. sideOrientation?: number;
  58166. frontUVs?: Vector4;
  58167. backUVs?: Vector4;
  58168. instance?: Mesh;
  58169. invertUV?: boolean;
  58170. }, scene?: Nullable<Scene>): Mesh;
  58171. private static _ExtrudeShapeGeneric;
  58172. }
  58173. }
  58174. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  58175. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  58176. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  58177. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  58178. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  58179. import { Nullable } from "babylonjs/types";
  58180. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58181. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  58182. /**
  58183. * AmmoJS Physics plugin
  58184. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  58185. * @see https://github.com/kripken/ammo.js/
  58186. */
  58187. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  58188. private _useDeltaForWorldStep;
  58189. /**
  58190. * Reference to the Ammo library
  58191. */
  58192. bjsAMMO: any;
  58193. /**
  58194. * Created ammoJS world which physics bodies are added to
  58195. */
  58196. world: any;
  58197. /**
  58198. * Name of the plugin
  58199. */
  58200. name: string;
  58201. private _timeStep;
  58202. private _fixedTimeStep;
  58203. private _maxSteps;
  58204. private _tmpQuaternion;
  58205. private _tmpAmmoTransform;
  58206. private _tmpAmmoQuaternion;
  58207. private _tmpAmmoConcreteContactResultCallback;
  58208. private _collisionConfiguration;
  58209. private _dispatcher;
  58210. private _overlappingPairCache;
  58211. private _solver;
  58212. private _softBodySolver;
  58213. private _tmpAmmoVectorA;
  58214. private _tmpAmmoVectorB;
  58215. private _tmpAmmoVectorC;
  58216. private _tmpAmmoVectorD;
  58217. private _tmpContactCallbackResult;
  58218. private _tmpAmmoVectorRCA;
  58219. private _tmpAmmoVectorRCB;
  58220. private _raycastResult;
  58221. private static readonly DISABLE_COLLISION_FLAG;
  58222. private static readonly KINEMATIC_FLAG;
  58223. private static readonly DISABLE_DEACTIVATION_FLAG;
  58224. /**
  58225. * Initializes the ammoJS plugin
  58226. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  58227. * @param ammoInjection can be used to inject your own ammo reference
  58228. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  58229. */
  58230. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  58231. /**
  58232. * Sets the gravity of the physics world (m/(s^2))
  58233. * @param gravity Gravity to set
  58234. */
  58235. setGravity(gravity: Vector3): void;
  58236. /**
  58237. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  58238. * @param timeStep timestep to use in seconds
  58239. */
  58240. setTimeStep(timeStep: number): void;
  58241. /**
  58242. * 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)
  58243. * @param fixedTimeStep fixedTimeStep to use in seconds
  58244. */
  58245. setFixedTimeStep(fixedTimeStep: number): void;
  58246. /**
  58247. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  58248. * @param maxSteps the maximum number of steps by the physics engine per frame
  58249. */
  58250. setMaxSteps(maxSteps: number): void;
  58251. /**
  58252. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  58253. * @returns the current timestep in seconds
  58254. */
  58255. getTimeStep(): number;
  58256. /**
  58257. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  58258. */
  58259. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  58260. private _isImpostorInContact;
  58261. private _isImpostorPairInContact;
  58262. private _stepSimulation;
  58263. /**
  58264. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  58265. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  58266. * After the step the babylon meshes are set to the position of the physics imposters
  58267. * @param delta amount of time to step forward
  58268. * @param impostors array of imposters to update before/after the step
  58269. */
  58270. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  58271. /**
  58272. * Update babylon mesh to match physics world object
  58273. * @param impostor imposter to match
  58274. */
  58275. private _afterSoftStep;
  58276. /**
  58277. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58278. * @param impostor imposter to match
  58279. */
  58280. private _ropeStep;
  58281. /**
  58282. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  58283. * @param impostor imposter to match
  58284. */
  58285. private _softbodyOrClothStep;
  58286. private _tmpMatrix;
  58287. /**
  58288. * Applies an impulse on the imposter
  58289. * @param impostor imposter to apply impulse to
  58290. * @param force amount of force to be applied to the imposter
  58291. * @param contactPoint the location to apply the impulse on the imposter
  58292. */
  58293. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58294. /**
  58295. * Applies a force on the imposter
  58296. * @param impostor imposter to apply force
  58297. * @param force amount of force to be applied to the imposter
  58298. * @param contactPoint the location to apply the force on the imposter
  58299. */
  58300. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  58301. /**
  58302. * Creates a physics body using the plugin
  58303. * @param impostor the imposter to create the physics body on
  58304. */
  58305. generatePhysicsBody(impostor: PhysicsImpostor): void;
  58306. /**
  58307. * Removes the physics body from the imposter and disposes of the body's memory
  58308. * @param impostor imposter to remove the physics body from
  58309. */
  58310. removePhysicsBody(impostor: PhysicsImpostor): void;
  58311. /**
  58312. * Generates a joint
  58313. * @param impostorJoint the imposter joint to create the joint with
  58314. */
  58315. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  58316. /**
  58317. * Removes a joint
  58318. * @param impostorJoint the imposter joint to remove the joint from
  58319. */
  58320. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  58321. private _addMeshVerts;
  58322. /**
  58323. * Initialise the soft body vertices to match its object's (mesh) vertices
  58324. * Softbody vertices (nodes) are in world space and to match this
  58325. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  58326. * @param impostor to create the softbody for
  58327. */
  58328. private _softVertexData;
  58329. /**
  58330. * Create an impostor's soft body
  58331. * @param impostor to create the softbody for
  58332. */
  58333. private _createSoftbody;
  58334. /**
  58335. * Create cloth for an impostor
  58336. * @param impostor to create the softbody for
  58337. */
  58338. private _createCloth;
  58339. /**
  58340. * Create rope for an impostor
  58341. * @param impostor to create the softbody for
  58342. */
  58343. private _createRope;
  58344. /**
  58345. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  58346. * @param impostor to create the custom physics shape for
  58347. */
  58348. private _createCustom;
  58349. private _addHullVerts;
  58350. private _createShape;
  58351. /**
  58352. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  58353. * @param impostor imposter containing the physics body and babylon object
  58354. */
  58355. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  58356. /**
  58357. * Sets the babylon object's position/rotation from the physics body's position/rotation
  58358. * @param impostor imposter containing the physics body and babylon object
  58359. * @param newPosition new position
  58360. * @param newRotation new rotation
  58361. */
  58362. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  58363. /**
  58364. * If this plugin is supported
  58365. * @returns true if its supported
  58366. */
  58367. isSupported(): boolean;
  58368. /**
  58369. * Sets the linear velocity of the physics body
  58370. * @param impostor imposter to set the velocity on
  58371. * @param velocity velocity to set
  58372. */
  58373. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58374. /**
  58375. * Sets the angular velocity of the physics body
  58376. * @param impostor imposter to set the velocity on
  58377. * @param velocity velocity to set
  58378. */
  58379. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  58380. /**
  58381. * gets the linear velocity
  58382. * @param impostor imposter to get linear velocity from
  58383. * @returns linear velocity
  58384. */
  58385. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58386. /**
  58387. * gets the angular velocity
  58388. * @param impostor imposter to get angular velocity from
  58389. * @returns angular velocity
  58390. */
  58391. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  58392. /**
  58393. * Sets the mass of physics body
  58394. * @param impostor imposter to set the mass on
  58395. * @param mass mass to set
  58396. */
  58397. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  58398. /**
  58399. * Gets the mass of the physics body
  58400. * @param impostor imposter to get the mass from
  58401. * @returns mass
  58402. */
  58403. getBodyMass(impostor: PhysicsImpostor): number;
  58404. /**
  58405. * Gets friction of the impostor
  58406. * @param impostor impostor to get friction from
  58407. * @returns friction value
  58408. */
  58409. getBodyFriction(impostor: PhysicsImpostor): number;
  58410. /**
  58411. * Sets friction of the impostor
  58412. * @param impostor impostor to set friction on
  58413. * @param friction friction value
  58414. */
  58415. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  58416. /**
  58417. * Gets restitution of the impostor
  58418. * @param impostor impostor to get restitution from
  58419. * @returns restitution value
  58420. */
  58421. getBodyRestitution(impostor: PhysicsImpostor): number;
  58422. /**
  58423. * Sets resitution of the impostor
  58424. * @param impostor impostor to set resitution on
  58425. * @param restitution resitution value
  58426. */
  58427. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  58428. /**
  58429. * Gets pressure inside the impostor
  58430. * @param impostor impostor to get pressure from
  58431. * @returns pressure value
  58432. */
  58433. getBodyPressure(impostor: PhysicsImpostor): number;
  58434. /**
  58435. * Sets pressure inside a soft body impostor
  58436. * Cloth and rope must remain 0 pressure
  58437. * @param impostor impostor to set pressure on
  58438. * @param pressure pressure value
  58439. */
  58440. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  58441. /**
  58442. * Gets stiffness of the impostor
  58443. * @param impostor impostor to get stiffness from
  58444. * @returns pressure value
  58445. */
  58446. getBodyStiffness(impostor: PhysicsImpostor): number;
  58447. /**
  58448. * Sets stiffness of the impostor
  58449. * @param impostor impostor to set stiffness on
  58450. * @param stiffness stiffness value from 0 to 1
  58451. */
  58452. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  58453. /**
  58454. * Gets velocityIterations of the impostor
  58455. * @param impostor impostor to get velocity iterations from
  58456. * @returns velocityIterations value
  58457. */
  58458. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  58459. /**
  58460. * Sets velocityIterations of the impostor
  58461. * @param impostor impostor to set velocity iterations on
  58462. * @param velocityIterations velocityIterations value
  58463. */
  58464. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  58465. /**
  58466. * Gets positionIterations of the impostor
  58467. * @param impostor impostor to get position iterations from
  58468. * @returns positionIterations value
  58469. */
  58470. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  58471. /**
  58472. * Sets positionIterations of the impostor
  58473. * @param impostor impostor to set position on
  58474. * @param positionIterations positionIterations value
  58475. */
  58476. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  58477. /**
  58478. * Append an anchor to a cloth object
  58479. * @param impostor is the cloth impostor to add anchor to
  58480. * @param otherImpostor is the rigid impostor to anchor to
  58481. * @param width ratio across width from 0 to 1
  58482. * @param height ratio up height from 0 to 1
  58483. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  58484. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58485. */
  58486. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58487. /**
  58488. * Append an hook to a rope object
  58489. * @param impostor is the rope impostor to add hook to
  58490. * @param otherImpostor is the rigid impostor to hook to
  58491. * @param length ratio along the rope from 0 to 1
  58492. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  58493. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  58494. */
  58495. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  58496. /**
  58497. * Sleeps the physics body and stops it from being active
  58498. * @param impostor impostor to sleep
  58499. */
  58500. sleepBody(impostor: PhysicsImpostor): void;
  58501. /**
  58502. * Activates the physics body
  58503. * @param impostor impostor to activate
  58504. */
  58505. wakeUpBody(impostor: PhysicsImpostor): void;
  58506. /**
  58507. * Updates the distance parameters of the joint
  58508. * @param joint joint to update
  58509. * @param maxDistance maximum distance of the joint
  58510. * @param minDistance minimum distance of the joint
  58511. */
  58512. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  58513. /**
  58514. * Sets a motor on the joint
  58515. * @param joint joint to set motor on
  58516. * @param speed speed of the motor
  58517. * @param maxForce maximum force of the motor
  58518. * @param motorIndex index of the motor
  58519. */
  58520. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  58521. /**
  58522. * Sets the motors limit
  58523. * @param joint joint to set limit on
  58524. * @param upperLimit upper limit
  58525. * @param lowerLimit lower limit
  58526. */
  58527. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  58528. /**
  58529. * Syncs the position and rotation of a mesh with the impostor
  58530. * @param mesh mesh to sync
  58531. * @param impostor impostor to update the mesh with
  58532. */
  58533. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  58534. /**
  58535. * Gets the radius of the impostor
  58536. * @param impostor impostor to get radius from
  58537. * @returns the radius
  58538. */
  58539. getRadius(impostor: PhysicsImpostor): number;
  58540. /**
  58541. * Gets the box size of the impostor
  58542. * @param impostor impostor to get box size from
  58543. * @param result the resulting box size
  58544. */
  58545. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  58546. /**
  58547. * Disposes of the impostor
  58548. */
  58549. dispose(): void;
  58550. /**
  58551. * Does a raycast in the physics world
  58552. * @param from when should the ray start?
  58553. * @param to when should the ray end?
  58554. * @returns PhysicsRaycastResult
  58555. */
  58556. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  58557. }
  58558. }
  58559. declare module "babylonjs/Probes/reflectionProbe" {
  58560. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58561. import { Vector3 } from "babylonjs/Maths/math.vector";
  58562. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58563. import { Nullable } from "babylonjs/types";
  58564. import { Scene } from "babylonjs/scene";
  58565. module "babylonjs/abstractScene" {
  58566. interface AbstractScene {
  58567. /**
  58568. * The list of reflection probes added to the scene
  58569. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58570. */
  58571. reflectionProbes: Array<ReflectionProbe>;
  58572. /**
  58573. * Removes the given reflection probe from this scene.
  58574. * @param toRemove The reflection probe to remove
  58575. * @returns The index of the removed reflection probe
  58576. */
  58577. removeReflectionProbe(toRemove: ReflectionProbe): number;
  58578. /**
  58579. * Adds the given reflection probe to this scene.
  58580. * @param newReflectionProbe The reflection probe to add
  58581. */
  58582. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  58583. }
  58584. }
  58585. /**
  58586. * Class used to generate realtime reflection / refraction cube textures
  58587. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  58588. */
  58589. export class ReflectionProbe {
  58590. /** defines the name of the probe */
  58591. name: string;
  58592. private _scene;
  58593. private _renderTargetTexture;
  58594. private _projectionMatrix;
  58595. private _viewMatrix;
  58596. private _target;
  58597. private _add;
  58598. private _attachedMesh;
  58599. private _invertYAxis;
  58600. /** Gets or sets probe position (center of the cube map) */
  58601. position: Vector3;
  58602. /**
  58603. * Creates a new reflection probe
  58604. * @param name defines the name of the probe
  58605. * @param size defines the texture resolution (for each face)
  58606. * @param scene defines the hosting scene
  58607. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  58608. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  58609. */
  58610. constructor(
  58611. /** defines the name of the probe */
  58612. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  58613. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  58614. get samples(): number;
  58615. set samples(value: number);
  58616. /** Gets or sets the refresh rate to use (on every frame by default) */
  58617. get refreshRate(): number;
  58618. set refreshRate(value: number);
  58619. /**
  58620. * Gets the hosting scene
  58621. * @returns a Scene
  58622. */
  58623. getScene(): Scene;
  58624. /** Gets the internal CubeTexture used to render to */
  58625. get cubeTexture(): RenderTargetTexture;
  58626. /** Gets the list of meshes to render */
  58627. get renderList(): Nullable<AbstractMesh[]>;
  58628. /**
  58629. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  58630. * @param mesh defines the mesh to attach to
  58631. */
  58632. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  58633. /**
  58634. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  58635. * @param renderingGroupId The rendering group id corresponding to its index
  58636. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58637. */
  58638. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  58639. /**
  58640. * Clean all associated resources
  58641. */
  58642. dispose(): void;
  58643. /**
  58644. * Converts the reflection probe information to a readable string for debug purpose.
  58645. * @param fullDetails Supports for multiple levels of logging within scene loading
  58646. * @returns the human readable reflection probe info
  58647. */
  58648. toString(fullDetails?: boolean): string;
  58649. /**
  58650. * Get the class name of the relfection probe.
  58651. * @returns "ReflectionProbe"
  58652. */
  58653. getClassName(): string;
  58654. /**
  58655. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  58656. * @returns The JSON representation of the texture
  58657. */
  58658. serialize(): any;
  58659. /**
  58660. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  58661. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  58662. * @param scene Define the scene the parsed reflection probe should be instantiated in
  58663. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  58664. * @returns The parsed reflection probe if successful
  58665. */
  58666. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  58667. }
  58668. }
  58669. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  58670. /** @hidden */
  58671. export var _BabylonLoaderRegistered: boolean;
  58672. /**
  58673. * Helps setting up some configuration for the babylon file loader.
  58674. */
  58675. export class BabylonFileLoaderConfiguration {
  58676. /**
  58677. * The loader does not allow injecting custom physix engine into the plugins.
  58678. * Unfortunately in ES6, we need to manually inject them into the plugin.
  58679. * So you could set this variable to your engine import to make it work.
  58680. */
  58681. static LoaderInjectedPhysicsEngine: any;
  58682. }
  58683. }
  58684. declare module "babylonjs/Loading/Plugins/index" {
  58685. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  58686. }
  58687. declare module "babylonjs/Loading/index" {
  58688. export * from "babylonjs/Loading/loadingScreen";
  58689. export * from "babylonjs/Loading/Plugins/index";
  58690. export * from "babylonjs/Loading/sceneLoader";
  58691. export * from "babylonjs/Loading/sceneLoaderFlags";
  58692. }
  58693. declare module "babylonjs/Materials/Background/index" {
  58694. export * from "babylonjs/Materials/Background/backgroundMaterial";
  58695. }
  58696. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  58697. import { Scene } from "babylonjs/scene";
  58698. import { Color3 } from "babylonjs/Maths/math.color";
  58699. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58700. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58701. /**
  58702. * The Physically based simple base material of BJS.
  58703. *
  58704. * This enables better naming and convention enforcements on top of the pbrMaterial.
  58705. * It is used as the base class for both the specGloss and metalRough conventions.
  58706. */
  58707. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  58708. /**
  58709. * Number of Simultaneous lights allowed on the material.
  58710. */
  58711. maxSimultaneousLights: number;
  58712. /**
  58713. * If sets to true, disables all the lights affecting the material.
  58714. */
  58715. disableLighting: boolean;
  58716. /**
  58717. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  58718. */
  58719. environmentTexture: BaseTexture;
  58720. /**
  58721. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  58722. */
  58723. invertNormalMapX: boolean;
  58724. /**
  58725. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  58726. */
  58727. invertNormalMapY: boolean;
  58728. /**
  58729. * Normal map used in the model.
  58730. */
  58731. normalTexture: BaseTexture;
  58732. /**
  58733. * Emissivie color used to self-illuminate the model.
  58734. */
  58735. emissiveColor: Color3;
  58736. /**
  58737. * Emissivie texture used to self-illuminate the model.
  58738. */
  58739. emissiveTexture: BaseTexture;
  58740. /**
  58741. * Occlusion Channel Strenght.
  58742. */
  58743. occlusionStrength: number;
  58744. /**
  58745. * Occlusion Texture of the material (adding extra occlusion effects).
  58746. */
  58747. occlusionTexture: BaseTexture;
  58748. /**
  58749. * Defines the alpha limits in alpha test mode.
  58750. */
  58751. alphaCutOff: number;
  58752. /**
  58753. * Gets the current double sided mode.
  58754. */
  58755. get doubleSided(): boolean;
  58756. /**
  58757. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  58758. */
  58759. set doubleSided(value: boolean);
  58760. /**
  58761. * Stores the pre-calculated light information of a mesh in a texture.
  58762. */
  58763. lightmapTexture: BaseTexture;
  58764. /**
  58765. * If true, the light map contains occlusion information instead of lighting info.
  58766. */
  58767. useLightmapAsShadowmap: boolean;
  58768. /**
  58769. * Instantiates a new PBRMaterial instance.
  58770. *
  58771. * @param name The material name
  58772. * @param scene The scene the material will be use in.
  58773. */
  58774. constructor(name: string, scene: Scene);
  58775. getClassName(): string;
  58776. }
  58777. }
  58778. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  58779. import { Scene } from "babylonjs/scene";
  58780. import { Color3 } from "babylonjs/Maths/math.color";
  58781. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58782. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58783. /**
  58784. * The PBR material of BJS following the metal roughness convention.
  58785. *
  58786. * This fits to the PBR convention in the GLTF definition:
  58787. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  58788. */
  58789. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  58790. /**
  58791. * The base color has two different interpretations depending on the value of metalness.
  58792. * When the material is a metal, the base color is the specific measured reflectance value
  58793. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  58794. * of the material.
  58795. */
  58796. baseColor: Color3;
  58797. /**
  58798. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  58799. * well as opacity information in the alpha channel.
  58800. */
  58801. baseTexture: BaseTexture;
  58802. /**
  58803. * Specifies the metallic scalar value of the material.
  58804. * Can also be used to scale the metalness values of the metallic texture.
  58805. */
  58806. metallic: number;
  58807. /**
  58808. * Specifies the roughness scalar value of the material.
  58809. * Can also be used to scale the roughness values of the metallic texture.
  58810. */
  58811. roughness: number;
  58812. /**
  58813. * Texture containing both the metallic value in the B channel and the
  58814. * roughness value in the G channel to keep better precision.
  58815. */
  58816. metallicRoughnessTexture: BaseTexture;
  58817. /**
  58818. * Instantiates a new PBRMetalRoughnessMaterial instance.
  58819. *
  58820. * @param name The material name
  58821. * @param scene The scene the material will be use in.
  58822. */
  58823. constructor(name: string, scene: Scene);
  58824. /**
  58825. * Return the currrent class name of the material.
  58826. */
  58827. getClassName(): string;
  58828. /**
  58829. * Makes a duplicate of the current material.
  58830. * @param name - name to use for the new material.
  58831. */
  58832. clone(name: string): PBRMetallicRoughnessMaterial;
  58833. /**
  58834. * Serialize the material to a parsable JSON object.
  58835. */
  58836. serialize(): any;
  58837. /**
  58838. * Parses a JSON object correponding to the serialize function.
  58839. */
  58840. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  58841. }
  58842. }
  58843. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  58844. import { Scene } from "babylonjs/scene";
  58845. import { Color3 } from "babylonjs/Maths/math.color";
  58846. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58847. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58848. /**
  58849. * The PBR material of BJS following the specular glossiness convention.
  58850. *
  58851. * This fits to the PBR convention in the GLTF definition:
  58852. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  58853. */
  58854. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  58855. /**
  58856. * Specifies the diffuse color of the material.
  58857. */
  58858. diffuseColor: Color3;
  58859. /**
  58860. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  58861. * channel.
  58862. */
  58863. diffuseTexture: BaseTexture;
  58864. /**
  58865. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  58866. */
  58867. specularColor: Color3;
  58868. /**
  58869. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  58870. */
  58871. glossiness: number;
  58872. /**
  58873. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  58874. */
  58875. specularGlossinessTexture: BaseTexture;
  58876. /**
  58877. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  58878. *
  58879. * @param name The material name
  58880. * @param scene The scene the material will be use in.
  58881. */
  58882. constructor(name: string, scene: Scene);
  58883. /**
  58884. * Return the currrent class name of the material.
  58885. */
  58886. getClassName(): string;
  58887. /**
  58888. * Makes a duplicate of the current material.
  58889. * @param name - name to use for the new material.
  58890. */
  58891. clone(name: string): PBRSpecularGlossinessMaterial;
  58892. /**
  58893. * Serialize the material to a parsable JSON object.
  58894. */
  58895. serialize(): any;
  58896. /**
  58897. * Parses a JSON object correponding to the serialize function.
  58898. */
  58899. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  58900. }
  58901. }
  58902. declare module "babylonjs/Materials/PBR/index" {
  58903. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  58904. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  58905. export * from "babylonjs/Materials/PBR/pbrMaterial";
  58906. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  58907. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  58908. }
  58909. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  58910. import { Nullable } from "babylonjs/types";
  58911. import { Scene } from "babylonjs/scene";
  58912. import { Matrix } from "babylonjs/Maths/math.vector";
  58913. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58914. /**
  58915. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  58916. * It can help converting any input color in a desired output one. This can then be used to create effects
  58917. * from sepia, black and white to sixties or futuristic rendering...
  58918. *
  58919. * The only supported format is currently 3dl.
  58920. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  58921. */
  58922. export class ColorGradingTexture extends BaseTexture {
  58923. /**
  58924. * The current texture matrix. (will always be identity in color grading texture)
  58925. */
  58926. private _textureMatrix;
  58927. /**
  58928. * The texture URL.
  58929. */
  58930. url: string;
  58931. /**
  58932. * Empty line regex stored for GC.
  58933. */
  58934. private static _noneEmptyLineRegex;
  58935. private _engine;
  58936. /**
  58937. * Instantiates a ColorGradingTexture from the following parameters.
  58938. *
  58939. * @param url The location of the color gradind data (currently only supporting 3dl)
  58940. * @param scene The scene the texture will be used in
  58941. */
  58942. constructor(url: string, scene: Scene);
  58943. /**
  58944. * Returns the texture matrix used in most of the material.
  58945. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  58946. */
  58947. getTextureMatrix(): Matrix;
  58948. /**
  58949. * Occurs when the file being loaded is a .3dl LUT file.
  58950. */
  58951. private load3dlTexture;
  58952. /**
  58953. * Starts the loading process of the texture.
  58954. */
  58955. private loadTexture;
  58956. /**
  58957. * Clones the color gradind texture.
  58958. */
  58959. clone(): ColorGradingTexture;
  58960. /**
  58961. * Called during delayed load for textures.
  58962. */
  58963. delayLoad(): void;
  58964. /**
  58965. * Parses a color grading texture serialized by Babylon.
  58966. * @param parsedTexture The texture information being parsedTexture
  58967. * @param scene The scene to load the texture in
  58968. * @param rootUrl The root url of the data assets to load
  58969. * @return A color gradind texture
  58970. */
  58971. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  58972. /**
  58973. * Serializes the LUT texture to json format.
  58974. */
  58975. serialize(): any;
  58976. }
  58977. }
  58978. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  58979. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58980. import { Scene } from "babylonjs/scene";
  58981. import { Nullable } from "babylonjs/types";
  58982. import "babylonjs/Engines/Extensions/engine.rawTexture";
  58983. /**
  58984. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  58985. */
  58986. export class EquiRectangularCubeTexture extends BaseTexture {
  58987. /** The six faces of the cube. */
  58988. private static _FacesMapping;
  58989. private _noMipmap;
  58990. private _onLoad;
  58991. private _onError;
  58992. /** The size of the cubemap. */
  58993. private _size;
  58994. /** The buffer of the image. */
  58995. private _buffer;
  58996. /** The width of the input image. */
  58997. private _width;
  58998. /** The height of the input image. */
  58999. private _height;
  59000. /** The URL to the image. */
  59001. url: string;
  59002. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  59003. coordinatesMode: number;
  59004. /**
  59005. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  59006. * @param url The location of the image
  59007. * @param scene The scene the texture will be used in
  59008. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  59009. * @param noMipmap Forces to not generate the mipmap if true
  59010. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  59011. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  59012. * @param onLoad — defines a callback called when texture is loaded
  59013. * @param onError — defines a callback called if there is an error
  59014. */
  59015. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  59016. /**
  59017. * Load the image data, by putting the image on a canvas and extracting its buffer.
  59018. */
  59019. private loadImage;
  59020. /**
  59021. * Convert the image buffer into a cubemap and create a CubeTexture.
  59022. */
  59023. private loadTexture;
  59024. /**
  59025. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  59026. * @param buffer The ArrayBuffer that should be converted.
  59027. * @returns The buffer as Float32Array.
  59028. */
  59029. private getFloat32ArrayFromArrayBuffer;
  59030. /**
  59031. * Get the current class name of the texture useful for serialization or dynamic coding.
  59032. * @returns "EquiRectangularCubeTexture"
  59033. */
  59034. getClassName(): string;
  59035. /**
  59036. * Create a clone of the current EquiRectangularCubeTexture and return it.
  59037. * @returns A clone of the current EquiRectangularCubeTexture.
  59038. */
  59039. clone(): EquiRectangularCubeTexture;
  59040. }
  59041. }
  59042. declare module "babylonjs/Misc/tga" {
  59043. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59044. /**
  59045. * Based on jsTGALoader - Javascript loader for TGA file
  59046. * By Vincent Thibault
  59047. * @see http://blog.robrowser.com/javascript-tga-loader.html
  59048. */
  59049. export class TGATools {
  59050. private static _TYPE_INDEXED;
  59051. private static _TYPE_RGB;
  59052. private static _TYPE_GREY;
  59053. private static _TYPE_RLE_INDEXED;
  59054. private static _TYPE_RLE_RGB;
  59055. private static _TYPE_RLE_GREY;
  59056. private static _ORIGIN_MASK;
  59057. private static _ORIGIN_SHIFT;
  59058. private static _ORIGIN_BL;
  59059. private static _ORIGIN_BR;
  59060. private static _ORIGIN_UL;
  59061. private static _ORIGIN_UR;
  59062. /**
  59063. * Gets the header of a TGA file
  59064. * @param data defines the TGA data
  59065. * @returns the header
  59066. */
  59067. static GetTGAHeader(data: Uint8Array): any;
  59068. /**
  59069. * Uploads TGA content to a Babylon Texture
  59070. * @hidden
  59071. */
  59072. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  59073. /** @hidden */
  59074. 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;
  59075. /** @hidden */
  59076. 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;
  59077. /** @hidden */
  59078. 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;
  59079. /** @hidden */
  59080. 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;
  59081. /** @hidden */
  59082. 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;
  59083. /** @hidden */
  59084. 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;
  59085. }
  59086. }
  59087. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  59088. import { Nullable } from "babylonjs/types";
  59089. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59090. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59091. /**
  59092. * Implementation of the TGA Texture Loader.
  59093. * @hidden
  59094. */
  59095. export class _TGATextureLoader implements IInternalTextureLoader {
  59096. /**
  59097. * Defines wether the loader supports cascade loading the different faces.
  59098. */
  59099. readonly supportCascades: boolean;
  59100. /**
  59101. * This returns if the loader support the current file information.
  59102. * @param extension defines the file extension of the file being loaded
  59103. * @returns true if the loader can load the specified file
  59104. */
  59105. canLoad(extension: string): boolean;
  59106. /**
  59107. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59108. * @param data contains the texture data
  59109. * @param texture defines the BabylonJS internal texture
  59110. * @param createPolynomials will be true if polynomials have been requested
  59111. * @param onLoad defines the callback to trigger once the texture is ready
  59112. * @param onError defines the callback to trigger in case of error
  59113. */
  59114. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59115. /**
  59116. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59117. * @param data contains the texture data
  59118. * @param texture defines the BabylonJS internal texture
  59119. * @param callback defines the method to call once ready to upload
  59120. */
  59121. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59122. }
  59123. }
  59124. declare module "babylonjs/Misc/basis" {
  59125. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59126. /**
  59127. * Info about the .basis files
  59128. */
  59129. class BasisFileInfo {
  59130. /**
  59131. * If the file has alpha
  59132. */
  59133. hasAlpha: boolean;
  59134. /**
  59135. * Info about each image of the basis file
  59136. */
  59137. images: Array<{
  59138. levels: Array<{
  59139. width: number;
  59140. height: number;
  59141. transcodedPixels: ArrayBufferView;
  59142. }>;
  59143. }>;
  59144. }
  59145. /**
  59146. * Result of transcoding a basis file
  59147. */
  59148. class TranscodeResult {
  59149. /**
  59150. * Info about the .basis file
  59151. */
  59152. fileInfo: BasisFileInfo;
  59153. /**
  59154. * Format to use when loading the file
  59155. */
  59156. format: number;
  59157. }
  59158. /**
  59159. * Configuration options for the Basis transcoder
  59160. */
  59161. export class BasisTranscodeConfiguration {
  59162. /**
  59163. * Supported compression formats used to determine the supported output format of the transcoder
  59164. */
  59165. supportedCompressionFormats?: {
  59166. /**
  59167. * etc1 compression format
  59168. */
  59169. etc1?: boolean;
  59170. /**
  59171. * s3tc compression format
  59172. */
  59173. s3tc?: boolean;
  59174. /**
  59175. * pvrtc compression format
  59176. */
  59177. pvrtc?: boolean;
  59178. /**
  59179. * etc2 compression format
  59180. */
  59181. etc2?: boolean;
  59182. };
  59183. /**
  59184. * If mipmap levels should be loaded for transcoded images (Default: true)
  59185. */
  59186. loadMipmapLevels?: boolean;
  59187. /**
  59188. * Index of a single image to load (Default: all images)
  59189. */
  59190. loadSingleImage?: number;
  59191. }
  59192. /**
  59193. * Used to load .Basis files
  59194. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  59195. */
  59196. export class BasisTools {
  59197. private static _IgnoreSupportedFormats;
  59198. /**
  59199. * URL to use when loading the basis transcoder
  59200. */
  59201. static JSModuleURL: string;
  59202. /**
  59203. * URL to use when loading the wasm module for the transcoder
  59204. */
  59205. static WasmModuleURL: string;
  59206. /**
  59207. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  59208. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  59209. * @returns internal format corresponding to the Basis format
  59210. */
  59211. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  59212. private static _WorkerPromise;
  59213. private static _Worker;
  59214. private static _actionId;
  59215. private static _CreateWorkerAsync;
  59216. /**
  59217. * Transcodes a loaded image file to compressed pixel data
  59218. * @param data image data to transcode
  59219. * @param config configuration options for the transcoding
  59220. * @returns a promise resulting in the transcoded image
  59221. */
  59222. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  59223. /**
  59224. * Loads a texture from the transcode result
  59225. * @param texture texture load to
  59226. * @param transcodeResult the result of transcoding the basis file to load from
  59227. */
  59228. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  59229. }
  59230. }
  59231. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  59232. import { Nullable } from "babylonjs/types";
  59233. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59234. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  59235. /**
  59236. * Loader for .basis file format
  59237. */
  59238. export class _BasisTextureLoader implements IInternalTextureLoader {
  59239. /**
  59240. * Defines whether the loader supports cascade loading the different faces.
  59241. */
  59242. readonly supportCascades: boolean;
  59243. /**
  59244. * This returns if the loader support the current file information.
  59245. * @param extension defines the file extension of the file being loaded
  59246. * @returns true if the loader can load the specified file
  59247. */
  59248. canLoad(extension: string): boolean;
  59249. /**
  59250. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  59251. * @param data contains the texture data
  59252. * @param texture defines the BabylonJS internal texture
  59253. * @param createPolynomials will be true if polynomials have been requested
  59254. * @param onLoad defines the callback to trigger once the texture is ready
  59255. * @param onError defines the callback to trigger in case of error
  59256. */
  59257. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  59258. /**
  59259. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  59260. * @param data contains the texture data
  59261. * @param texture defines the BabylonJS internal texture
  59262. * @param callback defines the method to call once ready to upload
  59263. */
  59264. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  59265. }
  59266. }
  59267. declare module "babylonjs/Materials/Textures/Loaders/index" {
  59268. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  59269. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  59270. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  59271. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  59272. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  59273. }
  59274. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  59275. import { Scene } from "babylonjs/scene";
  59276. import { Texture } from "babylonjs/Materials/Textures/texture";
  59277. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59278. /**
  59279. * 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.
  59280. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59281. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59282. */
  59283. export class CustomProceduralTexture extends ProceduralTexture {
  59284. private _animate;
  59285. private _time;
  59286. private _config;
  59287. private _texturePath;
  59288. /**
  59289. * Instantiates a new Custom Procedural Texture.
  59290. * 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.
  59291. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  59292. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  59293. * @param name Define the name of the texture
  59294. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  59295. * @param size Define the size of the texture to create
  59296. * @param scene Define the scene the texture belongs to
  59297. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  59298. * @param generateMipMaps Define if the texture should creates mip maps or not
  59299. */
  59300. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59301. private _loadJson;
  59302. /**
  59303. * Is the texture ready to be used ? (rendered at least once)
  59304. * @returns true if ready, otherwise, false.
  59305. */
  59306. isReady(): boolean;
  59307. /**
  59308. * Render the texture to its associated render target.
  59309. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  59310. */
  59311. render(useCameraPostProcess?: boolean): void;
  59312. /**
  59313. * Update the list of dependant textures samplers in the shader.
  59314. */
  59315. updateTextures(): void;
  59316. /**
  59317. * Update the uniform values of the procedural texture in the shader.
  59318. */
  59319. updateShaderUniforms(): void;
  59320. /**
  59321. * Define if the texture animates or not.
  59322. */
  59323. get animate(): boolean;
  59324. set animate(value: boolean);
  59325. }
  59326. }
  59327. declare module "babylonjs/Shaders/noise.fragment" {
  59328. /** @hidden */
  59329. export var noisePixelShader: {
  59330. name: string;
  59331. shader: string;
  59332. };
  59333. }
  59334. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  59335. import { Nullable } from "babylonjs/types";
  59336. import { Scene } from "babylonjs/scene";
  59337. import { Texture } from "babylonjs/Materials/Textures/texture";
  59338. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59339. import "babylonjs/Shaders/noise.fragment";
  59340. /**
  59341. * Class used to generate noise procedural textures
  59342. */
  59343. export class NoiseProceduralTexture extends ProceduralTexture {
  59344. private _time;
  59345. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  59346. brightness: number;
  59347. /** Defines the number of octaves to process */
  59348. octaves: number;
  59349. /** Defines the level of persistence (0.8 by default) */
  59350. persistence: number;
  59351. /** Gets or sets animation speed factor (default is 1) */
  59352. animationSpeedFactor: number;
  59353. /**
  59354. * Creates a new NoiseProceduralTexture
  59355. * @param name defines the name fo the texture
  59356. * @param size defines the size of the texture (default is 256)
  59357. * @param scene defines the hosting scene
  59358. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  59359. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  59360. */
  59361. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  59362. private _updateShaderUniforms;
  59363. protected _getDefines(): string;
  59364. /** Generate the current state of the procedural texture */
  59365. render(useCameraPostProcess?: boolean): void;
  59366. /**
  59367. * Serializes this noise procedural texture
  59368. * @returns a serialized noise procedural texture object
  59369. */
  59370. serialize(): any;
  59371. /**
  59372. * Clone the texture.
  59373. * @returns the cloned texture
  59374. */
  59375. clone(): NoiseProceduralTexture;
  59376. /**
  59377. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  59378. * @param parsedTexture defines parsed texture data
  59379. * @param scene defines the current scene
  59380. * @param rootUrl defines the root URL containing noise procedural texture information
  59381. * @returns a parsed NoiseProceduralTexture
  59382. */
  59383. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  59384. }
  59385. }
  59386. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  59387. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  59388. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  59389. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  59390. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  59391. }
  59392. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  59393. import { Nullable } from "babylonjs/types";
  59394. import { Scene } from "babylonjs/scene";
  59395. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  59396. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  59397. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  59398. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59399. /**
  59400. * Raw cube texture where the raw buffers are passed in
  59401. */
  59402. export class RawCubeTexture extends CubeTexture {
  59403. /**
  59404. * Creates a cube texture where the raw buffers are passed in.
  59405. * @param scene defines the scene the texture is attached to
  59406. * @param data defines the array of data to use to create each face
  59407. * @param size defines the size of the textures
  59408. * @param format defines the format of the data
  59409. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  59410. * @param generateMipMaps defines if the engine should generate the mip levels
  59411. * @param invertY defines if data must be stored with Y axis inverted
  59412. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  59413. * @param compression defines the compression used (null by default)
  59414. */
  59415. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  59416. /**
  59417. * Updates the raw cube texture.
  59418. * @param data defines the data to store
  59419. * @param format defines the data format
  59420. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  59421. * @param invertY defines if data must be stored with Y axis inverted
  59422. * @param compression defines the compression used (null by default)
  59423. * @param level defines which level of the texture to update
  59424. */
  59425. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  59426. /**
  59427. * Updates a raw cube texture with RGBD encoded data.
  59428. * @param data defines the array of data [mipmap][face] to use to create each face
  59429. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  59430. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  59431. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  59432. * @returns a promsie that resolves when the operation is complete
  59433. */
  59434. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  59435. /**
  59436. * Clones the raw cube texture.
  59437. * @return a new cube texture
  59438. */
  59439. clone(): CubeTexture;
  59440. /** @hidden */
  59441. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  59442. }
  59443. }
  59444. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  59445. import { Scene } from "babylonjs/scene";
  59446. import { Texture } from "babylonjs/Materials/Textures/texture";
  59447. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59448. /**
  59449. * Class used to store 3D textures containing user data
  59450. */
  59451. export class RawTexture3D extends Texture {
  59452. /** Gets or sets the texture format to use */
  59453. format: number;
  59454. private _engine;
  59455. /**
  59456. * Create a new RawTexture3D
  59457. * @param data defines the data of the texture
  59458. * @param width defines the width of the texture
  59459. * @param height defines the height of the texture
  59460. * @param depth defines the depth of the texture
  59461. * @param format defines the texture format to use
  59462. * @param scene defines the hosting scene
  59463. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59464. * @param invertY defines if texture must be stored with Y axis inverted
  59465. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59466. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59467. */
  59468. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59469. /** Gets or sets the texture format to use */
  59470. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59471. /**
  59472. * Update the texture with new data
  59473. * @param data defines the data to store in the texture
  59474. */
  59475. update(data: ArrayBufferView): void;
  59476. }
  59477. }
  59478. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  59479. import { Scene } from "babylonjs/scene";
  59480. import { Texture } from "babylonjs/Materials/Textures/texture";
  59481. import "babylonjs/Engines/Extensions/engine.rawTexture";
  59482. /**
  59483. * Class used to store 2D array textures containing user data
  59484. */
  59485. export class RawTexture2DArray extends Texture {
  59486. /** Gets or sets the texture format to use */
  59487. format: number;
  59488. private _engine;
  59489. /**
  59490. * Create a new RawTexture2DArray
  59491. * @param data defines the data of the texture
  59492. * @param width defines the width of the texture
  59493. * @param height defines the height of the texture
  59494. * @param depth defines the number of layers of the texture
  59495. * @param format defines the texture format to use
  59496. * @param scene defines the hosting scene
  59497. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  59498. * @param invertY defines if texture must be stored with Y axis inverted
  59499. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  59500. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  59501. */
  59502. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  59503. /** Gets or sets the texture format to use */
  59504. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  59505. /**
  59506. * Update the texture with new data
  59507. * @param data defines the data to store in the texture
  59508. */
  59509. update(data: ArrayBufferView): void;
  59510. }
  59511. }
  59512. declare module "babylonjs/Materials/Textures/refractionTexture" {
  59513. import { Scene } from "babylonjs/scene";
  59514. import { Plane } from "babylonjs/Maths/math.plane";
  59515. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  59516. /**
  59517. * Creates a refraction texture used by refraction channel of the standard material.
  59518. * It is like a mirror but to see through a material.
  59519. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59520. */
  59521. export class RefractionTexture extends RenderTargetTexture {
  59522. /**
  59523. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  59524. * 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.
  59525. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59526. */
  59527. refractionPlane: Plane;
  59528. /**
  59529. * Define how deep under the surface we should see.
  59530. */
  59531. depth: number;
  59532. /**
  59533. * Creates a refraction texture used by refraction channel of the standard material.
  59534. * It is like a mirror but to see through a material.
  59535. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  59536. * @param name Define the texture name
  59537. * @param size Define the size of the underlying texture
  59538. * @param scene Define the scene the refraction belongs to
  59539. * @param generateMipMaps Define if we need to generate mips level for the refraction
  59540. */
  59541. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  59542. /**
  59543. * Clone the refraction texture.
  59544. * @returns the cloned texture
  59545. */
  59546. clone(): RefractionTexture;
  59547. /**
  59548. * Serialize the texture to a JSON representation you could use in Parse later on
  59549. * @returns the serialized JSON representation
  59550. */
  59551. serialize(): any;
  59552. }
  59553. }
  59554. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  59555. import { Nullable } from "babylonjs/types";
  59556. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59557. import { Matrix } from "babylonjs/Maths/math.vector";
  59558. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  59559. import "babylonjs/Engines/Extensions/engine.videoTexture";
  59560. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  59561. import { Scene } from "babylonjs/scene";
  59562. /**
  59563. * Defines the options related to the creation of an HtmlElementTexture
  59564. */
  59565. export interface IHtmlElementTextureOptions {
  59566. /**
  59567. * Defines wether mip maps should be created or not.
  59568. */
  59569. generateMipMaps?: boolean;
  59570. /**
  59571. * Defines the sampling mode of the texture.
  59572. */
  59573. samplingMode?: number;
  59574. /**
  59575. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  59576. */
  59577. engine: Nullable<ThinEngine>;
  59578. /**
  59579. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  59580. */
  59581. scene: Nullable<Scene>;
  59582. }
  59583. /**
  59584. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  59585. * To be as efficient as possible depending on your constraints nothing aside the first upload
  59586. * is automatically managed.
  59587. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  59588. * in your application.
  59589. *
  59590. * As the update is not automatic, you need to call them manually.
  59591. */
  59592. export class HtmlElementTexture extends BaseTexture {
  59593. /**
  59594. * The texture URL.
  59595. */
  59596. element: HTMLVideoElement | HTMLCanvasElement;
  59597. private static readonly DefaultOptions;
  59598. private _textureMatrix;
  59599. private _engine;
  59600. private _isVideo;
  59601. private _generateMipMaps;
  59602. private _samplingMode;
  59603. /**
  59604. * Instantiates a HtmlElementTexture from the following parameters.
  59605. *
  59606. * @param name Defines the name of the texture
  59607. * @param element Defines the video or canvas the texture is filled with
  59608. * @param options Defines the other none mandatory texture creation options
  59609. */
  59610. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  59611. private _createInternalTexture;
  59612. /**
  59613. * Returns the texture matrix used in most of the material.
  59614. */
  59615. getTextureMatrix(): Matrix;
  59616. /**
  59617. * Updates the content of the texture.
  59618. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  59619. */
  59620. update(invertY?: Nullable<boolean>): void;
  59621. }
  59622. }
  59623. declare module "babylonjs/Materials/Textures/Packer/frame" {
  59624. import { Vector2 } from "babylonjs/Maths/math.vector";
  59625. /**
  59626. * Defines the basic options interface of a TexturePacker Frame
  59627. */
  59628. export interface ITexturePackerFrame {
  59629. /**
  59630. * The frame ID
  59631. */
  59632. id: number;
  59633. /**
  59634. * The frames Scale
  59635. */
  59636. scale: Vector2;
  59637. /**
  59638. * The Frames offset
  59639. */
  59640. offset: Vector2;
  59641. }
  59642. /**
  59643. * This is a support class for frame Data on texture packer sets.
  59644. */
  59645. export class TexturePackerFrame implements ITexturePackerFrame {
  59646. /**
  59647. * The frame ID
  59648. */
  59649. id: number;
  59650. /**
  59651. * The frames Scale
  59652. */
  59653. scale: Vector2;
  59654. /**
  59655. * The Frames offset
  59656. */
  59657. offset: Vector2;
  59658. /**
  59659. * Initializes a texture package frame.
  59660. * @param id The numerical frame identifier
  59661. * @param scale Scalar Vector2 for UV frame
  59662. * @param offset Vector2 for the frame position in UV units.
  59663. * @returns TexturePackerFrame
  59664. */
  59665. constructor(id: number, scale: Vector2, offset: Vector2);
  59666. }
  59667. }
  59668. declare module "babylonjs/Materials/Textures/Packer/packer" {
  59669. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59670. import { Scene } from "babylonjs/scene";
  59671. import { Nullable } from "babylonjs/types";
  59672. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  59673. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  59674. /**
  59675. * Defines the basic options interface of a TexturePacker
  59676. */
  59677. export interface ITexturePackerOptions {
  59678. /**
  59679. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  59680. */
  59681. map?: string[];
  59682. /**
  59683. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59684. */
  59685. uvsIn?: string;
  59686. /**
  59687. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  59688. */
  59689. uvsOut?: string;
  59690. /**
  59691. * number representing the layout style. Defaults to LAYOUT_STRIP
  59692. */
  59693. layout?: number;
  59694. /**
  59695. * number of columns if using custom column count layout(2). This defaults to 4.
  59696. */
  59697. colnum?: number;
  59698. /**
  59699. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  59700. */
  59701. updateInputMeshes?: boolean;
  59702. /**
  59703. * boolean flag to dispose all the source textures. Defaults to true.
  59704. */
  59705. disposeSources?: boolean;
  59706. /**
  59707. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  59708. */
  59709. fillBlanks?: boolean;
  59710. /**
  59711. * string value representing the context fill style color. Defaults to 'black'.
  59712. */
  59713. customFillColor?: string;
  59714. /**
  59715. * Width and Height Value of each Frame in the TexturePacker Sets
  59716. */
  59717. frameSize?: number;
  59718. /**
  59719. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  59720. */
  59721. paddingRatio?: number;
  59722. /**
  59723. * Number that declares the fill method for the padding gutter.
  59724. */
  59725. paddingMode?: number;
  59726. /**
  59727. * If in SUBUV_COLOR padding mode what color to use.
  59728. */
  59729. paddingColor?: Color3 | Color4;
  59730. }
  59731. /**
  59732. * Defines the basic interface of a TexturePacker JSON File
  59733. */
  59734. export interface ITexturePackerJSON {
  59735. /**
  59736. * The frame ID
  59737. */
  59738. name: string;
  59739. /**
  59740. * The base64 channel data
  59741. */
  59742. sets: any;
  59743. /**
  59744. * The options of the Packer
  59745. */
  59746. options: ITexturePackerOptions;
  59747. /**
  59748. * The frame data of the Packer
  59749. */
  59750. frames: Array<number>;
  59751. }
  59752. /**
  59753. * This is a support class that generates a series of packed texture sets.
  59754. * @see https://doc.babylonjs.com/babylon101/materials
  59755. */
  59756. export class TexturePacker {
  59757. /** Packer Layout Constant 0 */
  59758. static readonly LAYOUT_STRIP: number;
  59759. /** Packer Layout Constant 1 */
  59760. static readonly LAYOUT_POWER2: number;
  59761. /** Packer Layout Constant 2 */
  59762. static readonly LAYOUT_COLNUM: number;
  59763. /** Packer Layout Constant 0 */
  59764. static readonly SUBUV_WRAP: number;
  59765. /** Packer Layout Constant 1 */
  59766. static readonly SUBUV_EXTEND: number;
  59767. /** Packer Layout Constant 2 */
  59768. static readonly SUBUV_COLOR: number;
  59769. /** The Name of the Texture Package */
  59770. name: string;
  59771. /** The scene scope of the TexturePacker */
  59772. scene: Scene;
  59773. /** The Meshes to target */
  59774. meshes: AbstractMesh[];
  59775. /** Arguments passed with the Constructor */
  59776. options: ITexturePackerOptions;
  59777. /** The promise that is started upon initialization */
  59778. promise: Nullable<Promise<TexturePacker | string>>;
  59779. /** The Container object for the channel sets that are generated */
  59780. sets: object;
  59781. /** The Container array for the frames that are generated */
  59782. frames: TexturePackerFrame[];
  59783. /** The expected number of textures the system is parsing. */
  59784. private _expecting;
  59785. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  59786. private _paddingValue;
  59787. /**
  59788. * Initializes a texture package series from an array of meshes or a single mesh.
  59789. * @param name The name of the package
  59790. * @param meshes The target meshes to compose the package from
  59791. * @param options The arguments that texture packer should follow while building.
  59792. * @param scene The scene which the textures are scoped to.
  59793. * @returns TexturePacker
  59794. */
  59795. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  59796. /**
  59797. * Starts the package process
  59798. * @param resolve The promises resolution function
  59799. * @returns TexturePacker
  59800. */
  59801. private _createFrames;
  59802. /**
  59803. * Calculates the Size of the Channel Sets
  59804. * @returns Vector2
  59805. */
  59806. private _calculateSize;
  59807. /**
  59808. * Calculates the UV data for the frames.
  59809. * @param baseSize the base frameSize
  59810. * @param padding the base frame padding
  59811. * @param dtSize size of the Dynamic Texture for that channel
  59812. * @param dtUnits is 1/dtSize
  59813. * @param update flag to update the input meshes
  59814. */
  59815. private _calculateMeshUVFrames;
  59816. /**
  59817. * Calculates the frames Offset.
  59818. * @param index of the frame
  59819. * @returns Vector2
  59820. */
  59821. private _getFrameOffset;
  59822. /**
  59823. * Updates a Mesh to the frame data
  59824. * @param mesh that is the target
  59825. * @param frameID or the frame index
  59826. */
  59827. private _updateMeshUV;
  59828. /**
  59829. * Updates a Meshes materials to use the texture packer channels
  59830. * @param m is the mesh to target
  59831. * @param force all channels on the packer to be set.
  59832. */
  59833. private _updateTextureReferences;
  59834. /**
  59835. * Public method to set a Mesh to a frame
  59836. * @param m that is the target
  59837. * @param frameID or the frame index
  59838. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  59839. */
  59840. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  59841. /**
  59842. * Starts the async promise to compile the texture packer.
  59843. * @returns Promise<void>
  59844. */
  59845. processAsync(): Promise<void>;
  59846. /**
  59847. * Disposes all textures associated with this packer
  59848. */
  59849. dispose(): void;
  59850. /**
  59851. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  59852. * @param imageType is the image type to use.
  59853. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  59854. */
  59855. download(imageType?: string, quality?: number): void;
  59856. /**
  59857. * Public method to load a texturePacker JSON file.
  59858. * @param data of the JSON file in string format.
  59859. */
  59860. updateFromJSON(data: string): void;
  59861. }
  59862. }
  59863. declare module "babylonjs/Materials/Textures/Packer/index" {
  59864. export * from "babylonjs/Materials/Textures/Packer/packer";
  59865. export * from "babylonjs/Materials/Textures/Packer/frame";
  59866. }
  59867. declare module "babylonjs/Materials/Textures/index" {
  59868. export * from "babylonjs/Materials/Textures/baseTexture";
  59869. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  59870. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  59871. export * from "babylonjs/Materials/Textures/cubeTexture";
  59872. export * from "babylonjs/Materials/Textures/dynamicTexture";
  59873. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  59874. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  59875. export * from "babylonjs/Materials/Textures/internalTexture";
  59876. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  59877. export * from "babylonjs/Materials/Textures/Loaders/index";
  59878. export * from "babylonjs/Materials/Textures/mirrorTexture";
  59879. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  59880. export * from "babylonjs/Materials/Textures/Procedurals/index";
  59881. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  59882. export * from "babylonjs/Materials/Textures/rawTexture";
  59883. export * from "babylonjs/Materials/Textures/rawTexture3D";
  59884. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  59885. export * from "babylonjs/Materials/Textures/refractionTexture";
  59886. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  59887. export * from "babylonjs/Materials/Textures/texture";
  59888. export * from "babylonjs/Materials/Textures/videoTexture";
  59889. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  59890. export * from "babylonjs/Materials/Textures/Packer/index";
  59891. }
  59892. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  59893. /**
  59894. * Enum used to define the target of a block
  59895. */
  59896. export enum NodeMaterialBlockTargets {
  59897. /** Vertex shader */
  59898. Vertex = 1,
  59899. /** Fragment shader */
  59900. Fragment = 2,
  59901. /** Neutral */
  59902. Neutral = 4,
  59903. /** Vertex and Fragment */
  59904. VertexAndFragment = 3
  59905. }
  59906. }
  59907. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  59908. /**
  59909. * Defines the kind of connection point for node based material
  59910. */
  59911. export enum NodeMaterialBlockConnectionPointTypes {
  59912. /** Float */
  59913. Float = 1,
  59914. /** Int */
  59915. Int = 2,
  59916. /** Vector2 */
  59917. Vector2 = 4,
  59918. /** Vector3 */
  59919. Vector3 = 8,
  59920. /** Vector4 */
  59921. Vector4 = 16,
  59922. /** Color3 */
  59923. Color3 = 32,
  59924. /** Color4 */
  59925. Color4 = 64,
  59926. /** Matrix */
  59927. Matrix = 128,
  59928. /** Detect type based on connection */
  59929. AutoDetect = 1024,
  59930. /** Output type that will be defined by input type */
  59931. BasedOnInput = 2048
  59932. }
  59933. }
  59934. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  59935. /**
  59936. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  59937. */
  59938. export enum NodeMaterialBlockConnectionPointMode {
  59939. /** Value is an uniform */
  59940. Uniform = 0,
  59941. /** Value is a mesh attribute */
  59942. Attribute = 1,
  59943. /** Value is a varying between vertex and fragment shaders */
  59944. Varying = 2,
  59945. /** Mode is undefined */
  59946. Undefined = 3
  59947. }
  59948. }
  59949. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  59950. /**
  59951. * Enum used to define system values e.g. values automatically provided by the system
  59952. */
  59953. export enum NodeMaterialSystemValues {
  59954. /** World */
  59955. World = 1,
  59956. /** View */
  59957. View = 2,
  59958. /** Projection */
  59959. Projection = 3,
  59960. /** ViewProjection */
  59961. ViewProjection = 4,
  59962. /** WorldView */
  59963. WorldView = 5,
  59964. /** WorldViewProjection */
  59965. WorldViewProjection = 6,
  59966. /** CameraPosition */
  59967. CameraPosition = 7,
  59968. /** Fog Color */
  59969. FogColor = 8,
  59970. /** Delta time */
  59971. DeltaTime = 9
  59972. }
  59973. }
  59974. declare module "babylonjs/Materials/Node/Enums/index" {
  59975. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  59976. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  59977. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  59978. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  59979. }
  59980. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  59981. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59982. /**
  59983. * Root class for all node material optimizers
  59984. */
  59985. export class NodeMaterialOptimizer {
  59986. /**
  59987. * Function used to optimize a NodeMaterial graph
  59988. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  59989. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  59990. */
  59991. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  59992. }
  59993. }
  59994. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  59995. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  59996. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  59997. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  59998. import { Scene } from "babylonjs/scene";
  59999. /**
  60000. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  60001. */
  60002. export class TransformBlock extends NodeMaterialBlock {
  60003. /**
  60004. * Defines the value to use to complement W value to transform it to a Vector4
  60005. */
  60006. complementW: number;
  60007. /**
  60008. * Defines the value to use to complement z value to transform it to a Vector4
  60009. */
  60010. complementZ: number;
  60011. /**
  60012. * Creates a new TransformBlock
  60013. * @param name defines the block name
  60014. */
  60015. constructor(name: string);
  60016. /**
  60017. * Gets the current class name
  60018. * @returns the class name
  60019. */
  60020. getClassName(): string;
  60021. /**
  60022. * Gets the vector input
  60023. */
  60024. get vector(): NodeMaterialConnectionPoint;
  60025. /**
  60026. * Gets the output component
  60027. */
  60028. get output(): NodeMaterialConnectionPoint;
  60029. /**
  60030. * Gets the xyz output component
  60031. */
  60032. get xyz(): NodeMaterialConnectionPoint;
  60033. /**
  60034. * Gets the matrix transform input
  60035. */
  60036. get transform(): NodeMaterialConnectionPoint;
  60037. protected _buildBlock(state: NodeMaterialBuildState): this;
  60038. serialize(): any;
  60039. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60040. protected _dumpPropertiesCode(): string;
  60041. }
  60042. }
  60043. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  60044. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60045. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60046. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60047. /**
  60048. * Block used to output the vertex position
  60049. */
  60050. export class VertexOutputBlock extends NodeMaterialBlock {
  60051. /**
  60052. * Creates a new VertexOutputBlock
  60053. * @param name defines the block name
  60054. */
  60055. constructor(name: string);
  60056. /**
  60057. * Gets the current class name
  60058. * @returns the class name
  60059. */
  60060. getClassName(): string;
  60061. /**
  60062. * Gets the vector input component
  60063. */
  60064. get vector(): NodeMaterialConnectionPoint;
  60065. protected _buildBlock(state: NodeMaterialBuildState): this;
  60066. }
  60067. }
  60068. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  60069. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60070. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60071. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60072. /**
  60073. * Block used to output the final color
  60074. */
  60075. export class FragmentOutputBlock extends NodeMaterialBlock {
  60076. /**
  60077. * Create a new FragmentOutputBlock
  60078. * @param name defines the block name
  60079. */
  60080. constructor(name: string);
  60081. /**
  60082. * Gets the current class name
  60083. * @returns the class name
  60084. */
  60085. getClassName(): string;
  60086. /**
  60087. * Gets the rgba input component
  60088. */
  60089. get rgba(): NodeMaterialConnectionPoint;
  60090. /**
  60091. * Gets the rgb input component
  60092. */
  60093. get rgb(): NodeMaterialConnectionPoint;
  60094. /**
  60095. * Gets the a input component
  60096. */
  60097. get a(): NodeMaterialConnectionPoint;
  60098. protected _buildBlock(state: NodeMaterialBuildState): this;
  60099. }
  60100. }
  60101. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  60102. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60103. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60104. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60105. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60106. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60107. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60108. import { Effect } from "babylonjs/Materials/effect";
  60109. import { Mesh } from "babylonjs/Meshes/mesh";
  60110. import { Nullable } from "babylonjs/types";
  60111. import { Scene } from "babylonjs/scene";
  60112. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  60113. /**
  60114. * Block used to read a reflection texture from a sampler
  60115. */
  60116. export class ReflectionTextureBlock extends NodeMaterialBlock {
  60117. private _define3DName;
  60118. private _defineCubicName;
  60119. private _defineExplicitName;
  60120. private _defineProjectionName;
  60121. private _defineLocalCubicName;
  60122. private _defineSphericalName;
  60123. private _definePlanarName;
  60124. private _defineEquirectangularName;
  60125. private _defineMirroredEquirectangularFixedName;
  60126. private _defineEquirectangularFixedName;
  60127. private _defineSkyboxName;
  60128. private _cubeSamplerName;
  60129. private _2DSamplerName;
  60130. private _positionUVWName;
  60131. private _directionWName;
  60132. private _reflectionCoordsName;
  60133. private _reflection2DCoordsName;
  60134. private _reflectionColorName;
  60135. private _reflectionMatrixName;
  60136. /**
  60137. * Gets or sets the texture associated with the node
  60138. */
  60139. texture: Nullable<BaseTexture>;
  60140. /**
  60141. * Create a new TextureBlock
  60142. * @param name defines the block name
  60143. */
  60144. constructor(name: string);
  60145. /**
  60146. * Gets the current class name
  60147. * @returns the class name
  60148. */
  60149. getClassName(): string;
  60150. /**
  60151. * Gets the world position input component
  60152. */
  60153. get position(): NodeMaterialConnectionPoint;
  60154. /**
  60155. * Gets the world position input component
  60156. */
  60157. get worldPosition(): NodeMaterialConnectionPoint;
  60158. /**
  60159. * Gets the world normal input component
  60160. */
  60161. get worldNormal(): NodeMaterialConnectionPoint;
  60162. /**
  60163. * Gets the world input component
  60164. */
  60165. get world(): NodeMaterialConnectionPoint;
  60166. /**
  60167. * Gets the camera (or eye) position component
  60168. */
  60169. get cameraPosition(): NodeMaterialConnectionPoint;
  60170. /**
  60171. * Gets the view input component
  60172. */
  60173. get view(): NodeMaterialConnectionPoint;
  60174. /**
  60175. * Gets the rgb output component
  60176. */
  60177. get rgb(): NodeMaterialConnectionPoint;
  60178. /**
  60179. * Gets the r output component
  60180. */
  60181. get r(): NodeMaterialConnectionPoint;
  60182. /**
  60183. * Gets the g output component
  60184. */
  60185. get g(): NodeMaterialConnectionPoint;
  60186. /**
  60187. * Gets the b output component
  60188. */
  60189. get b(): NodeMaterialConnectionPoint;
  60190. autoConfigure(material: NodeMaterial): void;
  60191. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60192. isReady(): boolean;
  60193. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60194. private _injectVertexCode;
  60195. private _writeOutput;
  60196. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60197. protected _dumpPropertiesCode(): string;
  60198. serialize(): any;
  60199. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60200. }
  60201. }
  60202. declare module "babylonjs/Materials/Node/nodeMaterial" {
  60203. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60204. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  60205. import { Scene } from "babylonjs/scene";
  60206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60207. import { Matrix } from "babylonjs/Maths/math.vector";
  60208. import { Mesh } from "babylonjs/Meshes/mesh";
  60209. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60210. import { Observable } from "babylonjs/Misc/observable";
  60211. import { SubMesh } from "babylonjs/Meshes/subMesh";
  60212. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  60213. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  60214. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  60215. import { Nullable } from "babylonjs/types";
  60216. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60217. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60218. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60219. /**
  60220. * Interface used to configure the node material editor
  60221. */
  60222. export interface INodeMaterialEditorOptions {
  60223. /** Define the URl to load node editor script */
  60224. editorURL?: string;
  60225. }
  60226. /** @hidden */
  60227. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  60228. NORMAL: boolean;
  60229. TANGENT: boolean;
  60230. UV1: boolean;
  60231. /** BONES */
  60232. NUM_BONE_INFLUENCERS: number;
  60233. BonesPerMesh: number;
  60234. BONETEXTURE: boolean;
  60235. /** MORPH TARGETS */
  60236. MORPHTARGETS: boolean;
  60237. MORPHTARGETS_NORMAL: boolean;
  60238. MORPHTARGETS_TANGENT: boolean;
  60239. MORPHTARGETS_UV: boolean;
  60240. NUM_MORPH_INFLUENCERS: number;
  60241. /** IMAGE PROCESSING */
  60242. IMAGEPROCESSING: boolean;
  60243. VIGNETTE: boolean;
  60244. VIGNETTEBLENDMODEMULTIPLY: boolean;
  60245. VIGNETTEBLENDMODEOPAQUE: boolean;
  60246. TONEMAPPING: boolean;
  60247. TONEMAPPING_ACES: boolean;
  60248. CONTRAST: boolean;
  60249. EXPOSURE: boolean;
  60250. COLORCURVES: boolean;
  60251. COLORGRADING: boolean;
  60252. COLORGRADING3D: boolean;
  60253. SAMPLER3DGREENDEPTH: boolean;
  60254. SAMPLER3DBGRMAP: boolean;
  60255. IMAGEPROCESSINGPOSTPROCESS: boolean;
  60256. /** MISC. */
  60257. BUMPDIRECTUV: number;
  60258. constructor();
  60259. setValue(name: string, value: boolean): void;
  60260. }
  60261. /**
  60262. * Class used to configure NodeMaterial
  60263. */
  60264. export interface INodeMaterialOptions {
  60265. /**
  60266. * Defines if blocks should emit comments
  60267. */
  60268. emitComments: boolean;
  60269. }
  60270. /**
  60271. * Class used to create a node based material built by assembling shader blocks
  60272. */
  60273. export class NodeMaterial extends PushMaterial {
  60274. private static _BuildIdGenerator;
  60275. private _options;
  60276. private _vertexCompilationState;
  60277. private _fragmentCompilationState;
  60278. private _sharedData;
  60279. private _buildId;
  60280. private _buildWasSuccessful;
  60281. private _cachedWorldViewMatrix;
  60282. private _cachedWorldViewProjectionMatrix;
  60283. private _optimizers;
  60284. private _animationFrame;
  60285. /** Define the Url to load node editor script */
  60286. static EditorURL: string;
  60287. /** Define the Url to load snippets */
  60288. static SnippetUrl: string;
  60289. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  60290. static IgnoreTexturesAtLoadTime: boolean;
  60291. private BJSNODEMATERIALEDITOR;
  60292. /** Get the inspector from bundle or global */
  60293. private _getGlobalNodeMaterialEditor;
  60294. /**
  60295. * Snippet ID if the material was created from the snippet server
  60296. */
  60297. snippetId: string;
  60298. /**
  60299. * Gets or sets data used by visual editor
  60300. * @see https://nme.babylonjs.com
  60301. */
  60302. editorData: any;
  60303. /**
  60304. * 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)
  60305. */
  60306. ignoreAlpha: boolean;
  60307. /**
  60308. * Defines the maximum number of lights that can be used in the material
  60309. */
  60310. maxSimultaneousLights: number;
  60311. /**
  60312. * Observable raised when the material is built
  60313. */
  60314. onBuildObservable: Observable<NodeMaterial>;
  60315. /**
  60316. * Gets or sets the root nodes of the material vertex shader
  60317. */
  60318. _vertexOutputNodes: NodeMaterialBlock[];
  60319. /**
  60320. * Gets or sets the root nodes of the material fragment (pixel) shader
  60321. */
  60322. _fragmentOutputNodes: NodeMaterialBlock[];
  60323. /** Gets or sets options to control the node material overall behavior */
  60324. get options(): INodeMaterialOptions;
  60325. set options(options: INodeMaterialOptions);
  60326. /**
  60327. * Default configuration related to image processing available in the standard Material.
  60328. */
  60329. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  60330. /**
  60331. * Gets the image processing configuration used either in this material.
  60332. */
  60333. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60334. /**
  60335. * Sets the Default image processing configuration used either in the this material.
  60336. *
  60337. * If sets to null, the scene one is in use.
  60338. */
  60339. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60340. /**
  60341. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  60342. */
  60343. attachedBlocks: NodeMaterialBlock[];
  60344. /**
  60345. * Create a new node based material
  60346. * @param name defines the material name
  60347. * @param scene defines the hosting scene
  60348. * @param options defines creation option
  60349. */
  60350. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  60351. /**
  60352. * Gets the current class name of the material e.g. "NodeMaterial"
  60353. * @returns the class name
  60354. */
  60355. getClassName(): string;
  60356. /**
  60357. * Keep track of the image processing observer to allow dispose and replace.
  60358. */
  60359. private _imageProcessingObserver;
  60360. /**
  60361. * Attaches a new image processing configuration to the Standard Material.
  60362. * @param configuration
  60363. */
  60364. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  60365. /**
  60366. * Get a block by its name
  60367. * @param name defines the name of the block to retrieve
  60368. * @returns the required block or null if not found
  60369. */
  60370. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  60371. /**
  60372. * Get a block by its name
  60373. * @param predicate defines the predicate used to find the good candidate
  60374. * @returns the required block or null if not found
  60375. */
  60376. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  60377. /**
  60378. * Get an input block by its name
  60379. * @param predicate defines the predicate used to find the good candidate
  60380. * @returns the required input block or null if not found
  60381. */
  60382. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  60383. /**
  60384. * Gets the list of input blocks attached to this material
  60385. * @returns an array of InputBlocks
  60386. */
  60387. getInputBlocks(): InputBlock[];
  60388. /**
  60389. * Adds a new optimizer to the list of optimizers
  60390. * @param optimizer defines the optimizers to add
  60391. * @returns the current material
  60392. */
  60393. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60394. /**
  60395. * Remove an optimizer from the list of optimizers
  60396. * @param optimizer defines the optimizers to remove
  60397. * @returns the current material
  60398. */
  60399. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  60400. /**
  60401. * Add a new block to the list of output nodes
  60402. * @param node defines the node to add
  60403. * @returns the current material
  60404. */
  60405. addOutputNode(node: NodeMaterialBlock): this;
  60406. /**
  60407. * Remove a block from the list of root nodes
  60408. * @param node defines the node to remove
  60409. * @returns the current material
  60410. */
  60411. removeOutputNode(node: NodeMaterialBlock): this;
  60412. private _addVertexOutputNode;
  60413. private _removeVertexOutputNode;
  60414. private _addFragmentOutputNode;
  60415. private _removeFragmentOutputNode;
  60416. /**
  60417. * Specifies if the material will require alpha blending
  60418. * @returns a boolean specifying if alpha blending is needed
  60419. */
  60420. needAlphaBlending(): boolean;
  60421. /**
  60422. * Specifies if this material should be rendered in alpha test mode
  60423. * @returns a boolean specifying if an alpha test is needed.
  60424. */
  60425. needAlphaTesting(): boolean;
  60426. private _initializeBlock;
  60427. private _resetDualBlocks;
  60428. /**
  60429. * Remove a block from the current node material
  60430. * @param block defines the block to remove
  60431. */
  60432. removeBlock(block: NodeMaterialBlock): void;
  60433. /**
  60434. * Build the material and generates the inner effect
  60435. * @param verbose defines if the build should log activity
  60436. */
  60437. build(verbose?: boolean): void;
  60438. /**
  60439. * Runs an otpimization phase to try to improve the shader code
  60440. */
  60441. optimize(): void;
  60442. private _prepareDefinesForAttributes;
  60443. /**
  60444. * Get if the submesh is ready to be used and all its information available.
  60445. * Child classes can use it to update shaders
  60446. * @param mesh defines the mesh to check
  60447. * @param subMesh defines which submesh to check
  60448. * @param useInstances specifies that instances should be used
  60449. * @returns a boolean indicating that the submesh is ready or not
  60450. */
  60451. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  60452. /**
  60453. * Get a string representing the shaders built by the current node graph
  60454. */
  60455. get compiledShaders(): string;
  60456. /**
  60457. * Binds the world matrix to the material
  60458. * @param world defines the world transformation matrix
  60459. */
  60460. bindOnlyWorldMatrix(world: Matrix): void;
  60461. /**
  60462. * Binds the submesh to this material by preparing the effect and shader to draw
  60463. * @param world defines the world transformation matrix
  60464. * @param mesh defines the mesh containing the submesh
  60465. * @param subMesh defines the submesh to bind the material to
  60466. */
  60467. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  60468. /**
  60469. * Gets the active textures from the material
  60470. * @returns an array of textures
  60471. */
  60472. getActiveTextures(): BaseTexture[];
  60473. /**
  60474. * Gets the list of texture blocks
  60475. * @returns an array of texture blocks
  60476. */
  60477. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  60478. /**
  60479. * Specifies if the material uses a texture
  60480. * @param texture defines the texture to check against the material
  60481. * @returns a boolean specifying if the material uses the texture
  60482. */
  60483. hasTexture(texture: BaseTexture): boolean;
  60484. /**
  60485. * Disposes the material
  60486. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  60487. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  60488. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  60489. */
  60490. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  60491. /** Creates the node editor window. */
  60492. private _createNodeEditor;
  60493. /**
  60494. * Launch the node material editor
  60495. * @param config Define the configuration of the editor
  60496. * @return a promise fulfilled when the node editor is visible
  60497. */
  60498. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  60499. /**
  60500. * Clear the current material
  60501. */
  60502. clear(): void;
  60503. /**
  60504. * Clear the current material and set it to a default state
  60505. */
  60506. setToDefault(): void;
  60507. /**
  60508. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  60509. * @param url defines the url to load from
  60510. * @returns a promise that will fullfil when the material is fully loaded
  60511. */
  60512. loadAsync(url: string): Promise<void>;
  60513. private _gatherBlocks;
  60514. /**
  60515. * Generate a string containing the code declaration required to create an equivalent of this material
  60516. * @returns a string
  60517. */
  60518. generateCode(): string;
  60519. /**
  60520. * Serializes this material in a JSON representation
  60521. * @returns the serialized material object
  60522. */
  60523. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  60524. private _restoreConnections;
  60525. /**
  60526. * Clear the current graph and load a new one from a serialization object
  60527. * @param source defines the JSON representation of the material
  60528. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60529. */
  60530. loadFromSerialization(source: any, rootUrl?: string): void;
  60531. /**
  60532. * Makes a duplicate of the current material.
  60533. * @param name - name to use for the new material.
  60534. */
  60535. clone(name: string): NodeMaterial;
  60536. /**
  60537. * Creates a node material from parsed material data
  60538. * @param source defines the JSON representation of the material
  60539. * @param scene defines the hosting scene
  60540. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60541. * @returns a new node material
  60542. */
  60543. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  60544. /**
  60545. * Creates a node material from a snippet saved in a remote file
  60546. * @param name defines the name of the material to create
  60547. * @param url defines the url to load from
  60548. * @param scene defines the hosting scene
  60549. * @returns a promise that will resolve to the new node material
  60550. */
  60551. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  60552. /**
  60553. * Creates a node material from a snippet saved by the node material editor
  60554. * @param snippetId defines the snippet to load
  60555. * @param scene defines the hosting scene
  60556. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  60557. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  60558. * @returns a promise that will resolve to the new node material
  60559. */
  60560. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  60561. /**
  60562. * Creates a new node material set to default basic configuration
  60563. * @param name defines the name of the material
  60564. * @param scene defines the hosting scene
  60565. * @returns a new NodeMaterial
  60566. */
  60567. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  60568. }
  60569. }
  60570. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  60571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60573. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60574. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60575. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60576. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60577. import { Effect } from "babylonjs/Materials/effect";
  60578. import { Mesh } from "babylonjs/Meshes/mesh";
  60579. import { Nullable } from "babylonjs/types";
  60580. import { Texture } from "babylonjs/Materials/Textures/texture";
  60581. import { Scene } from "babylonjs/scene";
  60582. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  60583. /**
  60584. * Block used to read a texture from a sampler
  60585. */
  60586. export class TextureBlock extends NodeMaterialBlock {
  60587. private _defineName;
  60588. private _linearDefineName;
  60589. private _tempTextureRead;
  60590. private _samplerName;
  60591. private _transformedUVName;
  60592. private _textureTransformName;
  60593. private _textureInfoName;
  60594. private _mainUVName;
  60595. private _mainUVDefineName;
  60596. /**
  60597. * Gets or sets the texture associated with the node
  60598. */
  60599. texture: Nullable<Texture>;
  60600. /**
  60601. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  60602. */
  60603. convertToGammaSpace: boolean;
  60604. /**
  60605. * Create a new TextureBlock
  60606. * @param name defines the block name
  60607. */
  60608. constructor(name: string);
  60609. /**
  60610. * Gets the current class name
  60611. * @returns the class name
  60612. */
  60613. getClassName(): string;
  60614. /**
  60615. * Gets the uv input component
  60616. */
  60617. get uv(): NodeMaterialConnectionPoint;
  60618. /**
  60619. * Gets the rgba output component
  60620. */
  60621. get rgba(): NodeMaterialConnectionPoint;
  60622. /**
  60623. * Gets the rgb output component
  60624. */
  60625. get rgb(): NodeMaterialConnectionPoint;
  60626. /**
  60627. * Gets the r output component
  60628. */
  60629. get r(): NodeMaterialConnectionPoint;
  60630. /**
  60631. * Gets the g output component
  60632. */
  60633. get g(): NodeMaterialConnectionPoint;
  60634. /**
  60635. * Gets the b output component
  60636. */
  60637. get b(): NodeMaterialConnectionPoint;
  60638. /**
  60639. * Gets the a output component
  60640. */
  60641. get a(): NodeMaterialConnectionPoint;
  60642. get target(): NodeMaterialBlockTargets;
  60643. autoConfigure(material: NodeMaterial): void;
  60644. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  60645. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  60646. isReady(): boolean;
  60647. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60648. private get _isMixed();
  60649. private _injectVertexCode;
  60650. private _writeTextureRead;
  60651. private _writeOutput;
  60652. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  60653. protected _dumpPropertiesCode(): string;
  60654. serialize(): any;
  60655. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  60656. }
  60657. }
  60658. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  60659. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60660. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  60661. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  60662. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  60663. import { ReflectionTextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  60664. import { Scene } from "babylonjs/scene";
  60665. /**
  60666. * Class used to store shared data between 2 NodeMaterialBuildState
  60667. */
  60668. export class NodeMaterialBuildStateSharedData {
  60669. /**
  60670. * Gets the list of emitted varyings
  60671. */
  60672. temps: string[];
  60673. /**
  60674. * Gets the list of emitted varyings
  60675. */
  60676. varyings: string[];
  60677. /**
  60678. * Gets the varying declaration string
  60679. */
  60680. varyingDeclaration: string;
  60681. /**
  60682. * Input blocks
  60683. */
  60684. inputBlocks: InputBlock[];
  60685. /**
  60686. * Input blocks
  60687. */
  60688. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  60689. /**
  60690. * Bindable blocks (Blocks that need to set data to the effect)
  60691. */
  60692. bindableBlocks: NodeMaterialBlock[];
  60693. /**
  60694. * List of blocks that can provide a compilation fallback
  60695. */
  60696. blocksWithFallbacks: NodeMaterialBlock[];
  60697. /**
  60698. * List of blocks that can provide a define update
  60699. */
  60700. blocksWithDefines: NodeMaterialBlock[];
  60701. /**
  60702. * List of blocks that can provide a repeatable content
  60703. */
  60704. repeatableContentBlocks: NodeMaterialBlock[];
  60705. /**
  60706. * List of blocks that can provide a dynamic list of uniforms
  60707. */
  60708. dynamicUniformBlocks: NodeMaterialBlock[];
  60709. /**
  60710. * List of blocks that can block the isReady function for the material
  60711. */
  60712. blockingBlocks: NodeMaterialBlock[];
  60713. /**
  60714. * Gets the list of animated inputs
  60715. */
  60716. animatedInputs: InputBlock[];
  60717. /**
  60718. * Build Id used to avoid multiple recompilations
  60719. */
  60720. buildId: number;
  60721. /** List of emitted variables */
  60722. variableNames: {
  60723. [key: string]: number;
  60724. };
  60725. /** List of emitted defines */
  60726. defineNames: {
  60727. [key: string]: number;
  60728. };
  60729. /** Should emit comments? */
  60730. emitComments: boolean;
  60731. /** Emit build activity */
  60732. verbose: boolean;
  60733. /** Gets or sets the hosting scene */
  60734. scene: Scene;
  60735. /**
  60736. * Gets the compilation hints emitted at compilation time
  60737. */
  60738. hints: {
  60739. needWorldViewMatrix: boolean;
  60740. needWorldViewProjectionMatrix: boolean;
  60741. needAlphaBlending: boolean;
  60742. needAlphaTesting: boolean;
  60743. };
  60744. /**
  60745. * List of compilation checks
  60746. */
  60747. checks: {
  60748. emitVertex: boolean;
  60749. emitFragment: boolean;
  60750. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  60751. };
  60752. /** Creates a new shared data */
  60753. constructor();
  60754. /**
  60755. * Emits console errors and exceptions if there is a failing check
  60756. */
  60757. emitErrors(): void;
  60758. }
  60759. }
  60760. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  60761. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60762. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60763. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  60764. /**
  60765. * Class used to store node based material build state
  60766. */
  60767. export class NodeMaterialBuildState {
  60768. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  60769. supportUniformBuffers: boolean;
  60770. /**
  60771. * Gets the list of emitted attributes
  60772. */
  60773. attributes: string[];
  60774. /**
  60775. * Gets the list of emitted uniforms
  60776. */
  60777. uniforms: string[];
  60778. /**
  60779. * Gets the list of emitted constants
  60780. */
  60781. constants: string[];
  60782. /**
  60783. * Gets the list of emitted samplers
  60784. */
  60785. samplers: string[];
  60786. /**
  60787. * Gets the list of emitted functions
  60788. */
  60789. functions: {
  60790. [key: string]: string;
  60791. };
  60792. /**
  60793. * Gets the list of emitted extensions
  60794. */
  60795. extensions: {
  60796. [key: string]: string;
  60797. };
  60798. /**
  60799. * Gets the target of the compilation state
  60800. */
  60801. target: NodeMaterialBlockTargets;
  60802. /**
  60803. * Gets the list of emitted counters
  60804. */
  60805. counters: {
  60806. [key: string]: number;
  60807. };
  60808. /**
  60809. * Shared data between multiple NodeMaterialBuildState instances
  60810. */
  60811. sharedData: NodeMaterialBuildStateSharedData;
  60812. /** @hidden */
  60813. _vertexState: NodeMaterialBuildState;
  60814. /** @hidden */
  60815. _attributeDeclaration: string;
  60816. /** @hidden */
  60817. _uniformDeclaration: string;
  60818. /** @hidden */
  60819. _constantDeclaration: string;
  60820. /** @hidden */
  60821. _samplerDeclaration: string;
  60822. /** @hidden */
  60823. _varyingTransfer: string;
  60824. private _repeatableContentAnchorIndex;
  60825. /** @hidden */
  60826. _builtCompilationString: string;
  60827. /**
  60828. * Gets the emitted compilation strings
  60829. */
  60830. compilationString: string;
  60831. /**
  60832. * Finalize the compilation strings
  60833. * @param state defines the current compilation state
  60834. */
  60835. finalize(state: NodeMaterialBuildState): void;
  60836. /** @hidden */
  60837. get _repeatableContentAnchor(): string;
  60838. /** @hidden */
  60839. _getFreeVariableName(prefix: string): string;
  60840. /** @hidden */
  60841. _getFreeDefineName(prefix: string): string;
  60842. /** @hidden */
  60843. _excludeVariableName(name: string): void;
  60844. /** @hidden */
  60845. _emit2DSampler(name: string): void;
  60846. /** @hidden */
  60847. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  60848. /** @hidden */
  60849. _emitExtension(name: string, extension: string): void;
  60850. /** @hidden */
  60851. _emitFunction(name: string, code: string, comments: string): void;
  60852. /** @hidden */
  60853. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  60854. replaceStrings?: {
  60855. search: RegExp;
  60856. replace: string;
  60857. }[];
  60858. repeatKey?: string;
  60859. }): string;
  60860. /** @hidden */
  60861. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  60862. repeatKey?: string;
  60863. removeAttributes?: boolean;
  60864. removeUniforms?: boolean;
  60865. removeVaryings?: boolean;
  60866. removeIfDef?: boolean;
  60867. replaceStrings?: {
  60868. search: RegExp;
  60869. replace: string;
  60870. }[];
  60871. }, storeKey?: string): void;
  60872. /** @hidden */
  60873. _registerTempVariable(name: string): boolean;
  60874. /** @hidden */
  60875. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  60876. /** @hidden */
  60877. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  60878. /** @hidden */
  60879. _emitFloat(value: number): string;
  60880. }
  60881. }
  60882. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  60883. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  60884. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  60885. import { Nullable } from "babylonjs/types";
  60886. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  60887. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  60888. import { Effect } from "babylonjs/Materials/effect";
  60889. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  60890. import { Mesh } from "babylonjs/Meshes/mesh";
  60891. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  60892. import { Scene } from "babylonjs/scene";
  60893. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  60894. /**
  60895. * Defines a block that can be used inside a node based material
  60896. */
  60897. export class NodeMaterialBlock {
  60898. private _buildId;
  60899. private _buildTarget;
  60900. private _target;
  60901. private _isFinalMerger;
  60902. private _isInput;
  60903. protected _isUnique: boolean;
  60904. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  60905. inputsAreExclusive: boolean;
  60906. /** @hidden */
  60907. _codeVariableName: string;
  60908. /** @hidden */
  60909. _inputs: NodeMaterialConnectionPoint[];
  60910. /** @hidden */
  60911. _outputs: NodeMaterialConnectionPoint[];
  60912. /** @hidden */
  60913. _preparationId: number;
  60914. /**
  60915. * Gets or sets the name of the block
  60916. */
  60917. name: string;
  60918. /**
  60919. * Gets or sets the unique id of the node
  60920. */
  60921. uniqueId: number;
  60922. /**
  60923. * Gets or sets the comments associated with this block
  60924. */
  60925. comments: string;
  60926. /**
  60927. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  60928. */
  60929. get isUnique(): boolean;
  60930. /**
  60931. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  60932. */
  60933. get isFinalMerger(): boolean;
  60934. /**
  60935. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  60936. */
  60937. get isInput(): boolean;
  60938. /**
  60939. * Gets or sets the build Id
  60940. */
  60941. get buildId(): number;
  60942. set buildId(value: number);
  60943. /**
  60944. * Gets or sets the target of the block
  60945. */
  60946. get target(): NodeMaterialBlockTargets;
  60947. set target(value: NodeMaterialBlockTargets);
  60948. /**
  60949. * Gets the list of input points
  60950. */
  60951. get inputs(): NodeMaterialConnectionPoint[];
  60952. /** Gets the list of output points */
  60953. get outputs(): NodeMaterialConnectionPoint[];
  60954. /**
  60955. * Find an input by its name
  60956. * @param name defines the name of the input to look for
  60957. * @returns the input or null if not found
  60958. */
  60959. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60960. /**
  60961. * Find an output by its name
  60962. * @param name defines the name of the outputto look for
  60963. * @returns the output or null if not found
  60964. */
  60965. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  60966. /**
  60967. * Creates a new NodeMaterialBlock
  60968. * @param name defines the block name
  60969. * @param target defines the target of that block (Vertex by default)
  60970. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  60971. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  60972. */
  60973. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  60974. /**
  60975. * Initialize the block and prepare the context for build
  60976. * @param state defines the state that will be used for the build
  60977. */
  60978. initialize(state: NodeMaterialBuildState): void;
  60979. /**
  60980. * Bind data to effect. Will only be called for blocks with isBindable === true
  60981. * @param effect defines the effect to bind data to
  60982. * @param nodeMaterial defines the hosting NodeMaterial
  60983. * @param mesh defines the mesh that will be rendered
  60984. */
  60985. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  60986. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  60987. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  60988. protected _writeFloat(value: number): string;
  60989. /**
  60990. * Gets the current class name e.g. "NodeMaterialBlock"
  60991. * @returns the class name
  60992. */
  60993. getClassName(): string;
  60994. /**
  60995. * Register a new input. Must be called inside a block constructor
  60996. * @param name defines the connection point name
  60997. * @param type defines the connection point type
  60998. * @param isOptional defines a boolean indicating that this input can be omitted
  60999. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61000. * @returns the current block
  61001. */
  61002. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  61003. /**
  61004. * Register a new output. Must be called inside a block constructor
  61005. * @param name defines the connection point name
  61006. * @param type defines the connection point type
  61007. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  61008. * @returns the current block
  61009. */
  61010. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  61011. /**
  61012. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  61013. * @param forOutput defines an optional connection point to check compatibility with
  61014. * @returns the first available input or null
  61015. */
  61016. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  61017. /**
  61018. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  61019. * @param forBlock defines an optional block to check compatibility with
  61020. * @returns the first available input or null
  61021. */
  61022. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  61023. /**
  61024. * Gets the sibling of the given output
  61025. * @param current defines the current output
  61026. * @returns the next output in the list or null
  61027. */
  61028. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  61029. /**
  61030. * Connect current block with another block
  61031. * @param other defines the block to connect with
  61032. * @param options define the various options to help pick the right connections
  61033. * @returns the current block
  61034. */
  61035. connectTo(other: NodeMaterialBlock, options?: {
  61036. input?: string;
  61037. output?: string;
  61038. outputSwizzle?: string;
  61039. }): this | undefined;
  61040. protected _buildBlock(state: NodeMaterialBuildState): void;
  61041. /**
  61042. * Add uniforms, samplers and uniform buffers at compilation time
  61043. * @param state defines the state to update
  61044. * @param nodeMaterial defines the node material requesting the update
  61045. * @param defines defines the material defines to update
  61046. * @param uniformBuffers defines the list of uniform buffer names
  61047. */
  61048. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  61049. /**
  61050. * Add potential fallbacks if shader compilation fails
  61051. * @param mesh defines the mesh to be rendered
  61052. * @param fallbacks defines the current prioritized list of fallbacks
  61053. */
  61054. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61055. /**
  61056. * Initialize defines for shader compilation
  61057. * @param mesh defines the mesh to be rendered
  61058. * @param nodeMaterial defines the node material requesting the update
  61059. * @param defines defines the material defines to update
  61060. * @param useInstances specifies that instances should be used
  61061. */
  61062. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61063. /**
  61064. * Update defines for shader compilation
  61065. * @param mesh defines the mesh to be rendered
  61066. * @param nodeMaterial defines the node material requesting the update
  61067. * @param defines defines the material defines to update
  61068. * @param useInstances specifies that instances should be used
  61069. */
  61070. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61071. /**
  61072. * Lets the block try to connect some inputs automatically
  61073. * @param material defines the hosting NodeMaterial
  61074. */
  61075. autoConfigure(material: NodeMaterial): void;
  61076. /**
  61077. * Function called when a block is declared as repeatable content generator
  61078. * @param vertexShaderState defines the current compilation state for the vertex shader
  61079. * @param fragmentShaderState defines the current compilation state for the fragment shader
  61080. * @param mesh defines the mesh to be rendered
  61081. * @param defines defines the material defines to update
  61082. */
  61083. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61084. /**
  61085. * Checks if the block is ready
  61086. * @param mesh defines the mesh to be rendered
  61087. * @param nodeMaterial defines the node material requesting the update
  61088. * @param defines defines the material defines to update
  61089. * @param useInstances specifies that instances should be used
  61090. * @returns true if the block is ready
  61091. */
  61092. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  61093. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  61094. private _processBuild;
  61095. /**
  61096. * Compile the current node and generate the shader code
  61097. * @param state defines the current compilation state (uniforms, samplers, current string)
  61098. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  61099. * @returns true if already built
  61100. */
  61101. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  61102. protected _inputRename(name: string): string;
  61103. protected _outputRename(name: string): string;
  61104. protected _dumpPropertiesCode(): string;
  61105. /** @hidden */
  61106. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  61107. /** @hidden */
  61108. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  61109. /**
  61110. * Clone the current block to a new identical block
  61111. * @param scene defines the hosting scene
  61112. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  61113. * @returns a copy of the current block
  61114. */
  61115. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  61116. /**
  61117. * Serializes this block in a JSON representation
  61118. * @returns the serialized block object
  61119. */
  61120. serialize(): any;
  61121. /** @hidden */
  61122. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61123. /**
  61124. * Release resources
  61125. */
  61126. dispose(): void;
  61127. }
  61128. }
  61129. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  61130. /**
  61131. * Enum defining the type of animations supported by InputBlock
  61132. */
  61133. export enum AnimatedInputBlockTypes {
  61134. /** No animation */
  61135. None = 0,
  61136. /** Time based animation. Will only work for floats */
  61137. Time = 1
  61138. }
  61139. }
  61140. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  61141. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61142. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61143. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  61144. import { Nullable } from "babylonjs/types";
  61145. import { Effect } from "babylonjs/Materials/effect";
  61146. import { Matrix } from "babylonjs/Maths/math.vector";
  61147. import { Scene } from "babylonjs/scene";
  61148. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61149. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61150. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61151. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  61152. import { Observable } from "babylonjs/Misc/observable";
  61153. /**
  61154. * Block used to expose an input value
  61155. */
  61156. export class InputBlock extends NodeMaterialBlock {
  61157. private _mode;
  61158. private _associatedVariableName;
  61159. private _storedValue;
  61160. private _valueCallback;
  61161. private _type;
  61162. private _animationType;
  61163. /** Gets or set a value used to limit the range of float values */
  61164. min: number;
  61165. /** Gets or set a value used to limit the range of float values */
  61166. max: number;
  61167. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  61168. isBoolean: boolean;
  61169. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  61170. matrixMode: number;
  61171. /** @hidden */
  61172. _systemValue: Nullable<NodeMaterialSystemValues>;
  61173. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  61174. visibleInInspector: boolean;
  61175. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  61176. isConstant: boolean;
  61177. /** Gets or sets the group to use to display this block in the Inspector */
  61178. groupInInspector: string;
  61179. /** Gets an observable raised when the value is changed */
  61180. onValueChangedObservable: Observable<InputBlock>;
  61181. /**
  61182. * Gets or sets the connection point type (default is float)
  61183. */
  61184. get type(): NodeMaterialBlockConnectionPointTypes;
  61185. /**
  61186. * Creates a new InputBlock
  61187. * @param name defines the block name
  61188. * @param target defines the target of that block (Vertex by default)
  61189. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  61190. */
  61191. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  61192. /**
  61193. * Gets the output component
  61194. */
  61195. get output(): NodeMaterialConnectionPoint;
  61196. /**
  61197. * Set the source of this connection point to a vertex attribute
  61198. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  61199. * @returns the current connection point
  61200. */
  61201. setAsAttribute(attributeName?: string): InputBlock;
  61202. /**
  61203. * Set the source of this connection point to a system value
  61204. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  61205. * @returns the current connection point
  61206. */
  61207. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  61208. /**
  61209. * Gets or sets the value of that point.
  61210. * Please note that this value will be ignored if valueCallback is defined
  61211. */
  61212. get value(): any;
  61213. set value(value: any);
  61214. /**
  61215. * Gets or sets a callback used to get the value of that point.
  61216. * Please note that setting this value will force the connection point to ignore the value property
  61217. */
  61218. get valueCallback(): () => any;
  61219. set valueCallback(value: () => any);
  61220. /**
  61221. * Gets or sets the associated variable name in the shader
  61222. */
  61223. get associatedVariableName(): string;
  61224. set associatedVariableName(value: string);
  61225. /** Gets or sets the type of animation applied to the input */
  61226. get animationType(): AnimatedInputBlockTypes;
  61227. set animationType(value: AnimatedInputBlockTypes);
  61228. /**
  61229. * Gets a boolean indicating that this connection point not defined yet
  61230. */
  61231. get isUndefined(): boolean;
  61232. /**
  61233. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  61234. * In this case the connection point name must be the name of the uniform to use.
  61235. * Can only be set on inputs
  61236. */
  61237. get isUniform(): boolean;
  61238. set isUniform(value: boolean);
  61239. /**
  61240. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  61241. * In this case the connection point name must be the name of the attribute to use
  61242. * Can only be set on inputs
  61243. */
  61244. get isAttribute(): boolean;
  61245. set isAttribute(value: boolean);
  61246. /**
  61247. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  61248. * Can only be set on exit points
  61249. */
  61250. get isVarying(): boolean;
  61251. set isVarying(value: boolean);
  61252. /**
  61253. * Gets a boolean indicating that the current connection point is a system value
  61254. */
  61255. get isSystemValue(): boolean;
  61256. /**
  61257. * Gets or sets the current well known value or null if not defined as a system value
  61258. */
  61259. get systemValue(): Nullable<NodeMaterialSystemValues>;
  61260. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  61261. /**
  61262. * Gets the current class name
  61263. * @returns the class name
  61264. */
  61265. getClassName(): string;
  61266. /**
  61267. * Animate the input if animationType !== None
  61268. * @param scene defines the rendering scene
  61269. */
  61270. animate(scene: Scene): void;
  61271. private _emitDefine;
  61272. initialize(state: NodeMaterialBuildState): void;
  61273. /**
  61274. * Set the input block to its default value (based on its type)
  61275. */
  61276. setDefaultValue(): void;
  61277. private _emitConstant;
  61278. private _emit;
  61279. /** @hidden */
  61280. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  61281. /** @hidden */
  61282. _transmit(effect: Effect, scene: Scene): void;
  61283. protected _buildBlock(state: NodeMaterialBuildState): void;
  61284. protected _dumpPropertiesCode(): string;
  61285. dispose(): void;
  61286. serialize(): any;
  61287. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61288. }
  61289. }
  61290. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  61291. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  61292. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  61293. import { Nullable } from "babylonjs/types";
  61294. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  61295. import { Observable } from "babylonjs/Misc/observable";
  61296. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61297. /**
  61298. * Enum used to define the compatibility state between two connection points
  61299. */
  61300. export enum NodeMaterialConnectionPointCompatibilityStates {
  61301. /** Points are compatibles */
  61302. Compatible = 0,
  61303. /** Points are incompatible because of their types */
  61304. TypeIncompatible = 1,
  61305. /** Points are incompatible because of their targets (vertex vs fragment) */
  61306. TargetIncompatible = 2
  61307. }
  61308. /**
  61309. * Defines the direction of a connection point
  61310. */
  61311. export enum NodeMaterialConnectionPointDirection {
  61312. /** Input */
  61313. Input = 0,
  61314. /** Output */
  61315. Output = 1
  61316. }
  61317. /**
  61318. * Defines a connection point for a block
  61319. */
  61320. export class NodeMaterialConnectionPoint {
  61321. /** @hidden */
  61322. _ownerBlock: NodeMaterialBlock;
  61323. /** @hidden */
  61324. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  61325. private _endpoints;
  61326. private _associatedVariableName;
  61327. private _direction;
  61328. /** @hidden */
  61329. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61330. /** @hidden */
  61331. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  61332. private _type;
  61333. /** @hidden */
  61334. _enforceAssociatedVariableName: boolean;
  61335. /** Gets the direction of the point */
  61336. get direction(): NodeMaterialConnectionPointDirection;
  61337. /**
  61338. * Gets or sets the additional types supported by this connection point
  61339. */
  61340. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61341. /**
  61342. * Gets or sets the additional types excluded by this connection point
  61343. */
  61344. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  61345. /**
  61346. * Observable triggered when this point is connected
  61347. */
  61348. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  61349. /**
  61350. * Gets or sets the associated variable name in the shader
  61351. */
  61352. get associatedVariableName(): string;
  61353. set associatedVariableName(value: string);
  61354. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  61355. get innerType(): NodeMaterialBlockConnectionPointTypes;
  61356. /**
  61357. * Gets or sets the connection point type (default is float)
  61358. */
  61359. get type(): NodeMaterialBlockConnectionPointTypes;
  61360. set type(value: NodeMaterialBlockConnectionPointTypes);
  61361. /**
  61362. * Gets or sets the connection point name
  61363. */
  61364. name: string;
  61365. /**
  61366. * Gets or sets a boolean indicating that this connection point can be omitted
  61367. */
  61368. isOptional: boolean;
  61369. /**
  61370. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  61371. */
  61372. define: string;
  61373. /** @hidden */
  61374. _prioritizeVertex: boolean;
  61375. private _target;
  61376. /** Gets or sets the target of that connection point */
  61377. get target(): NodeMaterialBlockTargets;
  61378. set target(value: NodeMaterialBlockTargets);
  61379. /**
  61380. * Gets a boolean indicating that the current point is connected
  61381. */
  61382. get isConnected(): boolean;
  61383. /**
  61384. * Gets a boolean indicating that the current point is connected to an input block
  61385. */
  61386. get isConnectedToInputBlock(): boolean;
  61387. /**
  61388. * Gets a the connected input block (if any)
  61389. */
  61390. get connectInputBlock(): Nullable<InputBlock>;
  61391. /** Get the other side of the connection (if any) */
  61392. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  61393. /** Get the block that owns this connection point */
  61394. get ownerBlock(): NodeMaterialBlock;
  61395. /** Get the block connected on the other side of this connection (if any) */
  61396. get sourceBlock(): Nullable<NodeMaterialBlock>;
  61397. /** Get the block connected on the endpoints of this connection (if any) */
  61398. get connectedBlocks(): Array<NodeMaterialBlock>;
  61399. /** Gets the list of connected endpoints */
  61400. get endpoints(): NodeMaterialConnectionPoint[];
  61401. /** Gets a boolean indicating if that output point is connected to at least one input */
  61402. get hasEndpoints(): boolean;
  61403. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  61404. get isConnectedInVertexShader(): boolean;
  61405. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  61406. get isConnectedInFragmentShader(): boolean;
  61407. /**
  61408. * Creates a new connection point
  61409. * @param name defines the connection point name
  61410. * @param ownerBlock defines the block hosting this connection point
  61411. * @param direction defines the direction of the connection point
  61412. */
  61413. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  61414. /**
  61415. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  61416. * @returns the class name
  61417. */
  61418. getClassName(): string;
  61419. /**
  61420. * Gets a boolean indicating if the current point can be connected to another point
  61421. * @param connectionPoint defines the other connection point
  61422. * @returns a boolean
  61423. */
  61424. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  61425. /**
  61426. * Gets a number indicating if the current point can be connected to another point
  61427. * @param connectionPoint defines the other connection point
  61428. * @returns a number defining the compatibility state
  61429. */
  61430. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  61431. /**
  61432. * Connect this point to another connection point
  61433. * @param connectionPoint defines the other connection point
  61434. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  61435. * @returns the current connection point
  61436. */
  61437. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  61438. /**
  61439. * Disconnect this point from one of his endpoint
  61440. * @param endpoint defines the other connection point
  61441. * @returns the current connection point
  61442. */
  61443. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  61444. /**
  61445. * Serializes this point in a JSON representation
  61446. * @returns the serialized point object
  61447. */
  61448. serialize(): any;
  61449. /**
  61450. * Release resources
  61451. */
  61452. dispose(): void;
  61453. }
  61454. }
  61455. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  61456. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61457. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61458. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61459. import { Mesh } from "babylonjs/Meshes/mesh";
  61460. import { Effect } from "babylonjs/Materials/effect";
  61461. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61462. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61463. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61464. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61465. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  61466. /**
  61467. * Block used to add support for vertex skinning (bones)
  61468. */
  61469. export class BonesBlock extends NodeMaterialBlock {
  61470. /**
  61471. * Creates a new BonesBlock
  61472. * @param name defines the block name
  61473. */
  61474. constructor(name: string);
  61475. /**
  61476. * Initialize the block and prepare the context for build
  61477. * @param state defines the state that will be used for the build
  61478. */
  61479. initialize(state: NodeMaterialBuildState): void;
  61480. /**
  61481. * Gets the current class name
  61482. * @returns the class name
  61483. */
  61484. getClassName(): string;
  61485. /**
  61486. * Gets the matrix indices input component
  61487. */
  61488. get matricesIndices(): NodeMaterialConnectionPoint;
  61489. /**
  61490. * Gets the matrix weights input component
  61491. */
  61492. get matricesWeights(): NodeMaterialConnectionPoint;
  61493. /**
  61494. * Gets the extra matrix indices input component
  61495. */
  61496. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  61497. /**
  61498. * Gets the extra matrix weights input component
  61499. */
  61500. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  61501. /**
  61502. * Gets the world input component
  61503. */
  61504. get world(): NodeMaterialConnectionPoint;
  61505. /**
  61506. * Gets the output component
  61507. */
  61508. get output(): NodeMaterialConnectionPoint;
  61509. autoConfigure(material: NodeMaterial): void;
  61510. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  61511. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61512. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61513. protected _buildBlock(state: NodeMaterialBuildState): this;
  61514. }
  61515. }
  61516. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  61517. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61519. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61520. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61521. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61522. /**
  61523. * Block used to add support for instances
  61524. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  61525. */
  61526. export class InstancesBlock extends NodeMaterialBlock {
  61527. /**
  61528. * Creates a new InstancesBlock
  61529. * @param name defines the block name
  61530. */
  61531. constructor(name: string);
  61532. /**
  61533. * Gets the current class name
  61534. * @returns the class name
  61535. */
  61536. getClassName(): string;
  61537. /**
  61538. * Gets the first world row input component
  61539. */
  61540. get world0(): NodeMaterialConnectionPoint;
  61541. /**
  61542. * Gets the second world row input component
  61543. */
  61544. get world1(): NodeMaterialConnectionPoint;
  61545. /**
  61546. * Gets the third world row input component
  61547. */
  61548. get world2(): NodeMaterialConnectionPoint;
  61549. /**
  61550. * Gets the forth world row input component
  61551. */
  61552. get world3(): NodeMaterialConnectionPoint;
  61553. /**
  61554. * Gets the world input component
  61555. */
  61556. get world(): NodeMaterialConnectionPoint;
  61557. /**
  61558. * Gets the output component
  61559. */
  61560. get output(): NodeMaterialConnectionPoint;
  61561. /**
  61562. * Gets the isntanceID component
  61563. */
  61564. get instanceID(): NodeMaterialConnectionPoint;
  61565. autoConfigure(material: NodeMaterial): void;
  61566. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  61567. protected _buildBlock(state: NodeMaterialBuildState): this;
  61568. }
  61569. }
  61570. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  61571. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61572. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61573. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61575. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61576. import { Effect } from "babylonjs/Materials/effect";
  61577. import { Mesh } from "babylonjs/Meshes/mesh";
  61578. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61579. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61580. /**
  61581. * Block used to add morph targets support to vertex shader
  61582. */
  61583. export class MorphTargetsBlock extends NodeMaterialBlock {
  61584. private _repeatableContentAnchor;
  61585. /**
  61586. * Create a new MorphTargetsBlock
  61587. * @param name defines the block name
  61588. */
  61589. constructor(name: string);
  61590. /**
  61591. * Gets the current class name
  61592. * @returns the class name
  61593. */
  61594. getClassName(): string;
  61595. /**
  61596. * Gets the position input component
  61597. */
  61598. get position(): NodeMaterialConnectionPoint;
  61599. /**
  61600. * Gets the normal input component
  61601. */
  61602. get normal(): NodeMaterialConnectionPoint;
  61603. /**
  61604. * Gets the tangent input component
  61605. */
  61606. get tangent(): NodeMaterialConnectionPoint;
  61607. /**
  61608. * Gets the tangent input component
  61609. */
  61610. get uv(): NodeMaterialConnectionPoint;
  61611. /**
  61612. * Gets the position output component
  61613. */
  61614. get positionOutput(): NodeMaterialConnectionPoint;
  61615. /**
  61616. * Gets the normal output component
  61617. */
  61618. get normalOutput(): NodeMaterialConnectionPoint;
  61619. /**
  61620. * Gets the tangent output component
  61621. */
  61622. get tangentOutput(): NodeMaterialConnectionPoint;
  61623. /**
  61624. * Gets the tangent output component
  61625. */
  61626. get uvOutput(): NodeMaterialConnectionPoint;
  61627. initialize(state: NodeMaterialBuildState): void;
  61628. autoConfigure(material: NodeMaterial): void;
  61629. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61631. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  61632. protected _buildBlock(state: NodeMaterialBuildState): this;
  61633. }
  61634. }
  61635. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  61636. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61637. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61638. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61639. import { Nullable } from "babylonjs/types";
  61640. import { Scene } from "babylonjs/scene";
  61641. import { Effect } from "babylonjs/Materials/effect";
  61642. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61643. import { Mesh } from "babylonjs/Meshes/mesh";
  61644. import { Light } from "babylonjs/Lights/light";
  61645. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61646. /**
  61647. * Block used to get data information from a light
  61648. */
  61649. export class LightInformationBlock extends NodeMaterialBlock {
  61650. private _lightDataUniformName;
  61651. private _lightColorUniformName;
  61652. private _lightTypeDefineName;
  61653. /**
  61654. * Gets or sets the light associated with this block
  61655. */
  61656. light: Nullable<Light>;
  61657. /**
  61658. * Creates a new LightInformationBlock
  61659. * @param name defines the block name
  61660. */
  61661. constructor(name: string);
  61662. /**
  61663. * Gets the current class name
  61664. * @returns the class name
  61665. */
  61666. getClassName(): string;
  61667. /**
  61668. * Gets the world position input component
  61669. */
  61670. get worldPosition(): NodeMaterialConnectionPoint;
  61671. /**
  61672. * Gets the direction output component
  61673. */
  61674. get direction(): NodeMaterialConnectionPoint;
  61675. /**
  61676. * Gets the direction output component
  61677. */
  61678. get color(): NodeMaterialConnectionPoint;
  61679. /**
  61680. * Gets the direction output component
  61681. */
  61682. get intensity(): NodeMaterialConnectionPoint;
  61683. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61684. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61685. protected _buildBlock(state: NodeMaterialBuildState): this;
  61686. serialize(): any;
  61687. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61688. }
  61689. }
  61690. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  61691. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  61692. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  61693. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  61694. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  61695. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  61696. }
  61697. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  61698. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61699. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61700. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61701. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61702. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61703. import { Effect } from "babylonjs/Materials/effect";
  61704. import { Mesh } from "babylonjs/Meshes/mesh";
  61705. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61706. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  61707. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  61708. /**
  61709. * Block used to add image processing support to fragment shader
  61710. */
  61711. export class ImageProcessingBlock extends NodeMaterialBlock {
  61712. /**
  61713. * Create a new ImageProcessingBlock
  61714. * @param name defines the block name
  61715. */
  61716. constructor(name: string);
  61717. /**
  61718. * Gets the current class name
  61719. * @returns the class name
  61720. */
  61721. getClassName(): string;
  61722. /**
  61723. * Gets the color input component
  61724. */
  61725. get color(): NodeMaterialConnectionPoint;
  61726. /**
  61727. * Gets the output component
  61728. */
  61729. get output(): NodeMaterialConnectionPoint;
  61730. /**
  61731. * Initialize the block and prepare the context for build
  61732. * @param state defines the state that will be used for the build
  61733. */
  61734. initialize(state: NodeMaterialBuildState): void;
  61735. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  61736. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61737. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61738. protected _buildBlock(state: NodeMaterialBuildState): this;
  61739. }
  61740. }
  61741. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  61742. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61743. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61744. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61745. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61746. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61747. import { Effect } from "babylonjs/Materials/effect";
  61748. import { Mesh } from "babylonjs/Meshes/mesh";
  61749. import { Scene } from "babylonjs/scene";
  61750. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  61751. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  61752. /**
  61753. * Block used to pertub normals based on a normal map
  61754. */
  61755. export class PerturbNormalBlock extends NodeMaterialBlock {
  61756. private _tangentSpaceParameterName;
  61757. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  61758. invertX: boolean;
  61759. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  61760. invertY: boolean;
  61761. /**
  61762. * Create a new PerturbNormalBlock
  61763. * @param name defines the block name
  61764. */
  61765. constructor(name: string);
  61766. /**
  61767. * Gets the current class name
  61768. * @returns the class name
  61769. */
  61770. getClassName(): string;
  61771. /**
  61772. * Gets the world position input component
  61773. */
  61774. get worldPosition(): NodeMaterialConnectionPoint;
  61775. /**
  61776. * Gets the world normal input component
  61777. */
  61778. get worldNormal(): NodeMaterialConnectionPoint;
  61779. /**
  61780. * Gets the world tangent input component
  61781. */
  61782. get worldTangent(): NodeMaterialConnectionPoint;
  61783. /**
  61784. * Gets the uv input component
  61785. */
  61786. get uv(): NodeMaterialConnectionPoint;
  61787. /**
  61788. * Gets the normal map color input component
  61789. */
  61790. get normalMapColor(): NodeMaterialConnectionPoint;
  61791. /**
  61792. * Gets the strength input component
  61793. */
  61794. get strength(): NodeMaterialConnectionPoint;
  61795. /**
  61796. * Gets the output component
  61797. */
  61798. get output(): NodeMaterialConnectionPoint;
  61799. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61800. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61801. autoConfigure(material: NodeMaterial): void;
  61802. protected _buildBlock(state: NodeMaterialBuildState): this;
  61803. protected _dumpPropertiesCode(): string;
  61804. serialize(): any;
  61805. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  61806. }
  61807. }
  61808. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  61809. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61810. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61811. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61812. /**
  61813. * Block used to discard a pixel if a value is smaller than a cutoff
  61814. */
  61815. export class DiscardBlock extends NodeMaterialBlock {
  61816. /**
  61817. * Create a new DiscardBlock
  61818. * @param name defines the block name
  61819. */
  61820. constructor(name: string);
  61821. /**
  61822. * Gets the current class name
  61823. * @returns the class name
  61824. */
  61825. getClassName(): string;
  61826. /**
  61827. * Gets the color input component
  61828. */
  61829. get value(): NodeMaterialConnectionPoint;
  61830. /**
  61831. * Gets the cutoff input component
  61832. */
  61833. get cutoff(): NodeMaterialConnectionPoint;
  61834. protected _buildBlock(state: NodeMaterialBuildState): this;
  61835. }
  61836. }
  61837. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  61838. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61839. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61840. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61841. /**
  61842. * Block used to test if the fragment shader is front facing
  61843. */
  61844. export class FrontFacingBlock extends NodeMaterialBlock {
  61845. /**
  61846. * Creates a new FrontFacingBlock
  61847. * @param name defines the block name
  61848. */
  61849. constructor(name: string);
  61850. /**
  61851. * Gets the current class name
  61852. * @returns the class name
  61853. */
  61854. getClassName(): string;
  61855. /**
  61856. * Gets the output component
  61857. */
  61858. get output(): NodeMaterialConnectionPoint;
  61859. protected _buildBlock(state: NodeMaterialBuildState): this;
  61860. }
  61861. }
  61862. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  61863. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61864. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61865. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61866. /**
  61867. * Block used to get the derivative value on x and y of a given input
  61868. */
  61869. export class DerivativeBlock extends NodeMaterialBlock {
  61870. /**
  61871. * Create a new DerivativeBlock
  61872. * @param name defines the block name
  61873. */
  61874. constructor(name: string);
  61875. /**
  61876. * Gets the current class name
  61877. * @returns the class name
  61878. */
  61879. getClassName(): string;
  61880. /**
  61881. * Gets the input component
  61882. */
  61883. get input(): NodeMaterialConnectionPoint;
  61884. /**
  61885. * Gets the derivative output on x
  61886. */
  61887. get dx(): NodeMaterialConnectionPoint;
  61888. /**
  61889. * Gets the derivative output on y
  61890. */
  61891. get dy(): NodeMaterialConnectionPoint;
  61892. protected _buildBlock(state: NodeMaterialBuildState): this;
  61893. }
  61894. }
  61895. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  61896. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  61897. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  61898. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  61899. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  61900. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  61901. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  61902. }
  61903. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  61904. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61905. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61906. import { Mesh } from "babylonjs/Meshes/mesh";
  61907. import { Effect } from "babylonjs/Materials/effect";
  61908. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61909. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61910. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61911. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  61912. /**
  61913. * Block used to add support for scene fog
  61914. */
  61915. export class FogBlock extends NodeMaterialBlock {
  61916. private _fogDistanceName;
  61917. private _fogParameters;
  61918. /**
  61919. * Create a new FogBlock
  61920. * @param name defines the block name
  61921. */
  61922. constructor(name: string);
  61923. /**
  61924. * Gets the current class name
  61925. * @returns the class name
  61926. */
  61927. getClassName(): string;
  61928. /**
  61929. * Gets the world position input component
  61930. */
  61931. get worldPosition(): NodeMaterialConnectionPoint;
  61932. /**
  61933. * Gets the view input component
  61934. */
  61935. get view(): NodeMaterialConnectionPoint;
  61936. /**
  61937. * Gets the color input component
  61938. */
  61939. get input(): NodeMaterialConnectionPoint;
  61940. /**
  61941. * Gets the fog color input component
  61942. */
  61943. get fogColor(): NodeMaterialConnectionPoint;
  61944. /**
  61945. * Gets the output component
  61946. */
  61947. get output(): NodeMaterialConnectionPoint;
  61948. autoConfigure(material: NodeMaterial): void;
  61949. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  61950. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  61951. protected _buildBlock(state: NodeMaterialBuildState): this;
  61952. }
  61953. }
  61954. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  61955. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  61956. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  61957. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  61958. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61959. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  61960. import { Effect } from "babylonjs/Materials/effect";
  61961. import { Mesh } from "babylonjs/Meshes/mesh";
  61962. import { Light } from "babylonjs/Lights/light";
  61963. import { Nullable } from "babylonjs/types";
  61964. import { Scene } from "babylonjs/scene";
  61965. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  61966. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  61967. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  61968. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  61969. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  61970. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  61971. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  61972. /**
  61973. * Block used to add light in the fragment shader
  61974. */
  61975. export class LightBlock extends NodeMaterialBlock {
  61976. private _lightId;
  61977. /**
  61978. * Gets or sets the light associated with this block
  61979. */
  61980. light: Nullable<Light>;
  61981. /**
  61982. * Create a new LightBlock
  61983. * @param name defines the block name
  61984. */
  61985. constructor(name: string);
  61986. /**
  61987. * Gets the current class name
  61988. * @returns the class name
  61989. */
  61990. getClassName(): string;
  61991. /**
  61992. * Gets the world position input component
  61993. */
  61994. get worldPosition(): NodeMaterialConnectionPoint;
  61995. /**
  61996. * Gets the world normal input component
  61997. */
  61998. get worldNormal(): NodeMaterialConnectionPoint;
  61999. /**
  62000. * Gets the camera (or eye) position component
  62001. */
  62002. get cameraPosition(): NodeMaterialConnectionPoint;
  62003. /**
  62004. * Gets the glossiness component
  62005. */
  62006. get glossiness(): NodeMaterialConnectionPoint;
  62007. /**
  62008. * Gets the glossinness power component
  62009. */
  62010. get glossPower(): NodeMaterialConnectionPoint;
  62011. /**
  62012. * Gets the diffuse color component
  62013. */
  62014. get diffuseColor(): NodeMaterialConnectionPoint;
  62015. /**
  62016. * Gets the specular color component
  62017. */
  62018. get specularColor(): NodeMaterialConnectionPoint;
  62019. /**
  62020. * Gets the diffuse output component
  62021. */
  62022. get diffuseOutput(): NodeMaterialConnectionPoint;
  62023. /**
  62024. * Gets the specular output component
  62025. */
  62026. get specularOutput(): NodeMaterialConnectionPoint;
  62027. /**
  62028. * Gets the shadow output component
  62029. */
  62030. get shadow(): NodeMaterialConnectionPoint;
  62031. autoConfigure(material: NodeMaterial): void;
  62032. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  62033. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  62034. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  62035. private _injectVertexCode;
  62036. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62037. serialize(): any;
  62038. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62039. }
  62040. }
  62041. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  62042. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  62043. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  62044. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  62045. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  62046. }
  62047. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  62048. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  62049. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  62050. }
  62051. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  62052. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62053. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62054. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62055. /**
  62056. * Block used to multiply 2 values
  62057. */
  62058. export class MultiplyBlock extends NodeMaterialBlock {
  62059. /**
  62060. * Creates a new MultiplyBlock
  62061. * @param name defines the block name
  62062. */
  62063. constructor(name: string);
  62064. /**
  62065. * Gets the current class name
  62066. * @returns the class name
  62067. */
  62068. getClassName(): string;
  62069. /**
  62070. * Gets the left operand input component
  62071. */
  62072. get left(): NodeMaterialConnectionPoint;
  62073. /**
  62074. * Gets the right operand input component
  62075. */
  62076. get right(): NodeMaterialConnectionPoint;
  62077. /**
  62078. * Gets the output component
  62079. */
  62080. get output(): NodeMaterialConnectionPoint;
  62081. protected _buildBlock(state: NodeMaterialBuildState): this;
  62082. }
  62083. }
  62084. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  62085. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62086. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62087. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62088. /**
  62089. * Block used to add 2 vectors
  62090. */
  62091. export class AddBlock extends NodeMaterialBlock {
  62092. /**
  62093. * Creates a new AddBlock
  62094. * @param name defines the block name
  62095. */
  62096. constructor(name: string);
  62097. /**
  62098. * Gets the current class name
  62099. * @returns the class name
  62100. */
  62101. getClassName(): string;
  62102. /**
  62103. * Gets the left operand input component
  62104. */
  62105. get left(): NodeMaterialConnectionPoint;
  62106. /**
  62107. * Gets the right operand input component
  62108. */
  62109. get right(): NodeMaterialConnectionPoint;
  62110. /**
  62111. * Gets the output component
  62112. */
  62113. get output(): NodeMaterialConnectionPoint;
  62114. protected _buildBlock(state: NodeMaterialBuildState): this;
  62115. }
  62116. }
  62117. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  62118. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62119. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62120. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62121. /**
  62122. * Block used to scale a vector by a float
  62123. */
  62124. export class ScaleBlock extends NodeMaterialBlock {
  62125. /**
  62126. * Creates a new ScaleBlock
  62127. * @param name defines the block name
  62128. */
  62129. constructor(name: string);
  62130. /**
  62131. * Gets the current class name
  62132. * @returns the class name
  62133. */
  62134. getClassName(): string;
  62135. /**
  62136. * Gets the input component
  62137. */
  62138. get input(): NodeMaterialConnectionPoint;
  62139. /**
  62140. * Gets the factor input component
  62141. */
  62142. get factor(): NodeMaterialConnectionPoint;
  62143. /**
  62144. * Gets the output component
  62145. */
  62146. get output(): NodeMaterialConnectionPoint;
  62147. protected _buildBlock(state: NodeMaterialBuildState): this;
  62148. }
  62149. }
  62150. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  62151. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62152. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62153. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62154. import { Scene } from "babylonjs/scene";
  62155. /**
  62156. * Block used to clamp a float
  62157. */
  62158. export class ClampBlock extends NodeMaterialBlock {
  62159. /** Gets or sets the minimum range */
  62160. minimum: number;
  62161. /** Gets or sets the maximum range */
  62162. maximum: number;
  62163. /**
  62164. * Creates a new ClampBlock
  62165. * @param name defines the block name
  62166. */
  62167. constructor(name: string);
  62168. /**
  62169. * Gets the current class name
  62170. * @returns the class name
  62171. */
  62172. getClassName(): string;
  62173. /**
  62174. * Gets the value input component
  62175. */
  62176. get value(): NodeMaterialConnectionPoint;
  62177. /**
  62178. * Gets the output component
  62179. */
  62180. get output(): NodeMaterialConnectionPoint;
  62181. protected _buildBlock(state: NodeMaterialBuildState): this;
  62182. protected _dumpPropertiesCode(): string;
  62183. serialize(): any;
  62184. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62185. }
  62186. }
  62187. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  62188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62191. /**
  62192. * Block used to apply a cross product between 2 vectors
  62193. */
  62194. export class CrossBlock extends NodeMaterialBlock {
  62195. /**
  62196. * Creates a new CrossBlock
  62197. * @param name defines the block name
  62198. */
  62199. constructor(name: string);
  62200. /**
  62201. * Gets the current class name
  62202. * @returns the class name
  62203. */
  62204. getClassName(): string;
  62205. /**
  62206. * Gets the left operand input component
  62207. */
  62208. get left(): NodeMaterialConnectionPoint;
  62209. /**
  62210. * Gets the right operand input component
  62211. */
  62212. get right(): NodeMaterialConnectionPoint;
  62213. /**
  62214. * Gets the output component
  62215. */
  62216. get output(): NodeMaterialConnectionPoint;
  62217. protected _buildBlock(state: NodeMaterialBuildState): this;
  62218. }
  62219. }
  62220. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  62221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62224. /**
  62225. * Block used to apply a dot product between 2 vectors
  62226. */
  62227. export class DotBlock extends NodeMaterialBlock {
  62228. /**
  62229. * Creates a new DotBlock
  62230. * @param name defines the block name
  62231. */
  62232. constructor(name: string);
  62233. /**
  62234. * Gets the current class name
  62235. * @returns the class name
  62236. */
  62237. getClassName(): string;
  62238. /**
  62239. * Gets the left operand input component
  62240. */
  62241. get left(): NodeMaterialConnectionPoint;
  62242. /**
  62243. * Gets the right operand input component
  62244. */
  62245. get right(): NodeMaterialConnectionPoint;
  62246. /**
  62247. * Gets the output component
  62248. */
  62249. get output(): NodeMaterialConnectionPoint;
  62250. protected _buildBlock(state: NodeMaterialBuildState): this;
  62251. }
  62252. }
  62253. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  62254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62257. import { Vector2 } from "babylonjs/Maths/math.vector";
  62258. import { Scene } from "babylonjs/scene";
  62259. /**
  62260. * Block used to remap a float from a range to a new one
  62261. */
  62262. export class RemapBlock extends NodeMaterialBlock {
  62263. /**
  62264. * Gets or sets the source range
  62265. */
  62266. sourceRange: Vector2;
  62267. /**
  62268. * Gets or sets the target range
  62269. */
  62270. targetRange: Vector2;
  62271. /**
  62272. * Creates a new RemapBlock
  62273. * @param name defines the block name
  62274. */
  62275. constructor(name: string);
  62276. /**
  62277. * Gets the current class name
  62278. * @returns the class name
  62279. */
  62280. getClassName(): string;
  62281. /**
  62282. * Gets the input component
  62283. */
  62284. get input(): NodeMaterialConnectionPoint;
  62285. /**
  62286. * Gets the source min input component
  62287. */
  62288. get sourceMin(): NodeMaterialConnectionPoint;
  62289. /**
  62290. * Gets the source max input component
  62291. */
  62292. get sourceMax(): NodeMaterialConnectionPoint;
  62293. /**
  62294. * Gets the target min input component
  62295. */
  62296. get targetMin(): NodeMaterialConnectionPoint;
  62297. /**
  62298. * Gets the target max input component
  62299. */
  62300. get targetMax(): NodeMaterialConnectionPoint;
  62301. /**
  62302. * Gets the output component
  62303. */
  62304. get output(): NodeMaterialConnectionPoint;
  62305. protected _buildBlock(state: NodeMaterialBuildState): this;
  62306. protected _dumpPropertiesCode(): string;
  62307. serialize(): any;
  62308. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62309. }
  62310. }
  62311. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  62312. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62313. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62314. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62315. /**
  62316. * Block used to normalize a vector
  62317. */
  62318. export class NormalizeBlock extends NodeMaterialBlock {
  62319. /**
  62320. * Creates a new NormalizeBlock
  62321. * @param name defines the block name
  62322. */
  62323. constructor(name: string);
  62324. /**
  62325. * Gets the current class name
  62326. * @returns the class name
  62327. */
  62328. getClassName(): string;
  62329. /**
  62330. * Gets the input component
  62331. */
  62332. get input(): NodeMaterialConnectionPoint;
  62333. /**
  62334. * Gets the output component
  62335. */
  62336. get output(): NodeMaterialConnectionPoint;
  62337. protected _buildBlock(state: NodeMaterialBuildState): this;
  62338. }
  62339. }
  62340. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  62341. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62342. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62343. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62344. import { Scene } from "babylonjs/scene";
  62345. /**
  62346. * Operations supported by the Trigonometry block
  62347. */
  62348. export enum TrigonometryBlockOperations {
  62349. /** Cos */
  62350. Cos = 0,
  62351. /** Sin */
  62352. Sin = 1,
  62353. /** Abs */
  62354. Abs = 2,
  62355. /** Exp */
  62356. Exp = 3,
  62357. /** Exp2 */
  62358. Exp2 = 4,
  62359. /** Round */
  62360. Round = 5,
  62361. /** Floor */
  62362. Floor = 6,
  62363. /** Ceiling */
  62364. Ceiling = 7,
  62365. /** Square root */
  62366. Sqrt = 8,
  62367. /** Log */
  62368. Log = 9,
  62369. /** Tangent */
  62370. Tan = 10,
  62371. /** Arc tangent */
  62372. ArcTan = 11,
  62373. /** Arc cosinus */
  62374. ArcCos = 12,
  62375. /** Arc sinus */
  62376. ArcSin = 13,
  62377. /** Fraction */
  62378. Fract = 14,
  62379. /** Sign */
  62380. Sign = 15,
  62381. /** To radians (from degrees) */
  62382. Radians = 16,
  62383. /** To degrees (from radians) */
  62384. Degrees = 17
  62385. }
  62386. /**
  62387. * Block used to apply trigonometry operation to floats
  62388. */
  62389. export class TrigonometryBlock extends NodeMaterialBlock {
  62390. /**
  62391. * Gets or sets the operation applied by the block
  62392. */
  62393. operation: TrigonometryBlockOperations;
  62394. /**
  62395. * Creates a new TrigonometryBlock
  62396. * @param name defines the block name
  62397. */
  62398. constructor(name: string);
  62399. /**
  62400. * Gets the current class name
  62401. * @returns the class name
  62402. */
  62403. getClassName(): string;
  62404. /**
  62405. * Gets the input component
  62406. */
  62407. get input(): NodeMaterialConnectionPoint;
  62408. /**
  62409. * Gets the output component
  62410. */
  62411. get output(): NodeMaterialConnectionPoint;
  62412. protected _buildBlock(state: NodeMaterialBuildState): this;
  62413. serialize(): any;
  62414. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  62415. protected _dumpPropertiesCode(): string;
  62416. }
  62417. }
  62418. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  62419. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62420. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62421. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62422. /**
  62423. * Block used to create a Color3/4 out of individual inputs (one for each component)
  62424. */
  62425. export class ColorMergerBlock extends NodeMaterialBlock {
  62426. /**
  62427. * Create a new ColorMergerBlock
  62428. * @param name defines the block name
  62429. */
  62430. constructor(name: string);
  62431. /**
  62432. * Gets the current class name
  62433. * @returns the class name
  62434. */
  62435. getClassName(): string;
  62436. /**
  62437. * Gets the rgb component (input)
  62438. */
  62439. get rgbIn(): NodeMaterialConnectionPoint;
  62440. /**
  62441. * Gets the r component (input)
  62442. */
  62443. get r(): NodeMaterialConnectionPoint;
  62444. /**
  62445. * Gets the g component (input)
  62446. */
  62447. get g(): NodeMaterialConnectionPoint;
  62448. /**
  62449. * Gets the b component (input)
  62450. */
  62451. get b(): NodeMaterialConnectionPoint;
  62452. /**
  62453. * Gets the a component (input)
  62454. */
  62455. get a(): NodeMaterialConnectionPoint;
  62456. /**
  62457. * Gets the rgba component (output)
  62458. */
  62459. get rgba(): NodeMaterialConnectionPoint;
  62460. /**
  62461. * Gets the rgb component (output)
  62462. */
  62463. get rgbOut(): NodeMaterialConnectionPoint;
  62464. /**
  62465. * Gets the rgb component (output)
  62466. * @deprecated Please use rgbOut instead.
  62467. */
  62468. get rgb(): NodeMaterialConnectionPoint;
  62469. protected _buildBlock(state: NodeMaterialBuildState): this;
  62470. }
  62471. }
  62472. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  62473. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62474. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62475. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62476. /**
  62477. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  62478. */
  62479. export class VectorMergerBlock extends NodeMaterialBlock {
  62480. /**
  62481. * Create a new VectorMergerBlock
  62482. * @param name defines the block name
  62483. */
  62484. constructor(name: string);
  62485. /**
  62486. * Gets the current class name
  62487. * @returns the class name
  62488. */
  62489. getClassName(): string;
  62490. /**
  62491. * Gets the xyz component (input)
  62492. */
  62493. get xyzIn(): NodeMaterialConnectionPoint;
  62494. /**
  62495. * Gets the xy component (input)
  62496. */
  62497. get xyIn(): NodeMaterialConnectionPoint;
  62498. /**
  62499. * Gets the x component (input)
  62500. */
  62501. get x(): NodeMaterialConnectionPoint;
  62502. /**
  62503. * Gets the y component (input)
  62504. */
  62505. get y(): NodeMaterialConnectionPoint;
  62506. /**
  62507. * Gets the z component (input)
  62508. */
  62509. get z(): NodeMaterialConnectionPoint;
  62510. /**
  62511. * Gets the w component (input)
  62512. */
  62513. get w(): NodeMaterialConnectionPoint;
  62514. /**
  62515. * Gets the xyzw component (output)
  62516. */
  62517. get xyzw(): NodeMaterialConnectionPoint;
  62518. /**
  62519. * Gets the xyz component (output)
  62520. */
  62521. get xyzOut(): NodeMaterialConnectionPoint;
  62522. /**
  62523. * Gets the xy component (output)
  62524. */
  62525. get xyOut(): NodeMaterialConnectionPoint;
  62526. /**
  62527. * Gets the xy component (output)
  62528. * @deprecated Please use xyOut instead.
  62529. */
  62530. get xy(): NodeMaterialConnectionPoint;
  62531. /**
  62532. * Gets the xyz component (output)
  62533. * @deprecated Please use xyzOut instead.
  62534. */
  62535. get xyz(): NodeMaterialConnectionPoint;
  62536. protected _buildBlock(state: NodeMaterialBuildState): this;
  62537. }
  62538. }
  62539. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  62540. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62541. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62542. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62543. /**
  62544. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  62545. */
  62546. export class ColorSplitterBlock extends NodeMaterialBlock {
  62547. /**
  62548. * Create a new ColorSplitterBlock
  62549. * @param name defines the block name
  62550. */
  62551. constructor(name: string);
  62552. /**
  62553. * Gets the current class name
  62554. * @returns the class name
  62555. */
  62556. getClassName(): string;
  62557. /**
  62558. * Gets the rgba component (input)
  62559. */
  62560. get rgba(): NodeMaterialConnectionPoint;
  62561. /**
  62562. * Gets the rgb component (input)
  62563. */
  62564. get rgbIn(): NodeMaterialConnectionPoint;
  62565. /**
  62566. * Gets the rgb component (output)
  62567. */
  62568. get rgbOut(): NodeMaterialConnectionPoint;
  62569. /**
  62570. * Gets the r component (output)
  62571. */
  62572. get r(): NodeMaterialConnectionPoint;
  62573. /**
  62574. * Gets the g component (output)
  62575. */
  62576. get g(): NodeMaterialConnectionPoint;
  62577. /**
  62578. * Gets the b component (output)
  62579. */
  62580. get b(): NodeMaterialConnectionPoint;
  62581. /**
  62582. * Gets the a component (output)
  62583. */
  62584. get a(): NodeMaterialConnectionPoint;
  62585. protected _inputRename(name: string): string;
  62586. protected _outputRename(name: string): string;
  62587. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  62588. }
  62589. }
  62590. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  62591. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62592. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62593. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62594. /**
  62595. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  62596. */
  62597. export class VectorSplitterBlock extends NodeMaterialBlock {
  62598. /**
  62599. * Create a new VectorSplitterBlock
  62600. * @param name defines the block name
  62601. */
  62602. constructor(name: string);
  62603. /**
  62604. * Gets the current class name
  62605. * @returns the class name
  62606. */
  62607. getClassName(): string;
  62608. /**
  62609. * Gets the xyzw component (input)
  62610. */
  62611. get xyzw(): NodeMaterialConnectionPoint;
  62612. /**
  62613. * Gets the xyz component (input)
  62614. */
  62615. get xyzIn(): NodeMaterialConnectionPoint;
  62616. /**
  62617. * Gets the xy component (input)
  62618. */
  62619. get xyIn(): NodeMaterialConnectionPoint;
  62620. /**
  62621. * Gets the xyz component (output)
  62622. */
  62623. get xyzOut(): NodeMaterialConnectionPoint;
  62624. /**
  62625. * Gets the xy component (output)
  62626. */
  62627. get xyOut(): NodeMaterialConnectionPoint;
  62628. /**
  62629. * Gets the x component (output)
  62630. */
  62631. get x(): NodeMaterialConnectionPoint;
  62632. /**
  62633. * Gets the y component (output)
  62634. */
  62635. get y(): NodeMaterialConnectionPoint;
  62636. /**
  62637. * Gets the z component (output)
  62638. */
  62639. get z(): NodeMaterialConnectionPoint;
  62640. /**
  62641. * Gets the w component (output)
  62642. */
  62643. get w(): NodeMaterialConnectionPoint;
  62644. protected _inputRename(name: string): string;
  62645. protected _outputRename(name: string): string;
  62646. protected _buildBlock(state: NodeMaterialBuildState): this;
  62647. }
  62648. }
  62649. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  62650. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62651. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62652. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62653. /**
  62654. * Block used to lerp between 2 values
  62655. */
  62656. export class LerpBlock extends NodeMaterialBlock {
  62657. /**
  62658. * Creates a new LerpBlock
  62659. * @param name defines the block name
  62660. */
  62661. constructor(name: string);
  62662. /**
  62663. * Gets the current class name
  62664. * @returns the class name
  62665. */
  62666. getClassName(): string;
  62667. /**
  62668. * Gets the left operand input component
  62669. */
  62670. get left(): NodeMaterialConnectionPoint;
  62671. /**
  62672. * Gets the right operand input component
  62673. */
  62674. get right(): NodeMaterialConnectionPoint;
  62675. /**
  62676. * Gets the gradient operand input component
  62677. */
  62678. get gradient(): NodeMaterialConnectionPoint;
  62679. /**
  62680. * Gets the output component
  62681. */
  62682. get output(): NodeMaterialConnectionPoint;
  62683. protected _buildBlock(state: NodeMaterialBuildState): this;
  62684. }
  62685. }
  62686. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  62687. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62688. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62689. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62690. /**
  62691. * Block used to divide 2 vectors
  62692. */
  62693. export class DivideBlock extends NodeMaterialBlock {
  62694. /**
  62695. * Creates a new DivideBlock
  62696. * @param name defines the block name
  62697. */
  62698. constructor(name: string);
  62699. /**
  62700. * Gets the current class name
  62701. * @returns the class name
  62702. */
  62703. getClassName(): string;
  62704. /**
  62705. * Gets the left operand input component
  62706. */
  62707. get left(): NodeMaterialConnectionPoint;
  62708. /**
  62709. * Gets the right operand input component
  62710. */
  62711. get right(): NodeMaterialConnectionPoint;
  62712. /**
  62713. * Gets the output component
  62714. */
  62715. get output(): NodeMaterialConnectionPoint;
  62716. protected _buildBlock(state: NodeMaterialBuildState): this;
  62717. }
  62718. }
  62719. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  62720. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62721. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62722. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62723. /**
  62724. * Block used to subtract 2 vectors
  62725. */
  62726. export class SubtractBlock extends NodeMaterialBlock {
  62727. /**
  62728. * Creates a new SubtractBlock
  62729. * @param name defines the block name
  62730. */
  62731. constructor(name: string);
  62732. /**
  62733. * Gets the current class name
  62734. * @returns the class name
  62735. */
  62736. getClassName(): string;
  62737. /**
  62738. * Gets the left operand input component
  62739. */
  62740. get left(): NodeMaterialConnectionPoint;
  62741. /**
  62742. * Gets the right operand input component
  62743. */
  62744. get right(): NodeMaterialConnectionPoint;
  62745. /**
  62746. * Gets the output component
  62747. */
  62748. get output(): NodeMaterialConnectionPoint;
  62749. protected _buildBlock(state: NodeMaterialBuildState): this;
  62750. }
  62751. }
  62752. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  62753. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62754. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62755. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62756. /**
  62757. * Block used to step a value
  62758. */
  62759. export class StepBlock extends NodeMaterialBlock {
  62760. /**
  62761. * Creates a new StepBlock
  62762. * @param name defines the block name
  62763. */
  62764. constructor(name: string);
  62765. /**
  62766. * Gets the current class name
  62767. * @returns the class name
  62768. */
  62769. getClassName(): string;
  62770. /**
  62771. * Gets the value operand input component
  62772. */
  62773. get value(): NodeMaterialConnectionPoint;
  62774. /**
  62775. * Gets the edge operand input component
  62776. */
  62777. get edge(): NodeMaterialConnectionPoint;
  62778. /**
  62779. * Gets the output component
  62780. */
  62781. get output(): NodeMaterialConnectionPoint;
  62782. protected _buildBlock(state: NodeMaterialBuildState): this;
  62783. }
  62784. }
  62785. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  62786. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62787. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62788. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62789. /**
  62790. * Block used to get the opposite (1 - x) of a value
  62791. */
  62792. export class OneMinusBlock extends NodeMaterialBlock {
  62793. /**
  62794. * Creates a new OneMinusBlock
  62795. * @param name defines the block name
  62796. */
  62797. constructor(name: string);
  62798. /**
  62799. * Gets the current class name
  62800. * @returns the class name
  62801. */
  62802. getClassName(): string;
  62803. /**
  62804. * Gets the input component
  62805. */
  62806. get input(): NodeMaterialConnectionPoint;
  62807. /**
  62808. * Gets the output component
  62809. */
  62810. get output(): NodeMaterialConnectionPoint;
  62811. protected _buildBlock(state: NodeMaterialBuildState): this;
  62812. }
  62813. }
  62814. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  62815. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62816. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62817. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62818. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62819. /**
  62820. * Block used to get the view direction
  62821. */
  62822. export class ViewDirectionBlock extends NodeMaterialBlock {
  62823. /**
  62824. * Creates a new ViewDirectionBlock
  62825. * @param name defines the block name
  62826. */
  62827. constructor(name: string);
  62828. /**
  62829. * Gets the current class name
  62830. * @returns the class name
  62831. */
  62832. getClassName(): string;
  62833. /**
  62834. * Gets the world position component
  62835. */
  62836. get worldPosition(): NodeMaterialConnectionPoint;
  62837. /**
  62838. * Gets the camera position component
  62839. */
  62840. get cameraPosition(): NodeMaterialConnectionPoint;
  62841. /**
  62842. * Gets the output component
  62843. */
  62844. get output(): NodeMaterialConnectionPoint;
  62845. autoConfigure(material: NodeMaterial): void;
  62846. protected _buildBlock(state: NodeMaterialBuildState): this;
  62847. }
  62848. }
  62849. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  62850. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62851. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62852. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62853. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  62854. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  62855. /**
  62856. * Block used to compute fresnel value
  62857. */
  62858. export class FresnelBlock extends NodeMaterialBlock {
  62859. /**
  62860. * Create a new FresnelBlock
  62861. * @param name defines the block name
  62862. */
  62863. constructor(name: string);
  62864. /**
  62865. * Gets the current class name
  62866. * @returns the class name
  62867. */
  62868. getClassName(): string;
  62869. /**
  62870. * Gets the world normal input component
  62871. */
  62872. get worldNormal(): NodeMaterialConnectionPoint;
  62873. /**
  62874. * Gets the view direction input component
  62875. */
  62876. get viewDirection(): NodeMaterialConnectionPoint;
  62877. /**
  62878. * Gets the bias input component
  62879. */
  62880. get bias(): NodeMaterialConnectionPoint;
  62881. /**
  62882. * Gets the camera (or eye) position component
  62883. */
  62884. get power(): NodeMaterialConnectionPoint;
  62885. /**
  62886. * Gets the fresnel output component
  62887. */
  62888. get fresnel(): NodeMaterialConnectionPoint;
  62889. autoConfigure(material: NodeMaterial): void;
  62890. protected _buildBlock(state: NodeMaterialBuildState): this;
  62891. }
  62892. }
  62893. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  62894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62897. /**
  62898. * Block used to get the max of 2 values
  62899. */
  62900. export class MaxBlock extends NodeMaterialBlock {
  62901. /**
  62902. * Creates a new MaxBlock
  62903. * @param name defines the block name
  62904. */
  62905. constructor(name: string);
  62906. /**
  62907. * Gets the current class name
  62908. * @returns the class name
  62909. */
  62910. getClassName(): string;
  62911. /**
  62912. * Gets the left operand input component
  62913. */
  62914. get left(): NodeMaterialConnectionPoint;
  62915. /**
  62916. * Gets the right operand input component
  62917. */
  62918. get right(): NodeMaterialConnectionPoint;
  62919. /**
  62920. * Gets the output component
  62921. */
  62922. get output(): NodeMaterialConnectionPoint;
  62923. protected _buildBlock(state: NodeMaterialBuildState): this;
  62924. }
  62925. }
  62926. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  62927. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62928. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62929. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62930. /**
  62931. * Block used to get the min of 2 values
  62932. */
  62933. export class MinBlock extends NodeMaterialBlock {
  62934. /**
  62935. * Creates a new MinBlock
  62936. * @param name defines the block name
  62937. */
  62938. constructor(name: string);
  62939. /**
  62940. * Gets the current class name
  62941. * @returns the class name
  62942. */
  62943. getClassName(): string;
  62944. /**
  62945. * Gets the left operand input component
  62946. */
  62947. get left(): NodeMaterialConnectionPoint;
  62948. /**
  62949. * Gets the right operand input component
  62950. */
  62951. get right(): NodeMaterialConnectionPoint;
  62952. /**
  62953. * Gets the output component
  62954. */
  62955. get output(): NodeMaterialConnectionPoint;
  62956. protected _buildBlock(state: NodeMaterialBuildState): this;
  62957. }
  62958. }
  62959. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  62960. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62961. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62962. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62963. /**
  62964. * Block used to get the distance between 2 values
  62965. */
  62966. export class DistanceBlock extends NodeMaterialBlock {
  62967. /**
  62968. * Creates a new DistanceBlock
  62969. * @param name defines the block name
  62970. */
  62971. constructor(name: string);
  62972. /**
  62973. * Gets the current class name
  62974. * @returns the class name
  62975. */
  62976. getClassName(): string;
  62977. /**
  62978. * Gets the left operand input component
  62979. */
  62980. get left(): NodeMaterialConnectionPoint;
  62981. /**
  62982. * Gets the right operand input component
  62983. */
  62984. get right(): NodeMaterialConnectionPoint;
  62985. /**
  62986. * Gets the output component
  62987. */
  62988. get output(): NodeMaterialConnectionPoint;
  62989. protected _buildBlock(state: NodeMaterialBuildState): this;
  62990. }
  62991. }
  62992. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  62993. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  62994. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  62995. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  62996. /**
  62997. * Block used to get the length of a vector
  62998. */
  62999. export class LengthBlock extends NodeMaterialBlock {
  63000. /**
  63001. * Creates a new LengthBlock
  63002. * @param name defines the block name
  63003. */
  63004. constructor(name: string);
  63005. /**
  63006. * Gets the current class name
  63007. * @returns the class name
  63008. */
  63009. getClassName(): string;
  63010. /**
  63011. * Gets the value input component
  63012. */
  63013. get value(): NodeMaterialConnectionPoint;
  63014. /**
  63015. * Gets the output component
  63016. */
  63017. get output(): NodeMaterialConnectionPoint;
  63018. protected _buildBlock(state: NodeMaterialBuildState): this;
  63019. }
  63020. }
  63021. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  63022. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63023. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63024. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63025. /**
  63026. * Block used to get negative version of a value (i.e. x * -1)
  63027. */
  63028. export class NegateBlock extends NodeMaterialBlock {
  63029. /**
  63030. * Creates a new NegateBlock
  63031. * @param name defines the block name
  63032. */
  63033. constructor(name: string);
  63034. /**
  63035. * Gets the current class name
  63036. * @returns the class name
  63037. */
  63038. getClassName(): string;
  63039. /**
  63040. * Gets the value input component
  63041. */
  63042. get value(): NodeMaterialConnectionPoint;
  63043. /**
  63044. * Gets the output component
  63045. */
  63046. get output(): NodeMaterialConnectionPoint;
  63047. protected _buildBlock(state: NodeMaterialBuildState): this;
  63048. }
  63049. }
  63050. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  63051. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63052. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63053. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63054. /**
  63055. * Block used to get the value of the first parameter raised to the power of the second
  63056. */
  63057. export class PowBlock extends NodeMaterialBlock {
  63058. /**
  63059. * Creates a new PowBlock
  63060. * @param name defines the block name
  63061. */
  63062. constructor(name: string);
  63063. /**
  63064. * Gets the current class name
  63065. * @returns the class name
  63066. */
  63067. getClassName(): string;
  63068. /**
  63069. * Gets the value operand input component
  63070. */
  63071. get value(): NodeMaterialConnectionPoint;
  63072. /**
  63073. * Gets the power operand input component
  63074. */
  63075. get power(): NodeMaterialConnectionPoint;
  63076. /**
  63077. * Gets the output component
  63078. */
  63079. get output(): NodeMaterialConnectionPoint;
  63080. protected _buildBlock(state: NodeMaterialBuildState): this;
  63081. }
  63082. }
  63083. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  63084. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63085. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63086. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63087. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63088. /**
  63089. * Block used to get a random number
  63090. */
  63091. export class RandomNumberBlock extends NodeMaterialBlock {
  63092. /**
  63093. * Creates a new RandomNumberBlock
  63094. * @param name defines the block name
  63095. */
  63096. constructor(name: string);
  63097. /**
  63098. * Gets the current class name
  63099. * @returns the class name
  63100. */
  63101. getClassName(): string;
  63102. /**
  63103. * Gets the seed input component
  63104. */
  63105. get seed(): NodeMaterialConnectionPoint;
  63106. /**
  63107. * Gets the output component
  63108. */
  63109. get output(): NodeMaterialConnectionPoint;
  63110. protected _buildBlock(state: NodeMaterialBuildState): this;
  63111. }
  63112. }
  63113. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  63114. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63115. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63116. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63117. /**
  63118. * Block used to compute arc tangent of 2 values
  63119. */
  63120. export class ArcTan2Block extends NodeMaterialBlock {
  63121. /**
  63122. * Creates a new ArcTan2Block
  63123. * @param name defines the block name
  63124. */
  63125. constructor(name: string);
  63126. /**
  63127. * Gets the current class name
  63128. * @returns the class name
  63129. */
  63130. getClassName(): string;
  63131. /**
  63132. * Gets the x operand input component
  63133. */
  63134. get x(): NodeMaterialConnectionPoint;
  63135. /**
  63136. * Gets the y operand input component
  63137. */
  63138. get y(): NodeMaterialConnectionPoint;
  63139. /**
  63140. * Gets the output component
  63141. */
  63142. get output(): NodeMaterialConnectionPoint;
  63143. protected _buildBlock(state: NodeMaterialBuildState): this;
  63144. }
  63145. }
  63146. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  63147. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63148. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63149. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63150. /**
  63151. * Block used to smooth step a value
  63152. */
  63153. export class SmoothStepBlock extends NodeMaterialBlock {
  63154. /**
  63155. * Creates a new SmoothStepBlock
  63156. * @param name defines the block name
  63157. */
  63158. constructor(name: string);
  63159. /**
  63160. * Gets the current class name
  63161. * @returns the class name
  63162. */
  63163. getClassName(): string;
  63164. /**
  63165. * Gets the value operand input component
  63166. */
  63167. get value(): NodeMaterialConnectionPoint;
  63168. /**
  63169. * Gets the first edge operand input component
  63170. */
  63171. get edge0(): NodeMaterialConnectionPoint;
  63172. /**
  63173. * Gets the second edge operand input component
  63174. */
  63175. get edge1(): NodeMaterialConnectionPoint;
  63176. /**
  63177. * Gets the output component
  63178. */
  63179. get output(): NodeMaterialConnectionPoint;
  63180. protected _buildBlock(state: NodeMaterialBuildState): this;
  63181. }
  63182. }
  63183. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  63184. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63185. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63186. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63187. /**
  63188. * Block used to get the reciprocal (1 / x) of a value
  63189. */
  63190. export class ReciprocalBlock extends NodeMaterialBlock {
  63191. /**
  63192. * Creates a new ReciprocalBlock
  63193. * @param name defines the block name
  63194. */
  63195. constructor(name: string);
  63196. /**
  63197. * Gets the current class name
  63198. * @returns the class name
  63199. */
  63200. getClassName(): string;
  63201. /**
  63202. * Gets the input component
  63203. */
  63204. get input(): NodeMaterialConnectionPoint;
  63205. /**
  63206. * Gets the output component
  63207. */
  63208. get output(): NodeMaterialConnectionPoint;
  63209. protected _buildBlock(state: NodeMaterialBuildState): this;
  63210. }
  63211. }
  63212. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  63213. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63214. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63215. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63216. /**
  63217. * Block used to replace a color by another one
  63218. */
  63219. export class ReplaceColorBlock extends NodeMaterialBlock {
  63220. /**
  63221. * Creates a new ReplaceColorBlock
  63222. * @param name defines the block name
  63223. */
  63224. constructor(name: string);
  63225. /**
  63226. * Gets the current class name
  63227. * @returns the class name
  63228. */
  63229. getClassName(): string;
  63230. /**
  63231. * Gets the value input component
  63232. */
  63233. get value(): NodeMaterialConnectionPoint;
  63234. /**
  63235. * Gets the reference input component
  63236. */
  63237. get reference(): NodeMaterialConnectionPoint;
  63238. /**
  63239. * Gets the distance input component
  63240. */
  63241. get distance(): NodeMaterialConnectionPoint;
  63242. /**
  63243. * Gets the replacement input component
  63244. */
  63245. get replacement(): NodeMaterialConnectionPoint;
  63246. /**
  63247. * Gets the output component
  63248. */
  63249. get output(): NodeMaterialConnectionPoint;
  63250. protected _buildBlock(state: NodeMaterialBuildState): this;
  63251. }
  63252. }
  63253. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  63254. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63255. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63256. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63257. /**
  63258. * Block used to posterize a value
  63259. * @see https://en.wikipedia.org/wiki/Posterization
  63260. */
  63261. export class PosterizeBlock extends NodeMaterialBlock {
  63262. /**
  63263. * Creates a new PosterizeBlock
  63264. * @param name defines the block name
  63265. */
  63266. constructor(name: string);
  63267. /**
  63268. * Gets the current class name
  63269. * @returns the class name
  63270. */
  63271. getClassName(): string;
  63272. /**
  63273. * Gets the value input component
  63274. */
  63275. get value(): NodeMaterialConnectionPoint;
  63276. /**
  63277. * Gets the steps input component
  63278. */
  63279. get steps(): NodeMaterialConnectionPoint;
  63280. /**
  63281. * Gets the output component
  63282. */
  63283. get output(): NodeMaterialConnectionPoint;
  63284. protected _buildBlock(state: NodeMaterialBuildState): this;
  63285. }
  63286. }
  63287. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  63288. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63289. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63290. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63291. import { Scene } from "babylonjs/scene";
  63292. /**
  63293. * Operations supported by the Wave block
  63294. */
  63295. export enum WaveBlockKind {
  63296. /** SawTooth */
  63297. SawTooth = 0,
  63298. /** Square */
  63299. Square = 1,
  63300. /** Triangle */
  63301. Triangle = 2
  63302. }
  63303. /**
  63304. * Block used to apply wave operation to floats
  63305. */
  63306. export class WaveBlock extends NodeMaterialBlock {
  63307. /**
  63308. * Gets or sets the kibnd of wave to be applied by the block
  63309. */
  63310. kind: WaveBlockKind;
  63311. /**
  63312. * Creates a new WaveBlock
  63313. * @param name defines the block name
  63314. */
  63315. constructor(name: string);
  63316. /**
  63317. * Gets the current class name
  63318. * @returns the class name
  63319. */
  63320. getClassName(): string;
  63321. /**
  63322. * Gets the input component
  63323. */
  63324. get input(): NodeMaterialConnectionPoint;
  63325. /**
  63326. * Gets the output component
  63327. */
  63328. get output(): NodeMaterialConnectionPoint;
  63329. protected _buildBlock(state: NodeMaterialBuildState): this;
  63330. serialize(): any;
  63331. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63332. }
  63333. }
  63334. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  63335. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63336. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63337. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63338. import { Color3 } from "babylonjs/Maths/math.color";
  63339. import { Scene } from "babylonjs/scene";
  63340. /**
  63341. * Class used to store a color step for the GradientBlock
  63342. */
  63343. export class GradientBlockColorStep {
  63344. /**
  63345. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63346. */
  63347. step: number;
  63348. /**
  63349. * Gets or sets the color associated with this step
  63350. */
  63351. color: Color3;
  63352. /**
  63353. * Creates a new GradientBlockColorStep
  63354. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  63355. * @param color defines the color associated with this step
  63356. */
  63357. constructor(
  63358. /**
  63359. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  63360. */
  63361. step: number,
  63362. /**
  63363. * Gets or sets the color associated with this step
  63364. */
  63365. color: Color3);
  63366. }
  63367. /**
  63368. * Block used to return a color from a gradient based on an input value between 0 and 1
  63369. */
  63370. export class GradientBlock extends NodeMaterialBlock {
  63371. /**
  63372. * Gets or sets the list of color steps
  63373. */
  63374. colorSteps: GradientBlockColorStep[];
  63375. /**
  63376. * Creates a new GradientBlock
  63377. * @param name defines the block name
  63378. */
  63379. constructor(name: string);
  63380. /**
  63381. * Gets the current class name
  63382. * @returns the class name
  63383. */
  63384. getClassName(): string;
  63385. /**
  63386. * Gets the gradient input component
  63387. */
  63388. get gradient(): NodeMaterialConnectionPoint;
  63389. /**
  63390. * Gets the output component
  63391. */
  63392. get output(): NodeMaterialConnectionPoint;
  63393. private _writeColorConstant;
  63394. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63395. serialize(): any;
  63396. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63397. protected _dumpPropertiesCode(): string;
  63398. }
  63399. }
  63400. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  63401. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63402. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63403. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63404. /**
  63405. * Block used to normalize lerp between 2 values
  63406. */
  63407. export class NLerpBlock extends NodeMaterialBlock {
  63408. /**
  63409. * Creates a new NLerpBlock
  63410. * @param name defines the block name
  63411. */
  63412. constructor(name: string);
  63413. /**
  63414. * Gets the current class name
  63415. * @returns the class name
  63416. */
  63417. getClassName(): string;
  63418. /**
  63419. * Gets the left operand input component
  63420. */
  63421. get left(): NodeMaterialConnectionPoint;
  63422. /**
  63423. * Gets the right operand input component
  63424. */
  63425. get right(): NodeMaterialConnectionPoint;
  63426. /**
  63427. * Gets the gradient operand input component
  63428. */
  63429. get gradient(): NodeMaterialConnectionPoint;
  63430. /**
  63431. * Gets the output component
  63432. */
  63433. get output(): NodeMaterialConnectionPoint;
  63434. protected _buildBlock(state: NodeMaterialBuildState): this;
  63435. }
  63436. }
  63437. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  63438. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63439. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63440. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63441. import { Scene } from "babylonjs/scene";
  63442. /**
  63443. * block used to Generate a Worley Noise 3D Noise Pattern
  63444. */
  63445. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  63446. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  63447. manhattanDistance: boolean;
  63448. /**
  63449. * Creates a new WorleyNoise3DBlock
  63450. * @param name defines the block name
  63451. */
  63452. constructor(name: string);
  63453. /**
  63454. * Gets the current class name
  63455. * @returns the class name
  63456. */
  63457. getClassName(): string;
  63458. /**
  63459. * Gets the seed input component
  63460. */
  63461. get seed(): NodeMaterialConnectionPoint;
  63462. /**
  63463. * Gets the jitter input component
  63464. */
  63465. get jitter(): NodeMaterialConnectionPoint;
  63466. /**
  63467. * Gets the output component
  63468. */
  63469. get output(): NodeMaterialConnectionPoint;
  63470. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63471. /**
  63472. * Exposes the properties to the UI?
  63473. */
  63474. protected _dumpPropertiesCode(): string;
  63475. /**
  63476. * Exposes the properties to the Seralize?
  63477. */
  63478. serialize(): any;
  63479. /**
  63480. * Exposes the properties to the deseralize?
  63481. */
  63482. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  63483. }
  63484. }
  63485. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  63486. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63487. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63488. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63489. /**
  63490. * block used to Generate a Simplex Perlin 3d Noise Pattern
  63491. */
  63492. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  63493. /**
  63494. * Creates a new SimplexPerlin3DBlock
  63495. * @param name defines the block name
  63496. */
  63497. constructor(name: string);
  63498. /**
  63499. * Gets the current class name
  63500. * @returns the class name
  63501. */
  63502. getClassName(): string;
  63503. /**
  63504. * Gets the seed operand input component
  63505. */
  63506. get seed(): NodeMaterialConnectionPoint;
  63507. /**
  63508. * Gets the output component
  63509. */
  63510. get output(): NodeMaterialConnectionPoint;
  63511. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  63512. }
  63513. }
  63514. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  63515. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63516. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63517. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63518. /**
  63519. * Block used to blend normals
  63520. */
  63521. export class NormalBlendBlock extends NodeMaterialBlock {
  63522. /**
  63523. * Creates a new NormalBlendBlock
  63524. * @param name defines the block name
  63525. */
  63526. constructor(name: string);
  63527. /**
  63528. * Gets the current class name
  63529. * @returns the class name
  63530. */
  63531. getClassName(): string;
  63532. /**
  63533. * Gets the first input component
  63534. */
  63535. get normalMap0(): NodeMaterialConnectionPoint;
  63536. /**
  63537. * Gets the second input component
  63538. */
  63539. get normalMap1(): NodeMaterialConnectionPoint;
  63540. /**
  63541. * Gets the output component
  63542. */
  63543. get output(): NodeMaterialConnectionPoint;
  63544. protected _buildBlock(state: NodeMaterialBuildState): this;
  63545. }
  63546. }
  63547. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  63548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63550. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63551. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  63552. /**
  63553. * Block used to rotate a 2d vector by a given angle
  63554. */
  63555. export class Rotate2dBlock extends NodeMaterialBlock {
  63556. /**
  63557. * Creates a new Rotate2dBlock
  63558. * @param name defines the block name
  63559. */
  63560. constructor(name: string);
  63561. /**
  63562. * Gets the current class name
  63563. * @returns the class name
  63564. */
  63565. getClassName(): string;
  63566. /**
  63567. * Gets the input vector
  63568. */
  63569. get input(): NodeMaterialConnectionPoint;
  63570. /**
  63571. * Gets the input angle
  63572. */
  63573. get angle(): NodeMaterialConnectionPoint;
  63574. /**
  63575. * Gets the output component
  63576. */
  63577. get output(): NodeMaterialConnectionPoint;
  63578. autoConfigure(material: NodeMaterial): void;
  63579. protected _buildBlock(state: NodeMaterialBuildState): this;
  63580. }
  63581. }
  63582. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  63583. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63584. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63585. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63586. /**
  63587. * Block used to get the reflected vector from a direction and a normal
  63588. */
  63589. export class ReflectBlock extends NodeMaterialBlock {
  63590. /**
  63591. * Creates a new ReflectBlock
  63592. * @param name defines the block name
  63593. */
  63594. constructor(name: string);
  63595. /**
  63596. * Gets the current class name
  63597. * @returns the class name
  63598. */
  63599. getClassName(): string;
  63600. /**
  63601. * Gets the incident component
  63602. */
  63603. get incident(): NodeMaterialConnectionPoint;
  63604. /**
  63605. * Gets the normal component
  63606. */
  63607. get normal(): NodeMaterialConnectionPoint;
  63608. /**
  63609. * Gets the output component
  63610. */
  63611. get output(): NodeMaterialConnectionPoint;
  63612. protected _buildBlock(state: NodeMaterialBuildState): this;
  63613. }
  63614. }
  63615. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  63616. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63617. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63618. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63619. /**
  63620. * Block used to get the refracted vector from a direction and a normal
  63621. */
  63622. export class RefractBlock extends NodeMaterialBlock {
  63623. /**
  63624. * Creates a new RefractBlock
  63625. * @param name defines the block name
  63626. */
  63627. constructor(name: string);
  63628. /**
  63629. * Gets the current class name
  63630. * @returns the class name
  63631. */
  63632. getClassName(): string;
  63633. /**
  63634. * Gets the incident component
  63635. */
  63636. get incident(): NodeMaterialConnectionPoint;
  63637. /**
  63638. * Gets the normal component
  63639. */
  63640. get normal(): NodeMaterialConnectionPoint;
  63641. /**
  63642. * Gets the index of refraction component
  63643. */
  63644. get ior(): NodeMaterialConnectionPoint;
  63645. /**
  63646. * Gets the output component
  63647. */
  63648. get output(): NodeMaterialConnectionPoint;
  63649. protected _buildBlock(state: NodeMaterialBuildState): this;
  63650. }
  63651. }
  63652. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  63653. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  63654. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  63655. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63656. /**
  63657. * Block used to desaturate a color
  63658. */
  63659. export class DesaturateBlock extends NodeMaterialBlock {
  63660. /**
  63661. * Creates a new DesaturateBlock
  63662. * @param name defines the block name
  63663. */
  63664. constructor(name: string);
  63665. /**
  63666. * Gets the current class name
  63667. * @returns the class name
  63668. */
  63669. getClassName(): string;
  63670. /**
  63671. * Gets the color operand input component
  63672. */
  63673. get color(): NodeMaterialConnectionPoint;
  63674. /**
  63675. * Gets the level operand input component
  63676. */
  63677. get level(): NodeMaterialConnectionPoint;
  63678. /**
  63679. * Gets the output component
  63680. */
  63681. get output(): NodeMaterialConnectionPoint;
  63682. protected _buildBlock(state: NodeMaterialBuildState): this;
  63683. }
  63684. }
  63685. declare module "babylonjs/Materials/Node/Blocks/index" {
  63686. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  63687. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  63688. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  63689. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  63690. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  63691. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  63692. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  63693. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  63694. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  63695. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  63696. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  63697. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  63698. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  63699. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  63700. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  63701. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  63702. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  63703. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  63704. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  63705. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  63706. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  63707. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  63708. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  63709. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  63710. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  63711. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  63712. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  63713. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  63714. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  63715. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  63716. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  63717. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  63718. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  63719. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  63720. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  63721. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  63722. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  63723. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  63724. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  63725. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  63726. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  63727. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  63728. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  63729. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  63730. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  63731. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  63732. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  63733. }
  63734. declare module "babylonjs/Materials/Node/Optimizers/index" {
  63735. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  63736. }
  63737. declare module "babylonjs/Materials/Node/index" {
  63738. export * from "babylonjs/Materials/Node/Enums/index";
  63739. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  63740. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  63741. export * from "babylonjs/Materials/Node/nodeMaterial";
  63742. export * from "babylonjs/Materials/Node/Blocks/index";
  63743. export * from "babylonjs/Materials/Node/Optimizers/index";
  63744. }
  63745. declare module "babylonjs/Materials/effectRenderer" {
  63746. import { Nullable } from "babylonjs/types";
  63747. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63748. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63749. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63750. import { Viewport } from "babylonjs/Maths/math.viewport";
  63751. import { Observable } from "babylonjs/Misc/observable";
  63752. import { Effect } from "babylonjs/Materials/effect";
  63753. import "babylonjs/Shaders/postprocess.vertex";
  63754. /**
  63755. * Effect Render Options
  63756. */
  63757. export interface IEffectRendererOptions {
  63758. /**
  63759. * Defines the vertices positions.
  63760. */
  63761. positions?: number[];
  63762. /**
  63763. * Defines the indices.
  63764. */
  63765. indices?: number[];
  63766. }
  63767. /**
  63768. * Helper class to render one or more effects.
  63769. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63770. */
  63771. export class EffectRenderer {
  63772. private engine;
  63773. private static _DefaultOptions;
  63774. private _vertexBuffers;
  63775. private _indexBuffer;
  63776. private _fullscreenViewport;
  63777. /**
  63778. * Creates an effect renderer
  63779. * @param engine the engine to use for rendering
  63780. * @param options defines the options of the effect renderer
  63781. */
  63782. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63783. /**
  63784. * Sets the current viewport in normalized coordinates 0-1
  63785. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63786. */
  63787. setViewport(viewport?: Viewport): void;
  63788. /**
  63789. * Binds the embedded attributes buffer to the effect.
  63790. * @param effect Defines the effect to bind the attributes for
  63791. */
  63792. bindBuffers(effect: Effect): void;
  63793. /**
  63794. * Sets the current effect wrapper to use during draw.
  63795. * The effect needs to be ready before calling this api.
  63796. * This also sets the default full screen position attribute.
  63797. * @param effectWrapper Defines the effect to draw with
  63798. */
  63799. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63800. /**
  63801. * Draws a full screen quad.
  63802. */
  63803. draw(): void;
  63804. private isRenderTargetTexture;
  63805. /**
  63806. * renders one or more effects to a specified texture
  63807. * @param effectWrapper the effect to renderer
  63808. * @param outputTexture texture to draw to, if null it will render to the screen.
  63809. */
  63810. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63811. /**
  63812. * Disposes of the effect renderer
  63813. */
  63814. dispose(): void;
  63815. }
  63816. /**
  63817. * Options to create an EffectWrapper
  63818. */
  63819. interface EffectWrapperCreationOptions {
  63820. /**
  63821. * Engine to use to create the effect
  63822. */
  63823. engine: ThinEngine;
  63824. /**
  63825. * Fragment shader for the effect
  63826. */
  63827. fragmentShader: string;
  63828. /**
  63829. * Vertex shader for the effect
  63830. */
  63831. vertexShader?: string;
  63832. /**
  63833. * Attributes to use in the shader
  63834. */
  63835. attributeNames?: Array<string>;
  63836. /**
  63837. * Uniforms to use in the shader
  63838. */
  63839. uniformNames?: Array<string>;
  63840. /**
  63841. * Texture sampler names to use in the shader
  63842. */
  63843. samplerNames?: Array<string>;
  63844. /**
  63845. * The friendly name of the effect displayed in Spector.
  63846. */
  63847. name?: string;
  63848. }
  63849. /**
  63850. * Wraps an effect to be used for rendering
  63851. */
  63852. export class EffectWrapper {
  63853. /**
  63854. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63855. */
  63856. onApplyObservable: Observable<{}>;
  63857. /**
  63858. * The underlying effect
  63859. */
  63860. effect: Effect;
  63861. /**
  63862. * Creates an effect to be renderer
  63863. * @param creationOptions options to create the effect
  63864. */
  63865. constructor(creationOptions: EffectWrapperCreationOptions);
  63866. /**
  63867. * Disposes of the effect wrapper
  63868. */
  63869. dispose(): void;
  63870. }
  63871. }
  63872. declare module "babylonjs/Materials/index" {
  63873. export * from "babylonjs/Materials/Background/index";
  63874. export * from "babylonjs/Materials/colorCurves";
  63875. export * from "babylonjs/Materials/iEffectFallbacks";
  63876. export * from "babylonjs/Materials/effectFallbacks";
  63877. export * from "babylonjs/Materials/effect";
  63878. export * from "babylonjs/Materials/fresnelParameters";
  63879. export * from "babylonjs/Materials/imageProcessingConfiguration";
  63880. export * from "babylonjs/Materials/material";
  63881. export * from "babylonjs/Materials/materialDefines";
  63882. export * from "babylonjs/Materials/materialHelper";
  63883. export * from "babylonjs/Materials/multiMaterial";
  63884. export * from "babylonjs/Materials/PBR/index";
  63885. export * from "babylonjs/Materials/pushMaterial";
  63886. export * from "babylonjs/Materials/shaderMaterial";
  63887. export * from "babylonjs/Materials/standardMaterial";
  63888. export * from "babylonjs/Materials/Textures/index";
  63889. export * from "babylonjs/Materials/uniformBuffer";
  63890. export * from "babylonjs/Materials/materialFlags";
  63891. export * from "babylonjs/Materials/Node/index";
  63892. export * from "babylonjs/Materials/effectRenderer";
  63893. }
  63894. declare module "babylonjs/Maths/index" {
  63895. export * from "babylonjs/Maths/math.scalar";
  63896. export * from "babylonjs/Maths/math";
  63897. export * from "babylonjs/Maths/sphericalPolynomial";
  63898. }
  63899. declare module "babylonjs/Misc/workerPool" {
  63900. import { IDisposable } from "babylonjs/scene";
  63901. /**
  63902. * Helper class to push actions to a pool of workers.
  63903. */
  63904. export class WorkerPool implements IDisposable {
  63905. private _workerInfos;
  63906. private _pendingActions;
  63907. /**
  63908. * Constructor
  63909. * @param workers Array of workers to use for actions
  63910. */
  63911. constructor(workers: Array<Worker>);
  63912. /**
  63913. * Terminates all workers and clears any pending actions.
  63914. */
  63915. dispose(): void;
  63916. /**
  63917. * Pushes an action to the worker pool. If all the workers are active, the action will be
  63918. * pended until a worker has completed its action.
  63919. * @param action The action to perform. Call onComplete when the action is complete.
  63920. */
  63921. push(action: (worker: Worker, onComplete: () => void) => void): void;
  63922. private _execute;
  63923. }
  63924. }
  63925. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  63926. import { IDisposable } from "babylonjs/scene";
  63927. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  63928. /**
  63929. * Configuration for Draco compression
  63930. */
  63931. export interface IDracoCompressionConfiguration {
  63932. /**
  63933. * Configuration for the decoder.
  63934. */
  63935. decoder: {
  63936. /**
  63937. * The url to the WebAssembly module.
  63938. */
  63939. wasmUrl?: string;
  63940. /**
  63941. * The url to the WebAssembly binary.
  63942. */
  63943. wasmBinaryUrl?: string;
  63944. /**
  63945. * The url to the fallback JavaScript module.
  63946. */
  63947. fallbackUrl?: string;
  63948. };
  63949. }
  63950. /**
  63951. * Draco compression (https://google.github.io/draco/)
  63952. *
  63953. * This class wraps the Draco module.
  63954. *
  63955. * **Encoder**
  63956. *
  63957. * The encoder is not currently implemented.
  63958. *
  63959. * **Decoder**
  63960. *
  63961. * 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.
  63962. *
  63963. * To update the configuration, use the following code:
  63964. * ```javascript
  63965. * DracoCompression.Configuration = {
  63966. * decoder: {
  63967. * wasmUrl: "<url to the WebAssembly library>",
  63968. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  63969. * fallbackUrl: "<url to the fallback JavaScript library>",
  63970. * }
  63971. * };
  63972. * ```
  63973. *
  63974. * 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.
  63975. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  63976. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  63977. *
  63978. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  63979. * ```javascript
  63980. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  63981. * ```
  63982. *
  63983. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  63984. */
  63985. export class DracoCompression implements IDisposable {
  63986. private _workerPoolPromise?;
  63987. private _decoderModulePromise?;
  63988. /**
  63989. * The configuration. Defaults to the following urls:
  63990. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  63991. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  63992. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  63993. */
  63994. static Configuration: IDracoCompressionConfiguration;
  63995. /**
  63996. * Returns true if the decoder configuration is available.
  63997. */
  63998. static get DecoderAvailable(): boolean;
  63999. /**
  64000. * Default number of workers to create when creating the draco compression object.
  64001. */
  64002. static DefaultNumWorkers: number;
  64003. private static GetDefaultNumWorkers;
  64004. private static _Default;
  64005. /**
  64006. * Default instance for the draco compression object.
  64007. */
  64008. static get Default(): DracoCompression;
  64009. /**
  64010. * Constructor
  64011. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  64012. */
  64013. constructor(numWorkers?: number);
  64014. /**
  64015. * Stop all async operations and release resources.
  64016. */
  64017. dispose(): void;
  64018. /**
  64019. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  64020. * @returns a promise that resolves when ready
  64021. */
  64022. whenReadyAsync(): Promise<void>;
  64023. /**
  64024. * Decode Draco compressed mesh data to vertex data.
  64025. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  64026. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  64027. * @returns A promise that resolves with the decoded vertex data
  64028. */
  64029. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  64030. [kind: string]: number;
  64031. }): Promise<VertexData>;
  64032. }
  64033. }
  64034. declare module "babylonjs/Meshes/Compression/index" {
  64035. export * from "babylonjs/Meshes/Compression/dracoCompression";
  64036. }
  64037. declare module "babylonjs/Meshes/csg" {
  64038. import { Nullable } from "babylonjs/types";
  64039. import { Scene } from "babylonjs/scene";
  64040. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  64041. import { Mesh } from "babylonjs/Meshes/mesh";
  64042. import { Material } from "babylonjs/Materials/material";
  64043. /**
  64044. * Class for building Constructive Solid Geometry
  64045. */
  64046. export class CSG {
  64047. private polygons;
  64048. /**
  64049. * The world matrix
  64050. */
  64051. matrix: Matrix;
  64052. /**
  64053. * Stores the position
  64054. */
  64055. position: Vector3;
  64056. /**
  64057. * Stores the rotation
  64058. */
  64059. rotation: Vector3;
  64060. /**
  64061. * Stores the rotation quaternion
  64062. */
  64063. rotationQuaternion: Nullable<Quaternion>;
  64064. /**
  64065. * Stores the scaling vector
  64066. */
  64067. scaling: Vector3;
  64068. /**
  64069. * Convert the Mesh to CSG
  64070. * @param mesh The Mesh to convert to CSG
  64071. * @returns A new CSG from the Mesh
  64072. */
  64073. static FromMesh(mesh: Mesh): CSG;
  64074. /**
  64075. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  64076. * @param polygons Polygons used to construct a CSG solid
  64077. */
  64078. private static FromPolygons;
  64079. /**
  64080. * Clones, or makes a deep copy, of the CSG
  64081. * @returns A new CSG
  64082. */
  64083. clone(): CSG;
  64084. /**
  64085. * Unions this CSG with another CSG
  64086. * @param csg The CSG to union against this CSG
  64087. * @returns The unioned CSG
  64088. */
  64089. union(csg: CSG): CSG;
  64090. /**
  64091. * Unions this CSG with another CSG in place
  64092. * @param csg The CSG to union against this CSG
  64093. */
  64094. unionInPlace(csg: CSG): void;
  64095. /**
  64096. * Subtracts this CSG with another CSG
  64097. * @param csg The CSG to subtract against this CSG
  64098. * @returns A new CSG
  64099. */
  64100. subtract(csg: CSG): CSG;
  64101. /**
  64102. * Subtracts this CSG with another CSG in place
  64103. * @param csg The CSG to subtact against this CSG
  64104. */
  64105. subtractInPlace(csg: CSG): void;
  64106. /**
  64107. * Intersect this CSG with another CSG
  64108. * @param csg The CSG to intersect against this CSG
  64109. * @returns A new CSG
  64110. */
  64111. intersect(csg: CSG): CSG;
  64112. /**
  64113. * Intersects this CSG with another CSG in place
  64114. * @param csg The CSG to intersect against this CSG
  64115. */
  64116. intersectInPlace(csg: CSG): void;
  64117. /**
  64118. * Return a new CSG solid with solid and empty space switched. This solid is
  64119. * not modified.
  64120. * @returns A new CSG solid with solid and empty space switched
  64121. */
  64122. inverse(): CSG;
  64123. /**
  64124. * Inverses the CSG in place
  64125. */
  64126. inverseInPlace(): void;
  64127. /**
  64128. * This is used to keep meshes transformations so they can be restored
  64129. * when we build back a Babylon Mesh
  64130. * NB : All CSG operations are performed in world coordinates
  64131. * @param csg The CSG to copy the transform attributes from
  64132. * @returns This CSG
  64133. */
  64134. copyTransformAttributes(csg: CSG): CSG;
  64135. /**
  64136. * Build Raw mesh from CSG
  64137. * Coordinates here are in world space
  64138. * @param name The name of the mesh geometry
  64139. * @param scene The Scene
  64140. * @param keepSubMeshes Specifies if the submeshes should be kept
  64141. * @returns A new Mesh
  64142. */
  64143. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64144. /**
  64145. * Build Mesh from CSG taking material and transforms into account
  64146. * @param name The name of the Mesh
  64147. * @param material The material of the Mesh
  64148. * @param scene The Scene
  64149. * @param keepSubMeshes Specifies if submeshes should be kept
  64150. * @returns The new Mesh
  64151. */
  64152. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  64153. }
  64154. }
  64155. declare module "babylonjs/Meshes/trailMesh" {
  64156. import { Mesh } from "babylonjs/Meshes/mesh";
  64157. import { Scene } from "babylonjs/scene";
  64158. import { TransformNode } from "babylonjs/Meshes/transformNode";
  64159. /**
  64160. * Class used to create a trail following a mesh
  64161. */
  64162. export class TrailMesh extends Mesh {
  64163. private _generator;
  64164. private _autoStart;
  64165. private _running;
  64166. private _diameter;
  64167. private _length;
  64168. private _sectionPolygonPointsCount;
  64169. private _sectionVectors;
  64170. private _sectionNormalVectors;
  64171. private _beforeRenderObserver;
  64172. /**
  64173. * @constructor
  64174. * @param name The value used by scene.getMeshByName() to do a lookup.
  64175. * @param generator The mesh or transform node to generate a trail.
  64176. * @param scene The scene to add this mesh to.
  64177. * @param diameter Diameter of trailing mesh. Default is 1.
  64178. * @param length Length of trailing mesh. Default is 60.
  64179. * @param autoStart Automatically start trailing mesh. Default true.
  64180. */
  64181. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  64182. /**
  64183. * "TrailMesh"
  64184. * @returns "TrailMesh"
  64185. */
  64186. getClassName(): string;
  64187. private _createMesh;
  64188. /**
  64189. * Start trailing mesh.
  64190. */
  64191. start(): void;
  64192. /**
  64193. * Stop trailing mesh.
  64194. */
  64195. stop(): void;
  64196. /**
  64197. * Update trailing mesh geometry.
  64198. */
  64199. update(): void;
  64200. /**
  64201. * Returns a new TrailMesh object.
  64202. * @param name is a string, the name given to the new mesh
  64203. * @param newGenerator use new generator object for cloned trail mesh
  64204. * @returns a new mesh
  64205. */
  64206. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  64207. /**
  64208. * Serializes this trail mesh
  64209. * @param serializationObject object to write serialization to
  64210. */
  64211. serialize(serializationObject: any): void;
  64212. /**
  64213. * Parses a serialized trail mesh
  64214. * @param parsedMesh the serialized mesh
  64215. * @param scene the scene to create the trail mesh in
  64216. * @returns the created trail mesh
  64217. */
  64218. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  64219. }
  64220. }
  64221. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  64222. import { Nullable } from "babylonjs/types";
  64223. import { Scene } from "babylonjs/scene";
  64224. import { Vector4 } from "babylonjs/Maths/math.vector";
  64225. import { Color4 } from "babylonjs/Maths/math.color";
  64226. import { Mesh } from "babylonjs/Meshes/mesh";
  64227. /**
  64228. * Class containing static functions to help procedurally build meshes
  64229. */
  64230. export class TiledBoxBuilder {
  64231. /**
  64232. * Creates a box mesh
  64233. * 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)
  64234. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64235. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64236. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64237. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64238. * @param name defines the name of the mesh
  64239. * @param options defines the options used to create the mesh
  64240. * @param scene defines the hosting scene
  64241. * @returns the box mesh
  64242. */
  64243. static CreateTiledBox(name: string, options: {
  64244. pattern?: number;
  64245. width?: number;
  64246. height?: number;
  64247. depth?: number;
  64248. tileSize?: number;
  64249. tileWidth?: number;
  64250. tileHeight?: number;
  64251. alignHorizontal?: number;
  64252. alignVertical?: number;
  64253. faceUV?: Vector4[];
  64254. faceColors?: Color4[];
  64255. sideOrientation?: number;
  64256. updatable?: boolean;
  64257. }, scene?: Nullable<Scene>): Mesh;
  64258. }
  64259. }
  64260. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  64261. import { Vector4 } from "babylonjs/Maths/math.vector";
  64262. import { Mesh } from "babylonjs/Meshes/mesh";
  64263. /**
  64264. * Class containing static functions to help procedurally build meshes
  64265. */
  64266. export class TorusKnotBuilder {
  64267. /**
  64268. * Creates a torus knot mesh
  64269. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64270. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64271. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64272. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64273. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64275. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64276. * @param name defines the name of the mesh
  64277. * @param options defines the options used to create the mesh
  64278. * @param scene defines the hosting scene
  64279. * @returns the torus knot mesh
  64280. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64281. */
  64282. static CreateTorusKnot(name: string, options: {
  64283. radius?: number;
  64284. tube?: number;
  64285. radialSegments?: number;
  64286. tubularSegments?: number;
  64287. p?: number;
  64288. q?: number;
  64289. updatable?: boolean;
  64290. sideOrientation?: number;
  64291. frontUVs?: Vector4;
  64292. backUVs?: Vector4;
  64293. }, scene: any): Mesh;
  64294. }
  64295. }
  64296. declare module "babylonjs/Meshes/polygonMesh" {
  64297. import { Scene } from "babylonjs/scene";
  64298. import { Vector2 } from "babylonjs/Maths/math.vector";
  64299. import { Mesh } from "babylonjs/Meshes/mesh";
  64300. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  64301. import { Path2 } from "babylonjs/Maths/math.path";
  64302. /**
  64303. * Polygon
  64304. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  64305. */
  64306. export class Polygon {
  64307. /**
  64308. * Creates a rectangle
  64309. * @param xmin bottom X coord
  64310. * @param ymin bottom Y coord
  64311. * @param xmax top X coord
  64312. * @param ymax top Y coord
  64313. * @returns points that make the resulting rectation
  64314. */
  64315. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  64316. /**
  64317. * Creates a circle
  64318. * @param radius radius of circle
  64319. * @param cx scale in x
  64320. * @param cy scale in y
  64321. * @param numberOfSides number of sides that make up the circle
  64322. * @returns points that make the resulting circle
  64323. */
  64324. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  64325. /**
  64326. * Creates a polygon from input string
  64327. * @param input Input polygon data
  64328. * @returns the parsed points
  64329. */
  64330. static Parse(input: string): Vector2[];
  64331. /**
  64332. * Starts building a polygon from x and y coordinates
  64333. * @param x x coordinate
  64334. * @param y y coordinate
  64335. * @returns the started path2
  64336. */
  64337. static StartingAt(x: number, y: number): Path2;
  64338. }
  64339. /**
  64340. * Builds a polygon
  64341. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  64342. */
  64343. export class PolygonMeshBuilder {
  64344. private _points;
  64345. private _outlinepoints;
  64346. private _holes;
  64347. private _name;
  64348. private _scene;
  64349. private _epoints;
  64350. private _eholes;
  64351. private _addToepoint;
  64352. /**
  64353. * Babylon reference to the earcut plugin.
  64354. */
  64355. bjsEarcut: any;
  64356. /**
  64357. * Creates a PolygonMeshBuilder
  64358. * @param name name of the builder
  64359. * @param contours Path of the polygon
  64360. * @param scene scene to add to when creating the mesh
  64361. * @param earcutInjection can be used to inject your own earcut reference
  64362. */
  64363. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  64364. /**
  64365. * Adds a whole within the polygon
  64366. * @param hole Array of points defining the hole
  64367. * @returns this
  64368. */
  64369. addHole(hole: Vector2[]): PolygonMeshBuilder;
  64370. /**
  64371. * Creates the polygon
  64372. * @param updatable If the mesh should be updatable
  64373. * @param depth The depth of the mesh created
  64374. * @returns the created mesh
  64375. */
  64376. build(updatable?: boolean, depth?: number): Mesh;
  64377. /**
  64378. * Creates the polygon
  64379. * @param depth The depth of the mesh created
  64380. * @returns the created VertexData
  64381. */
  64382. buildVertexData(depth?: number): VertexData;
  64383. /**
  64384. * Adds a side to the polygon
  64385. * @param positions points that make the polygon
  64386. * @param normals normals of the polygon
  64387. * @param uvs uvs of the polygon
  64388. * @param indices indices of the polygon
  64389. * @param bounds bounds of the polygon
  64390. * @param points points of the polygon
  64391. * @param depth depth of the polygon
  64392. * @param flip flip of the polygon
  64393. */
  64394. private addSide;
  64395. }
  64396. }
  64397. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  64398. import { Scene } from "babylonjs/scene";
  64399. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64400. import { Color4 } from "babylonjs/Maths/math.color";
  64401. import { Mesh } from "babylonjs/Meshes/mesh";
  64402. import { Nullable } from "babylonjs/types";
  64403. /**
  64404. * Class containing static functions to help procedurally build meshes
  64405. */
  64406. export class PolygonBuilder {
  64407. /**
  64408. * Creates a polygon mesh
  64409. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  64410. * * 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
  64411. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64412. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64413. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  64414. * * Remember you can only change the shape positions, not their number when updating a polygon
  64415. * @param name defines the name of the mesh
  64416. * @param options defines the options used to create the mesh
  64417. * @param scene defines the hosting scene
  64418. * @param earcutInjection can be used to inject your own earcut reference
  64419. * @returns the polygon mesh
  64420. */
  64421. static CreatePolygon(name: string, options: {
  64422. shape: Vector3[];
  64423. holes?: Vector3[][];
  64424. depth?: number;
  64425. faceUV?: Vector4[];
  64426. faceColors?: Color4[];
  64427. updatable?: boolean;
  64428. sideOrientation?: number;
  64429. frontUVs?: Vector4;
  64430. backUVs?: Vector4;
  64431. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64432. /**
  64433. * Creates an extruded polygon mesh, with depth in the Y direction.
  64434. * * 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)
  64435. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64436. * @param name defines the name of the mesh
  64437. * @param options defines the options used to create the mesh
  64438. * @param scene defines the hosting scene
  64439. * @param earcutInjection can be used to inject your own earcut reference
  64440. * @returns the polygon mesh
  64441. */
  64442. static ExtrudePolygon(name: string, options: {
  64443. shape: Vector3[];
  64444. holes?: Vector3[][];
  64445. depth?: number;
  64446. faceUV?: Vector4[];
  64447. faceColors?: Color4[];
  64448. updatable?: boolean;
  64449. sideOrientation?: number;
  64450. frontUVs?: Vector4;
  64451. backUVs?: Vector4;
  64452. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  64453. }
  64454. }
  64455. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  64456. import { Scene } from "babylonjs/scene";
  64457. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64458. import { Mesh } from "babylonjs/Meshes/mesh";
  64459. import { Nullable } from "babylonjs/types";
  64460. /**
  64461. * Class containing static functions to help procedurally build meshes
  64462. */
  64463. export class LatheBuilder {
  64464. /**
  64465. * Creates lathe mesh.
  64466. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  64467. * * 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
  64468. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  64469. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  64470. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  64471. * * 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
  64472. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  64473. * * 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
  64474. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64475. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64476. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64477. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64478. * @param name defines the name of the mesh
  64479. * @param options defines the options used to create the mesh
  64480. * @param scene defines the hosting scene
  64481. * @returns the lathe mesh
  64482. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  64483. */
  64484. static CreateLathe(name: string, options: {
  64485. shape: Vector3[];
  64486. radius?: number;
  64487. tessellation?: number;
  64488. clip?: number;
  64489. arc?: number;
  64490. closed?: boolean;
  64491. updatable?: boolean;
  64492. sideOrientation?: number;
  64493. frontUVs?: Vector4;
  64494. backUVs?: Vector4;
  64495. cap?: number;
  64496. invertUV?: boolean;
  64497. }, scene?: Nullable<Scene>): Mesh;
  64498. }
  64499. }
  64500. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  64501. import { Nullable } from "babylonjs/types";
  64502. import { Scene } from "babylonjs/scene";
  64503. import { Vector4 } from "babylonjs/Maths/math.vector";
  64504. import { Mesh } from "babylonjs/Meshes/mesh";
  64505. /**
  64506. * Class containing static functions to help procedurally build meshes
  64507. */
  64508. export class TiledPlaneBuilder {
  64509. /**
  64510. * Creates a tiled plane mesh
  64511. * * The parameter `pattern` will, depending on value, do nothing or
  64512. * * * flip (reflect about central vertical) alternate tiles across and up
  64513. * * * flip every tile on alternate rows
  64514. * * * rotate (180 degs) alternate tiles across and up
  64515. * * * rotate every tile on alternate rows
  64516. * * * flip and rotate alternate tiles across and up
  64517. * * * flip and rotate every tile on alternate rows
  64518. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  64519. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  64520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  64522. * * 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)
  64523. * * 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)
  64524. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64525. * @param name defines the name of the mesh
  64526. * @param options defines the options used to create the mesh
  64527. * @param scene defines the hosting scene
  64528. * @returns the box mesh
  64529. */
  64530. static CreateTiledPlane(name: string, options: {
  64531. pattern?: number;
  64532. tileSize?: number;
  64533. tileWidth?: number;
  64534. tileHeight?: number;
  64535. size?: number;
  64536. width?: number;
  64537. height?: number;
  64538. alignHorizontal?: number;
  64539. alignVertical?: number;
  64540. sideOrientation?: number;
  64541. frontUVs?: Vector4;
  64542. backUVs?: Vector4;
  64543. updatable?: boolean;
  64544. }, scene?: Nullable<Scene>): Mesh;
  64545. }
  64546. }
  64547. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  64548. import { Nullable } from "babylonjs/types";
  64549. import { Scene } from "babylonjs/scene";
  64550. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  64551. import { Mesh } from "babylonjs/Meshes/mesh";
  64552. /**
  64553. * Class containing static functions to help procedurally build meshes
  64554. */
  64555. export class TubeBuilder {
  64556. /**
  64557. * Creates a tube mesh.
  64558. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64559. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  64560. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  64561. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  64562. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  64563. * * 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)
  64564. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  64565. * * 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
  64566. * * 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
  64567. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64568. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64569. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64571. * @param name defines the name of the mesh
  64572. * @param options defines the options used to create the mesh
  64573. * @param scene defines the hosting scene
  64574. * @returns the tube mesh
  64575. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64576. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  64577. */
  64578. static CreateTube(name: string, options: {
  64579. path: Vector3[];
  64580. radius?: number;
  64581. tessellation?: number;
  64582. radiusFunction?: {
  64583. (i: number, distance: number): number;
  64584. };
  64585. cap?: number;
  64586. arc?: number;
  64587. updatable?: boolean;
  64588. sideOrientation?: number;
  64589. frontUVs?: Vector4;
  64590. backUVs?: Vector4;
  64591. instance?: Mesh;
  64592. invertUV?: boolean;
  64593. }, scene?: Nullable<Scene>): Mesh;
  64594. }
  64595. }
  64596. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  64597. import { Scene } from "babylonjs/scene";
  64598. import { Vector4 } from "babylonjs/Maths/math.vector";
  64599. import { Mesh } from "babylonjs/Meshes/mesh";
  64600. import { Nullable } from "babylonjs/types";
  64601. /**
  64602. * Class containing static functions to help procedurally build meshes
  64603. */
  64604. export class IcoSphereBuilder {
  64605. /**
  64606. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64607. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64608. * * 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`)
  64609. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64610. * * 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
  64611. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64612. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64613. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64614. * @param name defines the name of the mesh
  64615. * @param options defines the options used to create the mesh
  64616. * @param scene defines the hosting scene
  64617. * @returns the icosahedron mesh
  64618. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64619. */
  64620. static CreateIcoSphere(name: string, options: {
  64621. radius?: number;
  64622. radiusX?: number;
  64623. radiusY?: number;
  64624. radiusZ?: number;
  64625. flat?: boolean;
  64626. subdivisions?: number;
  64627. sideOrientation?: number;
  64628. frontUVs?: Vector4;
  64629. backUVs?: Vector4;
  64630. updatable?: boolean;
  64631. }, scene?: Nullable<Scene>): Mesh;
  64632. }
  64633. }
  64634. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  64635. import { Vector3 } from "babylonjs/Maths/math.vector";
  64636. import { Mesh } from "babylonjs/Meshes/mesh";
  64637. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64638. /**
  64639. * Class containing static functions to help procedurally build meshes
  64640. */
  64641. export class DecalBuilder {
  64642. /**
  64643. * Creates a decal mesh.
  64644. * 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
  64645. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  64646. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  64647. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  64648. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  64649. * @param name defines the name of the mesh
  64650. * @param sourceMesh defines the mesh where the decal must be applied
  64651. * @param options defines the options used to create the mesh
  64652. * @param scene defines the hosting scene
  64653. * @returns the decal mesh
  64654. * @see https://doc.babylonjs.com/how_to/decals
  64655. */
  64656. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  64657. position?: Vector3;
  64658. normal?: Vector3;
  64659. size?: Vector3;
  64660. angle?: number;
  64661. }): Mesh;
  64662. }
  64663. }
  64664. declare module "babylonjs/Meshes/meshBuilder" {
  64665. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  64666. import { Nullable } from "babylonjs/types";
  64667. import { Scene } from "babylonjs/scene";
  64668. import { Mesh } from "babylonjs/Meshes/mesh";
  64669. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  64670. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  64671. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64672. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  64673. import { Plane } from "babylonjs/Maths/math.plane";
  64674. /**
  64675. * Class containing static functions to help procedurally build meshes
  64676. */
  64677. export class MeshBuilder {
  64678. /**
  64679. * Creates a box mesh
  64680. * * The parameter `size` sets the size (float) of each box side (default 1)
  64681. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  64682. * * 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)
  64683. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  64684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64685. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64686. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64687. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  64688. * @param name defines the name of the mesh
  64689. * @param options defines the options used to create the mesh
  64690. * @param scene defines the hosting scene
  64691. * @returns the box mesh
  64692. */
  64693. static CreateBox(name: string, options: {
  64694. size?: number;
  64695. width?: number;
  64696. height?: number;
  64697. depth?: number;
  64698. faceUV?: Vector4[];
  64699. faceColors?: Color4[];
  64700. sideOrientation?: number;
  64701. frontUVs?: Vector4;
  64702. backUVs?: Vector4;
  64703. wrap?: boolean;
  64704. topBaseAt?: number;
  64705. bottomBaseAt?: number;
  64706. updatable?: boolean;
  64707. }, scene?: Nullable<Scene>): Mesh;
  64708. /**
  64709. * Creates a tiled box mesh
  64710. * * faceTiles sets the pattern, tile size and number of tiles for a face
  64711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64712. * @param name defines the name of the mesh
  64713. * @param options defines the options used to create the mesh
  64714. * @param scene defines the hosting scene
  64715. * @returns the tiled box mesh
  64716. */
  64717. static CreateTiledBox(name: string, options: {
  64718. pattern?: number;
  64719. size?: number;
  64720. width?: number;
  64721. height?: number;
  64722. depth: number;
  64723. tileSize?: number;
  64724. tileWidth?: number;
  64725. tileHeight?: number;
  64726. faceUV?: Vector4[];
  64727. faceColors?: Color4[];
  64728. alignHorizontal?: number;
  64729. alignVertical?: number;
  64730. sideOrientation?: number;
  64731. updatable?: boolean;
  64732. }, scene?: Nullable<Scene>): Mesh;
  64733. /**
  64734. * Creates a sphere mesh
  64735. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  64736. * * 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`)
  64737. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  64738. * * 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
  64739. * * 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)
  64740. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64741. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64743. * @param name defines the name of the mesh
  64744. * @param options defines the options used to create the mesh
  64745. * @param scene defines the hosting scene
  64746. * @returns the sphere mesh
  64747. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  64748. */
  64749. static CreateSphere(name: string, options: {
  64750. segments?: number;
  64751. diameter?: number;
  64752. diameterX?: number;
  64753. diameterY?: number;
  64754. diameterZ?: number;
  64755. arc?: number;
  64756. slice?: number;
  64757. sideOrientation?: number;
  64758. frontUVs?: Vector4;
  64759. backUVs?: Vector4;
  64760. updatable?: boolean;
  64761. }, scene?: Nullable<Scene>): Mesh;
  64762. /**
  64763. * Creates a plane polygonal mesh. By default, this is a disc
  64764. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  64765. * * 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
  64766. * * 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
  64767. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64769. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64770. * @param name defines the name of the mesh
  64771. * @param options defines the options used to create the mesh
  64772. * @param scene defines the hosting scene
  64773. * @returns the plane polygonal mesh
  64774. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  64775. */
  64776. static CreateDisc(name: string, options: {
  64777. radius?: number;
  64778. tessellation?: number;
  64779. arc?: number;
  64780. updatable?: boolean;
  64781. sideOrientation?: number;
  64782. frontUVs?: Vector4;
  64783. backUVs?: Vector4;
  64784. }, scene?: Nullable<Scene>): Mesh;
  64785. /**
  64786. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  64787. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  64788. * * 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`)
  64789. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  64790. * * 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
  64791. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64792. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64793. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64794. * @param name defines the name of the mesh
  64795. * @param options defines the options used to create the mesh
  64796. * @param scene defines the hosting scene
  64797. * @returns the icosahedron mesh
  64798. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  64799. */
  64800. static CreateIcoSphere(name: string, options: {
  64801. radius?: number;
  64802. radiusX?: number;
  64803. radiusY?: number;
  64804. radiusZ?: number;
  64805. flat?: boolean;
  64806. subdivisions?: number;
  64807. sideOrientation?: number;
  64808. frontUVs?: Vector4;
  64809. backUVs?: Vector4;
  64810. updatable?: boolean;
  64811. }, scene?: Nullable<Scene>): Mesh;
  64812. /**
  64813. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  64814. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  64815. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  64816. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  64817. * * 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
  64818. * * 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
  64819. * * 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
  64820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  64823. * * 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
  64824. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  64825. * * 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
  64826. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  64827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64828. * @param name defines the name of the mesh
  64829. * @param options defines the options used to create the mesh
  64830. * @param scene defines the hosting scene
  64831. * @returns the ribbon mesh
  64832. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  64833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  64834. */
  64835. static CreateRibbon(name: string, options: {
  64836. pathArray: Vector3[][];
  64837. closeArray?: boolean;
  64838. closePath?: boolean;
  64839. offset?: number;
  64840. updatable?: boolean;
  64841. sideOrientation?: number;
  64842. frontUVs?: Vector4;
  64843. backUVs?: Vector4;
  64844. instance?: Mesh;
  64845. invertUV?: boolean;
  64846. uvs?: Vector2[];
  64847. colors?: Color4[];
  64848. }, scene?: Nullable<Scene>): Mesh;
  64849. /**
  64850. * Creates a cylinder or a cone mesh
  64851. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  64852. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  64853. * * 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.
  64854. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  64855. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  64856. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  64857. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  64858. * * 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).
  64859. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  64860. * * 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).
  64861. * * 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
  64862. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  64863. * * 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
  64864. * * 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.
  64865. * * If `enclose` is false, a ring surface is one element.
  64866. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  64867. * * 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
  64868. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64869. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64871. * @param name defines the name of the mesh
  64872. * @param options defines the options used to create the mesh
  64873. * @param scene defines the hosting scene
  64874. * @returns the cylinder mesh
  64875. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  64876. */
  64877. static CreateCylinder(name: string, options: {
  64878. height?: number;
  64879. diameterTop?: number;
  64880. diameterBottom?: number;
  64881. diameter?: number;
  64882. tessellation?: number;
  64883. subdivisions?: number;
  64884. arc?: number;
  64885. faceColors?: Color4[];
  64886. faceUV?: Vector4[];
  64887. updatable?: boolean;
  64888. hasRings?: boolean;
  64889. enclose?: boolean;
  64890. cap?: number;
  64891. sideOrientation?: number;
  64892. frontUVs?: Vector4;
  64893. backUVs?: Vector4;
  64894. }, scene?: Nullable<Scene>): Mesh;
  64895. /**
  64896. * Creates a torus mesh
  64897. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  64898. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  64899. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  64900. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64901. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64903. * @param name defines the name of the mesh
  64904. * @param options defines the options used to create the mesh
  64905. * @param scene defines the hosting scene
  64906. * @returns the torus mesh
  64907. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  64908. */
  64909. static CreateTorus(name: string, options: {
  64910. diameter?: number;
  64911. thickness?: number;
  64912. tessellation?: number;
  64913. updatable?: boolean;
  64914. sideOrientation?: number;
  64915. frontUVs?: Vector4;
  64916. backUVs?: Vector4;
  64917. }, scene?: Nullable<Scene>): Mesh;
  64918. /**
  64919. * Creates a torus knot mesh
  64920. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  64921. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  64922. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  64923. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  64924. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  64925. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  64926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  64927. * @param name defines the name of the mesh
  64928. * @param options defines the options used to create the mesh
  64929. * @param scene defines the hosting scene
  64930. * @returns the torus knot mesh
  64931. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  64932. */
  64933. static CreateTorusKnot(name: string, options: {
  64934. radius?: number;
  64935. tube?: number;
  64936. radialSegments?: number;
  64937. tubularSegments?: number;
  64938. p?: number;
  64939. q?: number;
  64940. updatable?: boolean;
  64941. sideOrientation?: number;
  64942. frontUVs?: Vector4;
  64943. backUVs?: Vector4;
  64944. }, scene?: Nullable<Scene>): Mesh;
  64945. /**
  64946. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  64947. * * 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
  64948. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  64949. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  64950. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  64951. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  64952. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  64953. * * 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
  64954. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  64955. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64956. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  64957. * @param name defines the name of the new line system
  64958. * @param options defines the options used to create the line system
  64959. * @param scene defines the hosting scene
  64960. * @returns a new line system mesh
  64961. */
  64962. static CreateLineSystem(name: string, options: {
  64963. lines: Vector3[][];
  64964. updatable?: boolean;
  64965. instance?: Nullable<LinesMesh>;
  64966. colors?: Nullable<Color4[][]>;
  64967. useVertexAlpha?: boolean;
  64968. }, scene: Nullable<Scene>): LinesMesh;
  64969. /**
  64970. * Creates a line mesh
  64971. * 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
  64972. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64973. * * The parameter `points` is an array successive Vector3
  64974. * * 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
  64975. * * The optional parameter `colors` is an array of successive Color4, one per line point
  64976. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  64977. * * When updating an instance, remember that only point positions can change, not the number of points
  64978. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  64979. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  64980. * @param name defines the name of the new line system
  64981. * @param options defines the options used to create the line system
  64982. * @param scene defines the hosting scene
  64983. * @returns a new line mesh
  64984. */
  64985. static CreateLines(name: string, options: {
  64986. points: Vector3[];
  64987. updatable?: boolean;
  64988. instance?: Nullable<LinesMesh>;
  64989. colors?: Color4[];
  64990. useVertexAlpha?: boolean;
  64991. }, scene?: Nullable<Scene>): LinesMesh;
  64992. /**
  64993. * Creates a dashed line mesh
  64994. * * 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
  64995. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  64996. * * The parameter `points` is an array successive Vector3
  64997. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  64998. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  64999. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  65000. * * 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
  65001. * * When updating an instance, remember that only point positions can change, not the number of points
  65002. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65003. * @param name defines the name of the mesh
  65004. * @param options defines the options used to create the mesh
  65005. * @param scene defines the hosting scene
  65006. * @returns the dashed line mesh
  65007. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  65008. */
  65009. static CreateDashedLines(name: string, options: {
  65010. points: Vector3[];
  65011. dashSize?: number;
  65012. gapSize?: number;
  65013. dashNb?: number;
  65014. updatable?: boolean;
  65015. instance?: LinesMesh;
  65016. }, scene?: Nullable<Scene>): LinesMesh;
  65017. /**
  65018. * 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.
  65019. * * 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.
  65020. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65021. * * 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.
  65022. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  65023. * * 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
  65024. * * 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
  65025. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  65026. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65027. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65028. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  65029. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65030. * @param name defines the name of the mesh
  65031. * @param options defines the options used to create the mesh
  65032. * @param scene defines the hosting scene
  65033. * @returns the extruded shape mesh
  65034. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65035. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65036. */
  65037. static ExtrudeShape(name: string, options: {
  65038. shape: Vector3[];
  65039. path: Vector3[];
  65040. scale?: number;
  65041. rotation?: number;
  65042. cap?: number;
  65043. updatable?: boolean;
  65044. sideOrientation?: number;
  65045. frontUVs?: Vector4;
  65046. backUVs?: Vector4;
  65047. instance?: Mesh;
  65048. invertUV?: boolean;
  65049. }, scene?: Nullable<Scene>): Mesh;
  65050. /**
  65051. * Creates an custom extruded shape mesh.
  65052. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  65053. * * 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.
  65054. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  65055. * * 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
  65056. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  65057. * * 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
  65058. * * It must returns a float value that will be the scale value applied to the shape on each path point
  65059. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  65060. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  65061. * * 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
  65062. * * 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
  65063. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  65064. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65065. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65066. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65067. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65068. * @param name defines the name of the mesh
  65069. * @param options defines the options used to create the mesh
  65070. * @param scene defines the hosting scene
  65071. * @returns the custom extruded shape mesh
  65072. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  65073. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65074. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  65075. */
  65076. static ExtrudeShapeCustom(name: string, options: {
  65077. shape: Vector3[];
  65078. path: Vector3[];
  65079. scaleFunction?: any;
  65080. rotationFunction?: any;
  65081. ribbonCloseArray?: boolean;
  65082. ribbonClosePath?: boolean;
  65083. cap?: number;
  65084. updatable?: boolean;
  65085. sideOrientation?: number;
  65086. frontUVs?: Vector4;
  65087. backUVs?: Vector4;
  65088. instance?: Mesh;
  65089. invertUV?: boolean;
  65090. }, scene?: Nullable<Scene>): Mesh;
  65091. /**
  65092. * Creates lathe mesh.
  65093. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  65094. * * 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
  65095. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  65096. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  65097. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  65098. * * 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
  65099. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  65100. * * 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
  65101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65103. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65104. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65105. * @param name defines the name of the mesh
  65106. * @param options defines the options used to create the mesh
  65107. * @param scene defines the hosting scene
  65108. * @returns the lathe mesh
  65109. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  65110. */
  65111. static CreateLathe(name: string, options: {
  65112. shape: Vector3[];
  65113. radius?: number;
  65114. tessellation?: number;
  65115. clip?: number;
  65116. arc?: number;
  65117. closed?: boolean;
  65118. updatable?: boolean;
  65119. sideOrientation?: number;
  65120. frontUVs?: Vector4;
  65121. backUVs?: Vector4;
  65122. cap?: number;
  65123. invertUV?: boolean;
  65124. }, scene?: Nullable<Scene>): Mesh;
  65125. /**
  65126. * Creates a tiled plane mesh
  65127. * * You can set a limited pattern arrangement with the tiles
  65128. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65129. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65131. * @param name defines the name of the mesh
  65132. * @param options defines the options used to create the mesh
  65133. * @param scene defines the hosting scene
  65134. * @returns the plane mesh
  65135. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65136. */
  65137. static CreateTiledPlane(name: string, options: {
  65138. pattern?: number;
  65139. tileSize?: number;
  65140. tileWidth?: number;
  65141. tileHeight?: number;
  65142. size?: number;
  65143. width?: number;
  65144. height?: number;
  65145. alignHorizontal?: number;
  65146. alignVertical?: number;
  65147. sideOrientation?: number;
  65148. frontUVs?: Vector4;
  65149. backUVs?: Vector4;
  65150. updatable?: boolean;
  65151. }, scene?: Nullable<Scene>): Mesh;
  65152. /**
  65153. * Creates a plane mesh
  65154. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  65155. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  65156. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  65157. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65158. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65159. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65160. * @param name defines the name of the mesh
  65161. * @param options defines the options used to create the mesh
  65162. * @param scene defines the hosting scene
  65163. * @returns the plane mesh
  65164. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  65165. */
  65166. static CreatePlane(name: string, options: {
  65167. size?: number;
  65168. width?: number;
  65169. height?: number;
  65170. sideOrientation?: number;
  65171. frontUVs?: Vector4;
  65172. backUVs?: Vector4;
  65173. updatable?: boolean;
  65174. sourcePlane?: Plane;
  65175. }, scene?: Nullable<Scene>): Mesh;
  65176. /**
  65177. * Creates a ground mesh
  65178. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  65179. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  65180. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65181. * @param name defines the name of the mesh
  65182. * @param options defines the options used to create the mesh
  65183. * @param scene defines the hosting scene
  65184. * @returns the ground mesh
  65185. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  65186. */
  65187. static CreateGround(name: string, options: {
  65188. width?: number;
  65189. height?: number;
  65190. subdivisions?: number;
  65191. subdivisionsX?: number;
  65192. subdivisionsY?: number;
  65193. updatable?: boolean;
  65194. }, scene?: Nullable<Scene>): Mesh;
  65195. /**
  65196. * Creates a tiled ground mesh
  65197. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  65198. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  65199. * * 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
  65200. * * 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
  65201. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65202. * @param name defines the name of the mesh
  65203. * @param options defines the options used to create the mesh
  65204. * @param scene defines the hosting scene
  65205. * @returns the tiled ground mesh
  65206. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  65207. */
  65208. static CreateTiledGround(name: string, options: {
  65209. xmin: number;
  65210. zmin: number;
  65211. xmax: number;
  65212. zmax: number;
  65213. subdivisions?: {
  65214. w: number;
  65215. h: number;
  65216. };
  65217. precision?: {
  65218. w: number;
  65219. h: number;
  65220. };
  65221. updatable?: boolean;
  65222. }, scene?: Nullable<Scene>): Mesh;
  65223. /**
  65224. * Creates a ground mesh from a height map
  65225. * * The parameter `url` sets the URL of the height map image resource.
  65226. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  65227. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  65228. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  65229. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  65230. * * 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.
  65231. * * 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).
  65232. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  65233. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  65234. * @param name defines the name of the mesh
  65235. * @param url defines the url to the height map
  65236. * @param options defines the options used to create the mesh
  65237. * @param scene defines the hosting scene
  65238. * @returns the ground mesh
  65239. * @see https://doc.babylonjs.com/babylon101/height_map
  65240. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  65241. */
  65242. static CreateGroundFromHeightMap(name: string, url: string, options: {
  65243. width?: number;
  65244. height?: number;
  65245. subdivisions?: number;
  65246. minHeight?: number;
  65247. maxHeight?: number;
  65248. colorFilter?: Color3;
  65249. alphaFilter?: number;
  65250. updatable?: boolean;
  65251. onReady?: (mesh: GroundMesh) => void;
  65252. }, scene?: Nullable<Scene>): GroundMesh;
  65253. /**
  65254. * Creates a polygon mesh
  65255. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  65256. * * 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
  65257. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  65258. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65259. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  65260. * * Remember you can only change the shape positions, not their number when updating a polygon
  65261. * @param name defines the name of the mesh
  65262. * @param options defines the options used to create the mesh
  65263. * @param scene defines the hosting scene
  65264. * @param earcutInjection can be used to inject your own earcut reference
  65265. * @returns the polygon mesh
  65266. */
  65267. static CreatePolygon(name: string, options: {
  65268. shape: Vector3[];
  65269. holes?: Vector3[][];
  65270. depth?: number;
  65271. faceUV?: Vector4[];
  65272. faceColors?: Color4[];
  65273. updatable?: boolean;
  65274. sideOrientation?: number;
  65275. frontUVs?: Vector4;
  65276. backUVs?: Vector4;
  65277. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65278. /**
  65279. * Creates an extruded polygon mesh, with depth in the Y direction.
  65280. * * 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)
  65281. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  65282. * @param name defines the name of the mesh
  65283. * @param options defines the options used to create the mesh
  65284. * @param scene defines the hosting scene
  65285. * @param earcutInjection can be used to inject your own earcut reference
  65286. * @returns the polygon mesh
  65287. */
  65288. static ExtrudePolygon(name: string, options: {
  65289. shape: Vector3[];
  65290. holes?: Vector3[][];
  65291. depth?: number;
  65292. faceUV?: Vector4[];
  65293. faceColors?: Color4[];
  65294. updatable?: boolean;
  65295. sideOrientation?: number;
  65296. frontUVs?: Vector4;
  65297. backUVs?: Vector4;
  65298. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  65299. /**
  65300. * Creates a tube mesh.
  65301. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  65302. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  65303. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  65304. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  65305. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  65306. * * 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)
  65307. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  65308. * * 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
  65309. * * 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
  65310. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65311. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65312. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  65313. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65314. * @param name defines the name of the mesh
  65315. * @param options defines the options used to create the mesh
  65316. * @param scene defines the hosting scene
  65317. * @returns the tube mesh
  65318. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  65319. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  65320. */
  65321. static CreateTube(name: string, options: {
  65322. path: Vector3[];
  65323. radius?: number;
  65324. tessellation?: number;
  65325. radiusFunction?: {
  65326. (i: number, distance: number): number;
  65327. };
  65328. cap?: number;
  65329. arc?: number;
  65330. updatable?: boolean;
  65331. sideOrientation?: number;
  65332. frontUVs?: Vector4;
  65333. backUVs?: Vector4;
  65334. instance?: Mesh;
  65335. invertUV?: boolean;
  65336. }, scene?: Nullable<Scene>): Mesh;
  65337. /**
  65338. * Creates a polyhedron mesh
  65339. * * 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
  65340. * * The parameter `size` (positive float, default 1) sets the polygon size
  65341. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  65342. * * 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`
  65343. * * 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
  65344. * * 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)`)
  65345. * * 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
  65346. * * 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
  65347. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  65348. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  65349. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  65350. * @param name defines the name of the mesh
  65351. * @param options defines the options used to create the mesh
  65352. * @param scene defines the hosting scene
  65353. * @returns the polyhedron mesh
  65354. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  65355. */
  65356. static CreatePolyhedron(name: string, options: {
  65357. type?: number;
  65358. size?: number;
  65359. sizeX?: number;
  65360. sizeY?: number;
  65361. sizeZ?: number;
  65362. custom?: any;
  65363. faceUV?: Vector4[];
  65364. faceColors?: Color4[];
  65365. flat?: boolean;
  65366. updatable?: boolean;
  65367. sideOrientation?: number;
  65368. frontUVs?: Vector4;
  65369. backUVs?: Vector4;
  65370. }, scene?: Nullable<Scene>): Mesh;
  65371. /**
  65372. * Creates a decal mesh.
  65373. * 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
  65374. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  65375. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  65376. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  65377. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  65378. * @param name defines the name of the mesh
  65379. * @param sourceMesh defines the mesh where the decal must be applied
  65380. * @param options defines the options used to create the mesh
  65381. * @param scene defines the hosting scene
  65382. * @returns the decal mesh
  65383. * @see https://doc.babylonjs.com/how_to/decals
  65384. */
  65385. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  65386. position?: Vector3;
  65387. normal?: Vector3;
  65388. size?: Vector3;
  65389. angle?: number;
  65390. }): Mesh;
  65391. }
  65392. }
  65393. declare module "babylonjs/Meshes/meshSimplification" {
  65394. import { Mesh } from "babylonjs/Meshes/mesh";
  65395. /**
  65396. * A simplifier interface for future simplification implementations
  65397. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65398. */
  65399. export interface ISimplifier {
  65400. /**
  65401. * Simplification of a given mesh according to the given settings.
  65402. * Since this requires computation, it is assumed that the function runs async.
  65403. * @param settings The settings of the simplification, including quality and distance
  65404. * @param successCallback A callback that will be called after the mesh was simplified.
  65405. * @param errorCallback in case of an error, this callback will be called. optional.
  65406. */
  65407. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  65408. }
  65409. /**
  65410. * Expected simplification settings.
  65411. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  65412. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65413. */
  65414. export interface ISimplificationSettings {
  65415. /**
  65416. * Gets or sets the expected quality
  65417. */
  65418. quality: number;
  65419. /**
  65420. * Gets or sets the distance when this optimized version should be used
  65421. */
  65422. distance: number;
  65423. /**
  65424. * Gets an already optimized mesh
  65425. */
  65426. optimizeMesh?: boolean;
  65427. }
  65428. /**
  65429. * Class used to specify simplification options
  65430. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65431. */
  65432. export class SimplificationSettings implements ISimplificationSettings {
  65433. /** expected quality */
  65434. quality: number;
  65435. /** distance when this optimized version should be used */
  65436. distance: number;
  65437. /** already optimized mesh */
  65438. optimizeMesh?: boolean | undefined;
  65439. /**
  65440. * Creates a SimplificationSettings
  65441. * @param quality expected quality
  65442. * @param distance distance when this optimized version should be used
  65443. * @param optimizeMesh already optimized mesh
  65444. */
  65445. constructor(
  65446. /** expected quality */
  65447. quality: number,
  65448. /** distance when this optimized version should be used */
  65449. distance: number,
  65450. /** already optimized mesh */
  65451. optimizeMesh?: boolean | undefined);
  65452. }
  65453. /**
  65454. * Interface used to define a simplification task
  65455. */
  65456. export interface ISimplificationTask {
  65457. /**
  65458. * Array of settings
  65459. */
  65460. settings: Array<ISimplificationSettings>;
  65461. /**
  65462. * Simplification type
  65463. */
  65464. simplificationType: SimplificationType;
  65465. /**
  65466. * Mesh to simplify
  65467. */
  65468. mesh: Mesh;
  65469. /**
  65470. * Callback called on success
  65471. */
  65472. successCallback?: () => void;
  65473. /**
  65474. * Defines if parallel processing can be used
  65475. */
  65476. parallelProcessing: boolean;
  65477. }
  65478. /**
  65479. * Queue used to order the simplification tasks
  65480. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65481. */
  65482. export class SimplificationQueue {
  65483. private _simplificationArray;
  65484. /**
  65485. * Gets a boolean indicating that the process is still running
  65486. */
  65487. running: boolean;
  65488. /**
  65489. * Creates a new queue
  65490. */
  65491. constructor();
  65492. /**
  65493. * Adds a new simplification task
  65494. * @param task defines a task to add
  65495. */
  65496. addTask(task: ISimplificationTask): void;
  65497. /**
  65498. * Execute next task
  65499. */
  65500. executeNext(): void;
  65501. /**
  65502. * Execute a simplification task
  65503. * @param task defines the task to run
  65504. */
  65505. runSimplification(task: ISimplificationTask): void;
  65506. private getSimplifier;
  65507. }
  65508. /**
  65509. * The implemented types of simplification
  65510. * At the moment only Quadratic Error Decimation is implemented
  65511. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65512. */
  65513. export enum SimplificationType {
  65514. /** Quadratic error decimation */
  65515. QUADRATIC = 0
  65516. }
  65517. /**
  65518. * An implementation of the Quadratic Error simplification algorithm.
  65519. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  65520. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  65521. * @author RaananW
  65522. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65523. */
  65524. export class QuadraticErrorSimplification implements ISimplifier {
  65525. private _mesh;
  65526. private triangles;
  65527. private vertices;
  65528. private references;
  65529. private _reconstructedMesh;
  65530. /** Gets or sets the number pf sync interations */
  65531. syncIterations: number;
  65532. /** Gets or sets the aggressiveness of the simplifier */
  65533. aggressiveness: number;
  65534. /** Gets or sets the number of allowed iterations for decimation */
  65535. decimationIterations: number;
  65536. /** Gets or sets the espilon to use for bounding box computation */
  65537. boundingBoxEpsilon: number;
  65538. /**
  65539. * Creates a new QuadraticErrorSimplification
  65540. * @param _mesh defines the target mesh
  65541. */
  65542. constructor(_mesh: Mesh);
  65543. /**
  65544. * Simplification of a given mesh according to the given settings.
  65545. * Since this requires computation, it is assumed that the function runs async.
  65546. * @param settings The settings of the simplification, including quality and distance
  65547. * @param successCallback A callback that will be called after the mesh was simplified.
  65548. */
  65549. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  65550. private runDecimation;
  65551. private initWithMesh;
  65552. private init;
  65553. private reconstructMesh;
  65554. private initDecimatedMesh;
  65555. private isFlipped;
  65556. private updateTriangles;
  65557. private identifyBorder;
  65558. private updateMesh;
  65559. private vertexError;
  65560. private calculateError;
  65561. }
  65562. }
  65563. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  65564. import { Scene } from "babylonjs/scene";
  65565. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  65566. import { ISceneComponent } from "babylonjs/sceneComponent";
  65567. module "babylonjs/scene" {
  65568. interface Scene {
  65569. /** @hidden (Backing field) */
  65570. _simplificationQueue: SimplificationQueue;
  65571. /**
  65572. * Gets or sets the simplification queue attached to the scene
  65573. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  65574. */
  65575. simplificationQueue: SimplificationQueue;
  65576. }
  65577. }
  65578. module "babylonjs/Meshes/mesh" {
  65579. interface Mesh {
  65580. /**
  65581. * Simplify the mesh according to the given array of settings.
  65582. * Function will return immediately and will simplify async
  65583. * @param settings a collection of simplification settings
  65584. * @param parallelProcessing should all levels calculate parallel or one after the other
  65585. * @param simplificationType the type of simplification to run
  65586. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  65587. * @returns the current mesh
  65588. */
  65589. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  65590. }
  65591. }
  65592. /**
  65593. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  65594. * created in a scene
  65595. */
  65596. export class SimplicationQueueSceneComponent implements ISceneComponent {
  65597. /**
  65598. * The component name helpfull to identify the component in the list of scene components.
  65599. */
  65600. readonly name: string;
  65601. /**
  65602. * The scene the component belongs to.
  65603. */
  65604. scene: Scene;
  65605. /**
  65606. * Creates a new instance of the component for the given scene
  65607. * @param scene Defines the scene to register the component in
  65608. */
  65609. constructor(scene: Scene);
  65610. /**
  65611. * Registers the component in a given scene
  65612. */
  65613. register(): void;
  65614. /**
  65615. * Rebuilds the elements related to this component in case of
  65616. * context lost for instance.
  65617. */
  65618. rebuild(): void;
  65619. /**
  65620. * Disposes the component and the associated ressources
  65621. */
  65622. dispose(): void;
  65623. private _beforeCameraUpdate;
  65624. }
  65625. }
  65626. declare module "babylonjs/Meshes/Builders/index" {
  65627. export * from "babylonjs/Meshes/Builders/boxBuilder";
  65628. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  65629. export * from "babylonjs/Meshes/Builders/discBuilder";
  65630. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  65631. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  65632. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  65633. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  65634. export * from "babylonjs/Meshes/Builders/torusBuilder";
  65635. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  65636. export * from "babylonjs/Meshes/Builders/linesBuilder";
  65637. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  65638. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  65639. export * from "babylonjs/Meshes/Builders/latheBuilder";
  65640. export * from "babylonjs/Meshes/Builders/planeBuilder";
  65641. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  65642. export * from "babylonjs/Meshes/Builders/groundBuilder";
  65643. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  65644. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  65645. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  65646. export * from "babylonjs/Meshes/Builders/decalBuilder";
  65647. }
  65648. declare module "babylonjs/Meshes/index" {
  65649. export * from "babylonjs/Meshes/abstractMesh";
  65650. export * from "babylonjs/Meshes/buffer";
  65651. export * from "babylonjs/Meshes/Compression/index";
  65652. export * from "babylonjs/Meshes/csg";
  65653. export * from "babylonjs/Meshes/geometry";
  65654. export * from "babylonjs/Meshes/groundMesh";
  65655. export * from "babylonjs/Meshes/trailMesh";
  65656. export * from "babylonjs/Meshes/instancedMesh";
  65657. export * from "babylonjs/Meshes/linesMesh";
  65658. export * from "babylonjs/Meshes/mesh";
  65659. export * from "babylonjs/Meshes/mesh.vertexData";
  65660. export * from "babylonjs/Meshes/meshBuilder";
  65661. export * from "babylonjs/Meshes/meshSimplification";
  65662. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  65663. export * from "babylonjs/Meshes/polygonMesh";
  65664. export * from "babylonjs/Meshes/subMesh";
  65665. export * from "babylonjs/Meshes/meshLODLevel";
  65666. export * from "babylonjs/Meshes/transformNode";
  65667. export * from "babylonjs/Meshes/Builders/index";
  65668. export * from "babylonjs/Meshes/dataBuffer";
  65669. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  65670. }
  65671. declare module "babylonjs/Morph/index" {
  65672. export * from "babylonjs/Morph/morphTarget";
  65673. export * from "babylonjs/Morph/morphTargetManager";
  65674. }
  65675. declare module "babylonjs/Navigation/INavigationEngine" {
  65676. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65677. import { Vector3 } from "babylonjs/Maths/math";
  65678. import { Mesh } from "babylonjs/Meshes/mesh";
  65679. import { Scene } from "babylonjs/scene";
  65680. /**
  65681. * Navigation plugin interface to add navigation constrained by a navigation mesh
  65682. */
  65683. export interface INavigationEnginePlugin {
  65684. /**
  65685. * plugin name
  65686. */
  65687. name: string;
  65688. /**
  65689. * Creates a navigation mesh
  65690. * @param meshes array of all the geometry used to compute the navigatio mesh
  65691. * @param parameters bunch of parameters used to filter geometry
  65692. */
  65693. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  65694. /**
  65695. * Create a navigation mesh debug mesh
  65696. * @param scene is where the mesh will be added
  65697. * @returns debug display mesh
  65698. */
  65699. createDebugNavMesh(scene: Scene): Mesh;
  65700. /**
  65701. * Get a navigation mesh constrained position, closest to the parameter position
  65702. * @param position world position
  65703. * @returns the closest point to position constrained by the navigation mesh
  65704. */
  65705. getClosestPoint(position: Vector3): Vector3;
  65706. /**
  65707. * Get a navigation mesh constrained position, closest to the parameter position
  65708. * @param position world position
  65709. * @param result output the closest point to position constrained by the navigation mesh
  65710. */
  65711. getClosestPointToRef(position: Vector3, result: Vector3): void;
  65712. /**
  65713. * Get a navigation mesh constrained position, within a particular radius
  65714. * @param position world position
  65715. * @param maxRadius the maximum distance to the constrained world position
  65716. * @returns the closest point to position constrained by the navigation mesh
  65717. */
  65718. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  65719. /**
  65720. * Get a navigation mesh constrained position, within a particular radius
  65721. * @param position world position
  65722. * @param maxRadius the maximum distance to the constrained world position
  65723. * @param result output the closest point to position constrained by the navigation mesh
  65724. */
  65725. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  65726. /**
  65727. * Compute the final position from a segment made of destination-position
  65728. * @param position world position
  65729. * @param destination world position
  65730. * @returns the resulting point along the navmesh
  65731. */
  65732. moveAlong(position: Vector3, destination: Vector3): Vector3;
  65733. /**
  65734. * Compute the final position from a segment made of destination-position
  65735. * @param position world position
  65736. * @param destination world position
  65737. * @param result output the resulting point along the navmesh
  65738. */
  65739. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  65740. /**
  65741. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  65742. * @param start world position
  65743. * @param end world position
  65744. * @returns array containing world position composing the path
  65745. */
  65746. computePath(start: Vector3, end: Vector3): Vector3[];
  65747. /**
  65748. * If this plugin is supported
  65749. * @returns true if plugin is supported
  65750. */
  65751. isSupported(): boolean;
  65752. /**
  65753. * Create a new Crowd so you can add agents
  65754. * @param maxAgents the maximum agent count in the crowd
  65755. * @param maxAgentRadius the maximum radius an agent can have
  65756. * @param scene to attach the crowd to
  65757. * @returns the crowd you can add agents to
  65758. */
  65759. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  65760. /**
  65761. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65762. * The queries will try to find a solution within those bounds
  65763. * default is (1,1,1)
  65764. * @param extent x,y,z value that define the extent around the queries point of reference
  65765. */
  65766. setDefaultQueryExtent(extent: Vector3): void;
  65767. /**
  65768. * Get the Bounding box extent specified by setDefaultQueryExtent
  65769. * @returns the box extent values
  65770. */
  65771. getDefaultQueryExtent(): Vector3;
  65772. /**
  65773. * build the navmesh from a previously saved state using getNavmeshData
  65774. * @param data the Uint8Array returned by getNavmeshData
  65775. */
  65776. buildFromNavmeshData(data: Uint8Array): void;
  65777. /**
  65778. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  65779. * @returns data the Uint8Array that can be saved and reused
  65780. */
  65781. getNavmeshData(): Uint8Array;
  65782. /**
  65783. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65784. * @param result output the box extent values
  65785. */
  65786. getDefaultQueryExtentToRef(result: Vector3): void;
  65787. /**
  65788. * Release all resources
  65789. */
  65790. dispose(): void;
  65791. }
  65792. /**
  65793. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  65794. */
  65795. export interface ICrowd {
  65796. /**
  65797. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  65798. * You can attach anything to that node. The node position is updated in the scene update tick.
  65799. * @param pos world position that will be constrained by the navigation mesh
  65800. * @param parameters agent parameters
  65801. * @param transform hooked to the agent that will be update by the scene
  65802. * @returns agent index
  65803. */
  65804. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  65805. /**
  65806. * Returns the agent position in world space
  65807. * @param index agent index returned by addAgent
  65808. * @returns world space position
  65809. */
  65810. getAgentPosition(index: number): Vector3;
  65811. /**
  65812. * Gets the agent position result in world space
  65813. * @param index agent index returned by addAgent
  65814. * @param result output world space position
  65815. */
  65816. getAgentPositionToRef(index: number, result: Vector3): void;
  65817. /**
  65818. * Gets the agent velocity in world space
  65819. * @param index agent index returned by addAgent
  65820. * @returns world space velocity
  65821. */
  65822. getAgentVelocity(index: number): Vector3;
  65823. /**
  65824. * Gets the agent velocity result in world space
  65825. * @param index agent index returned by addAgent
  65826. * @param result output world space velocity
  65827. */
  65828. getAgentVelocityToRef(index: number, result: Vector3): void;
  65829. /**
  65830. * remove a particular agent previously created
  65831. * @param index agent index returned by addAgent
  65832. */
  65833. removeAgent(index: number): void;
  65834. /**
  65835. * get the list of all agents attached to this crowd
  65836. * @returns list of agent indices
  65837. */
  65838. getAgents(): number[];
  65839. /**
  65840. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  65841. * @param deltaTime in seconds
  65842. */
  65843. update(deltaTime: number): void;
  65844. /**
  65845. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  65846. * @param index agent index returned by addAgent
  65847. * @param destination targeted world position
  65848. */
  65849. agentGoto(index: number, destination: Vector3): void;
  65850. /**
  65851. * Teleport the agent to a new position
  65852. * @param index agent index returned by addAgent
  65853. * @param destination targeted world position
  65854. */
  65855. agentTeleport(index: number, destination: Vector3): void;
  65856. /**
  65857. * Update agent parameters
  65858. * @param index agent index returned by addAgent
  65859. * @param parameters agent parameters
  65860. */
  65861. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  65862. /**
  65863. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  65864. * The queries will try to find a solution within those bounds
  65865. * default is (1,1,1)
  65866. * @param extent x,y,z value that define the extent around the queries point of reference
  65867. */
  65868. setDefaultQueryExtent(extent: Vector3): void;
  65869. /**
  65870. * Get the Bounding box extent specified by setDefaultQueryExtent
  65871. * @returns the box extent values
  65872. */
  65873. getDefaultQueryExtent(): Vector3;
  65874. /**
  65875. * Get the Bounding box extent result specified by setDefaultQueryExtent
  65876. * @param result output the box extent values
  65877. */
  65878. getDefaultQueryExtentToRef(result: Vector3): void;
  65879. /**
  65880. * Release all resources
  65881. */
  65882. dispose(): void;
  65883. }
  65884. /**
  65885. * Configures an agent
  65886. */
  65887. export interface IAgentParameters {
  65888. /**
  65889. * Agent radius. [Limit: >= 0]
  65890. */
  65891. radius: number;
  65892. /**
  65893. * Agent height. [Limit: > 0]
  65894. */
  65895. height: number;
  65896. /**
  65897. * Maximum allowed acceleration. [Limit: >= 0]
  65898. */
  65899. maxAcceleration: number;
  65900. /**
  65901. * Maximum allowed speed. [Limit: >= 0]
  65902. */
  65903. maxSpeed: number;
  65904. /**
  65905. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  65906. */
  65907. collisionQueryRange: number;
  65908. /**
  65909. * The path visibility optimization range. [Limit: > 0]
  65910. */
  65911. pathOptimizationRange: number;
  65912. /**
  65913. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  65914. */
  65915. separationWeight: number;
  65916. }
  65917. /**
  65918. * Configures the navigation mesh creation
  65919. */
  65920. export interface INavMeshParameters {
  65921. /**
  65922. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  65923. */
  65924. cs: number;
  65925. /**
  65926. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  65927. */
  65928. ch: number;
  65929. /**
  65930. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  65931. */
  65932. walkableSlopeAngle: number;
  65933. /**
  65934. * Minimum floor to 'ceiling' height that will still allow the floor area to
  65935. * be considered walkable. [Limit: >= 3] [Units: vx]
  65936. */
  65937. walkableHeight: number;
  65938. /**
  65939. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  65940. */
  65941. walkableClimb: number;
  65942. /**
  65943. * The distance to erode/shrink the walkable area of the heightfield away from
  65944. * obstructions. [Limit: >=0] [Units: vx]
  65945. */
  65946. walkableRadius: number;
  65947. /**
  65948. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  65949. */
  65950. maxEdgeLen: number;
  65951. /**
  65952. * The maximum distance a simplfied contour's border edges should deviate
  65953. * the original raw contour. [Limit: >=0] [Units: vx]
  65954. */
  65955. maxSimplificationError: number;
  65956. /**
  65957. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  65958. */
  65959. minRegionArea: number;
  65960. /**
  65961. * Any regions with a span count smaller than this value will, if possible,
  65962. * be merged with larger regions. [Limit: >=0] [Units: vx]
  65963. */
  65964. mergeRegionArea: number;
  65965. /**
  65966. * The maximum number of vertices allowed for polygons generated during the
  65967. * contour to polygon conversion process. [Limit: >= 3]
  65968. */
  65969. maxVertsPerPoly: number;
  65970. /**
  65971. * Sets the sampling distance to use when generating the detail mesh.
  65972. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  65973. */
  65974. detailSampleDist: number;
  65975. /**
  65976. * The maximum distance the detail mesh surface should deviate from heightfield
  65977. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  65978. */
  65979. detailSampleMaxError: number;
  65980. }
  65981. }
  65982. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  65983. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  65984. import { Mesh } from "babylonjs/Meshes/mesh";
  65985. import { Scene } from "babylonjs/scene";
  65986. import { Vector3 } from "babylonjs/Maths/math";
  65987. import { TransformNode } from "babylonjs/Meshes/transformNode";
  65988. /**
  65989. * RecastJS navigation plugin
  65990. */
  65991. export class RecastJSPlugin implements INavigationEnginePlugin {
  65992. /**
  65993. * Reference to the Recast library
  65994. */
  65995. bjsRECAST: any;
  65996. /**
  65997. * plugin name
  65998. */
  65999. name: string;
  66000. /**
  66001. * the first navmesh created. We might extend this to support multiple navmeshes
  66002. */
  66003. navMesh: any;
  66004. /**
  66005. * Initializes the recastJS plugin
  66006. * @param recastInjection can be used to inject your own recast reference
  66007. */
  66008. constructor(recastInjection?: any);
  66009. /**
  66010. * Creates a navigation mesh
  66011. * @param meshes array of all the geometry used to compute the navigatio mesh
  66012. * @param parameters bunch of parameters used to filter geometry
  66013. */
  66014. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  66015. /**
  66016. * Create a navigation mesh debug mesh
  66017. * @param scene is where the mesh will be added
  66018. * @returns debug display mesh
  66019. */
  66020. createDebugNavMesh(scene: Scene): Mesh;
  66021. /**
  66022. * Get a navigation mesh constrained position, closest to the parameter position
  66023. * @param position world position
  66024. * @returns the closest point to position constrained by the navigation mesh
  66025. */
  66026. getClosestPoint(position: Vector3): Vector3;
  66027. /**
  66028. * Get a navigation mesh constrained position, closest to the parameter position
  66029. * @param position world position
  66030. * @param result output the closest point to position constrained by the navigation mesh
  66031. */
  66032. getClosestPointToRef(position: Vector3, result: Vector3): void;
  66033. /**
  66034. * Get a navigation mesh constrained position, within a particular radius
  66035. * @param position world position
  66036. * @param maxRadius the maximum distance to the constrained world position
  66037. * @returns the closest point to position constrained by the navigation mesh
  66038. */
  66039. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  66040. /**
  66041. * Get a navigation mesh constrained position, within a particular radius
  66042. * @param position world position
  66043. * @param maxRadius the maximum distance to the constrained world position
  66044. * @param result output the closest point to position constrained by the navigation mesh
  66045. */
  66046. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  66047. /**
  66048. * Compute the final position from a segment made of destination-position
  66049. * @param position world position
  66050. * @param destination world position
  66051. * @returns the resulting point along the navmesh
  66052. */
  66053. moveAlong(position: Vector3, destination: Vector3): Vector3;
  66054. /**
  66055. * Compute the final position from a segment made of destination-position
  66056. * @param position world position
  66057. * @param destination world position
  66058. * @param result output the resulting point along the navmesh
  66059. */
  66060. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  66061. /**
  66062. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  66063. * @param start world position
  66064. * @param end world position
  66065. * @returns array containing world position composing the path
  66066. */
  66067. computePath(start: Vector3, end: Vector3): Vector3[];
  66068. /**
  66069. * Create a new Crowd so you can add agents
  66070. * @param maxAgents the maximum agent count in the crowd
  66071. * @param maxAgentRadius the maximum radius an agent can have
  66072. * @param scene to attach the crowd to
  66073. * @returns the crowd you can add agents to
  66074. */
  66075. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  66076. /**
  66077. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66078. * The queries will try to find a solution within those bounds
  66079. * default is (1,1,1)
  66080. * @param extent x,y,z value that define the extent around the queries point of reference
  66081. */
  66082. setDefaultQueryExtent(extent: Vector3): void;
  66083. /**
  66084. * Get the Bounding box extent specified by setDefaultQueryExtent
  66085. * @returns the box extent values
  66086. */
  66087. getDefaultQueryExtent(): Vector3;
  66088. /**
  66089. * build the navmesh from a previously saved state using getNavmeshData
  66090. * @param data the Uint8Array returned by getNavmeshData
  66091. */
  66092. buildFromNavmeshData(data: Uint8Array): void;
  66093. /**
  66094. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  66095. * @returns data the Uint8Array that can be saved and reused
  66096. */
  66097. getNavmeshData(): Uint8Array;
  66098. /**
  66099. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66100. * @param result output the box extent values
  66101. */
  66102. getDefaultQueryExtentToRef(result: Vector3): void;
  66103. /**
  66104. * Disposes
  66105. */
  66106. dispose(): void;
  66107. /**
  66108. * If this plugin is supported
  66109. * @returns true if plugin is supported
  66110. */
  66111. isSupported(): boolean;
  66112. }
  66113. /**
  66114. * Recast detour crowd implementation
  66115. */
  66116. export class RecastJSCrowd implements ICrowd {
  66117. /**
  66118. * Recast/detour plugin
  66119. */
  66120. bjsRECASTPlugin: RecastJSPlugin;
  66121. /**
  66122. * Link to the detour crowd
  66123. */
  66124. recastCrowd: any;
  66125. /**
  66126. * One transform per agent
  66127. */
  66128. transforms: TransformNode[];
  66129. /**
  66130. * All agents created
  66131. */
  66132. agents: number[];
  66133. /**
  66134. * Link to the scene is kept to unregister the crowd from the scene
  66135. */
  66136. private _scene;
  66137. /**
  66138. * Observer for crowd updates
  66139. */
  66140. private _onBeforeAnimationsObserver;
  66141. /**
  66142. * Constructor
  66143. * @param plugin recastJS plugin
  66144. * @param maxAgents the maximum agent count in the crowd
  66145. * @param maxAgentRadius the maximum radius an agent can have
  66146. * @param scene to attach the crowd to
  66147. * @returns the crowd you can add agents to
  66148. */
  66149. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  66150. /**
  66151. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  66152. * You can attach anything to that node. The node position is updated in the scene update tick.
  66153. * @param pos world position that will be constrained by the navigation mesh
  66154. * @param parameters agent parameters
  66155. * @param transform hooked to the agent that will be update by the scene
  66156. * @returns agent index
  66157. */
  66158. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  66159. /**
  66160. * Returns the agent position in world space
  66161. * @param index agent index returned by addAgent
  66162. * @returns world space position
  66163. */
  66164. getAgentPosition(index: number): Vector3;
  66165. /**
  66166. * Returns the agent position result in world space
  66167. * @param index agent index returned by addAgent
  66168. * @param result output world space position
  66169. */
  66170. getAgentPositionToRef(index: number, result: Vector3): void;
  66171. /**
  66172. * Returns the agent velocity in world space
  66173. * @param index agent index returned by addAgent
  66174. * @returns world space velocity
  66175. */
  66176. getAgentVelocity(index: number): Vector3;
  66177. /**
  66178. * Returns the agent velocity result in world space
  66179. * @param index agent index returned by addAgent
  66180. * @param result output world space velocity
  66181. */
  66182. getAgentVelocityToRef(index: number, result: Vector3): void;
  66183. /**
  66184. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  66185. * @param index agent index returned by addAgent
  66186. * @param destination targeted world position
  66187. */
  66188. agentGoto(index: number, destination: Vector3): void;
  66189. /**
  66190. * Teleport the agent to a new position
  66191. * @param index agent index returned by addAgent
  66192. * @param destination targeted world position
  66193. */
  66194. agentTeleport(index: number, destination: Vector3): void;
  66195. /**
  66196. * Update agent parameters
  66197. * @param index agent index returned by addAgent
  66198. * @param parameters agent parameters
  66199. */
  66200. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  66201. /**
  66202. * remove a particular agent previously created
  66203. * @param index agent index returned by addAgent
  66204. */
  66205. removeAgent(index: number): void;
  66206. /**
  66207. * get the list of all agents attached to this crowd
  66208. * @returns list of agent indices
  66209. */
  66210. getAgents(): number[];
  66211. /**
  66212. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  66213. * @param deltaTime in seconds
  66214. */
  66215. update(deltaTime: number): void;
  66216. /**
  66217. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  66218. * The queries will try to find a solution within those bounds
  66219. * default is (1,1,1)
  66220. * @param extent x,y,z value that define the extent around the queries point of reference
  66221. */
  66222. setDefaultQueryExtent(extent: Vector3): void;
  66223. /**
  66224. * Get the Bounding box extent specified by setDefaultQueryExtent
  66225. * @returns the box extent values
  66226. */
  66227. getDefaultQueryExtent(): Vector3;
  66228. /**
  66229. * Get the Bounding box extent result specified by setDefaultQueryExtent
  66230. * @param result output the box extent values
  66231. */
  66232. getDefaultQueryExtentToRef(result: Vector3): void;
  66233. /**
  66234. * Release all resources
  66235. */
  66236. dispose(): void;
  66237. }
  66238. }
  66239. declare module "babylonjs/Navigation/Plugins/index" {
  66240. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  66241. }
  66242. declare module "babylonjs/Navigation/index" {
  66243. export * from "babylonjs/Navigation/INavigationEngine";
  66244. export * from "babylonjs/Navigation/Plugins/index";
  66245. }
  66246. declare module "babylonjs/Offline/database" {
  66247. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  66248. /**
  66249. * Class used to enable access to IndexedDB
  66250. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  66251. */
  66252. export class Database implements IOfflineProvider {
  66253. private _callbackManifestChecked;
  66254. private _currentSceneUrl;
  66255. private _db;
  66256. private _enableSceneOffline;
  66257. private _enableTexturesOffline;
  66258. private _manifestVersionFound;
  66259. private _mustUpdateRessources;
  66260. private _hasReachedQuota;
  66261. private _isSupported;
  66262. private _idbFactory;
  66263. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  66264. private static IsUASupportingBlobStorage;
  66265. /**
  66266. * Gets a boolean indicating if Database storate is enabled (off by default)
  66267. */
  66268. static IDBStorageEnabled: boolean;
  66269. /**
  66270. * Gets a boolean indicating if scene must be saved in the database
  66271. */
  66272. get enableSceneOffline(): boolean;
  66273. /**
  66274. * Gets a boolean indicating if textures must be saved in the database
  66275. */
  66276. get enableTexturesOffline(): boolean;
  66277. /**
  66278. * Creates a new Database
  66279. * @param urlToScene defines the url to load the scene
  66280. * @param callbackManifestChecked defines the callback to use when manifest is checked
  66281. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  66282. */
  66283. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  66284. private static _ParseURL;
  66285. private static _ReturnFullUrlLocation;
  66286. private _checkManifestFile;
  66287. /**
  66288. * Open the database and make it available
  66289. * @param successCallback defines the callback to call on success
  66290. * @param errorCallback defines the callback to call on error
  66291. */
  66292. open(successCallback: () => void, errorCallback: () => void): void;
  66293. /**
  66294. * Loads an image from the database
  66295. * @param url defines the url to load from
  66296. * @param image defines the target DOM image
  66297. */
  66298. loadImage(url: string, image: HTMLImageElement): void;
  66299. private _loadImageFromDBAsync;
  66300. private _saveImageIntoDBAsync;
  66301. private _checkVersionFromDB;
  66302. private _loadVersionFromDBAsync;
  66303. private _saveVersionIntoDBAsync;
  66304. /**
  66305. * Loads a file from database
  66306. * @param url defines the URL to load from
  66307. * @param sceneLoaded defines a callback to call on success
  66308. * @param progressCallBack defines a callback to call when progress changed
  66309. * @param errorCallback defines a callback to call on error
  66310. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  66311. */
  66312. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  66313. private _loadFileAsync;
  66314. private _saveFileAsync;
  66315. /**
  66316. * Validates if xhr data is correct
  66317. * @param xhr defines the request to validate
  66318. * @param dataType defines the expected data type
  66319. * @returns true if data is correct
  66320. */
  66321. private static _ValidateXHRData;
  66322. }
  66323. }
  66324. declare module "babylonjs/Offline/index" {
  66325. export * from "babylonjs/Offline/database";
  66326. export * from "babylonjs/Offline/IOfflineProvider";
  66327. }
  66328. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  66329. /** @hidden */
  66330. export var gpuUpdateParticlesPixelShader: {
  66331. name: string;
  66332. shader: string;
  66333. };
  66334. }
  66335. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  66336. /** @hidden */
  66337. export var gpuUpdateParticlesVertexShader: {
  66338. name: string;
  66339. shader: string;
  66340. };
  66341. }
  66342. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  66343. /** @hidden */
  66344. export var clipPlaneFragmentDeclaration2: {
  66345. name: string;
  66346. shader: string;
  66347. };
  66348. }
  66349. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  66350. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  66351. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  66352. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66353. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  66354. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  66355. /** @hidden */
  66356. export var gpuRenderParticlesPixelShader: {
  66357. name: string;
  66358. shader: string;
  66359. };
  66360. }
  66361. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  66362. /** @hidden */
  66363. export var clipPlaneVertexDeclaration2: {
  66364. name: string;
  66365. shader: string;
  66366. };
  66367. }
  66368. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  66369. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  66370. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  66371. /** @hidden */
  66372. export var gpuRenderParticlesVertexShader: {
  66373. name: string;
  66374. shader: string;
  66375. };
  66376. }
  66377. declare module "babylonjs/Particles/gpuParticleSystem" {
  66378. import { Nullable } from "babylonjs/types";
  66379. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  66380. import { Observable } from "babylonjs/Misc/observable";
  66381. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  66382. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66383. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  66384. import { Scene, IDisposable } from "babylonjs/scene";
  66385. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  66386. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  66387. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  66388. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  66389. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  66390. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  66391. /**
  66392. * This represents a GPU particle system in Babylon
  66393. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  66394. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  66395. */
  66396. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  66397. /**
  66398. * The layer mask we are rendering the particles through.
  66399. */
  66400. layerMask: number;
  66401. private _capacity;
  66402. private _activeCount;
  66403. private _currentActiveCount;
  66404. private _accumulatedCount;
  66405. private _renderEffect;
  66406. private _updateEffect;
  66407. private _buffer0;
  66408. private _buffer1;
  66409. private _spriteBuffer;
  66410. private _updateVAO;
  66411. private _renderVAO;
  66412. private _targetIndex;
  66413. private _sourceBuffer;
  66414. private _targetBuffer;
  66415. private _engine;
  66416. private _currentRenderId;
  66417. private _started;
  66418. private _stopped;
  66419. private _timeDelta;
  66420. private _randomTexture;
  66421. private _randomTexture2;
  66422. private _attributesStrideSize;
  66423. private _updateEffectOptions;
  66424. private _randomTextureSize;
  66425. private _actualFrame;
  66426. private readonly _rawTextureWidth;
  66427. /**
  66428. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  66429. */
  66430. static get IsSupported(): boolean;
  66431. /**
  66432. * An event triggered when the system is disposed.
  66433. */
  66434. onDisposeObservable: Observable<GPUParticleSystem>;
  66435. /**
  66436. * Gets the maximum number of particles active at the same time.
  66437. * @returns The max number of active particles.
  66438. */
  66439. getCapacity(): number;
  66440. /**
  66441. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  66442. * to override the particles.
  66443. */
  66444. forceDepthWrite: boolean;
  66445. /**
  66446. * Gets or set the number of active particles
  66447. */
  66448. get activeParticleCount(): number;
  66449. set activeParticleCount(value: number);
  66450. private _preWarmDone;
  66451. /**
  66452. * Specifies if the particles are updated in emitter local space or world space.
  66453. * This is always false for GPU particles
  66454. */
  66455. get isLocal(): boolean;
  66456. set isLocal(value: boolean);
  66457. /**
  66458. * Is this system ready to be used/rendered
  66459. * @return true if the system is ready
  66460. */
  66461. isReady(): boolean;
  66462. /**
  66463. * Gets if the system has been started. (Note: this will still be true after stop is called)
  66464. * @returns True if it has been started, otherwise false.
  66465. */
  66466. isStarted(): boolean;
  66467. /**
  66468. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  66469. * @returns True if it has been stopped, otherwise false.
  66470. */
  66471. isStopped(): boolean;
  66472. /**
  66473. * Gets a boolean indicating that the system is stopping
  66474. * @returns true if the system is currently stopping
  66475. */
  66476. isStopping(): boolean;
  66477. /**
  66478. * Gets the number of particles active at the same time.
  66479. * @returns The number of active particles.
  66480. */
  66481. getActiveCount(): number;
  66482. /**
  66483. * Starts the particle system and begins to emit
  66484. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  66485. */
  66486. start(delay?: number): void;
  66487. /**
  66488. * Stops the particle system.
  66489. */
  66490. stop(): void;
  66491. /**
  66492. * Remove all active particles
  66493. */
  66494. reset(): void;
  66495. /**
  66496. * Returns the string "GPUParticleSystem"
  66497. * @returns a string containing the class name
  66498. */
  66499. getClassName(): string;
  66500. private _colorGradientsTexture;
  66501. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  66502. /**
  66503. * Adds a new color gradient
  66504. * @param gradient defines the gradient to use (between 0 and 1)
  66505. * @param color1 defines the color to affect to the specified gradient
  66506. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  66507. * @returns the current particle system
  66508. */
  66509. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  66510. private _refreshColorGradient;
  66511. /** Force the system to rebuild all gradients that need to be resync */
  66512. forceRefreshGradients(): void;
  66513. /**
  66514. * Remove a specific color gradient
  66515. * @param gradient defines the gradient to remove
  66516. * @returns the current particle system
  66517. */
  66518. removeColorGradient(gradient: number): GPUParticleSystem;
  66519. private _angularSpeedGradientsTexture;
  66520. private _sizeGradientsTexture;
  66521. private _velocityGradientsTexture;
  66522. private _limitVelocityGradientsTexture;
  66523. private _dragGradientsTexture;
  66524. private _addFactorGradient;
  66525. /**
  66526. * Adds a new size gradient
  66527. * @param gradient defines the gradient to use (between 0 and 1)
  66528. * @param factor defines the size factor to affect to the specified gradient
  66529. * @returns the current particle system
  66530. */
  66531. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  66532. /**
  66533. * Remove a specific size gradient
  66534. * @param gradient defines the gradient to remove
  66535. * @returns the current particle system
  66536. */
  66537. removeSizeGradient(gradient: number): GPUParticleSystem;
  66538. private _refreshFactorGradient;
  66539. /**
  66540. * Adds a new angular speed gradient
  66541. * @param gradient defines the gradient to use (between 0 and 1)
  66542. * @param factor defines the angular speed to affect to the specified gradient
  66543. * @returns the current particle system
  66544. */
  66545. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  66546. /**
  66547. * Remove a specific angular speed gradient
  66548. * @param gradient defines the gradient to remove
  66549. * @returns the current particle system
  66550. */
  66551. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  66552. /**
  66553. * Adds a new velocity gradient
  66554. * @param gradient defines the gradient to use (between 0 and 1)
  66555. * @param factor defines the velocity to affect to the specified gradient
  66556. * @returns the current particle system
  66557. */
  66558. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66559. /**
  66560. * Remove a specific velocity gradient
  66561. * @param gradient defines the gradient to remove
  66562. * @returns the current particle system
  66563. */
  66564. removeVelocityGradient(gradient: number): GPUParticleSystem;
  66565. /**
  66566. * Adds a new limit velocity gradient
  66567. * @param gradient defines the gradient to use (between 0 and 1)
  66568. * @param factor defines the limit velocity value to affect to the specified gradient
  66569. * @returns the current particle system
  66570. */
  66571. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  66572. /**
  66573. * Remove a specific limit velocity gradient
  66574. * @param gradient defines the gradient to remove
  66575. * @returns the current particle system
  66576. */
  66577. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  66578. /**
  66579. * Adds a new drag gradient
  66580. * @param gradient defines the gradient to use (between 0 and 1)
  66581. * @param factor defines the drag value to affect to the specified gradient
  66582. * @returns the current particle system
  66583. */
  66584. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  66585. /**
  66586. * Remove a specific drag gradient
  66587. * @param gradient defines the gradient to remove
  66588. * @returns the current particle system
  66589. */
  66590. removeDragGradient(gradient: number): GPUParticleSystem;
  66591. /**
  66592. * Not supported by GPUParticleSystem
  66593. * @param gradient defines the gradient to use (between 0 and 1)
  66594. * @param factor defines the emit rate value to affect to the specified gradient
  66595. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66596. * @returns the current particle system
  66597. */
  66598. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66599. /**
  66600. * Not supported by GPUParticleSystem
  66601. * @param gradient defines the gradient to remove
  66602. * @returns the current particle system
  66603. */
  66604. removeEmitRateGradient(gradient: number): IParticleSystem;
  66605. /**
  66606. * Not supported by GPUParticleSystem
  66607. * @param gradient defines the gradient to use (between 0 and 1)
  66608. * @param factor defines the start size value to affect to the specified gradient
  66609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66610. * @returns the current particle system
  66611. */
  66612. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66613. /**
  66614. * Not supported by GPUParticleSystem
  66615. * @param gradient defines the gradient to remove
  66616. * @returns the current particle system
  66617. */
  66618. removeStartSizeGradient(gradient: number): IParticleSystem;
  66619. /**
  66620. * Not supported by GPUParticleSystem
  66621. * @param gradient defines the gradient to use (between 0 and 1)
  66622. * @param min defines the color remap minimal range
  66623. * @param max defines the color remap maximal range
  66624. * @returns the current particle system
  66625. */
  66626. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66627. /**
  66628. * Not supported by GPUParticleSystem
  66629. * @param gradient defines the gradient to remove
  66630. * @returns the current particle system
  66631. */
  66632. removeColorRemapGradient(): IParticleSystem;
  66633. /**
  66634. * Not supported by GPUParticleSystem
  66635. * @param gradient defines the gradient to use (between 0 and 1)
  66636. * @param min defines the alpha remap minimal range
  66637. * @param max defines the alpha remap maximal range
  66638. * @returns the current particle system
  66639. */
  66640. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  66641. /**
  66642. * Not supported by GPUParticleSystem
  66643. * @param gradient defines the gradient to remove
  66644. * @returns the current particle system
  66645. */
  66646. removeAlphaRemapGradient(): IParticleSystem;
  66647. /**
  66648. * Not supported by GPUParticleSystem
  66649. * @param gradient defines the gradient to use (between 0 and 1)
  66650. * @param color defines the color to affect to the specified gradient
  66651. * @returns the current particle system
  66652. */
  66653. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  66654. /**
  66655. * Not supported by GPUParticleSystem
  66656. * @param gradient defines the gradient to remove
  66657. * @returns the current particle system
  66658. */
  66659. removeRampGradient(): IParticleSystem;
  66660. /**
  66661. * Not supported by GPUParticleSystem
  66662. * @returns the list of ramp gradients
  66663. */
  66664. getRampGradients(): Nullable<Array<Color3Gradient>>;
  66665. /**
  66666. * Not supported by GPUParticleSystem
  66667. * Gets or sets a boolean indicating that ramp gradients must be used
  66668. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  66669. */
  66670. get useRampGradients(): boolean;
  66671. set useRampGradients(value: boolean);
  66672. /**
  66673. * Not supported by GPUParticleSystem
  66674. * @param gradient defines the gradient to use (between 0 and 1)
  66675. * @param factor defines the life time factor to affect to the specified gradient
  66676. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  66677. * @returns the current particle system
  66678. */
  66679. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  66680. /**
  66681. * Not supported by GPUParticleSystem
  66682. * @param gradient defines the gradient to remove
  66683. * @returns the current particle system
  66684. */
  66685. removeLifeTimeGradient(gradient: number): IParticleSystem;
  66686. /**
  66687. * Instantiates a GPU particle system.
  66688. * 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.
  66689. * @param name The name of the particle system
  66690. * @param options The options used to create the system
  66691. * @param scene The scene the particle system belongs to
  66692. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  66693. */
  66694. constructor(name: string, options: Partial<{
  66695. capacity: number;
  66696. randomTextureSize: number;
  66697. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  66698. protected _reset(): void;
  66699. private _createUpdateVAO;
  66700. private _createRenderVAO;
  66701. private _initialize;
  66702. /** @hidden */
  66703. _recreateUpdateEffect(): void;
  66704. /** @hidden */
  66705. _recreateRenderEffect(): void;
  66706. /**
  66707. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  66708. * @param preWarm defines if we are in the pre-warmimg phase
  66709. */
  66710. animate(preWarm?: boolean): void;
  66711. private _createFactorGradientTexture;
  66712. private _createSizeGradientTexture;
  66713. private _createAngularSpeedGradientTexture;
  66714. private _createVelocityGradientTexture;
  66715. private _createLimitVelocityGradientTexture;
  66716. private _createDragGradientTexture;
  66717. private _createColorGradientTexture;
  66718. /**
  66719. * Renders the particle system in its current state
  66720. * @param preWarm defines if the system should only update the particles but not render them
  66721. * @returns the current number of particles
  66722. */
  66723. render(preWarm?: boolean): number;
  66724. /**
  66725. * Rebuilds the particle system
  66726. */
  66727. rebuild(): void;
  66728. private _releaseBuffers;
  66729. private _releaseVAOs;
  66730. /**
  66731. * Disposes the particle system and free the associated resources
  66732. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  66733. */
  66734. dispose(disposeTexture?: boolean): void;
  66735. /**
  66736. * Clones the particle system.
  66737. * @param name The name of the cloned object
  66738. * @param newEmitter The new emitter to use
  66739. * @returns the cloned particle system
  66740. */
  66741. clone(name: string, newEmitter: any): GPUParticleSystem;
  66742. /**
  66743. * Serializes the particle system to a JSON object
  66744. * @param serializeTexture defines if the texture must be serialized as well
  66745. * @returns the JSON object
  66746. */
  66747. serialize(serializeTexture?: boolean): any;
  66748. /**
  66749. * Parses a JSON object to create a GPU particle system.
  66750. * @param parsedParticleSystem The JSON object to parse
  66751. * @param scene The scene to create the particle system in
  66752. * @param rootUrl The root url to use to load external dependencies like texture
  66753. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  66754. * @returns the parsed GPU particle system
  66755. */
  66756. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  66757. }
  66758. }
  66759. declare module "babylonjs/Particles/particleSystemSet" {
  66760. import { Nullable } from "babylonjs/types";
  66761. import { Color3 } from "babylonjs/Maths/math.color";
  66762. import { TransformNode } from "babylonjs/Meshes/transformNode";
  66763. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66764. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66765. import { Scene, IDisposable } from "babylonjs/scene";
  66766. /**
  66767. * Represents a set of particle systems working together to create a specific effect
  66768. */
  66769. export class ParticleSystemSet implements IDisposable {
  66770. /**
  66771. * Gets or sets base Assets URL
  66772. */
  66773. static BaseAssetsUrl: string;
  66774. private _emitterCreationOptions;
  66775. private _emitterNode;
  66776. /**
  66777. * Gets the particle system list
  66778. */
  66779. systems: IParticleSystem[];
  66780. /**
  66781. * Gets the emitter node used with this set
  66782. */
  66783. get emitterNode(): Nullable<TransformNode>;
  66784. /**
  66785. * Creates a new emitter mesh as a sphere
  66786. * @param options defines the options used to create the sphere
  66787. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  66788. * @param scene defines the hosting scene
  66789. */
  66790. setEmitterAsSphere(options: {
  66791. diameter: number;
  66792. segments: number;
  66793. color: Color3;
  66794. }, renderingGroupId: number, scene: Scene): void;
  66795. /**
  66796. * Starts all particle systems of the set
  66797. * @param emitter defines an optional mesh to use as emitter for the particle systems
  66798. */
  66799. start(emitter?: AbstractMesh): void;
  66800. /**
  66801. * Release all associated resources
  66802. */
  66803. dispose(): void;
  66804. /**
  66805. * Serialize the set into a JSON compatible object
  66806. * @param serializeTexture defines if the texture must be serialized as well
  66807. * @returns a JSON compatible representation of the set
  66808. */
  66809. serialize(serializeTexture?: boolean): any;
  66810. /**
  66811. * Parse a new ParticleSystemSet from a serialized source
  66812. * @param data defines a JSON compatible representation of the set
  66813. * @param scene defines the hosting scene
  66814. * @param gpu defines if we want GPU particles or CPU particles
  66815. * @returns a new ParticleSystemSet
  66816. */
  66817. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  66818. }
  66819. }
  66820. declare module "babylonjs/Particles/particleHelper" {
  66821. import { Nullable } from "babylonjs/types";
  66822. import { Scene } from "babylonjs/scene";
  66823. import { Vector3 } from "babylonjs/Maths/math.vector";
  66824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66825. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66826. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  66827. /**
  66828. * This class is made for on one-liner static method to help creating particle system set.
  66829. */
  66830. export class ParticleHelper {
  66831. /**
  66832. * Gets or sets base Assets URL
  66833. */
  66834. static BaseAssetsUrl: string;
  66835. /** Define the Url to load snippets */
  66836. static SnippetUrl: string;
  66837. /**
  66838. * Create a default particle system that you can tweak
  66839. * @param emitter defines the emitter to use
  66840. * @param capacity defines the system capacity (default is 500 particles)
  66841. * @param scene defines the hosting scene
  66842. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  66843. * @returns the new Particle system
  66844. */
  66845. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  66846. /**
  66847. * This is the main static method (one-liner) of this helper to create different particle systems
  66848. * @param type This string represents the type to the particle system to create
  66849. * @param scene The scene where the particle system should live
  66850. * @param gpu If the system will use gpu
  66851. * @returns the ParticleSystemSet created
  66852. */
  66853. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  66854. /**
  66855. * Static function used to export a particle system to a ParticleSystemSet variable.
  66856. * Please note that the emitter shape is not exported
  66857. * @param systems defines the particle systems to export
  66858. * @returns the created particle system set
  66859. */
  66860. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  66861. /**
  66862. * Creates a particle system from a snippet saved in a remote file
  66863. * @param name defines the name of the particle system to create
  66864. * @param url defines the url to load from
  66865. * @param scene defines the hosting scene
  66866. * @param gpu If the system will use gpu
  66867. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66868. * @returns a promise that will resolve to the new particle system
  66869. */
  66870. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66871. /**
  66872. * Creates a particle system from a snippet saved by the particle system editor
  66873. * @param snippetId defines the snippet to load
  66874. * @param scene defines the hosting scene
  66875. * @param gpu If the system will use gpu
  66876. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  66877. * @returns a promise that will resolve to the new particle system
  66878. */
  66879. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  66880. }
  66881. }
  66882. declare module "babylonjs/Particles/particleSystemComponent" {
  66883. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  66884. import { Effect } from "babylonjs/Materials/effect";
  66885. import "babylonjs/Shaders/particles.vertex";
  66886. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  66887. module "babylonjs/Engines/engine" {
  66888. interface Engine {
  66889. /**
  66890. * Create an effect to use with particle systems.
  66891. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  66892. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  66893. * @param uniformsNames defines a list of attribute names
  66894. * @param samplers defines an array of string used to represent textures
  66895. * @param defines defines the string containing the defines to use to compile the shaders
  66896. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  66897. * @param onCompiled defines a function to call when the effect creation is successful
  66898. * @param onError defines a function to call when the effect creation has failed
  66899. * @returns the new Effect
  66900. */
  66901. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  66902. }
  66903. }
  66904. module "babylonjs/Meshes/mesh" {
  66905. interface Mesh {
  66906. /**
  66907. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  66908. * @returns an array of IParticleSystem
  66909. */
  66910. getEmittedParticleSystems(): IParticleSystem[];
  66911. /**
  66912. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  66913. * @returns an array of IParticleSystem
  66914. */
  66915. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  66916. }
  66917. }
  66918. /**
  66919. * @hidden
  66920. */
  66921. export var _IDoNeedToBeInTheBuild: number;
  66922. }
  66923. declare module "babylonjs/Particles/pointsCloudSystem" {
  66924. import { Color4 } from "babylonjs/Maths/math";
  66925. import { Mesh } from "babylonjs/Meshes/mesh";
  66926. import { Scene, IDisposable } from "babylonjs/scene";
  66927. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  66928. /** Defines the 4 color options */
  66929. export enum PointColor {
  66930. /** color value */
  66931. Color = 2,
  66932. /** uv value */
  66933. UV = 1,
  66934. /** random value */
  66935. Random = 0,
  66936. /** stated value */
  66937. Stated = 3
  66938. }
  66939. /**
  66940. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  66941. * 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.
  66942. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  66943. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  66944. *
  66945. * Full documentation here : TO BE ENTERED
  66946. */
  66947. export class PointsCloudSystem implements IDisposable {
  66948. /**
  66949. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  66950. * Example : var p = SPS.particles[i];
  66951. */
  66952. particles: CloudPoint[];
  66953. /**
  66954. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  66955. */
  66956. nbParticles: number;
  66957. /**
  66958. * This a counter for your own usage. It's not set by any SPS functions.
  66959. */
  66960. counter: number;
  66961. /**
  66962. * The PCS name. This name is also given to the underlying mesh.
  66963. */
  66964. name: string;
  66965. /**
  66966. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  66967. */
  66968. mesh: Mesh;
  66969. /**
  66970. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  66971. * Please read :
  66972. */
  66973. vars: any;
  66974. /**
  66975. * @hidden
  66976. */
  66977. _size: number;
  66978. private _scene;
  66979. private _promises;
  66980. private _positions;
  66981. private _indices;
  66982. private _normals;
  66983. private _colors;
  66984. private _uvs;
  66985. private _indices32;
  66986. private _positions32;
  66987. private _colors32;
  66988. private _uvs32;
  66989. private _updatable;
  66990. private _isVisibilityBoxLocked;
  66991. private _alwaysVisible;
  66992. private _groups;
  66993. private _groupCounter;
  66994. private _computeParticleColor;
  66995. private _computeParticleTexture;
  66996. private _computeParticleRotation;
  66997. private _computeBoundingBox;
  66998. private _isReady;
  66999. /**
  67000. * Creates a PCS (Points Cloud System) object
  67001. * @param name (String) is the PCS name, this will be the underlying mesh name
  67002. * @param pointSize (number) is the size for each point
  67003. * @param scene (Scene) is the scene in which the PCS is added
  67004. * @param options defines the options of the PCS e.g.
  67005. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  67006. */
  67007. constructor(name: string, pointSize: number, scene: Scene, options?: {
  67008. updatable?: boolean;
  67009. });
  67010. /**
  67011. * Builds the PCS underlying mesh. Returns a standard Mesh.
  67012. * If no points were added to the PCS, the returned mesh is just a single point.
  67013. * @returns a promise for the created mesh
  67014. */
  67015. buildMeshAsync(): Promise<Mesh>;
  67016. /**
  67017. * @hidden
  67018. */
  67019. private _buildMesh;
  67020. private _addParticle;
  67021. private _randomUnitVector;
  67022. private _getColorIndicesForCoord;
  67023. private _setPointsColorOrUV;
  67024. private _colorFromTexture;
  67025. private _calculateDensity;
  67026. /**
  67027. * Adds points to the PCS in random positions within a unit sphere
  67028. * @param nb (positive integer) the number of particles to be created from this model
  67029. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  67030. * @returns the number of groups in the system
  67031. */
  67032. addPoints(nb: number, pointFunction?: any): number;
  67033. /**
  67034. * Adds points to the PCS from the surface of 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. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67043. /**
  67044. * Adds points to the PCS inside the model shape
  67045. * @param mesh is any Mesh object that will be used as a surface model for the points
  67046. * @param nb (positive integer) the number of particles to be created from this model
  67047. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  67048. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  67049. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  67050. * @returns the number of groups in the system
  67051. */
  67052. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  67053. /**
  67054. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  67055. * This method calls `updateParticle()` for each particle of the SPS.
  67056. * For an animated SPS, it is usually called within the render loop.
  67057. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  67058. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  67059. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  67060. * @returns the PCS.
  67061. */
  67062. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  67063. /**
  67064. * Disposes the PCS.
  67065. */
  67066. dispose(): void;
  67067. /**
  67068. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  67069. * doc :
  67070. * @returns the PCS.
  67071. */
  67072. refreshVisibleSize(): PointsCloudSystem;
  67073. /**
  67074. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  67075. * @param size the size (float) of the visibility box
  67076. * note : this doesn't lock the PCS mesh bounding box.
  67077. * doc :
  67078. */
  67079. setVisibilityBox(size: number): void;
  67080. /**
  67081. * Gets whether the PCS is always visible or not
  67082. * doc :
  67083. */
  67084. get isAlwaysVisible(): boolean;
  67085. /**
  67086. * Sets the PCS as always visible or not
  67087. * doc :
  67088. */
  67089. set isAlwaysVisible(val: boolean);
  67090. /**
  67091. * Tells to `setParticles()` to compute the particle rotations or not
  67092. * Default value : false. The PCS is faster when it's set to false
  67093. * Note : particle rotations are only applied to parent particles
  67094. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  67095. */
  67096. set computeParticleRotation(val: boolean);
  67097. /**
  67098. * Tells to `setParticles()` to compute the particle colors or not.
  67099. * Default value : true. The PCS is faster when it's set to false.
  67100. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67101. */
  67102. set computeParticleColor(val: boolean);
  67103. set computeParticleTexture(val: boolean);
  67104. /**
  67105. * Gets if `setParticles()` computes the particle colors or not.
  67106. * Default value : false. The PCS is faster when it's set to false.
  67107. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  67108. */
  67109. get computeParticleColor(): boolean;
  67110. /**
  67111. * Gets if `setParticles()` computes the particle textures or not.
  67112. * Default value : false. The PCS is faster when it's set to false.
  67113. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  67114. */
  67115. get computeParticleTexture(): boolean;
  67116. /**
  67117. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  67118. */
  67119. set computeBoundingBox(val: boolean);
  67120. /**
  67121. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  67122. */
  67123. get computeBoundingBox(): boolean;
  67124. /**
  67125. * This function does nothing. It may be overwritten to set all the particle first values.
  67126. * The PCS doesn't call this function, you may have to call it by your own.
  67127. * doc :
  67128. */
  67129. initParticles(): void;
  67130. /**
  67131. * This function does nothing. It may be overwritten to recycle a particle
  67132. * The PCS doesn't call this function, you can to call it
  67133. * doc :
  67134. * @param particle The particle to recycle
  67135. * @returns the recycled particle
  67136. */
  67137. recycleParticle(particle: CloudPoint): CloudPoint;
  67138. /**
  67139. * Updates a particle : this function should be overwritten by the user.
  67140. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  67141. * doc :
  67142. * @example : just set a particle position or velocity and recycle conditions
  67143. * @param particle The particle to update
  67144. * @returns the updated particle
  67145. */
  67146. updateParticle(particle: CloudPoint): CloudPoint;
  67147. /**
  67148. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  67149. * This does nothing and may be overwritten by the user.
  67150. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67151. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67152. * @param update the boolean update value actually passed to setParticles()
  67153. */
  67154. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67155. /**
  67156. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  67157. * This will be passed three parameters.
  67158. * This does nothing and may be overwritten by the user.
  67159. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  67160. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  67161. * @param update the boolean update value actually passed to setParticles()
  67162. */
  67163. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  67164. }
  67165. }
  67166. declare module "babylonjs/Particles/cloudPoint" {
  67167. import { Nullable } from "babylonjs/types";
  67168. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  67169. import { Mesh } from "babylonjs/Meshes/mesh";
  67170. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  67171. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  67172. /**
  67173. * Represents one particle of a points cloud system.
  67174. */
  67175. export class CloudPoint {
  67176. /**
  67177. * particle global index
  67178. */
  67179. idx: number;
  67180. /**
  67181. * The color of the particle
  67182. */
  67183. color: Nullable<Color4>;
  67184. /**
  67185. * The world space position of the particle.
  67186. */
  67187. position: Vector3;
  67188. /**
  67189. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  67190. */
  67191. rotation: Vector3;
  67192. /**
  67193. * The world space rotation quaternion of the particle.
  67194. */
  67195. rotationQuaternion: Nullable<Quaternion>;
  67196. /**
  67197. * The uv of the particle.
  67198. */
  67199. uv: Nullable<Vector2>;
  67200. /**
  67201. * The current speed of the particle.
  67202. */
  67203. velocity: Vector3;
  67204. /**
  67205. * The pivot point in the particle local space.
  67206. */
  67207. pivot: Vector3;
  67208. /**
  67209. * Must the particle be translated from its pivot point in its local space ?
  67210. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  67211. * Default : false
  67212. */
  67213. translateFromPivot: boolean;
  67214. /**
  67215. * Index of this particle in the global "positions" array (Internal use)
  67216. * @hidden
  67217. */
  67218. _pos: number;
  67219. /**
  67220. * @hidden Index of this particle in the global "indices" array (Internal use)
  67221. */
  67222. _ind: number;
  67223. /**
  67224. * Group this particle belongs to
  67225. */
  67226. _group: PointsGroup;
  67227. /**
  67228. * Group id of this particle
  67229. */
  67230. groupId: number;
  67231. /**
  67232. * Index of the particle in its group id (Internal use)
  67233. */
  67234. idxInGroup: number;
  67235. /**
  67236. * @hidden Particle BoundingInfo object (Internal use)
  67237. */
  67238. _boundingInfo: BoundingInfo;
  67239. /**
  67240. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  67241. */
  67242. _pcs: PointsCloudSystem;
  67243. /**
  67244. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  67245. */
  67246. _stillInvisible: boolean;
  67247. /**
  67248. * @hidden Last computed particle rotation matrix
  67249. */
  67250. _rotationMatrix: number[];
  67251. /**
  67252. * Parent particle Id, if any.
  67253. * Default null.
  67254. */
  67255. parentId: Nullable<number>;
  67256. /**
  67257. * @hidden Internal global position in the PCS.
  67258. */
  67259. _globalPosition: Vector3;
  67260. /**
  67261. * Creates a Point Cloud object.
  67262. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  67263. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  67264. * @param group (PointsGroup) is the group the particle belongs to
  67265. * @param groupId (integer) is the group identifier in the PCS.
  67266. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  67267. * @param pcs defines the PCS it is associated to
  67268. */
  67269. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  67270. /**
  67271. * get point size
  67272. */
  67273. get size(): Vector3;
  67274. /**
  67275. * Set point size
  67276. */
  67277. set size(scale: Vector3);
  67278. /**
  67279. * Legacy support, changed quaternion to rotationQuaternion
  67280. */
  67281. get quaternion(): Nullable<Quaternion>;
  67282. /**
  67283. * Legacy support, changed quaternion to rotationQuaternion
  67284. */
  67285. set quaternion(q: Nullable<Quaternion>);
  67286. /**
  67287. * Returns a boolean. True if the particle intersects a mesh, else false
  67288. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  67289. * @param target is the object (point or mesh) what the intersection is computed against
  67290. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  67291. * @returns true if it intersects
  67292. */
  67293. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  67294. /**
  67295. * get the rotation matrix of the particle
  67296. * @hidden
  67297. */
  67298. getRotationMatrix(m: Matrix): void;
  67299. }
  67300. /**
  67301. * Represents a group of points in a points cloud system
  67302. * * PCS internal tool, don't use it manually.
  67303. */
  67304. export class PointsGroup {
  67305. /**
  67306. * The group id
  67307. * @hidden
  67308. */
  67309. groupID: number;
  67310. /**
  67311. * image data for group (internal use)
  67312. * @hidden
  67313. */
  67314. _groupImageData: Nullable<ArrayBufferView>;
  67315. /**
  67316. * Image Width (internal use)
  67317. * @hidden
  67318. */
  67319. _groupImgWidth: number;
  67320. /**
  67321. * Image Height (internal use)
  67322. * @hidden
  67323. */
  67324. _groupImgHeight: number;
  67325. /**
  67326. * Custom position function (internal use)
  67327. * @hidden
  67328. */
  67329. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  67330. /**
  67331. * density per facet for surface points
  67332. * @hidden
  67333. */
  67334. _groupDensity: number[];
  67335. /**
  67336. * Only when points are colored by texture carries pointer to texture list array
  67337. * @hidden
  67338. */
  67339. _textureNb: number;
  67340. /**
  67341. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  67342. * PCS internal tool, don't use it manually.
  67343. * @hidden
  67344. */
  67345. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  67346. }
  67347. }
  67348. declare module "babylonjs/Particles/index" {
  67349. export * from "babylonjs/Particles/baseParticleSystem";
  67350. export * from "babylonjs/Particles/EmitterTypes/index";
  67351. export * from "babylonjs/Particles/gpuParticleSystem";
  67352. export * from "babylonjs/Particles/IParticleSystem";
  67353. export * from "babylonjs/Particles/particle";
  67354. export * from "babylonjs/Particles/particleHelper";
  67355. export * from "babylonjs/Particles/particleSystem";
  67356. export * from "babylonjs/Particles/particleSystemComponent";
  67357. export * from "babylonjs/Particles/particleSystemSet";
  67358. export * from "babylonjs/Particles/solidParticle";
  67359. export * from "babylonjs/Particles/solidParticleSystem";
  67360. export * from "babylonjs/Particles/cloudPoint";
  67361. export * from "babylonjs/Particles/pointsCloudSystem";
  67362. export * from "babylonjs/Particles/subEmitter";
  67363. }
  67364. declare module "babylonjs/Physics/physicsEngineComponent" {
  67365. import { Nullable } from "babylonjs/types";
  67366. import { Observable, Observer } from "babylonjs/Misc/observable";
  67367. import { Vector3 } from "babylonjs/Maths/math.vector";
  67368. import { Mesh } from "babylonjs/Meshes/mesh";
  67369. import { ISceneComponent } from "babylonjs/sceneComponent";
  67370. import { Scene } from "babylonjs/scene";
  67371. import { Node } from "babylonjs/node";
  67372. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  67373. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67374. module "babylonjs/scene" {
  67375. interface Scene {
  67376. /** @hidden (Backing field) */
  67377. _physicsEngine: Nullable<IPhysicsEngine>;
  67378. /** @hidden */
  67379. _physicsTimeAccumulator: number;
  67380. /**
  67381. * Gets the current physics engine
  67382. * @returns a IPhysicsEngine or null if none attached
  67383. */
  67384. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  67385. /**
  67386. * Enables physics to the current scene
  67387. * @param gravity defines the scene's gravity for the physics engine
  67388. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  67389. * @return a boolean indicating if the physics engine was initialized
  67390. */
  67391. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  67392. /**
  67393. * Disables and disposes the physics engine associated with the scene
  67394. */
  67395. disablePhysicsEngine(): void;
  67396. /**
  67397. * Gets a boolean indicating if there is an active physics engine
  67398. * @returns a boolean indicating if there is an active physics engine
  67399. */
  67400. isPhysicsEnabled(): boolean;
  67401. /**
  67402. * Deletes a physics compound impostor
  67403. * @param compound defines the compound to delete
  67404. */
  67405. deleteCompoundImpostor(compound: any): void;
  67406. /**
  67407. * An event triggered when physic simulation is about to be run
  67408. */
  67409. onBeforePhysicsObservable: Observable<Scene>;
  67410. /**
  67411. * An event triggered when physic simulation has been done
  67412. */
  67413. onAfterPhysicsObservable: Observable<Scene>;
  67414. }
  67415. }
  67416. module "babylonjs/Meshes/abstractMesh" {
  67417. interface AbstractMesh {
  67418. /** @hidden */
  67419. _physicsImpostor: Nullable<PhysicsImpostor>;
  67420. /**
  67421. * Gets or sets impostor used for physic simulation
  67422. * @see http://doc.babylonjs.com/features/physics_engine
  67423. */
  67424. physicsImpostor: Nullable<PhysicsImpostor>;
  67425. /**
  67426. * Gets the current physics impostor
  67427. * @see http://doc.babylonjs.com/features/physics_engine
  67428. * @returns a physics impostor or null
  67429. */
  67430. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  67431. /** Apply a physic impulse to the mesh
  67432. * @param force defines the force to apply
  67433. * @param contactPoint defines where to apply the force
  67434. * @returns the current mesh
  67435. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  67436. */
  67437. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  67438. /**
  67439. * Creates a physic joint between two meshes
  67440. * @param otherMesh defines the other mesh to use
  67441. * @param pivot1 defines the pivot to use on this mesh
  67442. * @param pivot2 defines the pivot to use on the other mesh
  67443. * @param options defines additional options (can be plugin dependent)
  67444. * @returns the current mesh
  67445. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  67446. */
  67447. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  67448. /** @hidden */
  67449. _disposePhysicsObserver: Nullable<Observer<Node>>;
  67450. }
  67451. }
  67452. /**
  67453. * Defines the physics engine scene component responsible to manage a physics engine
  67454. */
  67455. export class PhysicsEngineSceneComponent implements ISceneComponent {
  67456. /**
  67457. * The component name helpful to identify the component in the list of scene components.
  67458. */
  67459. readonly name: string;
  67460. /**
  67461. * The scene the component belongs to.
  67462. */
  67463. scene: Scene;
  67464. /**
  67465. * Creates a new instance of the component for the given scene
  67466. * @param scene Defines the scene to register the component in
  67467. */
  67468. constructor(scene: Scene);
  67469. /**
  67470. * Registers the component in a given scene
  67471. */
  67472. register(): void;
  67473. /**
  67474. * Rebuilds the elements related to this component in case of
  67475. * context lost for instance.
  67476. */
  67477. rebuild(): void;
  67478. /**
  67479. * Disposes the component and the associated ressources
  67480. */
  67481. dispose(): void;
  67482. }
  67483. }
  67484. declare module "babylonjs/Physics/physicsHelper" {
  67485. import { Nullable } from "babylonjs/types";
  67486. import { Vector3 } from "babylonjs/Maths/math.vector";
  67487. import { Mesh } from "babylonjs/Meshes/mesh";
  67488. import { Scene } from "babylonjs/scene";
  67489. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  67490. /**
  67491. * A helper for physics simulations
  67492. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67493. */
  67494. export class PhysicsHelper {
  67495. private _scene;
  67496. private _physicsEngine;
  67497. /**
  67498. * Initializes the Physics helper
  67499. * @param scene Babylon.js scene
  67500. */
  67501. constructor(scene: Scene);
  67502. /**
  67503. * Applies a radial explosion impulse
  67504. * @param origin the origin of the explosion
  67505. * @param radiusOrEventOptions the radius or the options of radial explosion
  67506. * @param strength the explosion strength
  67507. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67508. * @returns A physics radial explosion event, or null
  67509. */
  67510. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67511. /**
  67512. * Applies a radial explosion force
  67513. * @param origin the origin of the explosion
  67514. * @param radiusOrEventOptions the radius or the options of radial explosion
  67515. * @param strength the explosion strength
  67516. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67517. * @returns A physics radial explosion event, or null
  67518. */
  67519. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  67520. /**
  67521. * Creates a gravitational field
  67522. * @param origin the origin of the explosion
  67523. * @param radiusOrEventOptions the radius or the options of radial explosion
  67524. * @param strength the explosion strength
  67525. * @param falloff possible options: Constant & Linear. Defaults to Constant
  67526. * @returns A physics gravitational field event, or null
  67527. */
  67528. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  67529. /**
  67530. * Creates a physics updraft event
  67531. * @param origin the origin of the updraft
  67532. * @param radiusOrEventOptions the radius or the options of the updraft
  67533. * @param strength the strength of the updraft
  67534. * @param height the height of the updraft
  67535. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  67536. * @returns A physics updraft event, or null
  67537. */
  67538. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  67539. /**
  67540. * Creates a physics vortex event
  67541. * @param origin the of the vortex
  67542. * @param radiusOrEventOptions the radius or the options of the vortex
  67543. * @param strength the strength of the vortex
  67544. * @param height the height of the vortex
  67545. * @returns a Physics vortex event, or null
  67546. * A physics vortex event or null
  67547. */
  67548. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  67549. }
  67550. /**
  67551. * Represents a physics radial explosion event
  67552. */
  67553. class PhysicsRadialExplosionEvent {
  67554. private _scene;
  67555. private _options;
  67556. private _sphere;
  67557. private _dataFetched;
  67558. /**
  67559. * Initializes a radial explosioin event
  67560. * @param _scene BabylonJS scene
  67561. * @param _options The options for the vortex event
  67562. */
  67563. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  67564. /**
  67565. * Returns the data related to the radial explosion event (sphere).
  67566. * @returns The radial explosion event data
  67567. */
  67568. getData(): PhysicsRadialExplosionEventData;
  67569. /**
  67570. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  67571. * @param impostor A physics imposter
  67572. * @param origin the origin of the explosion
  67573. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  67574. */
  67575. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  67576. /**
  67577. * Triggers affecterd impostors callbacks
  67578. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  67579. */
  67580. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  67581. /**
  67582. * Disposes the sphere.
  67583. * @param force Specifies if the sphere should be disposed by force
  67584. */
  67585. dispose(force?: boolean): void;
  67586. /*** Helpers ***/
  67587. private _prepareSphere;
  67588. private _intersectsWithSphere;
  67589. }
  67590. /**
  67591. * Represents a gravitational field event
  67592. */
  67593. class PhysicsGravitationalFieldEvent {
  67594. private _physicsHelper;
  67595. private _scene;
  67596. private _origin;
  67597. private _options;
  67598. private _tickCallback;
  67599. private _sphere;
  67600. private _dataFetched;
  67601. /**
  67602. * Initializes the physics gravitational field event
  67603. * @param _physicsHelper A physics helper
  67604. * @param _scene BabylonJS scene
  67605. * @param _origin The origin position of the gravitational field event
  67606. * @param _options The options for the vortex event
  67607. */
  67608. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  67609. /**
  67610. * Returns the data related to the gravitational field event (sphere).
  67611. * @returns A gravitational field event
  67612. */
  67613. getData(): PhysicsGravitationalFieldEventData;
  67614. /**
  67615. * Enables the gravitational field.
  67616. */
  67617. enable(): void;
  67618. /**
  67619. * Disables the gravitational field.
  67620. */
  67621. disable(): void;
  67622. /**
  67623. * Disposes the sphere.
  67624. * @param force The force to dispose from the gravitational field event
  67625. */
  67626. dispose(force?: boolean): void;
  67627. private _tick;
  67628. }
  67629. /**
  67630. * Represents a physics updraft event
  67631. */
  67632. class PhysicsUpdraftEvent {
  67633. private _scene;
  67634. private _origin;
  67635. private _options;
  67636. private _physicsEngine;
  67637. private _originTop;
  67638. private _originDirection;
  67639. private _tickCallback;
  67640. private _cylinder;
  67641. private _cylinderPosition;
  67642. private _dataFetched;
  67643. /**
  67644. * Initializes the physics updraft event
  67645. * @param _scene BabylonJS scene
  67646. * @param _origin The origin position of the updraft
  67647. * @param _options The options for the updraft event
  67648. */
  67649. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  67650. /**
  67651. * Returns the data related to the updraft event (cylinder).
  67652. * @returns A physics updraft event
  67653. */
  67654. getData(): PhysicsUpdraftEventData;
  67655. /**
  67656. * Enables the updraft.
  67657. */
  67658. enable(): void;
  67659. /**
  67660. * Disables the updraft.
  67661. */
  67662. disable(): void;
  67663. /**
  67664. * Disposes the cylinder.
  67665. * @param force Specifies if the updraft should be disposed by force
  67666. */
  67667. dispose(force?: boolean): void;
  67668. private getImpostorHitData;
  67669. private _tick;
  67670. /*** Helpers ***/
  67671. private _prepareCylinder;
  67672. private _intersectsWithCylinder;
  67673. }
  67674. /**
  67675. * Represents a physics vortex event
  67676. */
  67677. class PhysicsVortexEvent {
  67678. private _scene;
  67679. private _origin;
  67680. private _options;
  67681. private _physicsEngine;
  67682. private _originTop;
  67683. private _tickCallback;
  67684. private _cylinder;
  67685. private _cylinderPosition;
  67686. private _dataFetched;
  67687. /**
  67688. * Initializes the physics vortex event
  67689. * @param _scene The BabylonJS scene
  67690. * @param _origin The origin position of the vortex
  67691. * @param _options The options for the vortex event
  67692. */
  67693. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  67694. /**
  67695. * Returns the data related to the vortex event (cylinder).
  67696. * @returns The physics vortex event data
  67697. */
  67698. getData(): PhysicsVortexEventData;
  67699. /**
  67700. * Enables the vortex.
  67701. */
  67702. enable(): void;
  67703. /**
  67704. * Disables the cortex.
  67705. */
  67706. disable(): void;
  67707. /**
  67708. * Disposes the sphere.
  67709. * @param force
  67710. */
  67711. dispose(force?: boolean): void;
  67712. private getImpostorHitData;
  67713. private _tick;
  67714. /*** Helpers ***/
  67715. private _prepareCylinder;
  67716. private _intersectsWithCylinder;
  67717. }
  67718. /**
  67719. * Options fot the radial explosion event
  67720. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67721. */
  67722. export class PhysicsRadialExplosionEventOptions {
  67723. /**
  67724. * The radius of the sphere for the radial explosion.
  67725. */
  67726. radius: number;
  67727. /**
  67728. * The strenth of the explosion.
  67729. */
  67730. strength: number;
  67731. /**
  67732. * The strenght of the force in correspondence to the distance of the affected object
  67733. */
  67734. falloff: PhysicsRadialImpulseFalloff;
  67735. /**
  67736. * Sphere options for the radial explosion.
  67737. */
  67738. sphere: {
  67739. segments: number;
  67740. diameter: number;
  67741. };
  67742. /**
  67743. * Sphere options for the radial explosion.
  67744. */
  67745. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  67746. }
  67747. /**
  67748. * Options fot the updraft event
  67749. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67750. */
  67751. export class PhysicsUpdraftEventOptions {
  67752. /**
  67753. * The radius of the cylinder for the vortex
  67754. */
  67755. radius: number;
  67756. /**
  67757. * The strenth of the updraft.
  67758. */
  67759. strength: number;
  67760. /**
  67761. * The height of the cylinder for the updraft.
  67762. */
  67763. height: number;
  67764. /**
  67765. * The mode for the the updraft.
  67766. */
  67767. updraftMode: PhysicsUpdraftMode;
  67768. }
  67769. /**
  67770. * Options fot the vortex event
  67771. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67772. */
  67773. export class PhysicsVortexEventOptions {
  67774. /**
  67775. * The radius of the cylinder for the vortex
  67776. */
  67777. radius: number;
  67778. /**
  67779. * The strenth of the vortex.
  67780. */
  67781. strength: number;
  67782. /**
  67783. * The height of the cylinder for the vortex.
  67784. */
  67785. height: number;
  67786. /**
  67787. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  67788. */
  67789. centripetalForceThreshold: number;
  67790. /**
  67791. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  67792. */
  67793. centripetalForceMultiplier: number;
  67794. /**
  67795. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  67796. */
  67797. centrifugalForceMultiplier: number;
  67798. /**
  67799. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  67800. */
  67801. updraftForceMultiplier: number;
  67802. }
  67803. /**
  67804. * The strenght 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 PhysicsRadialImpulseFalloff {
  67808. /** Defines that impulse is constant in strength across it's whole radius */
  67809. Constant = 0,
  67810. /** Defines that impulse gets weaker if it's further from the origin */
  67811. Linear = 1
  67812. }
  67813. /**
  67814. * The strength of the force in correspondence to the distance of the affected object
  67815. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67816. */
  67817. export enum PhysicsUpdraftMode {
  67818. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  67819. Center = 0,
  67820. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  67821. Perpendicular = 1
  67822. }
  67823. /**
  67824. * Interface for a physics hit data
  67825. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67826. */
  67827. export interface PhysicsHitData {
  67828. /**
  67829. * The force applied at the contact point
  67830. */
  67831. force: Vector3;
  67832. /**
  67833. * The contact point
  67834. */
  67835. contactPoint: Vector3;
  67836. /**
  67837. * The distance from the origin to the contact point
  67838. */
  67839. distanceFromOrigin: number;
  67840. }
  67841. /**
  67842. * Interface for radial explosion event data
  67843. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67844. */
  67845. export interface PhysicsRadialExplosionEventData {
  67846. /**
  67847. * A sphere used for the radial explosion event
  67848. */
  67849. sphere: Mesh;
  67850. }
  67851. /**
  67852. * Interface for gravitational field event data
  67853. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67854. */
  67855. export interface PhysicsGravitationalFieldEventData {
  67856. /**
  67857. * A sphere mesh used for the gravitational field event
  67858. */
  67859. sphere: Mesh;
  67860. }
  67861. /**
  67862. * Interface for updraft event data
  67863. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67864. */
  67865. export interface PhysicsUpdraftEventData {
  67866. /**
  67867. * A cylinder used for the updraft event
  67868. */
  67869. cylinder: Mesh;
  67870. }
  67871. /**
  67872. * Interface for vortex event data
  67873. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67874. */
  67875. export interface PhysicsVortexEventData {
  67876. /**
  67877. * A cylinder used for the vortex event
  67878. */
  67879. cylinder: Mesh;
  67880. }
  67881. /**
  67882. * Interface for an affected physics impostor
  67883. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  67884. */
  67885. export interface PhysicsAffectedImpostorWithData {
  67886. /**
  67887. * The impostor affected by the effect
  67888. */
  67889. impostor: PhysicsImpostor;
  67890. /**
  67891. * The data about the hit/horce from the explosion
  67892. */
  67893. hitData: PhysicsHitData;
  67894. }
  67895. }
  67896. declare module "babylonjs/Physics/Plugins/index" {
  67897. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  67898. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  67899. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  67900. }
  67901. declare module "babylonjs/Physics/index" {
  67902. export * from "babylonjs/Physics/IPhysicsEngine";
  67903. export * from "babylonjs/Physics/physicsEngine";
  67904. export * from "babylonjs/Physics/physicsEngineComponent";
  67905. export * from "babylonjs/Physics/physicsHelper";
  67906. export * from "babylonjs/Physics/physicsImpostor";
  67907. export * from "babylonjs/Physics/physicsJoint";
  67908. export * from "babylonjs/Physics/Plugins/index";
  67909. }
  67910. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  67911. /** @hidden */
  67912. export var blackAndWhitePixelShader: {
  67913. name: string;
  67914. shader: string;
  67915. };
  67916. }
  67917. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  67918. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  67919. import { Camera } from "babylonjs/Cameras/camera";
  67920. import { Engine } from "babylonjs/Engines/engine";
  67921. import "babylonjs/Shaders/blackAndWhite.fragment";
  67922. /**
  67923. * Post process used to render in black and white
  67924. */
  67925. export class BlackAndWhitePostProcess extends PostProcess {
  67926. /**
  67927. * Linear about to convert he result to black and white (default: 1)
  67928. */
  67929. degree: number;
  67930. /**
  67931. * Creates a black and white post process
  67932. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  67933. * @param name The name of the effect.
  67934. * @param options The required width/height ratio to downsize to before computing the render pass.
  67935. * @param camera The camera to apply the render pass to.
  67936. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  67937. * @param engine The engine which the post process will be applied. (default: current engine)
  67938. * @param reusable If the post process can be reused on the same frame. (default: false)
  67939. */
  67940. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  67941. }
  67942. }
  67943. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  67944. import { Nullable } from "babylonjs/types";
  67945. import { Camera } from "babylonjs/Cameras/camera";
  67946. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  67947. import { Engine } from "babylonjs/Engines/engine";
  67948. /**
  67949. * This represents a set of one or more post processes in Babylon.
  67950. * A post process can be used to apply a shader to a texture after it is rendered.
  67951. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  67952. */
  67953. export class PostProcessRenderEffect {
  67954. private _postProcesses;
  67955. private _getPostProcesses;
  67956. private _singleInstance;
  67957. private _cameras;
  67958. private _indicesForCamera;
  67959. /**
  67960. * Name of the effect
  67961. * @hidden
  67962. */
  67963. _name: string;
  67964. /**
  67965. * Instantiates a post process render effect.
  67966. * A post process can be used to apply a shader to a texture after it is rendered.
  67967. * @param engine The engine the effect is tied to
  67968. * @param name The name of the effect
  67969. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  67970. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  67971. */
  67972. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  67973. /**
  67974. * Checks if all the post processes in the effect are supported.
  67975. */
  67976. get isSupported(): boolean;
  67977. /**
  67978. * Updates the current state of the effect
  67979. * @hidden
  67980. */
  67981. _update(): void;
  67982. /**
  67983. * Attaches the effect on cameras
  67984. * @param cameras The camera to attach to.
  67985. * @hidden
  67986. */
  67987. _attachCameras(cameras: Camera): void;
  67988. /**
  67989. * Attaches the effect on cameras
  67990. * @param cameras The camera to attach to.
  67991. * @hidden
  67992. */
  67993. _attachCameras(cameras: Camera[]): void;
  67994. /**
  67995. * Detaches the effect on cameras
  67996. * @param cameras The camera to detatch from.
  67997. * @hidden
  67998. */
  67999. _detachCameras(cameras: Camera): void;
  68000. /**
  68001. * Detatches the effect on cameras
  68002. * @param cameras The camera to detatch from.
  68003. * @hidden
  68004. */
  68005. _detachCameras(cameras: Camera[]): void;
  68006. /**
  68007. * Enables the effect on given cameras
  68008. * @param cameras The camera to enable.
  68009. * @hidden
  68010. */
  68011. _enable(cameras: Camera): void;
  68012. /**
  68013. * Enables the effect on given cameras
  68014. * @param cameras The camera to enable.
  68015. * @hidden
  68016. */
  68017. _enable(cameras: Nullable<Camera[]>): void;
  68018. /**
  68019. * Disables the effect on the given cameras
  68020. * @param cameras The camera to disable.
  68021. * @hidden
  68022. */
  68023. _disable(cameras: Camera): void;
  68024. /**
  68025. * Disables the effect on the given cameras
  68026. * @param cameras The camera to disable.
  68027. * @hidden
  68028. */
  68029. _disable(cameras: Nullable<Camera[]>): void;
  68030. /**
  68031. * Gets a list of the post processes contained in the effect.
  68032. * @param camera The camera to get the post processes on.
  68033. * @returns The list of the post processes in the effect.
  68034. */
  68035. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  68036. }
  68037. }
  68038. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  68039. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68040. /** @hidden */
  68041. export var extractHighlightsPixelShader: {
  68042. name: string;
  68043. shader: string;
  68044. };
  68045. }
  68046. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  68047. import { Nullable } from "babylonjs/types";
  68048. import { Camera } from "babylonjs/Cameras/camera";
  68049. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68050. import { Engine } from "babylonjs/Engines/engine";
  68051. import "babylonjs/Shaders/extractHighlights.fragment";
  68052. /**
  68053. * 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.
  68054. */
  68055. export class ExtractHighlightsPostProcess extends PostProcess {
  68056. /**
  68057. * The luminance threshold, pixels below this value will be set to black.
  68058. */
  68059. threshold: number;
  68060. /** @hidden */
  68061. _exposure: number;
  68062. /**
  68063. * Post process which has the input texture to be used when performing highlight extraction
  68064. * @hidden
  68065. */
  68066. _inputPostProcess: Nullable<PostProcess>;
  68067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68068. }
  68069. }
  68070. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  68071. /** @hidden */
  68072. export var bloomMergePixelShader: {
  68073. name: string;
  68074. shader: string;
  68075. };
  68076. }
  68077. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  68078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68079. import { Nullable } from "babylonjs/types";
  68080. import { Engine } from "babylonjs/Engines/engine";
  68081. import { Camera } from "babylonjs/Cameras/camera";
  68082. import "babylonjs/Shaders/bloomMerge.fragment";
  68083. /**
  68084. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68085. */
  68086. export class BloomMergePostProcess extends PostProcess {
  68087. /** Weight of the bloom to be added to the original input. */
  68088. weight: number;
  68089. /**
  68090. * Creates a new instance of @see BloomMergePostProcess
  68091. * @param name The name of the effect.
  68092. * @param originalFromInput Post process which's input will be used for the merge.
  68093. * @param blurred Blurred highlights post process which's output will be used.
  68094. * @param weight Weight of the bloom to be added to the original input.
  68095. * @param options The required width/height ratio to downsize to before computing the render pass.
  68096. * @param camera The camera to apply the render pass to.
  68097. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68098. * @param engine The engine which the post process will be applied. (default: current engine)
  68099. * @param reusable If the post process can be reused on the same frame. (default: false)
  68100. * @param textureType Type of textures used when performing the post process. (default: 0)
  68101. * @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)
  68102. */
  68103. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  68104. /** Weight of the bloom to be added to the original input. */
  68105. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68106. }
  68107. }
  68108. declare module "babylonjs/PostProcesses/bloomEffect" {
  68109. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68110. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68111. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  68112. import { Camera } from "babylonjs/Cameras/camera";
  68113. import { Scene } from "babylonjs/scene";
  68114. /**
  68115. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  68116. */
  68117. export class BloomEffect extends PostProcessRenderEffect {
  68118. private bloomScale;
  68119. /**
  68120. * @hidden Internal
  68121. */
  68122. _effects: Array<PostProcess>;
  68123. /**
  68124. * @hidden Internal
  68125. */
  68126. _downscale: ExtractHighlightsPostProcess;
  68127. private _blurX;
  68128. private _blurY;
  68129. private _merge;
  68130. /**
  68131. * The luminance threshold to find bright areas of the image to bloom.
  68132. */
  68133. get threshold(): number;
  68134. set threshold(value: number);
  68135. /**
  68136. * The strength of the bloom.
  68137. */
  68138. get weight(): number;
  68139. set weight(value: number);
  68140. /**
  68141. * Specifies the size of the bloom blur kernel, relative to the final output size
  68142. */
  68143. get kernel(): number;
  68144. set kernel(value: number);
  68145. /**
  68146. * Creates a new instance of @see BloomEffect
  68147. * @param scene The scene the effect belongs to.
  68148. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  68149. * @param bloomKernel The size of the kernel to be used when applying the blur.
  68150. * @param bloomWeight The the strength of bloom.
  68151. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68152. * @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)
  68153. */
  68154. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  68155. /**
  68156. * Disposes each of the internal effects for a given camera.
  68157. * @param camera The camera to dispose the effect on.
  68158. */
  68159. disposeEffects(camera: Camera): void;
  68160. /**
  68161. * @hidden Internal
  68162. */
  68163. _updateEffects(): void;
  68164. /**
  68165. * Internal
  68166. * @returns if all the contained post processes are ready.
  68167. * @hidden
  68168. */
  68169. _isReady(): boolean;
  68170. }
  68171. }
  68172. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  68173. /** @hidden */
  68174. export var chromaticAberrationPixelShader: {
  68175. name: string;
  68176. shader: string;
  68177. };
  68178. }
  68179. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  68180. import { Vector2 } from "babylonjs/Maths/math.vector";
  68181. import { Nullable } from "babylonjs/types";
  68182. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68183. import { Camera } from "babylonjs/Cameras/camera";
  68184. import { Engine } from "babylonjs/Engines/engine";
  68185. import "babylonjs/Shaders/chromaticAberration.fragment";
  68186. /**
  68187. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  68188. */
  68189. export class ChromaticAberrationPostProcess extends PostProcess {
  68190. /**
  68191. * The amount of seperation of rgb channels (default: 30)
  68192. */
  68193. aberrationAmount: number;
  68194. /**
  68195. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  68196. */
  68197. radialIntensity: number;
  68198. /**
  68199. * 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))
  68200. */
  68201. direction: Vector2;
  68202. /**
  68203. * 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))
  68204. */
  68205. centerPosition: Vector2;
  68206. /**
  68207. * Creates a new instance ChromaticAberrationPostProcess
  68208. * @param name The name of the effect.
  68209. * @param screenWidth The width of the screen to apply the effect on.
  68210. * @param screenHeight The height of the screen to apply the effect on.
  68211. * @param options The required width/height ratio to downsize to before computing the render pass.
  68212. * @param camera The camera to apply the render pass to.
  68213. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68214. * @param engine The engine which the post process will be applied. (default: current engine)
  68215. * @param reusable If the post process can be reused on the same frame. (default: false)
  68216. * @param textureType Type of textures used when performing the post process. (default: 0)
  68217. * @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)
  68218. */
  68219. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68220. }
  68221. }
  68222. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  68223. /** @hidden */
  68224. export var circleOfConfusionPixelShader: {
  68225. name: string;
  68226. shader: string;
  68227. };
  68228. }
  68229. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  68230. import { Nullable } from "babylonjs/types";
  68231. import { Engine } from "babylonjs/Engines/engine";
  68232. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68233. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68234. import { Camera } from "babylonjs/Cameras/camera";
  68235. import "babylonjs/Shaders/circleOfConfusion.fragment";
  68236. /**
  68237. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  68238. */
  68239. export class CircleOfConfusionPostProcess extends PostProcess {
  68240. /**
  68241. * 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.
  68242. */
  68243. lensSize: number;
  68244. /**
  68245. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68246. */
  68247. fStop: number;
  68248. /**
  68249. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68250. */
  68251. focusDistance: number;
  68252. /**
  68253. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  68254. */
  68255. focalLength: number;
  68256. private _depthTexture;
  68257. /**
  68258. * Creates a new instance CircleOfConfusionPostProcess
  68259. * @param name The name of the effect.
  68260. * @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.
  68261. * @param options The required width/height ratio to downsize to before computing the render pass.
  68262. * @param camera The camera to apply the render pass to.
  68263. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68264. * @param engine The engine which the post process will be applied. (default: current engine)
  68265. * @param reusable If the post process can be reused on the same frame. (default: false)
  68266. * @param textureType Type of textures used when performing the post process. (default: 0)
  68267. * @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)
  68268. */
  68269. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68270. /**
  68271. * 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.
  68272. */
  68273. set depthTexture(value: RenderTargetTexture);
  68274. }
  68275. }
  68276. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  68277. /** @hidden */
  68278. export var colorCorrectionPixelShader: {
  68279. name: string;
  68280. shader: string;
  68281. };
  68282. }
  68283. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  68284. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68285. import { Engine } from "babylonjs/Engines/engine";
  68286. import { Camera } from "babylonjs/Cameras/camera";
  68287. import "babylonjs/Shaders/colorCorrection.fragment";
  68288. /**
  68289. *
  68290. * This post-process allows the modification of rendered colors by using
  68291. * a 'look-up table' (LUT). This effect is also called Color Grading.
  68292. *
  68293. * The object needs to be provided an url to a texture containing the color
  68294. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  68295. * Use an image editing software to tweak the LUT to match your needs.
  68296. *
  68297. * For an example of a color LUT, see here:
  68298. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  68299. * For explanations on color grading, see here:
  68300. * @see http://udn.epicgames.com/Three/ColorGrading.html
  68301. *
  68302. */
  68303. export class ColorCorrectionPostProcess extends PostProcess {
  68304. private _colorTableTexture;
  68305. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68306. }
  68307. }
  68308. declare module "babylonjs/Shaders/convolution.fragment" {
  68309. /** @hidden */
  68310. export var convolutionPixelShader: {
  68311. name: string;
  68312. shader: string;
  68313. };
  68314. }
  68315. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  68316. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68317. import { Nullable } from "babylonjs/types";
  68318. import { Camera } from "babylonjs/Cameras/camera";
  68319. import { Engine } from "babylonjs/Engines/engine";
  68320. import "babylonjs/Shaders/convolution.fragment";
  68321. /**
  68322. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  68323. * input texture to perform effects such as edge detection or sharpening
  68324. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  68325. */
  68326. export class ConvolutionPostProcess extends PostProcess {
  68327. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68328. kernel: number[];
  68329. /**
  68330. * Creates a new instance ConvolutionPostProcess
  68331. * @param name The name of the effect.
  68332. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  68333. * @param options The required width/height ratio to downsize to before computing the render pass.
  68334. * @param camera The camera to apply the render pass to.
  68335. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68336. * @param engine The engine which the post process will be applied. (default: current engine)
  68337. * @param reusable If the post process can be reused on the same frame. (default: false)
  68338. * @param textureType Type of textures used when performing the post process. (default: 0)
  68339. */
  68340. constructor(name: string,
  68341. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  68342. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68343. /**
  68344. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68345. */
  68346. static EdgeDetect0Kernel: number[];
  68347. /**
  68348. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68349. */
  68350. static EdgeDetect1Kernel: number[];
  68351. /**
  68352. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68353. */
  68354. static EdgeDetect2Kernel: number[];
  68355. /**
  68356. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68357. */
  68358. static SharpenKernel: number[];
  68359. /**
  68360. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68361. */
  68362. static EmbossKernel: number[];
  68363. /**
  68364. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  68365. */
  68366. static GaussianKernel: number[];
  68367. }
  68368. }
  68369. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  68370. import { Nullable } from "babylonjs/types";
  68371. import { Vector2 } from "babylonjs/Maths/math.vector";
  68372. import { Camera } from "babylonjs/Cameras/camera";
  68373. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68374. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  68375. import { Engine } from "babylonjs/Engines/engine";
  68376. import { Scene } from "babylonjs/scene";
  68377. /**
  68378. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  68379. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  68380. * based on samples that have a large difference in distance than the center pixel.
  68381. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  68382. */
  68383. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  68384. direction: Vector2;
  68385. /**
  68386. * Creates a new instance CircleOfConfusionPostProcess
  68387. * @param name The name of the effect.
  68388. * @param scene The scene the effect belongs to.
  68389. * @param direction The direction the blur should be applied.
  68390. * @param kernel The size of the kernel used to blur.
  68391. * @param options The required width/height ratio to downsize to before computing the render pass.
  68392. * @param camera The camera to apply the render pass to.
  68393. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  68394. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  68395. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68396. * @param engine The engine which the post process will be applied. (default: current engine)
  68397. * @param reusable If the post process can be reused on the same frame. (default: false)
  68398. * @param textureType Type of textures used when performing the post process. (default: 0)
  68399. * @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)
  68400. */
  68401. 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);
  68402. }
  68403. }
  68404. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  68405. /** @hidden */
  68406. export var depthOfFieldMergePixelShader: {
  68407. name: string;
  68408. shader: string;
  68409. };
  68410. }
  68411. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  68412. import { Nullable } from "babylonjs/types";
  68413. import { Camera } from "babylonjs/Cameras/camera";
  68414. import { Effect } from "babylonjs/Materials/effect";
  68415. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68416. import { Engine } from "babylonjs/Engines/engine";
  68417. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  68418. /**
  68419. * Options to be set when merging outputs from the default pipeline.
  68420. */
  68421. export class DepthOfFieldMergePostProcessOptions {
  68422. /**
  68423. * The original image to merge on top of
  68424. */
  68425. originalFromInput: PostProcess;
  68426. /**
  68427. * Parameters to perform the merge of the depth of field effect
  68428. */
  68429. depthOfField?: {
  68430. circleOfConfusion: PostProcess;
  68431. blurSteps: Array<PostProcess>;
  68432. };
  68433. /**
  68434. * Parameters to perform the merge of bloom effect
  68435. */
  68436. bloom?: {
  68437. blurred: PostProcess;
  68438. weight: number;
  68439. };
  68440. }
  68441. /**
  68442. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  68443. */
  68444. export class DepthOfFieldMergePostProcess extends PostProcess {
  68445. private blurSteps;
  68446. /**
  68447. * Creates a new instance of DepthOfFieldMergePostProcess
  68448. * @param name The name of the effect.
  68449. * @param originalFromInput Post process which's input will be used for the merge.
  68450. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  68451. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  68452. * @param options The required width/height ratio to downsize to before computing the render pass.
  68453. * @param camera The camera to apply the render pass to.
  68454. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68455. * @param engine The engine which the post process will be applied. (default: current engine)
  68456. * @param reusable If the post process can be reused on the same frame. (default: false)
  68457. * @param textureType Type of textures used when performing the post process. (default: 0)
  68458. * @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)
  68459. */
  68460. 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);
  68461. /**
  68462. * Updates the effect with the current post process compile time values and recompiles the shader.
  68463. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68464. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68465. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68466. * @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
  68467. * @param onCompiled Called when the shader has been compiled.
  68468. * @param onError Called if there is an error when compiling a shader.
  68469. */
  68470. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68471. }
  68472. }
  68473. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  68474. import { Nullable } from "babylonjs/types";
  68475. import { Camera } from "babylonjs/Cameras/camera";
  68476. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  68477. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  68478. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  68479. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  68480. import { Scene } from "babylonjs/scene";
  68481. /**
  68482. * Specifies the level of max blur that should be applied when using the depth of field effect
  68483. */
  68484. export enum DepthOfFieldEffectBlurLevel {
  68485. /**
  68486. * Subtle blur
  68487. */
  68488. Low = 0,
  68489. /**
  68490. * Medium blur
  68491. */
  68492. Medium = 1,
  68493. /**
  68494. * Large blur
  68495. */
  68496. High = 2
  68497. }
  68498. /**
  68499. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  68500. */
  68501. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  68502. private _circleOfConfusion;
  68503. /**
  68504. * @hidden Internal, blurs from high to low
  68505. */
  68506. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  68507. private _depthOfFieldBlurY;
  68508. private _dofMerge;
  68509. /**
  68510. * @hidden Internal post processes in depth of field effect
  68511. */
  68512. _effects: Array<PostProcess>;
  68513. /**
  68514. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  68515. */
  68516. set focalLength(value: number);
  68517. get focalLength(): number;
  68518. /**
  68519. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  68520. */
  68521. set fStop(value: number);
  68522. get fStop(): number;
  68523. /**
  68524. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  68525. */
  68526. set focusDistance(value: number);
  68527. get focusDistance(): number;
  68528. /**
  68529. * 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.
  68530. */
  68531. set lensSize(value: number);
  68532. get lensSize(): number;
  68533. /**
  68534. * Creates a new instance DepthOfFieldEffect
  68535. * @param scene The scene the effect belongs to.
  68536. * @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.
  68537. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  68538. * @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)
  68539. */
  68540. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  68541. /**
  68542. * Get the current class name of the current effet
  68543. * @returns "DepthOfFieldEffect"
  68544. */
  68545. getClassName(): string;
  68546. /**
  68547. * 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.
  68548. */
  68549. set depthTexture(value: RenderTargetTexture);
  68550. /**
  68551. * Disposes each of the internal effects for a given camera.
  68552. * @param camera The camera to dispose the effect on.
  68553. */
  68554. disposeEffects(camera: Camera): void;
  68555. /**
  68556. * @hidden Internal
  68557. */
  68558. _updateEffects(): void;
  68559. /**
  68560. * Internal
  68561. * @returns if all the contained post processes are ready.
  68562. * @hidden
  68563. */
  68564. _isReady(): boolean;
  68565. }
  68566. }
  68567. declare module "babylonjs/Shaders/displayPass.fragment" {
  68568. /** @hidden */
  68569. export var displayPassPixelShader: {
  68570. name: string;
  68571. shader: string;
  68572. };
  68573. }
  68574. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  68575. import { Nullable } from "babylonjs/types";
  68576. import { Camera } from "babylonjs/Cameras/camera";
  68577. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68578. import { Engine } from "babylonjs/Engines/engine";
  68579. import "babylonjs/Shaders/displayPass.fragment";
  68580. /**
  68581. * DisplayPassPostProcess which produces an output the same as it's input
  68582. */
  68583. export class DisplayPassPostProcess extends PostProcess {
  68584. /**
  68585. * Creates the DisplayPassPostProcess
  68586. * @param name The name of the effect.
  68587. * @param options The required width/height ratio to downsize to before computing the render pass.
  68588. * @param camera The camera to apply the render pass to.
  68589. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68590. * @param engine The engine which the post process will be applied. (default: current engine)
  68591. * @param reusable If the post process can be reused on the same frame. (default: false)
  68592. */
  68593. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68594. }
  68595. }
  68596. declare module "babylonjs/Shaders/filter.fragment" {
  68597. /** @hidden */
  68598. export var filterPixelShader: {
  68599. name: string;
  68600. shader: string;
  68601. };
  68602. }
  68603. declare module "babylonjs/PostProcesses/filterPostProcess" {
  68604. import { Nullable } from "babylonjs/types";
  68605. import { Matrix } from "babylonjs/Maths/math.vector";
  68606. import { Camera } from "babylonjs/Cameras/camera";
  68607. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68608. import { Engine } from "babylonjs/Engines/engine";
  68609. import "babylonjs/Shaders/filter.fragment";
  68610. /**
  68611. * Applies a kernel filter to the image
  68612. */
  68613. export class FilterPostProcess extends PostProcess {
  68614. /** The matrix to be applied to the image */
  68615. kernelMatrix: Matrix;
  68616. /**
  68617. *
  68618. * @param name The name of the effect.
  68619. * @param kernelMatrix The matrix to be applied to the image
  68620. * @param options The required width/height ratio to downsize to before computing the render pass.
  68621. * @param camera The camera to apply the render pass to.
  68622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68623. * @param engine The engine which the post process will be applied. (default: current engine)
  68624. * @param reusable If the post process can be reused on the same frame. (default: false)
  68625. */
  68626. constructor(name: string,
  68627. /** The matrix to be applied to the image */
  68628. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  68629. }
  68630. }
  68631. declare module "babylonjs/Shaders/fxaa.fragment" {
  68632. /** @hidden */
  68633. export var fxaaPixelShader: {
  68634. name: string;
  68635. shader: string;
  68636. };
  68637. }
  68638. declare module "babylonjs/Shaders/fxaa.vertex" {
  68639. /** @hidden */
  68640. export var fxaaVertexShader: {
  68641. name: string;
  68642. shader: string;
  68643. };
  68644. }
  68645. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  68646. import { Nullable } from "babylonjs/types";
  68647. import { Camera } from "babylonjs/Cameras/camera";
  68648. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68649. import { Engine } from "babylonjs/Engines/engine";
  68650. import "babylonjs/Shaders/fxaa.fragment";
  68651. import "babylonjs/Shaders/fxaa.vertex";
  68652. /**
  68653. * Fxaa post process
  68654. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  68655. */
  68656. export class FxaaPostProcess extends PostProcess {
  68657. /** @hidden */
  68658. texelWidth: number;
  68659. /** @hidden */
  68660. texelHeight: number;
  68661. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68662. private _getDefines;
  68663. }
  68664. }
  68665. declare module "babylonjs/Shaders/grain.fragment" {
  68666. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  68667. /** @hidden */
  68668. export var grainPixelShader: {
  68669. name: string;
  68670. shader: string;
  68671. };
  68672. }
  68673. declare module "babylonjs/PostProcesses/grainPostProcess" {
  68674. import { Nullable } from "babylonjs/types";
  68675. import { Camera } from "babylonjs/Cameras/camera";
  68676. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68677. import { Engine } from "babylonjs/Engines/engine";
  68678. import "babylonjs/Shaders/grain.fragment";
  68679. /**
  68680. * The GrainPostProcess adds noise to the image at mid luminance levels
  68681. */
  68682. export class GrainPostProcess extends PostProcess {
  68683. /**
  68684. * The intensity of the grain added (default: 30)
  68685. */
  68686. intensity: number;
  68687. /**
  68688. * If the grain should be randomized on every frame
  68689. */
  68690. animated: boolean;
  68691. /**
  68692. * Creates a new instance of @see GrainPostProcess
  68693. * @param name The name of the effect.
  68694. * @param options The required width/height ratio to downsize to before computing the render pass.
  68695. * @param camera The camera to apply the render pass to.
  68696. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68697. * @param engine The engine which the post process will be applied. (default: current engine)
  68698. * @param reusable If the post process can be reused on the same frame. (default: false)
  68699. * @param textureType Type of textures used when performing the post process. (default: 0)
  68700. * @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)
  68701. */
  68702. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  68703. }
  68704. }
  68705. declare module "babylonjs/Shaders/highlights.fragment" {
  68706. /** @hidden */
  68707. export var highlightsPixelShader: {
  68708. name: string;
  68709. shader: string;
  68710. };
  68711. }
  68712. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  68713. import { Nullable } from "babylonjs/types";
  68714. import { Camera } from "babylonjs/Cameras/camera";
  68715. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68716. import { Engine } from "babylonjs/Engines/engine";
  68717. import "babylonjs/Shaders/highlights.fragment";
  68718. /**
  68719. * Extracts highlights from the image
  68720. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68721. */
  68722. export class HighlightsPostProcess extends PostProcess {
  68723. /**
  68724. * Extracts highlights from the image
  68725. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  68726. * @param name The name of the effect.
  68727. * @param options The required width/height ratio to downsize to before computing the render pass.
  68728. * @param camera The camera to apply the render pass to.
  68729. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68730. * @param engine The engine which the post process will be applied. (default: current engine)
  68731. * @param reusable If the post process can be reused on the same frame. (default: false)
  68732. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  68733. */
  68734. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  68735. }
  68736. }
  68737. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  68738. /** @hidden */
  68739. export var mrtFragmentDeclaration: {
  68740. name: string;
  68741. shader: string;
  68742. };
  68743. }
  68744. declare module "babylonjs/Shaders/geometry.fragment" {
  68745. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  68746. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  68747. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  68748. /** @hidden */
  68749. export var geometryPixelShader: {
  68750. name: string;
  68751. shader: string;
  68752. };
  68753. }
  68754. declare module "babylonjs/Shaders/geometry.vertex" {
  68755. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  68756. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  68757. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  68758. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  68759. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  68760. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  68761. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  68762. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  68763. /** @hidden */
  68764. export var geometryVertexShader: {
  68765. name: string;
  68766. shader: string;
  68767. };
  68768. }
  68769. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  68770. import { Matrix } from "babylonjs/Maths/math.vector";
  68771. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68772. import { Mesh } from "babylonjs/Meshes/mesh";
  68773. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  68774. import { Effect } from "babylonjs/Materials/effect";
  68775. import { Scene } from "babylonjs/scene";
  68776. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68777. import "babylonjs/Shaders/geometry.fragment";
  68778. import "babylonjs/Shaders/geometry.vertex";
  68779. /** @hidden */
  68780. interface ISavedTransformationMatrix {
  68781. world: Matrix;
  68782. viewProjection: Matrix;
  68783. }
  68784. /**
  68785. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  68786. */
  68787. export class GeometryBufferRenderer {
  68788. /**
  68789. * Constant used to retrieve the position texture index in the G-Buffer textures array
  68790. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  68791. */
  68792. static readonly POSITION_TEXTURE_TYPE: number;
  68793. /**
  68794. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  68795. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  68796. */
  68797. static readonly VELOCITY_TEXTURE_TYPE: number;
  68798. /**
  68799. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  68800. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  68801. */
  68802. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  68803. /**
  68804. * Dictionary used to store the previous transformation matrices of each rendered mesh
  68805. * in order to compute objects velocities when enableVelocity is set to "true"
  68806. * @hidden
  68807. */
  68808. _previousTransformationMatrices: {
  68809. [index: number]: ISavedTransformationMatrix;
  68810. };
  68811. /**
  68812. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  68813. * in order to compute objects velocities when enableVelocity is set to "true"
  68814. * @hidden
  68815. */
  68816. _previousBonesTransformationMatrices: {
  68817. [index: number]: Float32Array;
  68818. };
  68819. /**
  68820. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  68821. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  68822. */
  68823. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  68824. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  68825. renderTransparentMeshes: boolean;
  68826. private _scene;
  68827. private _multiRenderTarget;
  68828. private _ratio;
  68829. private _enablePosition;
  68830. private _enableVelocity;
  68831. private _enableReflectivity;
  68832. private _positionIndex;
  68833. private _velocityIndex;
  68834. private _reflectivityIndex;
  68835. protected _effect: Effect;
  68836. protected _cachedDefines: string;
  68837. /**
  68838. * Set the render list (meshes to be rendered) used in the G buffer.
  68839. */
  68840. set renderList(meshes: Mesh[]);
  68841. /**
  68842. * Gets wether or not G buffer are supported by the running hardware.
  68843. * This requires draw buffer supports
  68844. */
  68845. get isSupported(): boolean;
  68846. /**
  68847. * Returns the index of the given texture type in the G-Buffer textures array
  68848. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  68849. * @returns the index of the given texture type in the G-Buffer textures array
  68850. */
  68851. getTextureIndex(textureType: number): number;
  68852. /**
  68853. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  68854. */
  68855. get enablePosition(): boolean;
  68856. /**
  68857. * Sets whether or not objects positions are enabled for the G buffer.
  68858. */
  68859. set enablePosition(enable: boolean);
  68860. /**
  68861. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  68862. */
  68863. get enableVelocity(): boolean;
  68864. /**
  68865. * Sets wether or not objects velocities are enabled for the G buffer.
  68866. */
  68867. set enableVelocity(enable: boolean);
  68868. /**
  68869. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  68870. */
  68871. get enableReflectivity(): boolean;
  68872. /**
  68873. * Sets wether or not objects roughness are enabled for the G buffer.
  68874. */
  68875. set enableReflectivity(enable: boolean);
  68876. /**
  68877. * Gets the scene associated with the buffer.
  68878. */
  68879. get scene(): Scene;
  68880. /**
  68881. * Gets the ratio used by the buffer during its creation.
  68882. * How big is the buffer related to the main canvas.
  68883. */
  68884. get ratio(): number;
  68885. /** @hidden */
  68886. static _SceneComponentInitialization: (scene: Scene) => void;
  68887. /**
  68888. * Creates a new G Buffer for the scene
  68889. * @param scene The scene the buffer belongs to
  68890. * @param ratio How big is the buffer related to the main canvas.
  68891. */
  68892. constructor(scene: Scene, ratio?: number);
  68893. /**
  68894. * Checks wether everything is ready to render a submesh to the G buffer.
  68895. * @param subMesh the submesh to check readiness for
  68896. * @param useInstances is the mesh drawn using instance or not
  68897. * @returns true if ready otherwise false
  68898. */
  68899. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  68900. /**
  68901. * Gets the current underlying G Buffer.
  68902. * @returns the buffer
  68903. */
  68904. getGBuffer(): MultiRenderTarget;
  68905. /**
  68906. * Gets the number of samples used to render the buffer (anti aliasing).
  68907. */
  68908. get samples(): number;
  68909. /**
  68910. * Sets the number of samples used to render the buffer (anti aliasing).
  68911. */
  68912. set samples(value: number);
  68913. /**
  68914. * Disposes the renderer and frees up associated resources.
  68915. */
  68916. dispose(): void;
  68917. protected _createRenderTargets(): void;
  68918. private _copyBonesTransformationMatrices;
  68919. }
  68920. }
  68921. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  68922. import { Nullable } from "babylonjs/types";
  68923. import { Scene } from "babylonjs/scene";
  68924. import { ISceneComponent } from "babylonjs/sceneComponent";
  68925. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  68926. module "babylonjs/scene" {
  68927. interface Scene {
  68928. /** @hidden (Backing field) */
  68929. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68930. /**
  68931. * Gets or Sets the current geometry buffer associated to the scene.
  68932. */
  68933. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  68934. /**
  68935. * Enables a GeometryBufferRender and associates it with the scene
  68936. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  68937. * @returns the GeometryBufferRenderer
  68938. */
  68939. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  68940. /**
  68941. * Disables the GeometryBufferRender associated with the scene
  68942. */
  68943. disableGeometryBufferRenderer(): void;
  68944. }
  68945. }
  68946. /**
  68947. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  68948. * in several rendering techniques.
  68949. */
  68950. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  68951. /**
  68952. * The component name helpful to identify the component in the list of scene components.
  68953. */
  68954. readonly name: string;
  68955. /**
  68956. * The scene the component belongs to.
  68957. */
  68958. scene: Scene;
  68959. /**
  68960. * Creates a new instance of the component for the given scene
  68961. * @param scene Defines the scene to register the component in
  68962. */
  68963. constructor(scene: Scene);
  68964. /**
  68965. * Registers the component in a given scene
  68966. */
  68967. register(): void;
  68968. /**
  68969. * Rebuilds the elements related to this component in case of
  68970. * context lost for instance.
  68971. */
  68972. rebuild(): void;
  68973. /**
  68974. * Disposes the component and the associated ressources
  68975. */
  68976. dispose(): void;
  68977. private _gatherRenderTargets;
  68978. }
  68979. }
  68980. declare module "babylonjs/Shaders/motionBlur.fragment" {
  68981. /** @hidden */
  68982. export var motionBlurPixelShader: {
  68983. name: string;
  68984. shader: string;
  68985. };
  68986. }
  68987. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  68988. import { Nullable } from "babylonjs/types";
  68989. import { Camera } from "babylonjs/Cameras/camera";
  68990. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  68991. import { Scene } from "babylonjs/scene";
  68992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68993. import "babylonjs/Animations/animatable";
  68994. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  68995. import "babylonjs/Shaders/motionBlur.fragment";
  68996. import { Engine } from "babylonjs/Engines/engine";
  68997. /**
  68998. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  68999. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  69000. * As an example, all you have to do is to create the post-process:
  69001. * var mb = new BABYLON.MotionBlurPostProcess(
  69002. * 'mb', // The name of the effect.
  69003. * scene, // The scene containing the objects to blur according to their velocity.
  69004. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  69005. * camera // The camera to apply the render pass to.
  69006. * );
  69007. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  69008. */
  69009. export class MotionBlurPostProcess extends PostProcess {
  69010. /**
  69011. * Defines how much the image is blurred by the movement. Default value is equal to 1
  69012. */
  69013. motionStrength: number;
  69014. /**
  69015. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  69016. */
  69017. get motionBlurSamples(): number;
  69018. /**
  69019. * Sets the number of iterations to be used for motion blur quality
  69020. */
  69021. set motionBlurSamples(samples: number);
  69022. private _motionBlurSamples;
  69023. private _geometryBufferRenderer;
  69024. /**
  69025. * Creates a new instance MotionBlurPostProcess
  69026. * @param name The name of the effect.
  69027. * @param scene The scene containing the objects to blur according to their velocity.
  69028. * @param options The required width/height ratio to downsize to before computing the render pass.
  69029. * @param camera The camera to apply the render pass to.
  69030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69031. * @param engine The engine which the post process will be applied. (default: current engine)
  69032. * @param reusable If the post process can be reused on the same frame. (default: false)
  69033. * @param textureType Type of textures used when performing the post process. (default: 0)
  69034. * @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)
  69035. */
  69036. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69037. /**
  69038. * Excludes the given skinned mesh from computing bones velocities.
  69039. * 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.
  69040. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  69041. */
  69042. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69043. /**
  69044. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  69045. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  69046. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  69047. */
  69048. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  69049. /**
  69050. * Disposes the post process.
  69051. * @param camera The camera to dispose the post process on.
  69052. */
  69053. dispose(camera?: Camera): void;
  69054. }
  69055. }
  69056. declare module "babylonjs/Shaders/refraction.fragment" {
  69057. /** @hidden */
  69058. export var refractionPixelShader: {
  69059. name: string;
  69060. shader: string;
  69061. };
  69062. }
  69063. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  69064. import { Color3 } from "babylonjs/Maths/math.color";
  69065. import { Camera } from "babylonjs/Cameras/camera";
  69066. import { Texture } from "babylonjs/Materials/Textures/texture";
  69067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69068. import { Engine } from "babylonjs/Engines/engine";
  69069. import "babylonjs/Shaders/refraction.fragment";
  69070. /**
  69071. * Post process which applies a refractin texture
  69072. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69073. */
  69074. export class RefractionPostProcess extends PostProcess {
  69075. /** the base color of the refraction (used to taint the rendering) */
  69076. color: Color3;
  69077. /** simulated refraction depth */
  69078. depth: number;
  69079. /** the coefficient of the base color (0 to remove base color tainting) */
  69080. colorLevel: number;
  69081. private _refTexture;
  69082. private _ownRefractionTexture;
  69083. /**
  69084. * Gets or sets the refraction texture
  69085. * Please note that you are responsible for disposing the texture if you set it manually
  69086. */
  69087. get refractionTexture(): Texture;
  69088. set refractionTexture(value: Texture);
  69089. /**
  69090. * Initializes the RefractionPostProcess
  69091. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  69092. * @param name The name of the effect.
  69093. * @param refractionTextureUrl Url of the refraction texture to use
  69094. * @param color the base color of the refraction (used to taint the rendering)
  69095. * @param depth simulated refraction depth
  69096. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  69097. * @param camera The camera to apply the render pass to.
  69098. * @param options The required width/height ratio to downsize to before computing the render pass.
  69099. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69100. * @param engine The engine which the post process will be applied. (default: current engine)
  69101. * @param reusable If the post process can be reused on the same frame. (default: false)
  69102. */
  69103. constructor(name: string, refractionTextureUrl: string,
  69104. /** the base color of the refraction (used to taint the rendering) */
  69105. color: Color3,
  69106. /** simulated refraction depth */
  69107. depth: number,
  69108. /** the coefficient of the base color (0 to remove base color tainting) */
  69109. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  69110. /**
  69111. * Disposes of the post process
  69112. * @param camera Camera to dispose post process on
  69113. */
  69114. dispose(camera: Camera): void;
  69115. }
  69116. }
  69117. declare module "babylonjs/Shaders/sharpen.fragment" {
  69118. /** @hidden */
  69119. export var sharpenPixelShader: {
  69120. name: string;
  69121. shader: string;
  69122. };
  69123. }
  69124. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  69125. import { Nullable } from "babylonjs/types";
  69126. import { Camera } from "babylonjs/Cameras/camera";
  69127. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  69128. import "babylonjs/Shaders/sharpen.fragment";
  69129. import { Engine } from "babylonjs/Engines/engine";
  69130. /**
  69131. * The SharpenPostProcess applies a sharpen kernel to every pixel
  69132. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  69133. */
  69134. export class SharpenPostProcess extends PostProcess {
  69135. /**
  69136. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  69137. */
  69138. colorAmount: number;
  69139. /**
  69140. * How much sharpness should be applied (default: 0.3)
  69141. */
  69142. edgeAmount: number;
  69143. /**
  69144. * Creates a new instance ConvolutionPostProcess
  69145. * @param name The name of the effect.
  69146. * @param options The required width/height ratio to downsize to before computing the render pass.
  69147. * @param camera The camera to apply the render pass to.
  69148. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  69149. * @param engine The engine which the post process will be applied. (default: current engine)
  69150. * @param reusable If the post process can be reused on the same frame. (default: false)
  69151. * @param textureType Type of textures used when performing the post process. (default: 0)
  69152. * @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)
  69153. */
  69154. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  69155. }
  69156. }
  69157. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  69158. import { Nullable } from "babylonjs/types";
  69159. import { Camera } from "babylonjs/Cameras/camera";
  69160. import { Engine } from "babylonjs/Engines/engine";
  69161. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  69162. import { IInspectable } from "babylonjs/Misc/iInspectable";
  69163. /**
  69164. * PostProcessRenderPipeline
  69165. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69166. */
  69167. export class PostProcessRenderPipeline {
  69168. private engine;
  69169. private _renderEffects;
  69170. private _renderEffectsForIsolatedPass;
  69171. /**
  69172. * List of inspectable custom properties (used by the Inspector)
  69173. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  69174. */
  69175. inspectableCustomProperties: IInspectable[];
  69176. /**
  69177. * @hidden
  69178. */
  69179. protected _cameras: Camera[];
  69180. /** @hidden */
  69181. _name: string;
  69182. /**
  69183. * Gets pipeline name
  69184. */
  69185. get name(): string;
  69186. /** Gets the list of attached cameras */
  69187. get cameras(): Camera[];
  69188. /**
  69189. * Initializes a PostProcessRenderPipeline
  69190. * @param engine engine to add the pipeline to
  69191. * @param name name of the pipeline
  69192. */
  69193. constructor(engine: Engine, name: string);
  69194. /**
  69195. * Gets the class name
  69196. * @returns "PostProcessRenderPipeline"
  69197. */
  69198. getClassName(): string;
  69199. /**
  69200. * If all the render effects in the pipeline are supported
  69201. */
  69202. get isSupported(): boolean;
  69203. /**
  69204. * Adds an effect to the pipeline
  69205. * @param renderEffect the effect to add
  69206. */
  69207. addEffect(renderEffect: PostProcessRenderEffect): void;
  69208. /** @hidden */
  69209. _rebuild(): void;
  69210. /** @hidden */
  69211. _enableEffect(renderEffectName: string, cameras: Camera): void;
  69212. /** @hidden */
  69213. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  69214. /** @hidden */
  69215. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69216. /** @hidden */
  69217. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  69218. /** @hidden */
  69219. _attachCameras(cameras: Camera, unique: boolean): void;
  69220. /** @hidden */
  69221. _attachCameras(cameras: Camera[], unique: boolean): void;
  69222. /** @hidden */
  69223. _detachCameras(cameras: Camera): void;
  69224. /** @hidden */
  69225. _detachCameras(cameras: Nullable<Camera[]>): void;
  69226. /** @hidden */
  69227. _update(): void;
  69228. /** @hidden */
  69229. _reset(): void;
  69230. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  69231. /**
  69232. * Disposes of the pipeline
  69233. */
  69234. dispose(): void;
  69235. }
  69236. }
  69237. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  69238. import { Camera } from "babylonjs/Cameras/camera";
  69239. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69240. /**
  69241. * PostProcessRenderPipelineManager class
  69242. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69243. */
  69244. export class PostProcessRenderPipelineManager {
  69245. private _renderPipelines;
  69246. /**
  69247. * Initializes a PostProcessRenderPipelineManager
  69248. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69249. */
  69250. constructor();
  69251. /**
  69252. * Gets the list of supported render pipelines
  69253. */
  69254. get supportedPipelines(): PostProcessRenderPipeline[];
  69255. /**
  69256. * Adds a pipeline to the manager
  69257. * @param renderPipeline The pipeline to add
  69258. */
  69259. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  69260. /**
  69261. * Attaches a camera to the pipeline
  69262. * @param renderPipelineName The name of the pipeline to attach to
  69263. * @param cameras the camera to attach
  69264. * @param unique if the camera can be attached multiple times to the pipeline
  69265. */
  69266. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  69267. /**
  69268. * Detaches a camera from the pipeline
  69269. * @param renderPipelineName The name of the pipeline to detach from
  69270. * @param cameras the camera to detach
  69271. */
  69272. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  69273. /**
  69274. * Enables an effect by name on a pipeline
  69275. * @param renderPipelineName the name of the pipeline to enable the effect in
  69276. * @param renderEffectName the name of the effect to enable
  69277. * @param cameras the cameras that the effect should be enabled on
  69278. */
  69279. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69280. /**
  69281. * Disables an effect by name on a pipeline
  69282. * @param renderPipelineName the name of the pipeline to disable the effect in
  69283. * @param renderEffectName the name of the effect to disable
  69284. * @param cameras the cameras that the effect should be disabled on
  69285. */
  69286. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  69287. /**
  69288. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  69289. */
  69290. update(): void;
  69291. /** @hidden */
  69292. _rebuild(): void;
  69293. /**
  69294. * Disposes of the manager and pipelines
  69295. */
  69296. dispose(): void;
  69297. }
  69298. }
  69299. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  69300. import { ISceneComponent } from "babylonjs/sceneComponent";
  69301. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  69302. import { Scene } from "babylonjs/scene";
  69303. module "babylonjs/scene" {
  69304. interface Scene {
  69305. /** @hidden (Backing field) */
  69306. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69307. /**
  69308. * Gets the postprocess render pipeline manager
  69309. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  69310. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69311. */
  69312. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  69313. }
  69314. }
  69315. /**
  69316. * Defines the Render Pipeline scene component responsible to rendering pipelines
  69317. */
  69318. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  69319. /**
  69320. * The component name helpfull to identify the component in the list of scene components.
  69321. */
  69322. readonly name: string;
  69323. /**
  69324. * The scene the component belongs to.
  69325. */
  69326. scene: Scene;
  69327. /**
  69328. * Creates a new instance of the component for the given scene
  69329. * @param scene Defines the scene to register the component in
  69330. */
  69331. constructor(scene: Scene);
  69332. /**
  69333. * Registers the component in a given scene
  69334. */
  69335. register(): void;
  69336. /**
  69337. * Rebuilds the elements related to this component in case of
  69338. * context lost for instance.
  69339. */
  69340. rebuild(): void;
  69341. /**
  69342. * Disposes the component and the associated ressources
  69343. */
  69344. dispose(): void;
  69345. private _gatherRenderTargets;
  69346. }
  69347. }
  69348. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  69349. import { Nullable } from "babylonjs/types";
  69350. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  69351. import { Camera } from "babylonjs/Cameras/camera";
  69352. import { IDisposable } from "babylonjs/scene";
  69353. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  69354. import { Scene } from "babylonjs/scene";
  69355. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  69356. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  69357. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  69358. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  69359. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  69360. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69361. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  69362. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69363. import { Animation } from "babylonjs/Animations/animation";
  69364. /**
  69365. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  69366. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  69367. */
  69368. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  69369. private _scene;
  69370. private _camerasToBeAttached;
  69371. /**
  69372. * ID of the sharpen post process,
  69373. */
  69374. private readonly SharpenPostProcessId;
  69375. /**
  69376. * @ignore
  69377. * ID of the image processing post process;
  69378. */
  69379. readonly ImageProcessingPostProcessId: string;
  69380. /**
  69381. * @ignore
  69382. * ID of the Fast Approximate Anti-Aliasing post process;
  69383. */
  69384. readonly FxaaPostProcessId: string;
  69385. /**
  69386. * ID of the chromatic aberration post process,
  69387. */
  69388. private readonly ChromaticAberrationPostProcessId;
  69389. /**
  69390. * ID of the grain post process
  69391. */
  69392. private readonly GrainPostProcessId;
  69393. /**
  69394. * Sharpen post process which will apply a sharpen convolution to enhance edges
  69395. */
  69396. sharpen: SharpenPostProcess;
  69397. private _sharpenEffect;
  69398. private bloom;
  69399. /**
  69400. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  69401. */
  69402. depthOfField: DepthOfFieldEffect;
  69403. /**
  69404. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  69405. */
  69406. fxaa: FxaaPostProcess;
  69407. /**
  69408. * Image post processing pass used to perform operations such as tone mapping or color grading.
  69409. */
  69410. imageProcessing: ImageProcessingPostProcess;
  69411. /**
  69412. * Chromatic aberration post process which will shift rgb colors in the image
  69413. */
  69414. chromaticAberration: ChromaticAberrationPostProcess;
  69415. private _chromaticAberrationEffect;
  69416. /**
  69417. * Grain post process which add noise to the image
  69418. */
  69419. grain: GrainPostProcess;
  69420. private _grainEffect;
  69421. /**
  69422. * Glow post process which adds a glow to emissive areas of the image
  69423. */
  69424. private _glowLayer;
  69425. /**
  69426. * Animations which can be used to tweak settings over a period of time
  69427. */
  69428. animations: Animation[];
  69429. private _imageProcessingConfigurationObserver;
  69430. private _sharpenEnabled;
  69431. private _bloomEnabled;
  69432. private _depthOfFieldEnabled;
  69433. private _depthOfFieldBlurLevel;
  69434. private _fxaaEnabled;
  69435. private _imageProcessingEnabled;
  69436. private _defaultPipelineTextureType;
  69437. private _bloomScale;
  69438. private _chromaticAberrationEnabled;
  69439. private _grainEnabled;
  69440. private _buildAllowed;
  69441. /**
  69442. * Gets active scene
  69443. */
  69444. get scene(): Scene;
  69445. /**
  69446. * Enable or disable the sharpen process from the pipeline
  69447. */
  69448. set sharpenEnabled(enabled: boolean);
  69449. get sharpenEnabled(): boolean;
  69450. private _resizeObserver;
  69451. private _hardwareScaleLevel;
  69452. private _bloomKernel;
  69453. /**
  69454. * Specifies the size of the bloom blur kernel, relative to the final output size
  69455. */
  69456. get bloomKernel(): number;
  69457. set bloomKernel(value: number);
  69458. /**
  69459. * Specifies the weight of the bloom in the final rendering
  69460. */
  69461. private _bloomWeight;
  69462. /**
  69463. * Specifies the luma threshold for the area that will be blurred by the bloom
  69464. */
  69465. private _bloomThreshold;
  69466. private _hdr;
  69467. /**
  69468. * The strength of the bloom.
  69469. */
  69470. set bloomWeight(value: number);
  69471. get bloomWeight(): number;
  69472. /**
  69473. * The strength of the bloom.
  69474. */
  69475. set bloomThreshold(value: number);
  69476. get bloomThreshold(): number;
  69477. /**
  69478. * The scale of the bloom, lower value will provide better performance.
  69479. */
  69480. set bloomScale(value: number);
  69481. get bloomScale(): number;
  69482. /**
  69483. * Enable or disable the bloom from the pipeline
  69484. */
  69485. set bloomEnabled(enabled: boolean);
  69486. get bloomEnabled(): boolean;
  69487. private _rebuildBloom;
  69488. /**
  69489. * If the depth of field is enabled.
  69490. */
  69491. get depthOfFieldEnabled(): boolean;
  69492. set depthOfFieldEnabled(enabled: boolean);
  69493. /**
  69494. * Blur level of the depth of field effect. (Higher blur will effect performance)
  69495. */
  69496. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  69497. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  69498. /**
  69499. * If the anti aliasing is enabled.
  69500. */
  69501. set fxaaEnabled(enabled: boolean);
  69502. get fxaaEnabled(): boolean;
  69503. private _samples;
  69504. /**
  69505. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  69506. */
  69507. set samples(sampleCount: number);
  69508. get samples(): number;
  69509. /**
  69510. * If image processing is enabled.
  69511. */
  69512. set imageProcessingEnabled(enabled: boolean);
  69513. get imageProcessingEnabled(): boolean;
  69514. /**
  69515. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  69516. */
  69517. set glowLayerEnabled(enabled: boolean);
  69518. get glowLayerEnabled(): boolean;
  69519. /**
  69520. * Gets the glow layer (or null if not defined)
  69521. */
  69522. get glowLayer(): Nullable<GlowLayer>;
  69523. /**
  69524. * Enable or disable the chromaticAberration process from the pipeline
  69525. */
  69526. set chromaticAberrationEnabled(enabled: boolean);
  69527. get chromaticAberrationEnabled(): boolean;
  69528. /**
  69529. * Enable or disable the grain process from the pipeline
  69530. */
  69531. set grainEnabled(enabled: boolean);
  69532. get grainEnabled(): boolean;
  69533. /**
  69534. * @constructor
  69535. * @param name - The rendering pipeline name (default: "")
  69536. * @param hdr - If high dynamic range textures should be used (default: true)
  69537. * @param scene - The scene linked to this pipeline (default: the last created scene)
  69538. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  69539. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  69540. */
  69541. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  69542. /**
  69543. * Get the class name
  69544. * @returns "DefaultRenderingPipeline"
  69545. */
  69546. getClassName(): string;
  69547. /**
  69548. * Force the compilation of the entire pipeline.
  69549. */
  69550. prepare(): void;
  69551. private _hasCleared;
  69552. private _prevPostProcess;
  69553. private _prevPrevPostProcess;
  69554. private _setAutoClearAndTextureSharing;
  69555. private _depthOfFieldSceneObserver;
  69556. private _buildPipeline;
  69557. private _disposePostProcesses;
  69558. /**
  69559. * Adds a camera to the pipeline
  69560. * @param camera the camera to be added
  69561. */
  69562. addCamera(camera: Camera): void;
  69563. /**
  69564. * Removes a camera from the pipeline
  69565. * @param camera the camera to remove
  69566. */
  69567. removeCamera(camera: Camera): void;
  69568. /**
  69569. * Dispose of the pipeline and stop all post processes
  69570. */
  69571. dispose(): void;
  69572. /**
  69573. * Serialize the rendering pipeline (Used when exporting)
  69574. * @returns the serialized object
  69575. */
  69576. serialize(): any;
  69577. /**
  69578. * Parse the serialized pipeline
  69579. * @param source Source pipeline.
  69580. * @param scene The scene to load the pipeline to.
  69581. * @param rootUrl The URL of the serialized pipeline.
  69582. * @returns An instantiated pipeline from the serialized object.
  69583. */
  69584. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  69585. }
  69586. }
  69587. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  69588. /** @hidden */
  69589. export var lensHighlightsPixelShader: {
  69590. name: string;
  69591. shader: string;
  69592. };
  69593. }
  69594. declare module "babylonjs/Shaders/depthOfField.fragment" {
  69595. /** @hidden */
  69596. export var depthOfFieldPixelShader: {
  69597. name: string;
  69598. shader: string;
  69599. };
  69600. }
  69601. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  69602. import { Camera } from "babylonjs/Cameras/camera";
  69603. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69604. import { Scene } from "babylonjs/scene";
  69605. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69606. import "babylonjs/Shaders/chromaticAberration.fragment";
  69607. import "babylonjs/Shaders/lensHighlights.fragment";
  69608. import "babylonjs/Shaders/depthOfField.fragment";
  69609. /**
  69610. * BABYLON.JS Chromatic Aberration GLSL Shader
  69611. * Author: Olivier Guyot
  69612. * Separates very slightly R, G and B colors on the edges of the screen
  69613. * Inspired by Francois Tarlier & Martins Upitis
  69614. */
  69615. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  69616. /**
  69617. * @ignore
  69618. * The chromatic aberration PostProcess id in the pipeline
  69619. */
  69620. LensChromaticAberrationEffect: string;
  69621. /**
  69622. * @ignore
  69623. * The highlights enhancing PostProcess id in the pipeline
  69624. */
  69625. HighlightsEnhancingEffect: string;
  69626. /**
  69627. * @ignore
  69628. * The depth-of-field PostProcess id in the pipeline
  69629. */
  69630. LensDepthOfFieldEffect: string;
  69631. private _scene;
  69632. private _depthTexture;
  69633. private _grainTexture;
  69634. private _chromaticAberrationPostProcess;
  69635. private _highlightsPostProcess;
  69636. private _depthOfFieldPostProcess;
  69637. private _edgeBlur;
  69638. private _grainAmount;
  69639. private _chromaticAberration;
  69640. private _distortion;
  69641. private _highlightsGain;
  69642. private _highlightsThreshold;
  69643. private _dofDistance;
  69644. private _dofAperture;
  69645. private _dofDarken;
  69646. private _dofPentagon;
  69647. private _blurNoise;
  69648. /**
  69649. * @constructor
  69650. *
  69651. * Effect parameters are as follow:
  69652. * {
  69653. * chromatic_aberration: number; // from 0 to x (1 for realism)
  69654. * edge_blur: number; // from 0 to x (1 for realism)
  69655. * distortion: number; // from 0 to x (1 for realism)
  69656. * grain_amount: number; // from 0 to 1
  69657. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  69658. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  69659. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  69660. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  69661. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  69662. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  69663. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  69664. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  69665. * }
  69666. * Note: if an effect parameter is unset, effect is disabled
  69667. *
  69668. * @param name The rendering pipeline name
  69669. * @param parameters - An object containing all parameters (see above)
  69670. * @param scene The scene linked to this pipeline
  69671. * @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)
  69672. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69673. */
  69674. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  69675. /**
  69676. * Get the class name
  69677. * @returns "LensRenderingPipeline"
  69678. */
  69679. getClassName(): string;
  69680. /**
  69681. * Gets associated scene
  69682. */
  69683. get scene(): Scene;
  69684. /**
  69685. * Gets or sets the edge blur
  69686. */
  69687. get edgeBlur(): number;
  69688. set edgeBlur(value: number);
  69689. /**
  69690. * Gets or sets the grain amount
  69691. */
  69692. get grainAmount(): number;
  69693. set grainAmount(value: number);
  69694. /**
  69695. * Gets or sets the chromatic aberration amount
  69696. */
  69697. get chromaticAberration(): number;
  69698. set chromaticAberration(value: number);
  69699. /**
  69700. * Gets or sets the depth of field aperture
  69701. */
  69702. get dofAperture(): number;
  69703. set dofAperture(value: number);
  69704. /**
  69705. * Gets or sets the edge distortion
  69706. */
  69707. get edgeDistortion(): number;
  69708. set edgeDistortion(value: number);
  69709. /**
  69710. * Gets or sets the depth of field distortion
  69711. */
  69712. get dofDistortion(): number;
  69713. set dofDistortion(value: number);
  69714. /**
  69715. * Gets or sets the darken out of focus amount
  69716. */
  69717. get darkenOutOfFocus(): number;
  69718. set darkenOutOfFocus(value: number);
  69719. /**
  69720. * Gets or sets a boolean indicating if blur noise is enabled
  69721. */
  69722. get blurNoise(): boolean;
  69723. set blurNoise(value: boolean);
  69724. /**
  69725. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  69726. */
  69727. get pentagonBokeh(): boolean;
  69728. set pentagonBokeh(value: boolean);
  69729. /**
  69730. * Gets or sets the highlight grain amount
  69731. */
  69732. get highlightsGain(): number;
  69733. set highlightsGain(value: number);
  69734. /**
  69735. * Gets or sets the highlight threshold
  69736. */
  69737. get highlightsThreshold(): number;
  69738. set highlightsThreshold(value: number);
  69739. /**
  69740. * Sets the amount of blur at the edges
  69741. * @param amount blur amount
  69742. */
  69743. setEdgeBlur(amount: number): void;
  69744. /**
  69745. * Sets edge blur to 0
  69746. */
  69747. disableEdgeBlur(): void;
  69748. /**
  69749. * Sets the amout of grain
  69750. * @param amount Amount of grain
  69751. */
  69752. setGrainAmount(amount: number): void;
  69753. /**
  69754. * Set grain amount to 0
  69755. */
  69756. disableGrain(): void;
  69757. /**
  69758. * Sets the chromatic aberration amount
  69759. * @param amount amount of chromatic aberration
  69760. */
  69761. setChromaticAberration(amount: number): void;
  69762. /**
  69763. * Sets chromatic aberration amount to 0
  69764. */
  69765. disableChromaticAberration(): void;
  69766. /**
  69767. * Sets the EdgeDistortion amount
  69768. * @param amount amount of EdgeDistortion
  69769. */
  69770. setEdgeDistortion(amount: number): void;
  69771. /**
  69772. * Sets edge distortion to 0
  69773. */
  69774. disableEdgeDistortion(): void;
  69775. /**
  69776. * Sets the FocusDistance amount
  69777. * @param amount amount of FocusDistance
  69778. */
  69779. setFocusDistance(amount: number): void;
  69780. /**
  69781. * Disables depth of field
  69782. */
  69783. disableDepthOfField(): void;
  69784. /**
  69785. * Sets the Aperture amount
  69786. * @param amount amount of Aperture
  69787. */
  69788. setAperture(amount: number): void;
  69789. /**
  69790. * Sets the DarkenOutOfFocus amount
  69791. * @param amount amount of DarkenOutOfFocus
  69792. */
  69793. setDarkenOutOfFocus(amount: number): void;
  69794. private _pentagonBokehIsEnabled;
  69795. /**
  69796. * Creates a pentagon bokeh effect
  69797. */
  69798. enablePentagonBokeh(): void;
  69799. /**
  69800. * Disables the pentagon bokeh effect
  69801. */
  69802. disablePentagonBokeh(): void;
  69803. /**
  69804. * Enables noise blur
  69805. */
  69806. enableNoiseBlur(): void;
  69807. /**
  69808. * Disables noise blur
  69809. */
  69810. disableNoiseBlur(): void;
  69811. /**
  69812. * Sets the HighlightsGain amount
  69813. * @param amount amount of HighlightsGain
  69814. */
  69815. setHighlightsGain(amount: number): void;
  69816. /**
  69817. * Sets the HighlightsThreshold amount
  69818. * @param amount amount of HighlightsThreshold
  69819. */
  69820. setHighlightsThreshold(amount: number): void;
  69821. /**
  69822. * Disables highlights
  69823. */
  69824. disableHighlights(): void;
  69825. /**
  69826. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  69827. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  69828. */
  69829. dispose(disableDepthRender?: boolean): void;
  69830. private _createChromaticAberrationPostProcess;
  69831. private _createHighlightsPostProcess;
  69832. private _createDepthOfFieldPostProcess;
  69833. private _createGrainTexture;
  69834. }
  69835. }
  69836. declare module "babylonjs/Shaders/ssao2.fragment" {
  69837. /** @hidden */
  69838. export var ssao2PixelShader: {
  69839. name: string;
  69840. shader: string;
  69841. };
  69842. }
  69843. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  69844. /** @hidden */
  69845. export var ssaoCombinePixelShader: {
  69846. name: string;
  69847. shader: string;
  69848. };
  69849. }
  69850. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  69851. import { Camera } from "babylonjs/Cameras/camera";
  69852. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  69853. import { Scene } from "babylonjs/scene";
  69854. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  69855. import "babylonjs/Shaders/ssao2.fragment";
  69856. import "babylonjs/Shaders/ssaoCombine.fragment";
  69857. /**
  69858. * Render pipeline to produce ssao effect
  69859. */
  69860. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  69861. /**
  69862. * @ignore
  69863. * The PassPostProcess id in the pipeline that contains the original scene color
  69864. */
  69865. SSAOOriginalSceneColorEffect: string;
  69866. /**
  69867. * @ignore
  69868. * The SSAO PostProcess id in the pipeline
  69869. */
  69870. SSAORenderEffect: string;
  69871. /**
  69872. * @ignore
  69873. * The horizontal blur PostProcess id in the pipeline
  69874. */
  69875. SSAOBlurHRenderEffect: string;
  69876. /**
  69877. * @ignore
  69878. * The vertical blur PostProcess id in the pipeline
  69879. */
  69880. SSAOBlurVRenderEffect: string;
  69881. /**
  69882. * @ignore
  69883. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  69884. */
  69885. SSAOCombineRenderEffect: string;
  69886. /**
  69887. * The output strength of the SSAO post-process. Default value is 1.0.
  69888. */
  69889. totalStrength: number;
  69890. /**
  69891. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  69892. */
  69893. maxZ: number;
  69894. /**
  69895. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  69896. */
  69897. minZAspect: number;
  69898. private _samples;
  69899. /**
  69900. * Number of samples used for the SSAO calculations. Default value is 8
  69901. */
  69902. set samples(n: number);
  69903. get samples(): number;
  69904. private _textureSamples;
  69905. /**
  69906. * Number of samples to use for antialiasing
  69907. */
  69908. set textureSamples(n: number);
  69909. get textureSamples(): number;
  69910. /**
  69911. * Ratio object used for SSAO ratio and blur ratio
  69912. */
  69913. private _ratio;
  69914. /**
  69915. * Dynamically generated sphere sampler.
  69916. */
  69917. private _sampleSphere;
  69918. /**
  69919. * Blur filter offsets
  69920. */
  69921. private _samplerOffsets;
  69922. private _expensiveBlur;
  69923. /**
  69924. * If bilateral blur should be used
  69925. */
  69926. set expensiveBlur(b: boolean);
  69927. get expensiveBlur(): boolean;
  69928. /**
  69929. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  69930. */
  69931. radius: number;
  69932. /**
  69933. * The base color of the SSAO post-process
  69934. * The final result is "base + ssao" between [0, 1]
  69935. */
  69936. base: number;
  69937. /**
  69938. * Support test.
  69939. */
  69940. static get IsSupported(): boolean;
  69941. private _scene;
  69942. private _depthTexture;
  69943. private _normalTexture;
  69944. private _randomTexture;
  69945. private _originalColorPostProcess;
  69946. private _ssaoPostProcess;
  69947. private _blurHPostProcess;
  69948. private _blurVPostProcess;
  69949. private _ssaoCombinePostProcess;
  69950. /**
  69951. * Gets active scene
  69952. */
  69953. get scene(): Scene;
  69954. /**
  69955. * @constructor
  69956. * @param name The rendering pipeline name
  69957. * @param scene The scene linked to this pipeline
  69958. * @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 }
  69959. * @param cameras The array of cameras that the rendering pipeline will be attached to
  69960. */
  69961. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  69962. /**
  69963. * Get the class name
  69964. * @returns "SSAO2RenderingPipeline"
  69965. */
  69966. getClassName(): string;
  69967. /**
  69968. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  69969. */
  69970. dispose(disableGeometryBufferRenderer?: boolean): void;
  69971. private _createBlurPostProcess;
  69972. /** @hidden */
  69973. _rebuild(): void;
  69974. private _bits;
  69975. private _radicalInverse_VdC;
  69976. private _hammersley;
  69977. private _hemisphereSample_uniform;
  69978. private _generateHemisphere;
  69979. private _createSSAOPostProcess;
  69980. private _createSSAOCombinePostProcess;
  69981. private _createRandomTexture;
  69982. /**
  69983. * Serialize the rendering pipeline (Used when exporting)
  69984. * @returns the serialized object
  69985. */
  69986. serialize(): any;
  69987. /**
  69988. * Parse the serialized pipeline
  69989. * @param source Source pipeline.
  69990. * @param scene The scene to load the pipeline to.
  69991. * @param rootUrl The URL of the serialized pipeline.
  69992. * @returns An instantiated pipeline from the serialized object.
  69993. */
  69994. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  69995. }
  69996. }
  69997. declare module "babylonjs/Shaders/ssao.fragment" {
  69998. /** @hidden */
  69999. export var ssaoPixelShader: {
  70000. name: string;
  70001. shader: string;
  70002. };
  70003. }
  70004. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  70005. import { Camera } from "babylonjs/Cameras/camera";
  70006. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70007. import { Scene } from "babylonjs/scene";
  70008. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70009. import "babylonjs/Shaders/ssao.fragment";
  70010. import "babylonjs/Shaders/ssaoCombine.fragment";
  70011. /**
  70012. * Render pipeline to produce ssao effect
  70013. */
  70014. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  70015. /**
  70016. * @ignore
  70017. * The PassPostProcess id in the pipeline that contains the original scene color
  70018. */
  70019. SSAOOriginalSceneColorEffect: string;
  70020. /**
  70021. * @ignore
  70022. * The SSAO PostProcess id in the pipeline
  70023. */
  70024. SSAORenderEffect: string;
  70025. /**
  70026. * @ignore
  70027. * The horizontal blur PostProcess id in the pipeline
  70028. */
  70029. SSAOBlurHRenderEffect: string;
  70030. /**
  70031. * @ignore
  70032. * The vertical blur PostProcess id in the pipeline
  70033. */
  70034. SSAOBlurVRenderEffect: string;
  70035. /**
  70036. * @ignore
  70037. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  70038. */
  70039. SSAOCombineRenderEffect: string;
  70040. /**
  70041. * The output strength of the SSAO post-process. Default value is 1.0.
  70042. */
  70043. totalStrength: number;
  70044. /**
  70045. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  70046. */
  70047. radius: number;
  70048. /**
  70049. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  70050. * Must not be equal to fallOff and superior to fallOff.
  70051. * Default value is 0.0075
  70052. */
  70053. area: number;
  70054. /**
  70055. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  70056. * Must not be equal to area and inferior to area.
  70057. * Default value is 0.000001
  70058. */
  70059. fallOff: number;
  70060. /**
  70061. * The base color of the SSAO post-process
  70062. * The final result is "base + ssao" between [0, 1]
  70063. */
  70064. base: number;
  70065. private _scene;
  70066. private _depthTexture;
  70067. private _randomTexture;
  70068. private _originalColorPostProcess;
  70069. private _ssaoPostProcess;
  70070. private _blurHPostProcess;
  70071. private _blurVPostProcess;
  70072. private _ssaoCombinePostProcess;
  70073. private _firstUpdate;
  70074. /**
  70075. * Gets active scene
  70076. */
  70077. get scene(): Scene;
  70078. /**
  70079. * @constructor
  70080. * @param name - The rendering pipeline name
  70081. * @param scene - The scene linked to this pipeline
  70082. * @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 }
  70083. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  70084. */
  70085. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  70086. /**
  70087. * Get the class name
  70088. * @returns "SSAORenderingPipeline"
  70089. */
  70090. getClassName(): string;
  70091. /**
  70092. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  70093. */
  70094. dispose(disableDepthRender?: boolean): void;
  70095. private _createBlurPostProcess;
  70096. /** @hidden */
  70097. _rebuild(): void;
  70098. private _createSSAOPostProcess;
  70099. private _createSSAOCombinePostProcess;
  70100. private _createRandomTexture;
  70101. }
  70102. }
  70103. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  70104. /** @hidden */
  70105. export var screenSpaceReflectionPixelShader: {
  70106. name: string;
  70107. shader: string;
  70108. };
  70109. }
  70110. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  70111. import { Nullable } from "babylonjs/types";
  70112. import { Camera } from "babylonjs/Cameras/camera";
  70113. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  70114. import { Scene } from "babylonjs/scene";
  70115. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  70116. import { Engine } from "babylonjs/Engines/engine";
  70117. /**
  70118. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  70119. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  70120. */
  70121. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  70122. /**
  70123. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  70124. */
  70125. threshold: number;
  70126. /**
  70127. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  70128. */
  70129. strength: number;
  70130. /**
  70131. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  70132. */
  70133. reflectionSpecularFalloffExponent: number;
  70134. /**
  70135. * 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]
  70136. */
  70137. step: number;
  70138. /**
  70139. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  70140. */
  70141. roughnessFactor: number;
  70142. private _geometryBufferRenderer;
  70143. private _enableSmoothReflections;
  70144. private _reflectionSamples;
  70145. private _smoothSteps;
  70146. /**
  70147. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  70148. * @param name The name of the effect.
  70149. * @param scene The scene containing the objects to calculate reflections.
  70150. * @param options The required width/height ratio to downsize to before computing the render pass.
  70151. * @param camera The camera to apply the render pass to.
  70152. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  70153. * @param engine The engine which the post process will be applied. (default: current engine)
  70154. * @param reusable If the post process can be reused on the same frame. (default: false)
  70155. * @param textureType Type of textures used when performing the post process. (default: 0)
  70156. * @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)
  70157. */
  70158. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  70159. /**
  70160. * Gets wether or not smoothing reflections is enabled.
  70161. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70162. */
  70163. get enableSmoothReflections(): boolean;
  70164. /**
  70165. * Sets wether or not smoothing reflections is enabled.
  70166. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  70167. */
  70168. set enableSmoothReflections(enabled: boolean);
  70169. /**
  70170. * Gets the number of samples taken while computing reflections. More samples count is high,
  70171. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70172. */
  70173. get reflectionSamples(): number;
  70174. /**
  70175. * Sets the number of samples taken while computing reflections. More samples count is high,
  70176. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  70177. */
  70178. set reflectionSamples(samples: number);
  70179. /**
  70180. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  70181. * more the post-process will require GPU power and can generate a drop in FPS.
  70182. * Default value (5.0) work pretty well in all cases but can be adjusted.
  70183. */
  70184. get smoothSteps(): number;
  70185. set smoothSteps(steps: number);
  70186. private _updateEffectDefines;
  70187. }
  70188. }
  70189. declare module "babylonjs/Shaders/standard.fragment" {
  70190. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  70191. /** @hidden */
  70192. export var standardPixelShader: {
  70193. name: string;
  70194. shader: string;
  70195. };
  70196. }
  70197. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  70198. import { Nullable } from "babylonjs/types";
  70199. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  70200. import { Camera } from "babylonjs/Cameras/camera";
  70201. import { Texture } from "babylonjs/Materials/Textures/texture";
  70202. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70203. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70204. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  70205. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  70206. import { IDisposable } from "babylonjs/scene";
  70207. import { SpotLight } from "babylonjs/Lights/spotLight";
  70208. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  70209. import { Scene } from "babylonjs/scene";
  70210. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70211. import { Animation } from "babylonjs/Animations/animation";
  70212. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70213. import "babylonjs/Shaders/standard.fragment";
  70214. /**
  70215. * Standard rendering pipeline
  70216. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70217. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  70218. */
  70219. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  70220. /**
  70221. * Public members
  70222. */
  70223. /**
  70224. * Post-process which contains the original scene color before the pipeline applies all the effects
  70225. */
  70226. originalPostProcess: Nullable<PostProcess>;
  70227. /**
  70228. * Post-process used to down scale an image x4
  70229. */
  70230. downSampleX4PostProcess: Nullable<PostProcess>;
  70231. /**
  70232. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  70233. */
  70234. brightPassPostProcess: Nullable<PostProcess>;
  70235. /**
  70236. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  70237. */
  70238. blurHPostProcesses: PostProcess[];
  70239. /**
  70240. * Post-process array storing all the vertical blur post-processes used by the pipeline
  70241. */
  70242. blurVPostProcesses: PostProcess[];
  70243. /**
  70244. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  70245. */
  70246. textureAdderPostProcess: Nullable<PostProcess>;
  70247. /**
  70248. * Post-process used to create volumetric lighting effect
  70249. */
  70250. volumetricLightPostProcess: Nullable<PostProcess>;
  70251. /**
  70252. * Post-process used to smooth the previous volumetric light post-process on the X axis
  70253. */
  70254. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  70255. /**
  70256. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  70257. */
  70258. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  70259. /**
  70260. * Post-process used to merge the volumetric light effect and the real scene color
  70261. */
  70262. volumetricLightMergePostProces: Nullable<PostProcess>;
  70263. /**
  70264. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  70265. */
  70266. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  70267. /**
  70268. * Base post-process used to calculate the average luminance of the final image for HDR
  70269. */
  70270. luminancePostProcess: Nullable<PostProcess>;
  70271. /**
  70272. * Post-processes used to create down sample post-processes in order to get
  70273. * the average luminance of the final image for HDR
  70274. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  70275. */
  70276. luminanceDownSamplePostProcesses: PostProcess[];
  70277. /**
  70278. * Post-process used to create a HDR effect (light adaptation)
  70279. */
  70280. hdrPostProcess: Nullable<PostProcess>;
  70281. /**
  70282. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  70283. */
  70284. textureAdderFinalPostProcess: Nullable<PostProcess>;
  70285. /**
  70286. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  70287. */
  70288. lensFlareFinalPostProcess: Nullable<PostProcess>;
  70289. /**
  70290. * Post-process used to merge the final HDR post-process and the real scene color
  70291. */
  70292. hdrFinalPostProcess: Nullable<PostProcess>;
  70293. /**
  70294. * Post-process used to create a lens flare effect
  70295. */
  70296. lensFlarePostProcess: Nullable<PostProcess>;
  70297. /**
  70298. * Post-process that merges the result of the lens flare post-process and the real scene color
  70299. */
  70300. lensFlareComposePostProcess: Nullable<PostProcess>;
  70301. /**
  70302. * Post-process used to create a motion blur effect
  70303. */
  70304. motionBlurPostProcess: Nullable<PostProcess>;
  70305. /**
  70306. * Post-process used to create a depth of field effect
  70307. */
  70308. depthOfFieldPostProcess: Nullable<PostProcess>;
  70309. /**
  70310. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  70311. */
  70312. fxaaPostProcess: Nullable<FxaaPostProcess>;
  70313. /**
  70314. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  70315. */
  70316. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  70317. /**
  70318. * Represents the brightness threshold in order to configure the illuminated surfaces
  70319. */
  70320. brightThreshold: number;
  70321. /**
  70322. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  70323. */
  70324. blurWidth: number;
  70325. /**
  70326. * Sets if the blur for highlighted surfaces must be only horizontal
  70327. */
  70328. horizontalBlur: boolean;
  70329. /**
  70330. * Gets the overall exposure used by the pipeline
  70331. */
  70332. get exposure(): number;
  70333. /**
  70334. * Sets the overall exposure used by the pipeline
  70335. */
  70336. set exposure(value: number);
  70337. /**
  70338. * Texture used typically to simulate "dirty" on camera lens
  70339. */
  70340. lensTexture: Nullable<Texture>;
  70341. /**
  70342. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  70343. */
  70344. volumetricLightCoefficient: number;
  70345. /**
  70346. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  70347. */
  70348. volumetricLightPower: number;
  70349. /**
  70350. * Used the set the blur intensity to smooth the volumetric lights
  70351. */
  70352. volumetricLightBlurScale: number;
  70353. /**
  70354. * Light (spot or directional) used to generate the volumetric lights rays
  70355. * The source light must have a shadow generate so the pipeline can get its
  70356. * depth map
  70357. */
  70358. sourceLight: Nullable<SpotLight | DirectionalLight>;
  70359. /**
  70360. * For eye adaptation, represents the minimum luminance the eye can see
  70361. */
  70362. hdrMinimumLuminance: number;
  70363. /**
  70364. * For eye adaptation, represents the decrease luminance speed
  70365. */
  70366. hdrDecreaseRate: number;
  70367. /**
  70368. * For eye adaptation, represents the increase luminance speed
  70369. */
  70370. hdrIncreaseRate: number;
  70371. /**
  70372. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70373. */
  70374. get hdrAutoExposure(): boolean;
  70375. /**
  70376. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  70377. */
  70378. set hdrAutoExposure(value: boolean);
  70379. /**
  70380. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  70381. */
  70382. lensColorTexture: Nullable<Texture>;
  70383. /**
  70384. * The overall strengh for the lens flare effect
  70385. */
  70386. lensFlareStrength: number;
  70387. /**
  70388. * Dispersion coefficient for lens flare ghosts
  70389. */
  70390. lensFlareGhostDispersal: number;
  70391. /**
  70392. * Main lens flare halo width
  70393. */
  70394. lensFlareHaloWidth: number;
  70395. /**
  70396. * Based on the lens distortion effect, defines how much the lens flare result
  70397. * is distorted
  70398. */
  70399. lensFlareDistortionStrength: number;
  70400. /**
  70401. * Configures the blur intensity used for for lens flare (halo)
  70402. */
  70403. lensFlareBlurWidth: number;
  70404. /**
  70405. * Lens star texture must be used to simulate rays on the flares and is available
  70406. * in the documentation
  70407. */
  70408. lensStarTexture: Nullable<Texture>;
  70409. /**
  70410. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  70411. * flare effect by taking account of the dirt texture
  70412. */
  70413. lensFlareDirtTexture: Nullable<Texture>;
  70414. /**
  70415. * Represents the focal length for the depth of field effect
  70416. */
  70417. depthOfFieldDistance: number;
  70418. /**
  70419. * Represents the blur intensity for the blurred part of the depth of field effect
  70420. */
  70421. depthOfFieldBlurWidth: number;
  70422. /**
  70423. * Gets how much the image is blurred by the movement while using the motion blur post-process
  70424. */
  70425. get motionStrength(): number;
  70426. /**
  70427. * Sets how much the image is blurred by the movement while using the motion blur post-process
  70428. */
  70429. set motionStrength(strength: number);
  70430. /**
  70431. * Gets wether or not the motion blur post-process is object based or screen based.
  70432. */
  70433. get objectBasedMotionBlur(): boolean;
  70434. /**
  70435. * Sets wether or not the motion blur post-process should be object based or screen based
  70436. */
  70437. set objectBasedMotionBlur(value: boolean);
  70438. /**
  70439. * List of animations for the pipeline (IAnimatable implementation)
  70440. */
  70441. animations: Animation[];
  70442. /**
  70443. * Private members
  70444. */
  70445. private _scene;
  70446. private _currentDepthOfFieldSource;
  70447. private _basePostProcess;
  70448. private _fixedExposure;
  70449. private _currentExposure;
  70450. private _hdrAutoExposure;
  70451. private _hdrCurrentLuminance;
  70452. private _motionStrength;
  70453. private _isObjectBasedMotionBlur;
  70454. private _floatTextureType;
  70455. private _camerasToBeAttached;
  70456. private _ratio;
  70457. private _bloomEnabled;
  70458. private _depthOfFieldEnabled;
  70459. private _vlsEnabled;
  70460. private _lensFlareEnabled;
  70461. private _hdrEnabled;
  70462. private _motionBlurEnabled;
  70463. private _fxaaEnabled;
  70464. private _screenSpaceReflectionsEnabled;
  70465. private _motionBlurSamples;
  70466. private _volumetricLightStepsCount;
  70467. private _samples;
  70468. /**
  70469. * @ignore
  70470. * Specifies if the bloom pipeline is enabled
  70471. */
  70472. get BloomEnabled(): boolean;
  70473. set BloomEnabled(enabled: boolean);
  70474. /**
  70475. * @ignore
  70476. * Specifies if the depth of field pipeline is enabed
  70477. */
  70478. get DepthOfFieldEnabled(): boolean;
  70479. set DepthOfFieldEnabled(enabled: boolean);
  70480. /**
  70481. * @ignore
  70482. * Specifies if the lens flare pipeline is enabed
  70483. */
  70484. get LensFlareEnabled(): boolean;
  70485. set LensFlareEnabled(enabled: boolean);
  70486. /**
  70487. * @ignore
  70488. * Specifies if the HDR pipeline is enabled
  70489. */
  70490. get HDREnabled(): boolean;
  70491. set HDREnabled(enabled: boolean);
  70492. /**
  70493. * @ignore
  70494. * Specifies if the volumetric lights scattering effect is enabled
  70495. */
  70496. get VLSEnabled(): boolean;
  70497. set VLSEnabled(enabled: boolean);
  70498. /**
  70499. * @ignore
  70500. * Specifies if the motion blur effect is enabled
  70501. */
  70502. get MotionBlurEnabled(): boolean;
  70503. set MotionBlurEnabled(enabled: boolean);
  70504. /**
  70505. * Specifies if anti-aliasing is enabled
  70506. */
  70507. get fxaaEnabled(): boolean;
  70508. set fxaaEnabled(enabled: boolean);
  70509. /**
  70510. * Specifies if screen space reflections are enabled.
  70511. */
  70512. get screenSpaceReflectionsEnabled(): boolean;
  70513. set screenSpaceReflectionsEnabled(enabled: boolean);
  70514. /**
  70515. * Specifies the number of steps used to calculate the volumetric lights
  70516. * Typically in interval [50, 200]
  70517. */
  70518. get volumetricLightStepsCount(): number;
  70519. set volumetricLightStepsCount(count: number);
  70520. /**
  70521. * Specifies the number of samples used for the motion blur effect
  70522. * Typically in interval [16, 64]
  70523. */
  70524. get motionBlurSamples(): number;
  70525. set motionBlurSamples(samples: number);
  70526. /**
  70527. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  70528. */
  70529. get samples(): number;
  70530. set samples(sampleCount: number);
  70531. /**
  70532. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  70533. * @constructor
  70534. * @param name The rendering pipeline name
  70535. * @param scene The scene linked to this pipeline
  70536. * @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)
  70537. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  70538. * @param cameras The array of cameras that the rendering pipeline will be attached to
  70539. */
  70540. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  70541. private _buildPipeline;
  70542. private _createDownSampleX4PostProcess;
  70543. private _createBrightPassPostProcess;
  70544. private _createBlurPostProcesses;
  70545. private _createTextureAdderPostProcess;
  70546. private _createVolumetricLightPostProcess;
  70547. private _createLuminancePostProcesses;
  70548. private _createHdrPostProcess;
  70549. private _createLensFlarePostProcess;
  70550. private _createDepthOfFieldPostProcess;
  70551. private _createMotionBlurPostProcess;
  70552. private _getDepthTexture;
  70553. private _disposePostProcesses;
  70554. /**
  70555. * Dispose of the pipeline and stop all post processes
  70556. */
  70557. dispose(): void;
  70558. /**
  70559. * Serialize the rendering pipeline (Used when exporting)
  70560. * @returns the serialized object
  70561. */
  70562. serialize(): any;
  70563. /**
  70564. * Parse the serialized pipeline
  70565. * @param source Source pipeline.
  70566. * @param scene The scene to load the pipeline to.
  70567. * @param rootUrl The URL of the serialized pipeline.
  70568. * @returns An instantiated pipeline from the serialized object.
  70569. */
  70570. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  70571. /**
  70572. * Luminance steps
  70573. */
  70574. static LuminanceSteps: number;
  70575. }
  70576. }
  70577. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  70578. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  70579. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  70580. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  70581. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  70582. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  70583. }
  70584. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  70585. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  70586. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  70587. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  70588. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  70589. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  70590. }
  70591. declare module "babylonjs/Shaders/tonemap.fragment" {
  70592. /** @hidden */
  70593. export var tonemapPixelShader: {
  70594. name: string;
  70595. shader: string;
  70596. };
  70597. }
  70598. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  70599. import { Camera } from "babylonjs/Cameras/camera";
  70600. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70601. import "babylonjs/Shaders/tonemap.fragment";
  70602. import { Engine } from "babylonjs/Engines/engine";
  70603. /** Defines operator used for tonemapping */
  70604. export enum TonemappingOperator {
  70605. /** Hable */
  70606. Hable = 0,
  70607. /** Reinhard */
  70608. Reinhard = 1,
  70609. /** HejiDawson */
  70610. HejiDawson = 2,
  70611. /** Photographic */
  70612. Photographic = 3
  70613. }
  70614. /**
  70615. * Defines a post process to apply tone mapping
  70616. */
  70617. export class TonemapPostProcess extends PostProcess {
  70618. private _operator;
  70619. /** Defines the required exposure adjustement */
  70620. exposureAdjustment: number;
  70621. /**
  70622. * Creates a new TonemapPostProcess
  70623. * @param name defines the name of the postprocess
  70624. * @param _operator defines the operator to use
  70625. * @param exposureAdjustment defines the required exposure adjustement
  70626. * @param camera defines the camera to use (can be null)
  70627. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  70628. * @param engine defines the hosting engine (can be ignore if camera is set)
  70629. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  70630. */
  70631. constructor(name: string, _operator: TonemappingOperator,
  70632. /** Defines the required exposure adjustement */
  70633. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  70634. }
  70635. }
  70636. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  70637. /** @hidden */
  70638. export var volumetricLightScatteringPixelShader: {
  70639. name: string;
  70640. shader: string;
  70641. };
  70642. }
  70643. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  70644. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  70645. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  70646. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  70647. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  70648. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  70649. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  70650. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  70651. /** @hidden */
  70652. export var volumetricLightScatteringPassVertexShader: {
  70653. name: string;
  70654. shader: string;
  70655. };
  70656. }
  70657. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  70658. /** @hidden */
  70659. export var volumetricLightScatteringPassPixelShader: {
  70660. name: string;
  70661. shader: string;
  70662. };
  70663. }
  70664. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  70665. import { Vector3 } from "babylonjs/Maths/math.vector";
  70666. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70667. import { Mesh } from "babylonjs/Meshes/mesh";
  70668. import { Camera } from "babylonjs/Cameras/camera";
  70669. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  70670. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  70671. import { Scene } from "babylonjs/scene";
  70672. import "babylonjs/Meshes/Builders/planeBuilder";
  70673. import "babylonjs/Shaders/depth.vertex";
  70674. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  70675. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  70676. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  70677. import { Engine } from "babylonjs/Engines/engine";
  70678. /**
  70679. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  70680. */
  70681. export class VolumetricLightScatteringPostProcess extends PostProcess {
  70682. private _volumetricLightScatteringPass;
  70683. private _volumetricLightScatteringRTT;
  70684. private _viewPort;
  70685. private _screenCoordinates;
  70686. private _cachedDefines;
  70687. /**
  70688. * If not undefined, the mesh position is computed from the attached node position
  70689. */
  70690. attachedNode: {
  70691. position: Vector3;
  70692. };
  70693. /**
  70694. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  70695. */
  70696. customMeshPosition: Vector3;
  70697. /**
  70698. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  70699. */
  70700. useCustomMeshPosition: boolean;
  70701. /**
  70702. * If the post-process should inverse the light scattering direction
  70703. */
  70704. invert: boolean;
  70705. /**
  70706. * The internal mesh used by the post-process
  70707. */
  70708. mesh: Mesh;
  70709. /**
  70710. * @hidden
  70711. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  70712. */
  70713. get useDiffuseColor(): boolean;
  70714. set useDiffuseColor(useDiffuseColor: boolean);
  70715. /**
  70716. * Array containing the excluded meshes not rendered in the internal pass
  70717. */
  70718. excludedMeshes: AbstractMesh[];
  70719. /**
  70720. * Controls the overall intensity of the post-process
  70721. */
  70722. exposure: number;
  70723. /**
  70724. * Dissipates each sample's contribution in range [0, 1]
  70725. */
  70726. decay: number;
  70727. /**
  70728. * Controls the overall intensity of each sample
  70729. */
  70730. weight: number;
  70731. /**
  70732. * Controls the density of each sample
  70733. */
  70734. density: number;
  70735. /**
  70736. * @constructor
  70737. * @param name The post-process name
  70738. * @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)
  70739. * @param camera The camera that the post-process will be attached to
  70740. * @param mesh The mesh used to create the light scattering
  70741. * @param samples The post-process quality, default 100
  70742. * @param samplingModeThe post-process filtering mode
  70743. * @param engine The babylon engine
  70744. * @param reusable If the post-process is reusable
  70745. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  70746. */
  70747. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  70748. /**
  70749. * Returns the string "VolumetricLightScatteringPostProcess"
  70750. * @returns "VolumetricLightScatteringPostProcess"
  70751. */
  70752. getClassName(): string;
  70753. private _isReady;
  70754. /**
  70755. * Sets the new light position for light scattering effect
  70756. * @param position The new custom light position
  70757. */
  70758. setCustomMeshPosition(position: Vector3): void;
  70759. /**
  70760. * Returns the light position for light scattering effect
  70761. * @return Vector3 The custom light position
  70762. */
  70763. getCustomMeshPosition(): Vector3;
  70764. /**
  70765. * Disposes the internal assets and detaches the post-process from the camera
  70766. */
  70767. dispose(camera: Camera): void;
  70768. /**
  70769. * Returns the render target texture used by the post-process
  70770. * @return the render target texture used by the post-process
  70771. */
  70772. getPass(): RenderTargetTexture;
  70773. private _meshExcluded;
  70774. private _createPass;
  70775. private _updateMeshScreenCoordinates;
  70776. /**
  70777. * Creates a default mesh for the Volumeric Light Scattering post-process
  70778. * @param name The mesh name
  70779. * @param scene The scene where to create the mesh
  70780. * @return the default mesh
  70781. */
  70782. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  70783. }
  70784. }
  70785. declare module "babylonjs/PostProcesses/index" {
  70786. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  70787. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  70788. export * from "babylonjs/PostProcesses/bloomEffect";
  70789. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  70790. export * from "babylonjs/PostProcesses/blurPostProcess";
  70791. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  70792. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  70793. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  70794. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  70795. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  70796. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  70797. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  70798. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  70799. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  70800. export * from "babylonjs/PostProcesses/filterPostProcess";
  70801. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  70802. export * from "babylonjs/PostProcesses/grainPostProcess";
  70803. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  70804. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  70805. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  70806. export * from "babylonjs/PostProcesses/passPostProcess";
  70807. export * from "babylonjs/PostProcesses/postProcess";
  70808. export * from "babylonjs/PostProcesses/postProcessManager";
  70809. export * from "babylonjs/PostProcesses/refractionPostProcess";
  70810. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  70811. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  70812. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  70813. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  70814. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  70815. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  70816. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  70817. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  70818. }
  70819. declare module "babylonjs/Probes/index" {
  70820. export * from "babylonjs/Probes/reflectionProbe";
  70821. }
  70822. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  70823. import { Scene } from "babylonjs/scene";
  70824. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  70825. import { SmartArray } from "babylonjs/Misc/smartArray";
  70826. import { ISceneComponent } from "babylonjs/sceneComponent";
  70827. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  70828. import "babylonjs/Meshes/Builders/boxBuilder";
  70829. import "babylonjs/Shaders/color.fragment";
  70830. import "babylonjs/Shaders/color.vertex";
  70831. import { Color3 } from "babylonjs/Maths/math.color";
  70832. module "babylonjs/scene" {
  70833. interface Scene {
  70834. /** @hidden (Backing field) */
  70835. _boundingBoxRenderer: BoundingBoxRenderer;
  70836. /** @hidden (Backing field) */
  70837. _forceShowBoundingBoxes: boolean;
  70838. /**
  70839. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  70840. */
  70841. forceShowBoundingBoxes: boolean;
  70842. /**
  70843. * Gets the bounding box renderer associated with the scene
  70844. * @returns a BoundingBoxRenderer
  70845. */
  70846. getBoundingBoxRenderer(): BoundingBoxRenderer;
  70847. }
  70848. }
  70849. module "babylonjs/Meshes/abstractMesh" {
  70850. interface AbstractMesh {
  70851. /** @hidden (Backing field) */
  70852. _showBoundingBox: boolean;
  70853. /**
  70854. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  70855. */
  70856. showBoundingBox: boolean;
  70857. }
  70858. }
  70859. /**
  70860. * Component responsible of rendering the bounding box of the meshes in a scene.
  70861. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  70862. */
  70863. export class BoundingBoxRenderer implements ISceneComponent {
  70864. /**
  70865. * The component name helpfull to identify the component in the list of scene components.
  70866. */
  70867. readonly name: string;
  70868. /**
  70869. * The scene the component belongs to.
  70870. */
  70871. scene: Scene;
  70872. /**
  70873. * Color of the bounding box lines placed in front of an object
  70874. */
  70875. frontColor: Color3;
  70876. /**
  70877. * Color of the bounding box lines placed behind an object
  70878. */
  70879. backColor: Color3;
  70880. /**
  70881. * Defines if the renderer should show the back lines or not
  70882. */
  70883. showBackLines: boolean;
  70884. /**
  70885. * @hidden
  70886. */
  70887. renderList: SmartArray<BoundingBox>;
  70888. private _colorShader;
  70889. private _vertexBuffers;
  70890. private _indexBuffer;
  70891. private _fillIndexBuffer;
  70892. private _fillIndexData;
  70893. /**
  70894. * Instantiates a new bounding box renderer in a scene.
  70895. * @param scene the scene the renderer renders in
  70896. */
  70897. constructor(scene: Scene);
  70898. /**
  70899. * Registers the component in a given scene
  70900. */
  70901. register(): void;
  70902. private _evaluateSubMesh;
  70903. private _activeMesh;
  70904. private _prepareRessources;
  70905. private _createIndexBuffer;
  70906. /**
  70907. * Rebuilds the elements related to this component in case of
  70908. * context lost for instance.
  70909. */
  70910. rebuild(): void;
  70911. /**
  70912. * @hidden
  70913. */
  70914. reset(): void;
  70915. /**
  70916. * Render the bounding boxes of a specific rendering group
  70917. * @param renderingGroupId defines the rendering group to render
  70918. */
  70919. render(renderingGroupId: number): void;
  70920. /**
  70921. * In case of occlusion queries, we can render the occlusion bounding box through this method
  70922. * @param mesh Define the mesh to render the occlusion bounding box for
  70923. */
  70924. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  70925. /**
  70926. * Dispose and release the resources attached to this renderer.
  70927. */
  70928. dispose(): void;
  70929. }
  70930. }
  70931. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  70932. import { Nullable } from "babylonjs/types";
  70933. import { Scene } from "babylonjs/scene";
  70934. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  70935. import { Camera } from "babylonjs/Cameras/camera";
  70936. import { ISceneComponent } from "babylonjs/sceneComponent";
  70937. module "babylonjs/scene" {
  70938. interface Scene {
  70939. /** @hidden (Backing field) */
  70940. _depthRenderer: {
  70941. [id: string]: DepthRenderer;
  70942. };
  70943. /**
  70944. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  70945. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  70946. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  70947. * @returns the created depth renderer
  70948. */
  70949. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  70950. /**
  70951. * Disables a depth renderer for a given camera
  70952. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  70953. */
  70954. disableDepthRenderer(camera?: Nullable<Camera>): void;
  70955. }
  70956. }
  70957. /**
  70958. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  70959. * in several rendering techniques.
  70960. */
  70961. export class DepthRendererSceneComponent implements ISceneComponent {
  70962. /**
  70963. * The component name helpfull to identify the component in the list of scene components.
  70964. */
  70965. readonly name: string;
  70966. /**
  70967. * The scene the component belongs to.
  70968. */
  70969. scene: Scene;
  70970. /**
  70971. * Creates a new instance of the component for the given scene
  70972. * @param scene Defines the scene to register the component in
  70973. */
  70974. constructor(scene: Scene);
  70975. /**
  70976. * Registers the component in a given scene
  70977. */
  70978. register(): void;
  70979. /**
  70980. * Rebuilds the elements related to this component in case of
  70981. * context lost for instance.
  70982. */
  70983. rebuild(): void;
  70984. /**
  70985. * Disposes the component and the associated ressources
  70986. */
  70987. dispose(): void;
  70988. private _gatherRenderTargets;
  70989. private _gatherActiveCameraRenderTargets;
  70990. }
  70991. }
  70992. declare module "babylonjs/Shaders/outline.fragment" {
  70993. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  70994. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  70995. /** @hidden */
  70996. export var outlinePixelShader: {
  70997. name: string;
  70998. shader: string;
  70999. };
  71000. }
  71001. declare module "babylonjs/Shaders/outline.vertex" {
  71002. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  71003. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  71004. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  71005. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  71006. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  71007. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  71008. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  71009. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  71010. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  71011. /** @hidden */
  71012. export var outlineVertexShader: {
  71013. name: string;
  71014. shader: string;
  71015. };
  71016. }
  71017. declare module "babylonjs/Rendering/outlineRenderer" {
  71018. import { SubMesh } from "babylonjs/Meshes/subMesh";
  71019. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  71020. import { Scene } from "babylonjs/scene";
  71021. import { ISceneComponent } from "babylonjs/sceneComponent";
  71022. import "babylonjs/Shaders/outline.fragment";
  71023. import "babylonjs/Shaders/outline.vertex";
  71024. module "babylonjs/scene" {
  71025. interface Scene {
  71026. /** @hidden */
  71027. _outlineRenderer: OutlineRenderer;
  71028. /**
  71029. * Gets the outline renderer associated with the scene
  71030. * @returns a OutlineRenderer
  71031. */
  71032. getOutlineRenderer(): OutlineRenderer;
  71033. }
  71034. }
  71035. module "babylonjs/Meshes/abstractMesh" {
  71036. interface AbstractMesh {
  71037. /** @hidden (Backing field) */
  71038. _renderOutline: boolean;
  71039. /**
  71040. * Gets or sets a boolean indicating if the outline must be rendered as well
  71041. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  71042. */
  71043. renderOutline: boolean;
  71044. /** @hidden (Backing field) */
  71045. _renderOverlay: boolean;
  71046. /**
  71047. * Gets or sets a boolean indicating if the overlay must be rendered as well
  71048. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  71049. */
  71050. renderOverlay: boolean;
  71051. }
  71052. }
  71053. /**
  71054. * This class is responsible to draw bothe outline/overlay of meshes.
  71055. * It should not be used directly but through the available method on mesh.
  71056. */
  71057. export class OutlineRenderer implements ISceneComponent {
  71058. /**
  71059. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  71060. */
  71061. private static _StencilReference;
  71062. /**
  71063. * The name of the component. Each component must have a unique name.
  71064. */
  71065. name: string;
  71066. /**
  71067. * The scene the component belongs to.
  71068. */
  71069. scene: Scene;
  71070. /**
  71071. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  71072. */
  71073. zOffset: number;
  71074. private _engine;
  71075. private _effect;
  71076. private _cachedDefines;
  71077. private _savedDepthWrite;
  71078. /**
  71079. * Instantiates a new outline renderer. (There could be only one per scene).
  71080. * @param scene Defines the scene it belongs to
  71081. */
  71082. constructor(scene: Scene);
  71083. /**
  71084. * Register the component to one instance of a scene.
  71085. */
  71086. register(): void;
  71087. /**
  71088. * Rebuilds the elements related to this component in case of
  71089. * context lost for instance.
  71090. */
  71091. rebuild(): void;
  71092. /**
  71093. * Disposes the component and the associated ressources.
  71094. */
  71095. dispose(): void;
  71096. /**
  71097. * Renders the outline in the canvas.
  71098. * @param subMesh Defines the sumesh to render
  71099. * @param batch Defines the batch of meshes in case of instances
  71100. * @param useOverlay Defines if the rendering is for the overlay or the outline
  71101. */
  71102. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  71103. /**
  71104. * Returns whether or not the outline renderer is ready for a given submesh.
  71105. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  71106. * @param subMesh Defines the submesh to check readyness for
  71107. * @param useInstances Defines wheter wee are trying to render instances or not
  71108. * @returns true if ready otherwise false
  71109. */
  71110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  71111. private _beforeRenderingMesh;
  71112. private _afterRenderingMesh;
  71113. }
  71114. }
  71115. declare module "babylonjs/Rendering/index" {
  71116. export * from "babylonjs/Rendering/boundingBoxRenderer";
  71117. export * from "babylonjs/Rendering/depthRenderer";
  71118. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  71119. export * from "babylonjs/Rendering/edgesRenderer";
  71120. export * from "babylonjs/Rendering/geometryBufferRenderer";
  71121. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  71122. export * from "babylonjs/Rendering/outlineRenderer";
  71123. export * from "babylonjs/Rendering/renderingGroup";
  71124. export * from "babylonjs/Rendering/renderingManager";
  71125. export * from "babylonjs/Rendering/utilityLayerRenderer";
  71126. }
  71127. declare module "babylonjs/Sprites/ISprites" {
  71128. /**
  71129. * Defines the basic options interface of a Sprite Frame Source Size.
  71130. */
  71131. export interface ISpriteJSONSpriteSourceSize {
  71132. /**
  71133. * number of the original width of the Frame
  71134. */
  71135. w: number;
  71136. /**
  71137. * number of the original height of the Frame
  71138. */
  71139. h: number;
  71140. }
  71141. /**
  71142. * Defines the basic options interface of a Sprite Frame Data.
  71143. */
  71144. export interface ISpriteJSONSpriteFrameData {
  71145. /**
  71146. * number of the x offset of the Frame
  71147. */
  71148. x: number;
  71149. /**
  71150. * number of the y offset of the Frame
  71151. */
  71152. y: number;
  71153. /**
  71154. * number of the width of the Frame
  71155. */
  71156. w: number;
  71157. /**
  71158. * number of the height of the Frame
  71159. */
  71160. h: number;
  71161. }
  71162. /**
  71163. * Defines the basic options interface of a JSON Sprite.
  71164. */
  71165. export interface ISpriteJSONSprite {
  71166. /**
  71167. * string name of the Frame
  71168. */
  71169. filename: string;
  71170. /**
  71171. * ISpriteJSONSpriteFrame basic object of the frame data
  71172. */
  71173. frame: ISpriteJSONSpriteFrameData;
  71174. /**
  71175. * boolean to flag is the frame was rotated.
  71176. */
  71177. rotated: boolean;
  71178. /**
  71179. * boolean to flag is the frame was trimmed.
  71180. */
  71181. trimmed: boolean;
  71182. /**
  71183. * ISpriteJSONSpriteFrame basic object of the source data
  71184. */
  71185. spriteSourceSize: ISpriteJSONSpriteFrameData;
  71186. /**
  71187. * ISpriteJSONSpriteFrame basic object of the source data
  71188. */
  71189. sourceSize: ISpriteJSONSpriteSourceSize;
  71190. }
  71191. /**
  71192. * Defines the basic options interface of a JSON atlas.
  71193. */
  71194. export interface ISpriteJSONAtlas {
  71195. /**
  71196. * Array of objects that contain the frame data.
  71197. */
  71198. frames: Array<ISpriteJSONSprite>;
  71199. /**
  71200. * object basic object containing the sprite meta data.
  71201. */
  71202. meta?: object;
  71203. }
  71204. }
  71205. declare module "babylonjs/Shaders/spriteMap.fragment" {
  71206. /** @hidden */
  71207. export var spriteMapPixelShader: {
  71208. name: string;
  71209. shader: string;
  71210. };
  71211. }
  71212. declare module "babylonjs/Shaders/spriteMap.vertex" {
  71213. /** @hidden */
  71214. export var spriteMapVertexShader: {
  71215. name: string;
  71216. shader: string;
  71217. };
  71218. }
  71219. declare module "babylonjs/Sprites/spriteMap" {
  71220. import { IDisposable, Scene } from "babylonjs/scene";
  71221. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  71222. import { Texture } from "babylonjs/Materials/Textures/texture";
  71223. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71224. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  71225. import "babylonjs/Meshes/Builders/planeBuilder";
  71226. import "babylonjs/Shaders/spriteMap.fragment";
  71227. import "babylonjs/Shaders/spriteMap.vertex";
  71228. /**
  71229. * Defines the basic options interface of a SpriteMap
  71230. */
  71231. export interface ISpriteMapOptions {
  71232. /**
  71233. * Vector2 of the number of cells in the grid.
  71234. */
  71235. stageSize?: Vector2;
  71236. /**
  71237. * Vector2 of the size of the output plane in World Units.
  71238. */
  71239. outputSize?: Vector2;
  71240. /**
  71241. * Vector3 of the position of the output plane in World Units.
  71242. */
  71243. outputPosition?: Vector3;
  71244. /**
  71245. * Vector3 of the rotation of the output plane.
  71246. */
  71247. outputRotation?: Vector3;
  71248. /**
  71249. * number of layers that the system will reserve in resources.
  71250. */
  71251. layerCount?: number;
  71252. /**
  71253. * number of max animation frames a single cell will reserve in resources.
  71254. */
  71255. maxAnimationFrames?: number;
  71256. /**
  71257. * number cell index of the base tile when the system compiles.
  71258. */
  71259. baseTile?: number;
  71260. /**
  71261. * boolean flip the sprite after its been repositioned by the framing data.
  71262. */
  71263. flipU?: boolean;
  71264. /**
  71265. * Vector3 scalar of the global RGB values of the SpriteMap.
  71266. */
  71267. colorMultiply?: Vector3;
  71268. }
  71269. /**
  71270. * Defines the IDisposable interface in order to be cleanable from resources.
  71271. */
  71272. export interface ISpriteMap extends IDisposable {
  71273. /**
  71274. * String name of the SpriteMap.
  71275. */
  71276. name: string;
  71277. /**
  71278. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  71279. */
  71280. atlasJSON: ISpriteJSONAtlas;
  71281. /**
  71282. * Texture of the SpriteMap.
  71283. */
  71284. spriteSheet: Texture;
  71285. /**
  71286. * The parameters to initialize the SpriteMap with.
  71287. */
  71288. options: ISpriteMapOptions;
  71289. }
  71290. /**
  71291. * Class used to manage a grid restricted sprite deployment on an Output plane.
  71292. */
  71293. export class SpriteMap implements ISpriteMap {
  71294. /** The Name of the spriteMap */
  71295. name: string;
  71296. /** The JSON file with the frame and meta data */
  71297. atlasJSON: ISpriteJSONAtlas;
  71298. /** The systems Sprite Sheet Texture */
  71299. spriteSheet: Texture;
  71300. /** Arguments passed with the Constructor */
  71301. options: ISpriteMapOptions;
  71302. /** Public Sprite Storage array, parsed from atlasJSON */
  71303. sprites: Array<ISpriteJSONSprite>;
  71304. /** Returns the Number of Sprites in the System */
  71305. get spriteCount(): number;
  71306. /** Returns the Position of Output Plane*/
  71307. get position(): Vector3;
  71308. /** Returns the Position of Output Plane*/
  71309. set position(v: Vector3);
  71310. /** Returns the Rotation of Output Plane*/
  71311. get rotation(): Vector3;
  71312. /** Returns the Rotation of Output Plane*/
  71313. set rotation(v: Vector3);
  71314. /** Sets the AnimationMap*/
  71315. get animationMap(): RawTexture;
  71316. /** Sets the AnimationMap*/
  71317. set animationMap(v: RawTexture);
  71318. /** Scene that the SpriteMap was created in */
  71319. private _scene;
  71320. /** Texture Buffer of Float32 that holds tile frame data*/
  71321. private _frameMap;
  71322. /** Texture Buffers of Float32 that holds tileMap data*/
  71323. private _tileMaps;
  71324. /** Texture Buffer of Float32 that holds Animation Data*/
  71325. private _animationMap;
  71326. /** Custom ShaderMaterial Central to the System*/
  71327. private _material;
  71328. /** Custom ShaderMaterial Central to the System*/
  71329. private _output;
  71330. /** Systems Time Ticker*/
  71331. private _time;
  71332. /**
  71333. * Creates a new SpriteMap
  71334. * @param name defines the SpriteMaps Name
  71335. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  71336. * @param spriteSheet is the Texture that the Sprites are on.
  71337. * @param options a basic deployment configuration
  71338. * @param scene The Scene that the map is deployed on
  71339. */
  71340. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  71341. /**
  71342. * Returns tileID location
  71343. * @returns Vector2 the cell position ID
  71344. */
  71345. getTileID(): Vector2;
  71346. /**
  71347. * Gets the UV location of the mouse over the SpriteMap.
  71348. * @returns Vector2 the UV position of the mouse interaction
  71349. */
  71350. getMousePosition(): Vector2;
  71351. /**
  71352. * Creates the "frame" texture Buffer
  71353. * -------------------------------------
  71354. * Structure of frames
  71355. * "filename": "Falling-Water-2.png",
  71356. * "frame": {"x":69,"y":103,"w":24,"h":32},
  71357. * "rotated": true,
  71358. * "trimmed": true,
  71359. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  71360. * "sourceSize": {"w":32,"h":32}
  71361. * @returns RawTexture of the frameMap
  71362. */
  71363. private _createFrameBuffer;
  71364. /**
  71365. * Creates the tileMap texture Buffer
  71366. * @param buffer normally and array of numbers, or a false to generate from scratch
  71367. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  71368. * @returns RawTexture of the tileMap
  71369. */
  71370. private _createTileBuffer;
  71371. /**
  71372. * Modifies the data of the tileMaps
  71373. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  71374. * @param pos is the iVector2 Coordinates of the Tile
  71375. * @param tile The SpriteIndex of the new Tile
  71376. */
  71377. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  71378. /**
  71379. * Creates the animationMap texture Buffer
  71380. * @param buffer normally and array of numbers, or a false to generate from scratch
  71381. * @returns RawTexture of the animationMap
  71382. */
  71383. private _createTileAnimationBuffer;
  71384. /**
  71385. * Modifies the data of the animationMap
  71386. * @param cellID is the Index of the Sprite
  71387. * @param _frame is the target Animation frame
  71388. * @param toCell is the Target Index of the next frame of the animation
  71389. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  71390. * @param speed is a global scalar of the time variable on the map.
  71391. */
  71392. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  71393. /**
  71394. * Exports the .tilemaps file
  71395. */
  71396. saveTileMaps(): void;
  71397. /**
  71398. * Imports the .tilemaps file
  71399. * @param url of the .tilemaps file
  71400. */
  71401. loadTileMaps(url: string): void;
  71402. /**
  71403. * Release associated resources
  71404. */
  71405. dispose(): void;
  71406. }
  71407. }
  71408. declare module "babylonjs/Sprites/spritePackedManager" {
  71409. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  71410. import { Scene } from "babylonjs/scene";
  71411. /**
  71412. * Class used to manage multiple sprites of different sizes on the same spritesheet
  71413. * @see http://doc.babylonjs.com/babylon101/sprites
  71414. */
  71415. export class SpritePackedManager extends SpriteManager {
  71416. /** defines the packed manager's name */
  71417. name: string;
  71418. /**
  71419. * Creates a new sprite manager from a packed sprite sheet
  71420. * @param name defines the manager's name
  71421. * @param imgUrl defines the sprite sheet url
  71422. * @param capacity defines the maximum allowed number of sprites
  71423. * @param scene defines the hosting scene
  71424. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  71425. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71426. * @param samplingMode defines the smapling mode to use with spritesheet
  71427. * @param fromPacked set to true; do not alter
  71428. */
  71429. constructor(
  71430. /** defines the packed manager's name */
  71431. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  71432. }
  71433. }
  71434. declare module "babylonjs/Sprites/index" {
  71435. export * from "babylonjs/Sprites/sprite";
  71436. export * from "babylonjs/Sprites/ISprites";
  71437. export * from "babylonjs/Sprites/spriteManager";
  71438. export * from "babylonjs/Sprites/spriteMap";
  71439. export * from "babylonjs/Sprites/spritePackedManager";
  71440. export * from "babylonjs/Sprites/spriteSceneComponent";
  71441. }
  71442. declare module "babylonjs/States/index" {
  71443. export * from "babylonjs/States/alphaCullingState";
  71444. export * from "babylonjs/States/depthCullingState";
  71445. export * from "babylonjs/States/stencilState";
  71446. }
  71447. declare module "babylonjs/Misc/assetsManager" {
  71448. import { Scene } from "babylonjs/scene";
  71449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71450. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71451. import { Skeleton } from "babylonjs/Bones/skeleton";
  71452. import { Observable } from "babylonjs/Misc/observable";
  71453. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  71454. import { Texture } from "babylonjs/Materials/Textures/texture";
  71455. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  71456. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  71457. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  71458. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  71459. /**
  71460. * Defines the list of states available for a task inside a AssetsManager
  71461. */
  71462. export enum AssetTaskState {
  71463. /**
  71464. * Initialization
  71465. */
  71466. INIT = 0,
  71467. /**
  71468. * Running
  71469. */
  71470. RUNNING = 1,
  71471. /**
  71472. * Done
  71473. */
  71474. DONE = 2,
  71475. /**
  71476. * Error
  71477. */
  71478. ERROR = 3
  71479. }
  71480. /**
  71481. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  71482. */
  71483. export abstract class AbstractAssetTask {
  71484. /**
  71485. * Task name
  71486. */ name: string;
  71487. /**
  71488. * Callback called when the task is successful
  71489. */
  71490. onSuccess: (task: any) => void;
  71491. /**
  71492. * Callback called when the task is not successful
  71493. */
  71494. onError: (task: any, message?: string, exception?: any) => void;
  71495. /**
  71496. * Creates a new AssetsManager
  71497. * @param name defines the name of the task
  71498. */
  71499. constructor(
  71500. /**
  71501. * Task name
  71502. */ name: string);
  71503. private _isCompleted;
  71504. private _taskState;
  71505. private _errorObject;
  71506. /**
  71507. * Get if the task is completed
  71508. */
  71509. get isCompleted(): boolean;
  71510. /**
  71511. * Gets the current state of the task
  71512. */
  71513. get taskState(): AssetTaskState;
  71514. /**
  71515. * Gets the current error object (if task is in error)
  71516. */
  71517. get errorObject(): {
  71518. message?: string;
  71519. exception?: any;
  71520. };
  71521. /**
  71522. * Internal only
  71523. * @hidden
  71524. */
  71525. _setErrorObject(message?: string, exception?: any): void;
  71526. /**
  71527. * Execute the current task
  71528. * @param scene defines the scene where you want your assets to be loaded
  71529. * @param onSuccess is a callback called when the task is successfully executed
  71530. * @param onError is a callback called if an error occurs
  71531. */
  71532. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71533. /**
  71534. * Execute the current task
  71535. * @param scene defines the scene where you want your assets to be loaded
  71536. * @param onSuccess is a callback called when the task is successfully executed
  71537. * @param onError is a callback called if an error occurs
  71538. */
  71539. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71540. /**
  71541. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  71542. * This can be used with failed tasks that have the reason for failure fixed.
  71543. */
  71544. reset(): void;
  71545. private onErrorCallback;
  71546. private onDoneCallback;
  71547. }
  71548. /**
  71549. * Define the interface used by progress events raised during assets loading
  71550. */
  71551. export interface IAssetsProgressEvent {
  71552. /**
  71553. * Defines the number of remaining tasks to process
  71554. */
  71555. remainingCount: number;
  71556. /**
  71557. * Defines the total number of tasks
  71558. */
  71559. totalCount: number;
  71560. /**
  71561. * Defines the task that was just processed
  71562. */
  71563. task: AbstractAssetTask;
  71564. }
  71565. /**
  71566. * Class used to share progress information about assets loading
  71567. */
  71568. export class AssetsProgressEvent implements IAssetsProgressEvent {
  71569. /**
  71570. * Defines the number of remaining tasks to process
  71571. */
  71572. remainingCount: number;
  71573. /**
  71574. * Defines the total number of tasks
  71575. */
  71576. totalCount: number;
  71577. /**
  71578. * Defines the task that was just processed
  71579. */
  71580. task: AbstractAssetTask;
  71581. /**
  71582. * Creates a AssetsProgressEvent
  71583. * @param remainingCount defines the number of remaining tasks to process
  71584. * @param totalCount defines the total number of tasks
  71585. * @param task defines the task that was just processed
  71586. */
  71587. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  71588. }
  71589. /**
  71590. * Define a task used by AssetsManager to load meshes
  71591. */
  71592. export class MeshAssetTask extends AbstractAssetTask {
  71593. /**
  71594. * Defines the name of the task
  71595. */
  71596. name: string;
  71597. /**
  71598. * Defines the list of mesh's names you want to load
  71599. */
  71600. meshesNames: any;
  71601. /**
  71602. * Defines the root url to use as a base to load your meshes and associated resources
  71603. */
  71604. rootUrl: string;
  71605. /**
  71606. * Defines the filename of the scene to load from
  71607. */
  71608. sceneFilename: string;
  71609. /**
  71610. * Gets the list of loaded meshes
  71611. */
  71612. loadedMeshes: Array<AbstractMesh>;
  71613. /**
  71614. * Gets the list of loaded particle systems
  71615. */
  71616. loadedParticleSystems: Array<IParticleSystem>;
  71617. /**
  71618. * Gets the list of loaded skeletons
  71619. */
  71620. loadedSkeletons: Array<Skeleton>;
  71621. /**
  71622. * Gets the list of loaded animation groups
  71623. */
  71624. loadedAnimationGroups: Array<AnimationGroup>;
  71625. /**
  71626. * Callback called when the task is successful
  71627. */
  71628. onSuccess: (task: MeshAssetTask) => void;
  71629. /**
  71630. * Callback called when the task is successful
  71631. */
  71632. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  71633. /**
  71634. * Creates a new MeshAssetTask
  71635. * @param name defines the name of the task
  71636. * @param meshesNames defines the list of mesh's names you want to load
  71637. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  71638. * @param sceneFilename defines the filename of the scene to load from
  71639. */
  71640. constructor(
  71641. /**
  71642. * Defines the name of the task
  71643. */
  71644. name: string,
  71645. /**
  71646. * Defines the list of mesh's names you want to load
  71647. */
  71648. meshesNames: any,
  71649. /**
  71650. * Defines the root url to use as a base to load your meshes and associated resources
  71651. */
  71652. rootUrl: string,
  71653. /**
  71654. * Defines the filename of the scene to load from
  71655. */
  71656. sceneFilename: string);
  71657. /**
  71658. * Execute the current task
  71659. * @param scene defines the scene where you want your assets to be loaded
  71660. * @param onSuccess is a callback called when the task is successfully executed
  71661. * @param onError is a callback called if an error occurs
  71662. */
  71663. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71664. }
  71665. /**
  71666. * Define a task used by AssetsManager to load text content
  71667. */
  71668. export class TextFileAssetTask extends AbstractAssetTask {
  71669. /**
  71670. * Defines the name of the task
  71671. */
  71672. name: string;
  71673. /**
  71674. * Defines the location of the file to load
  71675. */
  71676. url: string;
  71677. /**
  71678. * Gets the loaded text string
  71679. */
  71680. text: string;
  71681. /**
  71682. * Callback called when the task is successful
  71683. */
  71684. onSuccess: (task: TextFileAssetTask) => void;
  71685. /**
  71686. * Callback called when the task is successful
  71687. */
  71688. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  71689. /**
  71690. * Creates a new TextFileAssetTask object
  71691. * @param name defines the name of the task
  71692. * @param url defines the location of the file to load
  71693. */
  71694. constructor(
  71695. /**
  71696. * Defines the name of the task
  71697. */
  71698. name: string,
  71699. /**
  71700. * Defines the location of the file to load
  71701. */
  71702. url: string);
  71703. /**
  71704. * Execute the current task
  71705. * @param scene defines the scene where you want your assets to be loaded
  71706. * @param onSuccess is a callback called when the task is successfully executed
  71707. * @param onError is a callback called if an error occurs
  71708. */
  71709. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71710. }
  71711. /**
  71712. * Define a task used by AssetsManager to load binary data
  71713. */
  71714. export class BinaryFileAssetTask extends AbstractAssetTask {
  71715. /**
  71716. * Defines the name of the task
  71717. */
  71718. name: string;
  71719. /**
  71720. * Defines the location of the file to load
  71721. */
  71722. url: string;
  71723. /**
  71724. * Gets the lodaded data (as an array buffer)
  71725. */
  71726. data: ArrayBuffer;
  71727. /**
  71728. * Callback called when the task is successful
  71729. */
  71730. onSuccess: (task: BinaryFileAssetTask) => void;
  71731. /**
  71732. * Callback called when the task is successful
  71733. */
  71734. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  71735. /**
  71736. * Creates a new BinaryFileAssetTask object
  71737. * @param name defines the name of the new task
  71738. * @param url defines the location of the file to load
  71739. */
  71740. constructor(
  71741. /**
  71742. * Defines the name of the task
  71743. */
  71744. name: string,
  71745. /**
  71746. * Defines the location of the file to load
  71747. */
  71748. url: string);
  71749. /**
  71750. * Execute the current task
  71751. * @param scene defines the scene where you want your assets to be loaded
  71752. * @param onSuccess is a callback called when the task is successfully executed
  71753. * @param onError is a callback called if an error occurs
  71754. */
  71755. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71756. }
  71757. /**
  71758. * Define a task used by AssetsManager to load images
  71759. */
  71760. export class ImageAssetTask extends AbstractAssetTask {
  71761. /**
  71762. * Defines the name of the task
  71763. */
  71764. name: string;
  71765. /**
  71766. * Defines the location of the image to load
  71767. */
  71768. url: string;
  71769. /**
  71770. * Gets the loaded images
  71771. */
  71772. image: HTMLImageElement;
  71773. /**
  71774. * Callback called when the task is successful
  71775. */
  71776. onSuccess: (task: ImageAssetTask) => void;
  71777. /**
  71778. * Callback called when the task is successful
  71779. */
  71780. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  71781. /**
  71782. * Creates a new ImageAssetTask
  71783. * @param name defines the name of the task
  71784. * @param url defines the location of the image to load
  71785. */
  71786. constructor(
  71787. /**
  71788. * Defines the name of the task
  71789. */
  71790. name: string,
  71791. /**
  71792. * Defines the location of the image to load
  71793. */
  71794. url: string);
  71795. /**
  71796. * Execute the current task
  71797. * @param scene defines the scene where you want your assets to be loaded
  71798. * @param onSuccess is a callback called when the task is successfully executed
  71799. * @param onError is a callback called if an error occurs
  71800. */
  71801. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71802. }
  71803. /**
  71804. * Defines the interface used by texture loading tasks
  71805. */
  71806. export interface ITextureAssetTask<TEX extends BaseTexture> {
  71807. /**
  71808. * Gets the loaded texture
  71809. */
  71810. texture: TEX;
  71811. }
  71812. /**
  71813. * Define a task used by AssetsManager to load 2D textures
  71814. */
  71815. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  71816. /**
  71817. * Defines the name of the task
  71818. */
  71819. name: string;
  71820. /**
  71821. * Defines the location of the file to load
  71822. */
  71823. url: string;
  71824. /**
  71825. * Defines if mipmap should not be generated (default is false)
  71826. */
  71827. noMipmap?: boolean | undefined;
  71828. /**
  71829. * Defines if texture must be inverted on Y axis (default is true)
  71830. */
  71831. invertY: boolean;
  71832. /**
  71833. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71834. */
  71835. samplingMode: number;
  71836. /**
  71837. * Gets the loaded texture
  71838. */
  71839. texture: Texture;
  71840. /**
  71841. * Callback called when the task is successful
  71842. */
  71843. onSuccess: (task: TextureAssetTask) => void;
  71844. /**
  71845. * Callback called when the task is successful
  71846. */
  71847. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  71848. /**
  71849. * Creates a new TextureAssetTask object
  71850. * @param name defines the name of the task
  71851. * @param url defines the location of the file to load
  71852. * @param noMipmap defines if mipmap should not be generated (default is false)
  71853. * @param invertY defines if texture must be inverted on Y axis (default is true)
  71854. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71855. */
  71856. constructor(
  71857. /**
  71858. * Defines the name of the task
  71859. */
  71860. name: string,
  71861. /**
  71862. * Defines the location of the file to load
  71863. */
  71864. url: string,
  71865. /**
  71866. * Defines if mipmap should not be generated (default is false)
  71867. */
  71868. noMipmap?: boolean | undefined,
  71869. /**
  71870. * Defines if texture must be inverted on Y axis (default is true)
  71871. */
  71872. invertY?: boolean,
  71873. /**
  71874. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  71875. */
  71876. samplingMode?: number);
  71877. /**
  71878. * Execute the current task
  71879. * @param scene defines the scene where you want your assets to be loaded
  71880. * @param onSuccess is a callback called when the task is successfully executed
  71881. * @param onError is a callback called if an error occurs
  71882. */
  71883. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71884. }
  71885. /**
  71886. * Define a task used by AssetsManager to load cube textures
  71887. */
  71888. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  71889. /**
  71890. * Defines the name of the task
  71891. */
  71892. name: string;
  71893. /**
  71894. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71895. */
  71896. url: string;
  71897. /**
  71898. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71899. */
  71900. extensions?: string[] | undefined;
  71901. /**
  71902. * Defines if mipmaps should not be generated (default is false)
  71903. */
  71904. noMipmap?: boolean | undefined;
  71905. /**
  71906. * Defines the explicit list of files (undefined by default)
  71907. */
  71908. files?: string[] | undefined;
  71909. /**
  71910. * Gets the loaded texture
  71911. */
  71912. texture: CubeTexture;
  71913. /**
  71914. * Callback called when the task is successful
  71915. */
  71916. onSuccess: (task: CubeTextureAssetTask) => void;
  71917. /**
  71918. * Callback called when the task is successful
  71919. */
  71920. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  71921. /**
  71922. * Creates a new CubeTextureAssetTask
  71923. * @param name defines the name of the task
  71924. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71925. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71926. * @param noMipmap defines if mipmaps should not be generated (default is false)
  71927. * @param files defines the explicit list of files (undefined by default)
  71928. */
  71929. constructor(
  71930. /**
  71931. * Defines the name of the task
  71932. */
  71933. name: string,
  71934. /**
  71935. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  71936. */
  71937. url: string,
  71938. /**
  71939. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  71940. */
  71941. extensions?: string[] | undefined,
  71942. /**
  71943. * Defines if mipmaps should not be generated (default is false)
  71944. */
  71945. noMipmap?: boolean | undefined,
  71946. /**
  71947. * Defines the explicit list of files (undefined by default)
  71948. */
  71949. files?: string[] | undefined);
  71950. /**
  71951. * Execute the current task
  71952. * @param scene defines the scene where you want your assets to be loaded
  71953. * @param onSuccess is a callback called when the task is successfully executed
  71954. * @param onError is a callback called if an error occurs
  71955. */
  71956. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  71957. }
  71958. /**
  71959. * Define a task used by AssetsManager to load HDR cube textures
  71960. */
  71961. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  71962. /**
  71963. * Defines the name of the task
  71964. */
  71965. name: string;
  71966. /**
  71967. * Defines the location of the file to load
  71968. */
  71969. url: string;
  71970. /**
  71971. * Defines the desired size (the more it increases the longer the generation will be)
  71972. */
  71973. size: number;
  71974. /**
  71975. * Defines if mipmaps should not be generated (default is false)
  71976. */
  71977. noMipmap: boolean;
  71978. /**
  71979. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  71980. */
  71981. generateHarmonics: boolean;
  71982. /**
  71983. * 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)
  71984. */
  71985. gammaSpace: boolean;
  71986. /**
  71987. * Internal Use Only
  71988. */
  71989. reserved: boolean;
  71990. /**
  71991. * Gets the loaded texture
  71992. */
  71993. texture: HDRCubeTexture;
  71994. /**
  71995. * Callback called when the task is successful
  71996. */
  71997. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  71998. /**
  71999. * Callback called when the task is successful
  72000. */
  72001. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  72002. /**
  72003. * Creates a new HDRCubeTextureAssetTask object
  72004. * @param name defines the name of the task
  72005. * @param url defines the location of the file to load
  72006. * @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.
  72007. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72008. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72009. * @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)
  72010. * @param reserved Internal use only
  72011. */
  72012. constructor(
  72013. /**
  72014. * Defines the name of the task
  72015. */
  72016. name: string,
  72017. /**
  72018. * Defines the location of the file to load
  72019. */
  72020. url: string,
  72021. /**
  72022. * Defines the desired size (the more it increases the longer the generation will be)
  72023. */
  72024. size: number,
  72025. /**
  72026. * Defines if mipmaps should not be generated (default is false)
  72027. */
  72028. noMipmap?: boolean,
  72029. /**
  72030. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  72031. */
  72032. generateHarmonics?: boolean,
  72033. /**
  72034. * 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)
  72035. */
  72036. gammaSpace?: boolean,
  72037. /**
  72038. * Internal Use Only
  72039. */
  72040. reserved?: boolean);
  72041. /**
  72042. * Execute the current task
  72043. * @param scene defines the scene where you want your assets to be loaded
  72044. * @param onSuccess is a callback called when the task is successfully executed
  72045. * @param onError is a callback called if an error occurs
  72046. */
  72047. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72048. }
  72049. /**
  72050. * Define a task used by AssetsManager to load Equirectangular cube textures
  72051. */
  72052. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  72053. /**
  72054. * Defines the name of the task
  72055. */
  72056. name: string;
  72057. /**
  72058. * Defines the location of the file to load
  72059. */
  72060. url: string;
  72061. /**
  72062. * Defines the desired size (the more it increases the longer the generation will be)
  72063. */
  72064. size: number;
  72065. /**
  72066. * Defines if mipmaps should not be generated (default is false)
  72067. */
  72068. noMipmap: boolean;
  72069. /**
  72070. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72071. * but the standard material would require them in Gamma space) (default is true)
  72072. */
  72073. gammaSpace: boolean;
  72074. /**
  72075. * Gets the loaded texture
  72076. */
  72077. texture: EquiRectangularCubeTexture;
  72078. /**
  72079. * Callback called when the task is successful
  72080. */
  72081. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  72082. /**
  72083. * Callback called when the task is successful
  72084. */
  72085. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  72086. /**
  72087. * Creates a new EquiRectangularCubeTextureAssetTask object
  72088. * @param name defines the name of the task
  72089. * @param url defines the location of the file to load
  72090. * @param size defines the desired size (the more it increases the longer the generation will be)
  72091. * If the size is omitted this implies you are using a preprocessed cubemap.
  72092. * @param noMipmap defines if mipmaps should not be generated (default is false)
  72093. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  72094. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  72095. * (default is true)
  72096. */
  72097. constructor(
  72098. /**
  72099. * Defines the name of the task
  72100. */
  72101. name: string,
  72102. /**
  72103. * Defines the location of the file to load
  72104. */
  72105. url: string,
  72106. /**
  72107. * Defines the desired size (the more it increases the longer the generation will be)
  72108. */
  72109. size: number,
  72110. /**
  72111. * Defines if mipmaps should not be generated (default is false)
  72112. */
  72113. noMipmap?: boolean,
  72114. /**
  72115. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  72116. * but the standard material would require them in Gamma space) (default is true)
  72117. */
  72118. gammaSpace?: boolean);
  72119. /**
  72120. * Execute the current task
  72121. * @param scene defines the scene where you want your assets to be loaded
  72122. * @param onSuccess is a callback called when the task is successfully executed
  72123. * @param onError is a callback called if an error occurs
  72124. */
  72125. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  72126. }
  72127. /**
  72128. * This class can be used to easily import assets into a scene
  72129. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  72130. */
  72131. export class AssetsManager {
  72132. private _scene;
  72133. private _isLoading;
  72134. protected _tasks: AbstractAssetTask[];
  72135. protected _waitingTasksCount: number;
  72136. protected _totalTasksCount: number;
  72137. /**
  72138. * Callback called when all tasks are processed
  72139. */
  72140. onFinish: (tasks: AbstractAssetTask[]) => void;
  72141. /**
  72142. * Callback called when a task is successful
  72143. */
  72144. onTaskSuccess: (task: AbstractAssetTask) => void;
  72145. /**
  72146. * Callback called when a task had an error
  72147. */
  72148. onTaskError: (task: AbstractAssetTask) => void;
  72149. /**
  72150. * Callback called when a task is done (whatever the result is)
  72151. */
  72152. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  72153. /**
  72154. * Observable called when all tasks are processed
  72155. */
  72156. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  72157. /**
  72158. * Observable called when a task had an error
  72159. */
  72160. onTaskErrorObservable: Observable<AbstractAssetTask>;
  72161. /**
  72162. * Observable called when all tasks were executed
  72163. */
  72164. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  72165. /**
  72166. * Observable called when a task is done (whatever the result is)
  72167. */
  72168. onProgressObservable: Observable<IAssetsProgressEvent>;
  72169. /**
  72170. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  72171. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  72172. */
  72173. useDefaultLoadingScreen: boolean;
  72174. /**
  72175. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  72176. * when all assets have been downloaded.
  72177. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  72178. */
  72179. autoHideLoadingUI: boolean;
  72180. /**
  72181. * Creates a new AssetsManager
  72182. * @param scene defines the scene to work on
  72183. */
  72184. constructor(scene: Scene);
  72185. /**
  72186. * Add a MeshAssetTask to the list of active tasks
  72187. * @param taskName defines the name of the new task
  72188. * @param meshesNames defines the name of meshes to load
  72189. * @param rootUrl defines the root url to use to locate files
  72190. * @param sceneFilename defines the filename of the scene file
  72191. * @returns a new MeshAssetTask object
  72192. */
  72193. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  72194. /**
  72195. * Add a TextFileAssetTask to the list of active tasks
  72196. * @param taskName defines the name of the new task
  72197. * @param url defines the url of the file to load
  72198. * @returns a new TextFileAssetTask object
  72199. */
  72200. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  72201. /**
  72202. * Add a BinaryFileAssetTask to the list of active tasks
  72203. * @param taskName defines the name of the new task
  72204. * @param url defines the url of the file to load
  72205. * @returns a new BinaryFileAssetTask object
  72206. */
  72207. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  72208. /**
  72209. * Add a ImageAssetTask to the list of active tasks
  72210. * @param taskName defines the name of the new task
  72211. * @param url defines the url of the file to load
  72212. * @returns a new ImageAssetTask object
  72213. */
  72214. addImageTask(taskName: string, url: string): ImageAssetTask;
  72215. /**
  72216. * Add a TextureAssetTask 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 noMipmap defines if the texture must not receive mipmaps (false by default)
  72220. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  72221. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  72222. * @returns a new TextureAssetTask object
  72223. */
  72224. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  72225. /**
  72226. * Add a CubeTextureAssetTask to the list of active tasks
  72227. * @param taskName defines the name of the new task
  72228. * @param url defines the url of the file to load
  72229. * @param extensions defines the extension to use to load the cube map (can be null)
  72230. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72231. * @param files defines the list of files to load (can be null)
  72232. * @returns a new CubeTextureAssetTask object
  72233. */
  72234. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  72235. /**
  72236. *
  72237. * Add a HDRCubeTextureAssetTask to the list of active tasks
  72238. * @param taskName defines the name of the new task
  72239. * @param url defines the url of the file to load
  72240. * @param size defines the size you want for the cubemap (can be null)
  72241. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72242. * @param generateHarmonics defines if you want to automatically generate (true by default)
  72243. * @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)
  72244. * @param reserved Internal use only
  72245. * @returns a new HDRCubeTextureAssetTask object
  72246. */
  72247. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  72248. /**
  72249. *
  72250. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  72251. * @param taskName defines the name of the new task
  72252. * @param url defines the url of the file to load
  72253. * @param size defines the size you want for the cubemap (can be null)
  72254. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  72255. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  72256. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  72257. * @returns a new EquiRectangularCubeTextureAssetTask object
  72258. */
  72259. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  72260. /**
  72261. * Remove a task from the assets manager.
  72262. * @param task the task to remove
  72263. */
  72264. removeTask(task: AbstractAssetTask): void;
  72265. private _decreaseWaitingTasksCount;
  72266. private _runTask;
  72267. /**
  72268. * Reset the AssetsManager and remove all tasks
  72269. * @return the current instance of the AssetsManager
  72270. */
  72271. reset(): AssetsManager;
  72272. /**
  72273. * Start the loading process
  72274. * @return the current instance of the AssetsManager
  72275. */
  72276. load(): AssetsManager;
  72277. /**
  72278. * Start the loading process as an async operation
  72279. * @return a promise returning the list of failed tasks
  72280. */
  72281. loadAsync(): Promise<void>;
  72282. }
  72283. }
  72284. declare module "babylonjs/Misc/deferred" {
  72285. /**
  72286. * Wrapper class for promise with external resolve and reject.
  72287. */
  72288. export class Deferred<T> {
  72289. /**
  72290. * The promise associated with this deferred object.
  72291. */
  72292. readonly promise: Promise<T>;
  72293. private _resolve;
  72294. private _reject;
  72295. /**
  72296. * The resolve method of the promise associated with this deferred object.
  72297. */
  72298. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  72299. /**
  72300. * The reject method of the promise associated with this deferred object.
  72301. */
  72302. get reject(): (reason?: any) => void;
  72303. /**
  72304. * Constructor for this deferred object.
  72305. */
  72306. constructor();
  72307. }
  72308. }
  72309. declare module "babylonjs/Misc/meshExploder" {
  72310. import { Mesh } from "babylonjs/Meshes/mesh";
  72311. /**
  72312. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  72313. */
  72314. export class MeshExploder {
  72315. private _centerMesh;
  72316. private _meshes;
  72317. private _meshesOrigins;
  72318. private _toCenterVectors;
  72319. private _scaledDirection;
  72320. private _newPosition;
  72321. private _centerPosition;
  72322. /**
  72323. * Explodes meshes from a center mesh.
  72324. * @param meshes The meshes to explode.
  72325. * @param centerMesh The mesh to be center of explosion.
  72326. */
  72327. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  72328. private _setCenterMesh;
  72329. /**
  72330. * Get class name
  72331. * @returns "MeshExploder"
  72332. */
  72333. getClassName(): string;
  72334. /**
  72335. * "Exploded meshes"
  72336. * @returns Array of meshes with the centerMesh at index 0.
  72337. */
  72338. getMeshes(): Array<Mesh>;
  72339. /**
  72340. * Explodes meshes giving a specific direction
  72341. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  72342. */
  72343. explode(direction?: number): void;
  72344. }
  72345. }
  72346. declare module "babylonjs/Misc/filesInput" {
  72347. import { Engine } from "babylonjs/Engines/engine";
  72348. import { Scene } from "babylonjs/scene";
  72349. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  72350. /**
  72351. * Class used to help managing file picking and drag'n'drop
  72352. */
  72353. export class FilesInput {
  72354. /**
  72355. * List of files ready to be loaded
  72356. */
  72357. static get FilesToLoad(): {
  72358. [key: string]: File;
  72359. };
  72360. /**
  72361. * Callback called when a file is processed
  72362. */
  72363. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  72364. private _engine;
  72365. private _currentScene;
  72366. private _sceneLoadedCallback;
  72367. private _progressCallback;
  72368. private _additionalRenderLoopLogicCallback;
  72369. private _textureLoadingCallback;
  72370. private _startingProcessingFilesCallback;
  72371. private _onReloadCallback;
  72372. private _errorCallback;
  72373. private _elementToMonitor;
  72374. private _sceneFileToLoad;
  72375. private _filesToLoad;
  72376. /**
  72377. * Creates a new FilesInput
  72378. * @param engine defines the rendering engine
  72379. * @param scene defines the hosting scene
  72380. * @param sceneLoadedCallback callback called when scene is loaded
  72381. * @param progressCallback callback called to track progress
  72382. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  72383. * @param textureLoadingCallback callback called when a texture is loading
  72384. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  72385. * @param onReloadCallback callback called when a reload is requested
  72386. * @param errorCallback callback call if an error occurs
  72387. */
  72388. 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);
  72389. private _dragEnterHandler;
  72390. private _dragOverHandler;
  72391. private _dropHandler;
  72392. /**
  72393. * Calls this function to listen to drag'n'drop events on a specific DOM element
  72394. * @param elementToMonitor defines the DOM element to track
  72395. */
  72396. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  72397. /**
  72398. * Release all associated resources
  72399. */
  72400. dispose(): void;
  72401. private renderFunction;
  72402. private drag;
  72403. private drop;
  72404. private _traverseFolder;
  72405. private _processFiles;
  72406. /**
  72407. * Load files from a drop event
  72408. * @param event defines the drop event to use as source
  72409. */
  72410. loadFiles(event: any): void;
  72411. private _processReload;
  72412. /**
  72413. * Reload the current scene from the loaded files
  72414. */
  72415. reload(): void;
  72416. }
  72417. }
  72418. declare module "babylonjs/Misc/HighDynamicRange/index" {
  72419. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  72420. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  72421. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  72422. }
  72423. declare module "babylonjs/Misc/sceneOptimizer" {
  72424. import { Scene, IDisposable } from "babylonjs/scene";
  72425. import { Observable } from "babylonjs/Misc/observable";
  72426. /**
  72427. * Defines the root class used to create scene optimization to use with SceneOptimizer
  72428. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72429. */
  72430. export class SceneOptimization {
  72431. /**
  72432. * Defines the priority of this optimization (0 by default which means first in the list)
  72433. */
  72434. priority: number;
  72435. /**
  72436. * Gets a string describing the action executed by the current optimization
  72437. * @returns description string
  72438. */
  72439. getDescription(): string;
  72440. /**
  72441. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72442. * @param scene defines the current scene where to apply this optimization
  72443. * @param optimizer defines the current optimizer
  72444. * @returns true if everything that can be done was applied
  72445. */
  72446. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72447. /**
  72448. * Creates the SceneOptimization object
  72449. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72450. * @param desc defines the description associated with the optimization
  72451. */
  72452. constructor(
  72453. /**
  72454. * Defines the priority of this optimization (0 by default which means first in the list)
  72455. */
  72456. priority?: number);
  72457. }
  72458. /**
  72459. * Defines an optimization used to reduce the size of render target textures
  72460. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72461. */
  72462. export class TextureOptimization extends SceneOptimization {
  72463. /**
  72464. * Defines the priority of this optimization (0 by default which means first in the list)
  72465. */
  72466. priority: number;
  72467. /**
  72468. * 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
  72469. */
  72470. maximumSize: number;
  72471. /**
  72472. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72473. */
  72474. step: number;
  72475. /**
  72476. * Gets a string describing the action executed by the current optimization
  72477. * @returns description string
  72478. */
  72479. getDescription(): string;
  72480. /**
  72481. * Creates the TextureOptimization object
  72482. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72483. * @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
  72484. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72485. */
  72486. constructor(
  72487. /**
  72488. * Defines the priority of this optimization (0 by default which means first in the list)
  72489. */
  72490. priority?: number,
  72491. /**
  72492. * 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
  72493. */
  72494. maximumSize?: number,
  72495. /**
  72496. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  72497. */
  72498. step?: number);
  72499. /**
  72500. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72501. * @param scene defines the current scene where to apply this optimization
  72502. * @param optimizer defines the current optimizer
  72503. * @returns true if everything that can be done was applied
  72504. */
  72505. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72506. }
  72507. /**
  72508. * Defines an optimization used to increase or decrease the rendering resolution
  72509. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72510. */
  72511. export class HardwareScalingOptimization extends SceneOptimization {
  72512. /**
  72513. * Defines the priority of this optimization (0 by default which means first in the list)
  72514. */
  72515. priority: number;
  72516. /**
  72517. * Defines the maximum scale to use (2 by default)
  72518. */
  72519. maximumScale: number;
  72520. /**
  72521. * Defines the step to use between two passes (0.5 by default)
  72522. */
  72523. step: number;
  72524. private _currentScale;
  72525. private _directionOffset;
  72526. /**
  72527. * Gets a string describing the action executed by the current optimization
  72528. * @return description string
  72529. */
  72530. getDescription(): string;
  72531. /**
  72532. * Creates the HardwareScalingOptimization object
  72533. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72534. * @param maximumScale defines the maximum scale to use (2 by default)
  72535. * @param step defines the step to use between two passes (0.5 by default)
  72536. */
  72537. constructor(
  72538. /**
  72539. * Defines the priority of this optimization (0 by default which means first in the list)
  72540. */
  72541. priority?: number,
  72542. /**
  72543. * Defines the maximum scale to use (2 by default)
  72544. */
  72545. maximumScale?: number,
  72546. /**
  72547. * Defines the step to use between two passes (0.5 by default)
  72548. */
  72549. step?: number);
  72550. /**
  72551. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72552. * @param scene defines the current scene where to apply this optimization
  72553. * @param optimizer defines the current optimizer
  72554. * @returns true if everything that can be done was applied
  72555. */
  72556. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72557. }
  72558. /**
  72559. * Defines an optimization used to remove shadows
  72560. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72561. */
  72562. export class ShadowsOptimization extends SceneOptimization {
  72563. /**
  72564. * Gets a string describing the action executed by the current optimization
  72565. * @return description string
  72566. */
  72567. getDescription(): string;
  72568. /**
  72569. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72570. * @param scene defines the current scene where to apply this optimization
  72571. * @param optimizer defines the current optimizer
  72572. * @returns true if everything that can be done was applied
  72573. */
  72574. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72575. }
  72576. /**
  72577. * Defines an optimization used to turn post-processes off
  72578. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72579. */
  72580. export class PostProcessesOptimization extends SceneOptimization {
  72581. /**
  72582. * Gets a string describing the action executed by the current optimization
  72583. * @return description string
  72584. */
  72585. getDescription(): string;
  72586. /**
  72587. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72588. * @param scene defines the current scene where to apply this optimization
  72589. * @param optimizer defines the current optimizer
  72590. * @returns true if everything that can be done was applied
  72591. */
  72592. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72593. }
  72594. /**
  72595. * Defines an optimization used to turn lens flares off
  72596. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72597. */
  72598. export class LensFlaresOptimization extends SceneOptimization {
  72599. /**
  72600. * Gets a string describing the action executed by the current optimization
  72601. * @return description string
  72602. */
  72603. getDescription(): string;
  72604. /**
  72605. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72606. * @param scene defines the current scene where to apply this optimization
  72607. * @param optimizer defines the current optimizer
  72608. * @returns true if everything that can be done was applied
  72609. */
  72610. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72611. }
  72612. /**
  72613. * Defines an optimization based on user defined callback.
  72614. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72615. */
  72616. export class CustomOptimization extends SceneOptimization {
  72617. /**
  72618. * Callback called to apply the custom optimization.
  72619. */
  72620. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  72621. /**
  72622. * Callback called to get custom description
  72623. */
  72624. onGetDescription: () => string;
  72625. /**
  72626. * Gets a string describing the action executed by the current optimization
  72627. * @returns description string
  72628. */
  72629. getDescription(): string;
  72630. /**
  72631. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72632. * @param scene defines the current scene where to apply this optimization
  72633. * @param optimizer defines the current optimizer
  72634. * @returns true if everything that can be done was applied
  72635. */
  72636. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72637. }
  72638. /**
  72639. * Defines an optimization used to turn particles off
  72640. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72641. */
  72642. export class ParticlesOptimization extends SceneOptimization {
  72643. /**
  72644. * Gets a string describing the action executed by the current optimization
  72645. * @return description string
  72646. */
  72647. getDescription(): string;
  72648. /**
  72649. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72650. * @param scene defines the current scene where to apply this optimization
  72651. * @param optimizer defines the current optimizer
  72652. * @returns true if everything that can be done was applied
  72653. */
  72654. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72655. }
  72656. /**
  72657. * Defines an optimization used to turn render targets off
  72658. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72659. */
  72660. export class RenderTargetsOptimization extends SceneOptimization {
  72661. /**
  72662. * Gets a string describing the action executed by the current optimization
  72663. * @return description string
  72664. */
  72665. getDescription(): string;
  72666. /**
  72667. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72668. * @param scene defines the current scene where to apply this optimization
  72669. * @param optimizer defines the current optimizer
  72670. * @returns true if everything that can be done was applied
  72671. */
  72672. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  72673. }
  72674. /**
  72675. * Defines an optimization used to merge meshes with compatible materials
  72676. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72677. */
  72678. export class MergeMeshesOptimization extends SceneOptimization {
  72679. private static _UpdateSelectionTree;
  72680. /**
  72681. * Gets or sets a boolean which defines if optimization octree has to be updated
  72682. */
  72683. static get UpdateSelectionTree(): boolean;
  72684. /**
  72685. * Gets or sets a boolean which defines if optimization octree has to be updated
  72686. */
  72687. static set UpdateSelectionTree(value: boolean);
  72688. /**
  72689. * Gets a string describing the action executed by the current optimization
  72690. * @return description string
  72691. */
  72692. getDescription(): string;
  72693. private _canBeMerged;
  72694. /**
  72695. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  72696. * @param scene defines the current scene where to apply this optimization
  72697. * @param optimizer defines the current optimizer
  72698. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  72699. * @returns true if everything that can be done was applied
  72700. */
  72701. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  72702. }
  72703. /**
  72704. * Defines a list of options used by SceneOptimizer
  72705. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72706. */
  72707. export class SceneOptimizerOptions {
  72708. /**
  72709. * Defines the target frame rate to reach (60 by default)
  72710. */
  72711. targetFrameRate: number;
  72712. /**
  72713. * Defines the interval between two checkes (2000ms by default)
  72714. */
  72715. trackerDuration: number;
  72716. /**
  72717. * Gets the list of optimizations to apply
  72718. */
  72719. optimizations: SceneOptimization[];
  72720. /**
  72721. * Creates a new list of options used by SceneOptimizer
  72722. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  72723. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  72724. */
  72725. constructor(
  72726. /**
  72727. * Defines the target frame rate to reach (60 by default)
  72728. */
  72729. targetFrameRate?: number,
  72730. /**
  72731. * Defines the interval between two checkes (2000ms by default)
  72732. */
  72733. trackerDuration?: number);
  72734. /**
  72735. * Add a new optimization
  72736. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  72737. * @returns the current SceneOptimizerOptions
  72738. */
  72739. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  72740. /**
  72741. * Add a new custom optimization
  72742. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  72743. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  72744. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  72745. * @returns the current SceneOptimizerOptions
  72746. */
  72747. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  72748. /**
  72749. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  72750. * @param targetFrameRate defines the target frame rate (60 by default)
  72751. * @returns a SceneOptimizerOptions object
  72752. */
  72753. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72754. /**
  72755. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  72756. * @param targetFrameRate defines the target frame rate (60 by default)
  72757. * @returns a SceneOptimizerOptions object
  72758. */
  72759. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72760. /**
  72761. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  72762. * @param targetFrameRate defines the target frame rate (60 by default)
  72763. * @returns a SceneOptimizerOptions object
  72764. */
  72765. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  72766. }
  72767. /**
  72768. * Class used to run optimizations in order to reach a target frame rate
  72769. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  72770. */
  72771. export class SceneOptimizer implements IDisposable {
  72772. private _isRunning;
  72773. private _options;
  72774. private _scene;
  72775. private _currentPriorityLevel;
  72776. private _targetFrameRate;
  72777. private _trackerDuration;
  72778. private _currentFrameRate;
  72779. private _sceneDisposeObserver;
  72780. private _improvementMode;
  72781. /**
  72782. * Defines an observable called when the optimizer reaches the target frame rate
  72783. */
  72784. onSuccessObservable: Observable<SceneOptimizer>;
  72785. /**
  72786. * Defines an observable called when the optimizer enables an optimization
  72787. */
  72788. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  72789. /**
  72790. * Defines an observable called when the optimizer is not able to reach the target frame rate
  72791. */
  72792. onFailureObservable: Observable<SceneOptimizer>;
  72793. /**
  72794. * Gets a boolean indicating if the optimizer is in improvement mode
  72795. */
  72796. get isInImprovementMode(): boolean;
  72797. /**
  72798. * Gets the current priority level (0 at start)
  72799. */
  72800. get currentPriorityLevel(): number;
  72801. /**
  72802. * Gets the current frame rate checked by the SceneOptimizer
  72803. */
  72804. get currentFrameRate(): number;
  72805. /**
  72806. * Gets or sets the current target frame rate (60 by default)
  72807. */
  72808. get targetFrameRate(): number;
  72809. /**
  72810. * Gets or sets the current target frame rate (60 by default)
  72811. */
  72812. set targetFrameRate(value: number);
  72813. /**
  72814. * Gets or sets the current interval between two checks (every 2000ms by default)
  72815. */
  72816. get trackerDuration(): number;
  72817. /**
  72818. * Gets or sets the current interval between two checks (every 2000ms by default)
  72819. */
  72820. set trackerDuration(value: number);
  72821. /**
  72822. * Gets the list of active optimizations
  72823. */
  72824. get optimizations(): SceneOptimization[];
  72825. /**
  72826. * Creates a new SceneOptimizer
  72827. * @param scene defines the scene to work on
  72828. * @param options defines the options to use with the SceneOptimizer
  72829. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  72830. * @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)
  72831. */
  72832. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  72833. /**
  72834. * Stops the current optimizer
  72835. */
  72836. stop(): void;
  72837. /**
  72838. * Reset the optimizer to initial step (current priority level = 0)
  72839. */
  72840. reset(): void;
  72841. /**
  72842. * Start the optimizer. By default it will try to reach a specific framerate
  72843. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  72844. */
  72845. start(): void;
  72846. private _checkCurrentState;
  72847. /**
  72848. * Release all resources
  72849. */
  72850. dispose(): void;
  72851. /**
  72852. * Helper function to create a SceneOptimizer with one single line of code
  72853. * @param scene defines the scene to work on
  72854. * @param options defines the options to use with the SceneOptimizer
  72855. * @param onSuccess defines a callback to call on success
  72856. * @param onFailure defines a callback to call on failure
  72857. * @returns the new SceneOptimizer object
  72858. */
  72859. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  72860. }
  72861. }
  72862. declare module "babylonjs/Misc/sceneSerializer" {
  72863. import { Scene } from "babylonjs/scene";
  72864. /**
  72865. * Class used to serialize a scene into a string
  72866. */
  72867. export class SceneSerializer {
  72868. /**
  72869. * Clear cache used by a previous serialization
  72870. */
  72871. static ClearCache(): void;
  72872. /**
  72873. * Serialize a scene into a JSON compatible object
  72874. * @param scene defines the scene to serialize
  72875. * @returns a JSON compatible object
  72876. */
  72877. static Serialize(scene: Scene): any;
  72878. /**
  72879. * Serialize a mesh into a JSON compatible object
  72880. * @param toSerialize defines the mesh to serialize
  72881. * @param withParents defines if parents must be serialized as well
  72882. * @param withChildren defines if children must be serialized as well
  72883. * @returns a JSON compatible object
  72884. */
  72885. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  72886. }
  72887. }
  72888. declare module "babylonjs/Misc/textureTools" {
  72889. import { Texture } from "babylonjs/Materials/Textures/texture";
  72890. /**
  72891. * Class used to host texture specific utilities
  72892. */
  72893. export class TextureTools {
  72894. /**
  72895. * Uses the GPU to create a copy texture rescaled at a given size
  72896. * @param texture Texture to copy from
  72897. * @param width defines the desired width
  72898. * @param height defines the desired height
  72899. * @param useBilinearMode defines if bilinear mode has to be used
  72900. * @return the generated texture
  72901. */
  72902. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  72903. }
  72904. }
  72905. declare module "babylonjs/Misc/videoRecorder" {
  72906. import { Nullable } from "babylonjs/types";
  72907. import { Engine } from "babylonjs/Engines/engine";
  72908. /**
  72909. * This represents the different options available for the video capture.
  72910. */
  72911. export interface VideoRecorderOptions {
  72912. /** Defines the mime type of the video. */
  72913. mimeType: string;
  72914. /** Defines the FPS the video should be recorded at. */
  72915. fps: number;
  72916. /** Defines the chunk size for the recording data. */
  72917. recordChunckSize: number;
  72918. /** The audio tracks to attach to the recording. */
  72919. audioTracks?: MediaStreamTrack[];
  72920. }
  72921. /**
  72922. * This can help with recording videos from BabylonJS.
  72923. * This is based on the available WebRTC functionalities of the browser.
  72924. *
  72925. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  72926. */
  72927. export class VideoRecorder {
  72928. private static readonly _defaultOptions;
  72929. /**
  72930. * Returns whether or not the VideoRecorder is available in your browser.
  72931. * @param engine Defines the Babylon Engine.
  72932. * @returns true if supported otherwise false.
  72933. */
  72934. static IsSupported(engine: Engine): boolean;
  72935. private readonly _options;
  72936. private _canvas;
  72937. private _mediaRecorder;
  72938. private _recordedChunks;
  72939. private _fileName;
  72940. private _resolve;
  72941. private _reject;
  72942. /**
  72943. * True when a recording is already in progress.
  72944. */
  72945. get isRecording(): boolean;
  72946. /**
  72947. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  72948. * @param engine Defines the BabylonJS Engine you wish to record.
  72949. * @param options Defines options that can be used to customize the capture.
  72950. */
  72951. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  72952. /**
  72953. * Stops the current recording before the default capture timeout passed in the startRecording function.
  72954. */
  72955. stopRecording(): void;
  72956. /**
  72957. * Starts recording the canvas for a max duration specified in parameters.
  72958. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  72959. * If null no automatic download will start and you can rely on the promise to get the data back.
  72960. * @param maxDuration Defines the maximum recording time in seconds.
  72961. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  72962. * @return A promise callback at the end of the recording with the video data in Blob.
  72963. */
  72964. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  72965. /**
  72966. * Releases internal resources used during the recording.
  72967. */
  72968. dispose(): void;
  72969. private _handleDataAvailable;
  72970. private _handleError;
  72971. private _handleStop;
  72972. }
  72973. }
  72974. declare module "babylonjs/Misc/screenshotTools" {
  72975. import { Camera } from "babylonjs/Cameras/camera";
  72976. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  72977. import { Engine } from "babylonjs/Engines/engine";
  72978. /**
  72979. * Class containing a set of static utilities functions for screenshots
  72980. */
  72981. export class ScreenshotTools {
  72982. /**
  72983. * Captures a screenshot of the current rendering
  72984. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  72985. * @param engine defines the rendering engine
  72986. * @param camera defines the source camera
  72987. * @param size This parameter can be set to a single number or to an object with the
  72988. * following (optional) properties: precision, width, height. If a single number is passed,
  72989. * it will be used for both width and height. If an object is passed, the screenshot size
  72990. * will be derived from the parameters. The precision property is a multiplier allowing
  72991. * rendering at a higher or lower resolution
  72992. * @param successCallback defines the callback receives a single parameter which contains the
  72993. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  72994. * src parameter of an <img> to display it
  72995. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  72996. * Check your browser for supported MIME types
  72997. */
  72998. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  72999. /**
  73000. * Captures a screenshot of the current rendering
  73001. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73002. * @param engine defines the rendering engine
  73003. * @param camera defines the source camera
  73004. * @param size This parameter can be set to a single number or to an object with the
  73005. * following (optional) properties: precision, width, height. If a single number is passed,
  73006. * it will be used for both width and height. If an object is passed, the screenshot size
  73007. * will be derived from the parameters. The precision property is a multiplier allowing
  73008. * rendering at a higher or lower resolution
  73009. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  73010. * Check your browser for supported MIME types
  73011. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73012. * to the src parameter of an <img> to display it
  73013. */
  73014. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  73015. /**
  73016. * Generates an image screenshot from the specified camera.
  73017. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73018. * @param engine The engine to use for rendering
  73019. * @param camera The camera to use for rendering
  73020. * @param size This parameter can be set to a single number or to an object with the
  73021. * following (optional) properties: precision, width, height. If a single number is passed,
  73022. * it will be used for both width and height. If an object is passed, the screenshot size
  73023. * will be derived from the parameters. The precision property is a multiplier allowing
  73024. * rendering at a higher or lower resolution
  73025. * @param successCallback The callback receives a single parameter which contains the
  73026. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  73027. * src parameter of an <img> to display it
  73028. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73029. * Check your browser for supported MIME types
  73030. * @param samples Texture samples (default: 1)
  73031. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73032. * @param fileName A name for for the downloaded file.
  73033. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73034. */
  73035. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  73036. /**
  73037. * Generates an image screenshot from the specified camera.
  73038. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  73039. * @param engine The engine to use for rendering
  73040. * @param camera The camera to use for rendering
  73041. * @param size This parameter can be set to a single number or to an object with the
  73042. * following (optional) properties: precision, width, height. If a single number is passed,
  73043. * it will be used for both width and height. If an object is passed, the screenshot size
  73044. * will be derived from the parameters. The precision property is a multiplier allowing
  73045. * rendering at a higher or lower resolution
  73046. * @param mimeType The MIME type of the screenshot image (default: image/png).
  73047. * Check your browser for supported MIME types
  73048. * @param samples Texture samples (default: 1)
  73049. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  73050. * @param fileName A name for for the downloaded file.
  73051. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  73052. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  73053. * to the src parameter of an <img> to display it
  73054. */
  73055. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  73056. /**
  73057. * Gets height and width for screenshot size
  73058. * @private
  73059. */
  73060. private static _getScreenshotSize;
  73061. }
  73062. }
  73063. declare module "babylonjs/Misc/dataReader" {
  73064. /**
  73065. * Interface for a data buffer
  73066. */
  73067. export interface IDataBuffer {
  73068. /**
  73069. * Reads bytes from the data buffer.
  73070. * @param byteOffset The byte offset to read
  73071. * @param byteLength The byte length to read
  73072. * @returns A promise that resolves when the bytes are read
  73073. */
  73074. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  73075. /**
  73076. * The byte length of the buffer.
  73077. */
  73078. readonly byteLength: number;
  73079. }
  73080. /**
  73081. * Utility class for reading from a data buffer
  73082. */
  73083. export class DataReader {
  73084. /**
  73085. * The data buffer associated with this data reader.
  73086. */
  73087. readonly buffer: IDataBuffer;
  73088. /**
  73089. * The current byte offset from the beginning of the data buffer.
  73090. */
  73091. byteOffset: number;
  73092. private _dataView;
  73093. private _dataByteOffset;
  73094. /**
  73095. * Constructor
  73096. * @param buffer The buffer to read
  73097. */
  73098. constructor(buffer: IDataBuffer);
  73099. /**
  73100. * Loads the given byte length.
  73101. * @param byteLength The byte length to load
  73102. * @returns A promise that resolves when the load is complete
  73103. */
  73104. loadAsync(byteLength: number): Promise<void>;
  73105. /**
  73106. * Read a unsigned 32-bit integer from the currently loaded data range.
  73107. * @returns The 32-bit integer read
  73108. */
  73109. readUint32(): number;
  73110. /**
  73111. * Read a byte array from the currently loaded data range.
  73112. * @param byteLength The byte length to read
  73113. * @returns The byte array read
  73114. */
  73115. readUint8Array(byteLength: number): Uint8Array;
  73116. /**
  73117. * Read a string from the currently loaded data range.
  73118. * @param byteLength The byte length to read
  73119. * @returns The string read
  73120. */
  73121. readString(byteLength: number): string;
  73122. /**
  73123. * Skips the given byte length the currently loaded data range.
  73124. * @param byteLength The byte length to skip
  73125. */
  73126. skipBytes(byteLength: number): void;
  73127. }
  73128. }
  73129. declare module "babylonjs/Misc/dataStorage" {
  73130. /**
  73131. * Class for storing data to local storage if available or in-memory storage otherwise
  73132. */
  73133. export class DataStorage {
  73134. private static _Storage;
  73135. private static _GetStorage;
  73136. /**
  73137. * Reads a string from the data storage
  73138. * @param key The key to read
  73139. * @param defaultValue The value if the key doesn't exist
  73140. * @returns The string value
  73141. */
  73142. static ReadString(key: string, defaultValue: string): string;
  73143. /**
  73144. * Writes a string to the data storage
  73145. * @param key The key to write
  73146. * @param value The value to write
  73147. */
  73148. static WriteString(key: string, value: string): void;
  73149. /**
  73150. * Reads a boolean from the data storage
  73151. * @param key The key to read
  73152. * @param defaultValue The value if the key doesn't exist
  73153. * @returns The boolean value
  73154. */
  73155. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  73156. /**
  73157. * Writes a boolean to the data storage
  73158. * @param key The key to write
  73159. * @param value The value to write
  73160. */
  73161. static WriteBoolean(key: string, value: boolean): void;
  73162. /**
  73163. * Reads a number from the data storage
  73164. * @param key The key to read
  73165. * @param defaultValue The value if the key doesn't exist
  73166. * @returns The number value
  73167. */
  73168. static ReadNumber(key: string, defaultValue: number): number;
  73169. /**
  73170. * Writes a number to the data storage
  73171. * @param key The key to write
  73172. * @param value The value to write
  73173. */
  73174. static WriteNumber(key: string, value: number): void;
  73175. }
  73176. }
  73177. declare module "babylonjs/Misc/index" {
  73178. export * from "babylonjs/Misc/andOrNotEvaluator";
  73179. export * from "babylonjs/Misc/assetsManager";
  73180. export * from "babylonjs/Misc/basis";
  73181. export * from "babylonjs/Misc/dds";
  73182. export * from "babylonjs/Misc/decorators";
  73183. export * from "babylonjs/Misc/deferred";
  73184. export * from "babylonjs/Misc/environmentTextureTools";
  73185. export * from "babylonjs/Misc/meshExploder";
  73186. export * from "babylonjs/Misc/filesInput";
  73187. export * from "babylonjs/Misc/HighDynamicRange/index";
  73188. export * from "babylonjs/Misc/khronosTextureContainer";
  73189. export * from "babylonjs/Misc/observable";
  73190. export * from "babylonjs/Misc/performanceMonitor";
  73191. export * from "babylonjs/Misc/promise";
  73192. export * from "babylonjs/Misc/sceneOptimizer";
  73193. export * from "babylonjs/Misc/sceneSerializer";
  73194. export * from "babylonjs/Misc/smartArray";
  73195. export * from "babylonjs/Misc/stringDictionary";
  73196. export * from "babylonjs/Misc/tags";
  73197. export * from "babylonjs/Misc/textureTools";
  73198. export * from "babylonjs/Misc/tga";
  73199. export * from "babylonjs/Misc/tools";
  73200. export * from "babylonjs/Misc/videoRecorder";
  73201. export * from "babylonjs/Misc/virtualJoystick";
  73202. export * from "babylonjs/Misc/workerPool";
  73203. export * from "babylonjs/Misc/logger";
  73204. export * from "babylonjs/Misc/typeStore";
  73205. export * from "babylonjs/Misc/filesInputStore";
  73206. export * from "babylonjs/Misc/deepCopier";
  73207. export * from "babylonjs/Misc/pivotTools";
  73208. export * from "babylonjs/Misc/precisionDate";
  73209. export * from "babylonjs/Misc/screenshotTools";
  73210. export * from "babylonjs/Misc/typeStore";
  73211. export * from "babylonjs/Misc/webRequest";
  73212. export * from "babylonjs/Misc/iInspectable";
  73213. export * from "babylonjs/Misc/brdfTextureTools";
  73214. export * from "babylonjs/Misc/rgbdTextureTools";
  73215. export * from "babylonjs/Misc/gradients";
  73216. export * from "babylonjs/Misc/perfCounter";
  73217. export * from "babylonjs/Misc/fileRequest";
  73218. export * from "babylonjs/Misc/customAnimationFrameRequester";
  73219. export * from "babylonjs/Misc/retryStrategy";
  73220. export * from "babylonjs/Misc/interfaces/screenshotSize";
  73221. export * from "babylonjs/Misc/canvasGenerator";
  73222. export * from "babylonjs/Misc/fileTools";
  73223. export * from "babylonjs/Misc/stringTools";
  73224. export * from "babylonjs/Misc/dataReader";
  73225. export * from "babylonjs/Misc/minMaxReducer";
  73226. export * from "babylonjs/Misc/depthReducer";
  73227. export * from "babylonjs/Misc/dataStorage";
  73228. }
  73229. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  73230. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73231. import { Observable } from "babylonjs/Misc/observable";
  73232. import { Matrix } from "babylonjs/Maths/math.vector";
  73233. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73234. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73235. /**
  73236. * Options used for hit testing
  73237. */
  73238. export interface IWebXRLegacyHitTestOptions {
  73239. /**
  73240. * Only test when user interacted with the scene. Default - hit test every frame
  73241. */
  73242. testOnPointerDownOnly?: boolean;
  73243. /**
  73244. * The node to use to transform the local results to world coordinates
  73245. */
  73246. worldParentNode?: TransformNode;
  73247. }
  73248. /**
  73249. * Interface defining the babylon result of raycasting/hit-test
  73250. */
  73251. export interface IWebXRLegacyHitResult {
  73252. /**
  73253. * Transformation matrix that can be applied to a node that will put it in the hit point location
  73254. */
  73255. transformationMatrix: Matrix;
  73256. /**
  73257. * The native hit test result
  73258. */
  73259. xrHitResult: XRHitResult | XRHitTestResult;
  73260. }
  73261. /**
  73262. * The currently-working hit-test module.
  73263. * Hit test (or Ray-casting) is used to interact with the real world.
  73264. * For further information read here - https://github.com/immersive-web/hit-test
  73265. */
  73266. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  73267. /**
  73268. * options to use when constructing this feature
  73269. */
  73270. readonly options: IWebXRLegacyHitTestOptions;
  73271. private _direction;
  73272. private _mat;
  73273. private _onSelectEnabled;
  73274. private _origin;
  73275. /**
  73276. * The module's name
  73277. */
  73278. static readonly Name: string;
  73279. /**
  73280. * The (Babylon) version of this module.
  73281. * This is an integer representing the implementation version.
  73282. * This number does not correspond to the WebXR specs version
  73283. */
  73284. static readonly Version: number;
  73285. /**
  73286. * Populated with the last native XR Hit Results
  73287. */
  73288. lastNativeXRHitResults: XRHitResult[];
  73289. /**
  73290. * Triggered when new babylon (transformed) hit test results are available
  73291. */
  73292. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  73293. /**
  73294. * Creates a new instance of the (legacy version) hit test feature
  73295. * @param _xrSessionManager an instance of WebXRSessionManager
  73296. * @param options options to use when constructing this feature
  73297. */
  73298. constructor(_xrSessionManager: WebXRSessionManager,
  73299. /**
  73300. * options to use when constructing this feature
  73301. */
  73302. options?: IWebXRLegacyHitTestOptions);
  73303. /**
  73304. * execute a hit test with an XR Ray
  73305. *
  73306. * @param xrSession a native xrSession that will execute this hit test
  73307. * @param xrRay the ray (position and direction) to use for ray-casting
  73308. * @param referenceSpace native XR reference space to use for the hit-test
  73309. * @param filter filter function that will filter the results
  73310. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73311. */
  73312. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  73313. /**
  73314. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  73315. * @param event the (select) event to use to select with
  73316. * @param referenceSpace the reference space to use for this hit test
  73317. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  73318. */
  73319. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  73320. /**
  73321. * attach this feature
  73322. * Will usually be called by the features manager
  73323. *
  73324. * @returns true if successful.
  73325. */
  73326. attach(): boolean;
  73327. /**
  73328. * detach this feature.
  73329. * Will usually be called by the features manager
  73330. *
  73331. * @returns true if successful.
  73332. */
  73333. detach(): boolean;
  73334. /**
  73335. * Dispose this feature and all of the resources attached
  73336. */
  73337. dispose(): void;
  73338. protected _onXRFrame(frame: XRFrame): void;
  73339. private _onHitTestResults;
  73340. private _onSelect;
  73341. }
  73342. }
  73343. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  73344. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73345. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73346. import { Observable } from "babylonjs/Misc/observable";
  73347. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  73348. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73349. /**
  73350. * Options used in the plane detector module
  73351. */
  73352. export interface IWebXRPlaneDetectorOptions {
  73353. /**
  73354. * The node to use to transform the local results to world coordinates
  73355. */
  73356. worldParentNode?: TransformNode;
  73357. }
  73358. /**
  73359. * A babylon interface for a WebXR plane.
  73360. * A Plane is actually a polygon, built from N points in space
  73361. *
  73362. * Supported in chrome 79, not supported in canary 81 ATM
  73363. */
  73364. export interface IWebXRPlane {
  73365. /**
  73366. * a babylon-assigned ID for this polygon
  73367. */
  73368. id: number;
  73369. /**
  73370. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  73371. */
  73372. polygonDefinition: Array<Vector3>;
  73373. /**
  73374. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  73375. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  73376. */
  73377. transformationMatrix: Matrix;
  73378. /**
  73379. * the native xr-plane object
  73380. */
  73381. xrPlane: XRPlane;
  73382. }
  73383. /**
  73384. * The plane detector is used to detect planes in the real world when in AR
  73385. * For more information see https://github.com/immersive-web/real-world-geometry/
  73386. */
  73387. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  73388. private _options;
  73389. private _detectedPlanes;
  73390. private _enabled;
  73391. private _lastFrameDetected;
  73392. /**
  73393. * The module's name
  73394. */
  73395. static readonly Name: string;
  73396. /**
  73397. * The (Babylon) version of this module.
  73398. * This is an integer representing the implementation version.
  73399. * This number does not correspond to the WebXR specs version
  73400. */
  73401. static readonly Version: number;
  73402. /**
  73403. * Observers registered here will be executed when a new plane was added to the session
  73404. */
  73405. onPlaneAddedObservable: Observable<IWebXRPlane>;
  73406. /**
  73407. * Observers registered here will be executed when a plane is no longer detected in the session
  73408. */
  73409. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  73410. /**
  73411. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  73412. * This can execute N times every frame
  73413. */
  73414. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  73415. /**
  73416. * construct a new Plane Detector
  73417. * @param _xrSessionManager an instance of xr Session manager
  73418. * @param _options configuration to use when constructing this feature
  73419. */
  73420. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  73421. /**
  73422. * Dispose this feature and all of the resources attached
  73423. */
  73424. dispose(): void;
  73425. protected _onXRFrame(frame: XRFrame): void;
  73426. private _init;
  73427. private _updatePlaneWithXRPlane;
  73428. /**
  73429. * avoiding using Array.find for global support.
  73430. * @param xrPlane the plane to find in the array
  73431. */
  73432. private findIndexInPlaneArray;
  73433. }
  73434. }
  73435. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  73436. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73437. import { Observable } from "babylonjs/Misc/observable";
  73438. import { Matrix } from "babylonjs/Maths/math.vector";
  73439. import { TransformNode } from "babylonjs/Meshes/transformNode";
  73440. import { WebXRPlaneDetector } from "babylonjs/XR/features/WebXRPlaneDetector";
  73441. import { WebXRHitTestLegacy } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73442. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73443. /**
  73444. * Configuration options of the anchor system
  73445. */
  73446. export interface IWebXRAnchorSystemOptions {
  73447. /**
  73448. * Should a new anchor be added every time a select event is triggered
  73449. */
  73450. addAnchorOnSelect?: boolean;
  73451. /**
  73452. * should the anchor system use plane detection.
  73453. * If set to true, the plane-detection feature should be set using setPlaneDetector
  73454. */
  73455. usePlaneDetection?: boolean;
  73456. /**
  73457. * a node that will be used to convert local to world coordinates
  73458. */
  73459. worldParentNode?: TransformNode;
  73460. }
  73461. /**
  73462. * A babylon container for an XR Anchor
  73463. */
  73464. export interface IWebXRAnchor {
  73465. /**
  73466. * A babylon-assigned ID for this anchor
  73467. */
  73468. id: number;
  73469. /**
  73470. * Transformation matrix to apply to an object attached to this anchor
  73471. */
  73472. transformationMatrix: Matrix;
  73473. /**
  73474. * The native anchor object
  73475. */
  73476. xrAnchor: XRAnchor;
  73477. }
  73478. /**
  73479. * An implementation of the anchor system of WebXR.
  73480. * Note that the current documented implementation is not available in any browser. Future implementations
  73481. * will use the frame to create an anchor and not the session or a detected plane
  73482. * For further information see https://github.com/immersive-web/anchors/
  73483. */
  73484. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  73485. private _options;
  73486. private _enabled;
  73487. private _hitTestModule;
  73488. private _lastFrameDetected;
  73489. private _onSelect;
  73490. private _planeDetector;
  73491. private _trackedAnchors;
  73492. /**
  73493. * The module's name
  73494. */
  73495. static readonly Name: string;
  73496. /**
  73497. * The (Babylon) version of this module.
  73498. * This is an integer representing the implementation version.
  73499. * This number does not correspond to the WebXR specs version
  73500. */
  73501. static readonly Version: number;
  73502. /**
  73503. * Observers registered here will be executed when a new anchor was added to the session
  73504. */
  73505. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  73506. /**
  73507. * Observers registered here will be executed when an anchor was removed from the session
  73508. */
  73509. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  73510. /**
  73511. * Observers registered here will be executed when an existing anchor updates
  73512. * This can execute N times every frame
  73513. */
  73514. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  73515. /**
  73516. * constructs a new anchor system
  73517. * @param _xrSessionManager an instance of WebXRSessionManager
  73518. * @param _options configuration object for this feature
  73519. */
  73520. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  73521. /**
  73522. * Add anchor at a specific XR point.
  73523. *
  73524. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  73525. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  73526. * @returns a promise the fulfills when the anchor was created
  73527. */
  73528. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  73529. /**
  73530. * attach this feature
  73531. * Will usually be called by the features manager
  73532. *
  73533. * @returns true if successful.
  73534. */
  73535. attach(): boolean;
  73536. /**
  73537. * detach this feature.
  73538. * Will usually be called by the features manager
  73539. *
  73540. * @returns true if successful.
  73541. */
  73542. detach(): boolean;
  73543. /**
  73544. * Dispose this feature and all of the resources attached
  73545. */
  73546. dispose(): void;
  73547. /**
  73548. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  73549. * @param hitTestModule the hit-test module to use.
  73550. */
  73551. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  73552. /**
  73553. * set the plane detector to use in order to create anchors from frames
  73554. * @param planeDetector the plane-detector module to use
  73555. * @param enable enable plane-anchors. default is true
  73556. */
  73557. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  73558. protected _onXRFrame(frame: XRFrame): void;
  73559. /**
  73560. * avoiding using Array.find for global support.
  73561. * @param xrAnchor the plane to find in the array
  73562. */
  73563. private _findIndexInAnchorArray;
  73564. private _updateAnchorWithXRFrame;
  73565. }
  73566. }
  73567. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  73568. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73569. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73570. import { Observable } from "babylonjs/Misc/observable";
  73571. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73572. /**
  73573. * Options interface for the background remover plugin
  73574. */
  73575. export interface IWebXRBackgroundRemoverOptions {
  73576. /**
  73577. * Further background meshes to disable when entering AR
  73578. */
  73579. backgroundMeshes?: AbstractMesh[];
  73580. /**
  73581. * flags to configure the removal of the environment helper.
  73582. * If not set, the entire background will be removed. If set, flags should be set as well.
  73583. */
  73584. environmentHelperRemovalFlags?: {
  73585. /**
  73586. * Should the skybox be removed (default false)
  73587. */
  73588. skyBox?: boolean;
  73589. /**
  73590. * Should the ground be removed (default false)
  73591. */
  73592. ground?: boolean;
  73593. };
  73594. /**
  73595. * don't disable the environment helper
  73596. */
  73597. ignoreEnvironmentHelper?: boolean;
  73598. }
  73599. /**
  73600. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  73601. */
  73602. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  73603. /**
  73604. * read-only options to be used in this module
  73605. */
  73606. readonly options: IWebXRBackgroundRemoverOptions;
  73607. /**
  73608. * The module's name
  73609. */
  73610. static readonly Name: string;
  73611. /**
  73612. * The (Babylon) version of this module.
  73613. * This is an integer representing the implementation version.
  73614. * This number does not correspond to the WebXR specs version
  73615. */
  73616. static readonly Version: number;
  73617. /**
  73618. * registered observers will be triggered when the background state changes
  73619. */
  73620. onBackgroundStateChangedObservable: Observable<boolean>;
  73621. /**
  73622. * constructs a new background remover module
  73623. * @param _xrSessionManager the session manager for this module
  73624. * @param options read-only options to be used in this module
  73625. */
  73626. constructor(_xrSessionManager: WebXRSessionManager,
  73627. /**
  73628. * read-only options to be used in this module
  73629. */
  73630. options?: IWebXRBackgroundRemoverOptions);
  73631. /**
  73632. * attach this feature
  73633. * Will usually be called by the features manager
  73634. *
  73635. * @returns true if successful.
  73636. */
  73637. attach(): boolean;
  73638. /**
  73639. * detach this feature.
  73640. * Will usually be called by the features manager
  73641. *
  73642. * @returns true if successful.
  73643. */
  73644. detach(): boolean;
  73645. /**
  73646. * Dispose this feature and all of the resources attached
  73647. */
  73648. dispose(): void;
  73649. protected _onXRFrame(_xrFrame: XRFrame): void;
  73650. private _setBackgroundState;
  73651. }
  73652. }
  73653. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  73654. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73655. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  73656. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  73657. import { WebXRInput } from "babylonjs/XR/webXRInput";
  73658. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73659. import { Nullable } from "babylonjs/types";
  73660. /**
  73661. * Options for the controller physics feature
  73662. */
  73663. export class IWebXRControllerPhysicsOptions {
  73664. /**
  73665. * Should the headset get its own impostor
  73666. */
  73667. enableHeadsetImpostor?: boolean;
  73668. /**
  73669. * Optional parameters for the headset impostor
  73670. */
  73671. headsetImpostorParams?: {
  73672. /**
  73673. * The type of impostor to create. Default is sphere
  73674. */
  73675. impostorType: number;
  73676. /**
  73677. * the size of the impostor. Defaults to 10cm
  73678. */
  73679. impostorSize?: number | {
  73680. width: number;
  73681. height: number;
  73682. depth: number;
  73683. };
  73684. /**
  73685. * Friction definitions
  73686. */
  73687. friction?: number;
  73688. /**
  73689. * Restitution
  73690. */
  73691. restitution?: number;
  73692. };
  73693. /**
  73694. * The physics properties of the future impostors
  73695. */
  73696. physicsProperties?: {
  73697. /**
  73698. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  73699. * Note that this requires a physics engine that supports mesh impostors!
  73700. */
  73701. useControllerMesh?: boolean;
  73702. /**
  73703. * The type of impostor to create. Default is sphere
  73704. */
  73705. impostorType?: number;
  73706. /**
  73707. * the size of the impostor. Defaults to 10cm
  73708. */
  73709. impostorSize?: number | {
  73710. width: number;
  73711. height: number;
  73712. depth: number;
  73713. };
  73714. /**
  73715. * Friction definitions
  73716. */
  73717. friction?: number;
  73718. /**
  73719. * Restitution
  73720. */
  73721. restitution?: number;
  73722. };
  73723. /**
  73724. * the xr input to use with this pointer selection
  73725. */
  73726. xrInput: WebXRInput;
  73727. }
  73728. /**
  73729. * Add physics impostor to your webxr controllers,
  73730. * including naive calculation of their linear and angular velocity
  73731. */
  73732. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  73733. private readonly _options;
  73734. private _attachController;
  73735. private _controllers;
  73736. private _debugMode;
  73737. private _delta;
  73738. private _headsetImpostor?;
  73739. private _headsetMesh?;
  73740. private _lastTimestamp;
  73741. private _tmpQuaternion;
  73742. private _tmpVector;
  73743. /**
  73744. * The module's name
  73745. */
  73746. static readonly Name: string;
  73747. /**
  73748. * The (Babylon) version of this module.
  73749. * This is an integer representing the implementation version.
  73750. * This number does not correspond to the webxr specs version
  73751. */
  73752. static readonly Version: number;
  73753. /**
  73754. * Construct a new Controller Physics Feature
  73755. * @param _xrSessionManager the corresponding xr session manager
  73756. * @param _options options to create this feature with
  73757. */
  73758. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  73759. /**
  73760. * @hidden
  73761. * enable debugging - will show console outputs and the impostor mesh
  73762. */
  73763. _enablePhysicsDebug(): void;
  73764. /**
  73765. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  73766. * @param xrController the controller to add
  73767. */
  73768. addController(xrController: WebXRInputSource): void;
  73769. /**
  73770. * attach this feature
  73771. * Will usually be called by the features manager
  73772. *
  73773. * @returns true if successful.
  73774. */
  73775. attach(): boolean;
  73776. /**
  73777. * detach this feature.
  73778. * Will usually be called by the features manager
  73779. *
  73780. * @returns true if successful.
  73781. */
  73782. detach(): boolean;
  73783. /**
  73784. * Get the headset impostor, if enabled
  73785. * @returns the impostor
  73786. */
  73787. getHeadsetImpostor(): PhysicsImpostor | undefined;
  73788. /**
  73789. * Get the physics impostor of a specific controller.
  73790. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  73791. * @param controller the controller or the controller id of which to get the impostor
  73792. * @returns the impostor or null
  73793. */
  73794. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  73795. /**
  73796. * Update the physics properties provided in the constructor
  73797. * @param newProperties the new properties object
  73798. */
  73799. setPhysicsProperties(newProperties: {
  73800. impostorType?: number;
  73801. impostorSize?: number | {
  73802. width: number;
  73803. height: number;
  73804. depth: number;
  73805. };
  73806. friction?: number;
  73807. restitution?: number;
  73808. }): void;
  73809. protected _onXRFrame(_xrFrame: any): void;
  73810. private _detachController;
  73811. }
  73812. }
  73813. declare module "babylonjs/XR/features/WebXRHitTest" {
  73814. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  73815. import { Observable } from "babylonjs/Misc/observable";
  73816. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  73817. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  73818. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult } from "babylonjs/XR/features/WebXRHitTestLegacy";
  73819. /**
  73820. * Options used for hit testing (version 2)
  73821. */
  73822. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  73823. /**
  73824. * Do not create a permanent hit test. Will usually be used when only
  73825. * transient inputs are needed.
  73826. */
  73827. disablePermanentHitTest?: boolean;
  73828. /**
  73829. * Enable transient (for example touch-based) hit test inspections
  73830. */
  73831. enableTransientHitTest?: boolean;
  73832. /**
  73833. * Offset ray for the permanent hit test
  73834. */
  73835. offsetRay?: Vector3;
  73836. /**
  73837. * Offset ray for the transient hit test
  73838. */
  73839. transientOffsetRay?: Vector3;
  73840. /**
  73841. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  73842. */
  73843. useReferenceSpace?: boolean;
  73844. }
  73845. /**
  73846. * Interface defining the babylon result of hit-test
  73847. */
  73848. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  73849. /**
  73850. * The input source that generated this hit test (if transient)
  73851. */
  73852. inputSource?: XRInputSource;
  73853. /**
  73854. * Is this a transient hit test
  73855. */
  73856. isTransient?: boolean;
  73857. /**
  73858. * Position of the hit test result
  73859. */
  73860. position: Vector3;
  73861. /**
  73862. * Rotation of the hit test result
  73863. */
  73864. rotationQuaternion: Quaternion;
  73865. }
  73866. /**
  73867. * The currently-working hit-test module.
  73868. * Hit test (or Ray-casting) is used to interact with the real world.
  73869. * For further information read here - https://github.com/immersive-web/hit-test
  73870. *
  73871. * Tested on chrome (mobile) 80.
  73872. */
  73873. export class WebXRHitTest extends WebXRAbstractFeature {
  73874. /**
  73875. * options to use when constructing this feature
  73876. */
  73877. readonly options: IWebXRHitTestOptions;
  73878. private _tmpMat;
  73879. private _tmpPos;
  73880. private _tmpQuat;
  73881. private _transientXrHitTestSource;
  73882. private _xrHitTestSource;
  73883. private initHitTestSource;
  73884. /**
  73885. * The module's name
  73886. */
  73887. static readonly Name: string;
  73888. /**
  73889. * The (Babylon) version of this module.
  73890. * This is an integer representing the implementation version.
  73891. * This number does not correspond to the WebXR specs version
  73892. */
  73893. static readonly Version: number;
  73894. /**
  73895. * When set to true, each hit test will have its own position/rotation objects
  73896. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  73897. * the developers will clone them or copy them as they see fit.
  73898. */
  73899. autoCloneTransformation: boolean;
  73900. /**
  73901. * Populated with the last native XR Hit Results
  73902. */
  73903. lastNativeXRHitResults: XRHitResult[];
  73904. /**
  73905. * Triggered when new babylon (transformed) hit test results are available
  73906. */
  73907. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  73908. /**
  73909. * Use this to temporarily pause hit test checks.
  73910. */
  73911. paused: boolean;
  73912. /**
  73913. * Creates a new instance of the hit test feature
  73914. * @param _xrSessionManager an instance of WebXRSessionManager
  73915. * @param options options to use when constructing this feature
  73916. */
  73917. constructor(_xrSessionManager: WebXRSessionManager,
  73918. /**
  73919. * options to use when constructing this feature
  73920. */
  73921. options?: IWebXRHitTestOptions);
  73922. /**
  73923. * attach this feature
  73924. * Will usually be called by the features manager
  73925. *
  73926. * @returns true if successful.
  73927. */
  73928. attach(): boolean;
  73929. /**
  73930. * detach this feature.
  73931. * Will usually be called by the features manager
  73932. *
  73933. * @returns true if successful.
  73934. */
  73935. detach(): boolean;
  73936. /**
  73937. * Dispose this feature and all of the resources attached
  73938. */
  73939. dispose(): void;
  73940. protected _onXRFrame(frame: XRFrame): void;
  73941. private _processWebXRHitTestResult;
  73942. }
  73943. }
  73944. declare module "babylonjs/XR/features/index" {
  73945. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  73946. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  73947. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  73948. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  73949. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  73950. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  73951. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  73952. export * from "babylonjs/XR/features/WebXRHitTest";
  73953. }
  73954. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  73955. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  73956. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73957. import { Scene } from "babylonjs/scene";
  73958. /**
  73959. * The motion controller class for all microsoft mixed reality controllers
  73960. */
  73961. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  73962. protected readonly _mapping: {
  73963. defaultButton: {
  73964. valueNodeName: string;
  73965. unpressedNodeName: string;
  73966. pressedNodeName: string;
  73967. };
  73968. defaultAxis: {
  73969. valueNodeName: string;
  73970. minNodeName: string;
  73971. maxNodeName: string;
  73972. };
  73973. buttons: {
  73974. "xr-standard-trigger": {
  73975. rootNodeName: string;
  73976. componentProperty: string;
  73977. states: string[];
  73978. };
  73979. "xr-standard-squeeze": {
  73980. rootNodeName: string;
  73981. componentProperty: string;
  73982. states: string[];
  73983. };
  73984. "xr-standard-touchpad": {
  73985. rootNodeName: string;
  73986. labelAnchorNodeName: string;
  73987. touchPointNodeName: string;
  73988. };
  73989. "xr-standard-thumbstick": {
  73990. rootNodeName: string;
  73991. componentProperty: string;
  73992. states: string[];
  73993. };
  73994. };
  73995. axes: {
  73996. "xr-standard-touchpad": {
  73997. "x-axis": {
  73998. rootNodeName: string;
  73999. };
  74000. "y-axis": {
  74001. rootNodeName: string;
  74002. };
  74003. };
  74004. "xr-standard-thumbstick": {
  74005. "x-axis": {
  74006. rootNodeName: string;
  74007. };
  74008. "y-axis": {
  74009. rootNodeName: string;
  74010. };
  74011. };
  74012. };
  74013. };
  74014. /**
  74015. * The base url used to load the left and right controller models
  74016. */
  74017. static MODEL_BASE_URL: string;
  74018. /**
  74019. * The name of the left controller model file
  74020. */
  74021. static MODEL_LEFT_FILENAME: string;
  74022. /**
  74023. * The name of the right controller model file
  74024. */
  74025. static MODEL_RIGHT_FILENAME: string;
  74026. profileId: string;
  74027. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74028. protected _getFilenameAndPath(): {
  74029. filename: string;
  74030. path: string;
  74031. };
  74032. protected _getModelLoadingConstraints(): boolean;
  74033. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74034. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74035. protected _updateModel(): void;
  74036. }
  74037. }
  74038. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  74039. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74040. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74041. import { Scene } from "babylonjs/scene";
  74042. /**
  74043. * The motion controller class for oculus touch (quest, rift).
  74044. * This class supports legacy mapping as well the standard xr mapping
  74045. */
  74046. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  74047. private _forceLegacyControllers;
  74048. private _modelRootNode;
  74049. /**
  74050. * The base url used to load the left and right controller models
  74051. */
  74052. static MODEL_BASE_URL: string;
  74053. /**
  74054. * The name of the left controller model file
  74055. */
  74056. static MODEL_LEFT_FILENAME: string;
  74057. /**
  74058. * The name of the right controller model file
  74059. */
  74060. static MODEL_RIGHT_FILENAME: string;
  74061. /**
  74062. * Base Url for the Quest controller model.
  74063. */
  74064. static QUEST_MODEL_BASE_URL: string;
  74065. profileId: string;
  74066. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  74067. protected _getFilenameAndPath(): {
  74068. filename: string;
  74069. path: string;
  74070. };
  74071. protected _getModelLoadingConstraints(): boolean;
  74072. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74073. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74074. protected _updateModel(): void;
  74075. /**
  74076. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  74077. * between the touch and touch 2.
  74078. */
  74079. private _isQuest;
  74080. }
  74081. }
  74082. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  74083. import { IMinimalMotionControllerObject, MotionControllerHandness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74084. import { Scene } from "babylonjs/scene";
  74085. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74086. /**
  74087. * The motion controller class for the standard HTC-Vive controllers
  74088. */
  74089. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  74090. private _modelRootNode;
  74091. /**
  74092. * The base url used to load the left and right controller models
  74093. */
  74094. static MODEL_BASE_URL: string;
  74095. /**
  74096. * File name for the controller model.
  74097. */
  74098. static MODEL_FILENAME: string;
  74099. profileId: string;
  74100. /**
  74101. * Create a new Vive motion controller object
  74102. * @param scene the scene to use to create this controller
  74103. * @param gamepadObject the corresponding gamepad object
  74104. * @param handness the handness of the controller
  74105. */
  74106. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  74107. protected _getFilenameAndPath(): {
  74108. filename: string;
  74109. path: string;
  74110. };
  74111. protected _getModelLoadingConstraints(): boolean;
  74112. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  74113. protected _setRootMesh(meshes: AbstractMesh[]): void;
  74114. protected _updateModel(): void;
  74115. }
  74116. }
  74117. declare module "babylonjs/XR/motionController/index" {
  74118. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  74119. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  74120. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  74121. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  74122. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  74123. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  74124. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  74125. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  74126. }
  74127. declare module "babylonjs/XR/index" {
  74128. export * from "babylonjs/XR/webXRCamera";
  74129. export * from "babylonjs/XR/webXREnterExitUI";
  74130. export * from "babylonjs/XR/webXRExperienceHelper";
  74131. export * from "babylonjs/XR/webXRInput";
  74132. export * from "babylonjs/XR/webXRInputSource";
  74133. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  74134. export * from "babylonjs/XR/webXRTypes";
  74135. export * from "babylonjs/XR/webXRSessionManager";
  74136. export * from "babylonjs/XR/webXRDefaultExperience";
  74137. export * from "babylonjs/XR/webXRFeaturesManager";
  74138. export * from "babylonjs/XR/features/index";
  74139. export * from "babylonjs/XR/motionController/index";
  74140. }
  74141. declare module "babylonjs/index" {
  74142. export * from "babylonjs/abstractScene";
  74143. export * from "babylonjs/Actions/index";
  74144. export * from "babylonjs/Animations/index";
  74145. export * from "babylonjs/assetContainer";
  74146. export * from "babylonjs/Audio/index";
  74147. export * from "babylonjs/Behaviors/index";
  74148. export * from "babylonjs/Bones/index";
  74149. export * from "babylonjs/Cameras/index";
  74150. export * from "babylonjs/Collisions/index";
  74151. export * from "babylonjs/Culling/index";
  74152. export * from "babylonjs/Debug/index";
  74153. export * from "babylonjs/Engines/index";
  74154. export * from "babylonjs/Events/index";
  74155. export * from "babylonjs/Gamepads/index";
  74156. export * from "babylonjs/Gizmos/index";
  74157. export * from "babylonjs/Helpers/index";
  74158. export * from "babylonjs/Instrumentation/index";
  74159. export * from "babylonjs/Layers/index";
  74160. export * from "babylonjs/LensFlares/index";
  74161. export * from "babylonjs/Lights/index";
  74162. export * from "babylonjs/Loading/index";
  74163. export * from "babylonjs/Materials/index";
  74164. export * from "babylonjs/Maths/index";
  74165. export * from "babylonjs/Meshes/index";
  74166. export * from "babylonjs/Morph/index";
  74167. export * from "babylonjs/Navigation/index";
  74168. export * from "babylonjs/node";
  74169. export * from "babylonjs/Offline/index";
  74170. export * from "babylonjs/Particles/index";
  74171. export * from "babylonjs/Physics/index";
  74172. export * from "babylonjs/PostProcesses/index";
  74173. export * from "babylonjs/Probes/index";
  74174. export * from "babylonjs/Rendering/index";
  74175. export * from "babylonjs/scene";
  74176. export * from "babylonjs/sceneComponent";
  74177. export * from "babylonjs/Sprites/index";
  74178. export * from "babylonjs/States/index";
  74179. export * from "babylonjs/Misc/index";
  74180. export * from "babylonjs/XR/index";
  74181. export * from "babylonjs/types";
  74182. }
  74183. declare module "babylonjs/Animations/pathCursor" {
  74184. import { Vector3 } from "babylonjs/Maths/math.vector";
  74185. import { Path2 } from "babylonjs/Maths/math.path";
  74186. /**
  74187. * A cursor which tracks a point on a path
  74188. */
  74189. export class PathCursor {
  74190. private path;
  74191. /**
  74192. * Stores path cursor callbacks for when an onchange event is triggered
  74193. */
  74194. private _onchange;
  74195. /**
  74196. * The value of the path cursor
  74197. */
  74198. value: number;
  74199. /**
  74200. * The animation array of the path cursor
  74201. */
  74202. animations: Animation[];
  74203. /**
  74204. * Initializes the path cursor
  74205. * @param path The path to track
  74206. */
  74207. constructor(path: Path2);
  74208. /**
  74209. * Gets the cursor point on the path
  74210. * @returns A point on the path cursor at the cursor location
  74211. */
  74212. getPoint(): Vector3;
  74213. /**
  74214. * Moves the cursor ahead by the step amount
  74215. * @param step The amount to move the cursor forward
  74216. * @returns This path cursor
  74217. */
  74218. moveAhead(step?: number): PathCursor;
  74219. /**
  74220. * Moves the cursor behind by the step amount
  74221. * @param step The amount to move the cursor back
  74222. * @returns This path cursor
  74223. */
  74224. moveBack(step?: number): PathCursor;
  74225. /**
  74226. * Moves the cursor by the step amount
  74227. * If the step amount is greater than one, an exception is thrown
  74228. * @param step The amount to move the cursor
  74229. * @returns This path cursor
  74230. */
  74231. move(step: number): PathCursor;
  74232. /**
  74233. * Ensures that the value is limited between zero and one
  74234. * @returns This path cursor
  74235. */
  74236. private ensureLimits;
  74237. /**
  74238. * Runs onchange callbacks on change (used by the animation engine)
  74239. * @returns This path cursor
  74240. */
  74241. private raiseOnChange;
  74242. /**
  74243. * Executes a function on change
  74244. * @param f A path cursor onchange callback
  74245. * @returns This path cursor
  74246. */
  74247. onchange(f: (cursor: PathCursor) => void): PathCursor;
  74248. }
  74249. }
  74250. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  74251. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  74252. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  74253. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  74254. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  74255. }
  74256. declare module "babylonjs/Engines/Processors/Expressions/index" {
  74257. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  74258. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  74259. }
  74260. declare module "babylonjs/Engines/Processors/index" {
  74261. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  74262. export * from "babylonjs/Engines/Processors/Expressions/index";
  74263. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  74264. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  74265. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  74266. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  74267. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  74268. export * from "babylonjs/Engines/Processors/shaderProcessor";
  74269. }
  74270. declare module "babylonjs/Legacy/legacy" {
  74271. import * as Babylon from "babylonjs/index";
  74272. export * from "babylonjs/index";
  74273. }
  74274. declare module "babylonjs/Shaders/blur.fragment" {
  74275. /** @hidden */
  74276. export var blurPixelShader: {
  74277. name: string;
  74278. shader: string;
  74279. };
  74280. }
  74281. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  74282. /** @hidden */
  74283. export var pointCloudVertexDeclaration: {
  74284. name: string;
  74285. shader: string;
  74286. };
  74287. }
  74288. declare module "babylonjs" {
  74289. export * from "babylonjs/Legacy/legacy";
  74290. }
  74291. declare module BABYLON {
  74292. /** Alias type for value that can be null */
  74293. export type Nullable<T> = T | null;
  74294. /**
  74295. * Alias type for number that are floats
  74296. * @ignorenaming
  74297. */
  74298. export type float = number;
  74299. /**
  74300. * Alias type for number that are doubles.
  74301. * @ignorenaming
  74302. */
  74303. export type double = number;
  74304. /**
  74305. * Alias type for number that are integer
  74306. * @ignorenaming
  74307. */
  74308. export type int = number;
  74309. /** Alias type for number array or Float32Array */
  74310. export type FloatArray = number[] | Float32Array;
  74311. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  74312. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  74313. /**
  74314. * Alias for types that can be used by a Buffer or VertexBuffer.
  74315. */
  74316. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  74317. /**
  74318. * Alias type for primitive types
  74319. * @ignorenaming
  74320. */
  74321. type Primitive = undefined | null | boolean | string | number | Function;
  74322. /**
  74323. * Type modifier to make all the properties of an object Readonly
  74324. */
  74325. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  74326. /**
  74327. * Type modifier to make all the properties of an object Readonly recursively
  74328. */
  74329. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  74330. /**
  74331. * Type modifier to make object properties readonly.
  74332. */
  74333. export type DeepImmutableObject<T> = {
  74334. readonly [K in keyof T]: DeepImmutable<T[K]>;
  74335. };
  74336. /** @hidden */
  74337. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  74338. }
  74339. }
  74340. declare module BABYLON {
  74341. /**
  74342. * A class serves as a medium between the observable and its observers
  74343. */
  74344. export class EventState {
  74345. /**
  74346. * Create a new EventState
  74347. * @param mask defines the mask associated with this state
  74348. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74349. * @param target defines the original target of the state
  74350. * @param currentTarget defines the current target of the state
  74351. */
  74352. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  74353. /**
  74354. * Initialize the current event state
  74355. * @param mask defines the mask associated with this state
  74356. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  74357. * @param target defines the original target of the state
  74358. * @param currentTarget defines the current target of the state
  74359. * @returns the current event state
  74360. */
  74361. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  74362. /**
  74363. * An Observer can set this property to true to prevent subsequent observers of being notified
  74364. */
  74365. skipNextObservers: boolean;
  74366. /**
  74367. * Get the mask value that were used to trigger the event corresponding to this EventState object
  74368. */
  74369. mask: number;
  74370. /**
  74371. * The object that originally notified the event
  74372. */
  74373. target?: any;
  74374. /**
  74375. * The current object in the bubbling phase
  74376. */
  74377. currentTarget?: any;
  74378. /**
  74379. * This will be populated with the return value of the last function that was executed.
  74380. * If it is the first function in the callback chain it will be the event data.
  74381. */
  74382. lastReturnValue?: any;
  74383. }
  74384. /**
  74385. * Represent an Observer registered to a given Observable object.
  74386. */
  74387. export class Observer<T> {
  74388. /**
  74389. * Defines the callback to call when the observer is notified
  74390. */
  74391. callback: (eventData: T, eventState: EventState) => void;
  74392. /**
  74393. * Defines the mask of the observer (used to filter notifications)
  74394. */
  74395. mask: number;
  74396. /**
  74397. * Defines the current scope used to restore the JS context
  74398. */
  74399. scope: any;
  74400. /** @hidden */
  74401. _willBeUnregistered: boolean;
  74402. /**
  74403. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  74404. */
  74405. unregisterOnNextCall: boolean;
  74406. /**
  74407. * Creates a new observer
  74408. * @param callback defines the callback to call when the observer is notified
  74409. * @param mask defines the mask of the observer (used to filter notifications)
  74410. * @param scope defines the current scope used to restore the JS context
  74411. */
  74412. constructor(
  74413. /**
  74414. * Defines the callback to call when the observer is notified
  74415. */
  74416. callback: (eventData: T, eventState: EventState) => void,
  74417. /**
  74418. * Defines the mask of the observer (used to filter notifications)
  74419. */
  74420. mask: number,
  74421. /**
  74422. * Defines the current scope used to restore the JS context
  74423. */
  74424. scope?: any);
  74425. }
  74426. /**
  74427. * Represent a list of observers registered to multiple Observables object.
  74428. */
  74429. export class MultiObserver<T> {
  74430. private _observers;
  74431. private _observables;
  74432. /**
  74433. * Release associated resources
  74434. */
  74435. dispose(): void;
  74436. /**
  74437. * Raise a callback when one of the observable will notify
  74438. * @param observables defines a list of observables to watch
  74439. * @param callback defines the callback to call on notification
  74440. * @param mask defines the mask used to filter notifications
  74441. * @param scope defines the current scope used to restore the JS context
  74442. * @returns the new MultiObserver
  74443. */
  74444. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  74445. }
  74446. /**
  74447. * The Observable class is a simple implementation of the Observable pattern.
  74448. *
  74449. * 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.
  74450. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  74451. * 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).
  74452. * 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.
  74453. */
  74454. export class Observable<T> {
  74455. private _observers;
  74456. private _eventState;
  74457. private _onObserverAdded;
  74458. /**
  74459. * Gets the list of observers
  74460. */
  74461. get observers(): Array<Observer<T>>;
  74462. /**
  74463. * Creates a new observable
  74464. * @param onObserverAdded defines a callback to call when a new observer is added
  74465. */
  74466. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  74467. /**
  74468. * Create a new Observer with the specified callback
  74469. * @param callback the callback that will be executed for that Observer
  74470. * @param mask the mask used to filter observers
  74471. * @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.
  74472. * @param scope optional scope for the callback to be called from
  74473. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  74474. * @returns the new observer created for the callback
  74475. */
  74476. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  74477. /**
  74478. * Create a new Observer with the specified callback and unregisters after the next notification
  74479. * @param callback the callback that will be executed for that Observer
  74480. * @returns the new observer created for the callback
  74481. */
  74482. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  74483. /**
  74484. * Remove an Observer from the Observable object
  74485. * @param observer the instance of the Observer to remove
  74486. * @returns false if it doesn't belong to this Observable
  74487. */
  74488. remove(observer: Nullable<Observer<T>>): boolean;
  74489. /**
  74490. * Remove a callback from the Observable object
  74491. * @param callback the callback to remove
  74492. * @param scope optional scope. If used only the callbacks with this scope will be removed
  74493. * @returns false if it doesn't belong to this Observable
  74494. */
  74495. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  74496. private _deferUnregister;
  74497. private _remove;
  74498. /**
  74499. * Moves the observable to the top of the observer list making it get called first when notified
  74500. * @param observer the observer to move
  74501. */
  74502. makeObserverTopPriority(observer: Observer<T>): void;
  74503. /**
  74504. * Moves the observable to the bottom of the observer list making it get called last when notified
  74505. * @param observer the observer to move
  74506. */
  74507. makeObserverBottomPriority(observer: Observer<T>): void;
  74508. /**
  74509. * Notify all Observers by calling their respective callback with the given data
  74510. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  74511. * @param eventData defines the data to send to all observers
  74512. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  74513. * @param target defines the original target of the state
  74514. * @param currentTarget defines the current target of the state
  74515. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  74516. */
  74517. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  74518. /**
  74519. * Calling this will execute each callback, expecting it to be a promise or return a value.
  74520. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  74521. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  74522. * and it is crucial that all callbacks will be executed.
  74523. * The order of the callbacks is kept, callbacks are not executed parallel.
  74524. *
  74525. * @param eventData The data to be sent to each callback
  74526. * @param mask is used to filter observers defaults to -1
  74527. * @param target defines the callback target (see EventState)
  74528. * @param currentTarget defines he current object in the bubbling phase
  74529. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  74530. */
  74531. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  74532. /**
  74533. * Notify a specific observer
  74534. * @param observer defines the observer to notify
  74535. * @param eventData defines the data to be sent to each callback
  74536. * @param mask is used to filter observers defaults to -1
  74537. */
  74538. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  74539. /**
  74540. * Gets a boolean indicating if the observable has at least one observer
  74541. * @returns true is the Observable has at least one Observer registered
  74542. */
  74543. hasObservers(): boolean;
  74544. /**
  74545. * Clear the list of observers
  74546. */
  74547. clear(): void;
  74548. /**
  74549. * Clone the current observable
  74550. * @returns a new observable
  74551. */
  74552. clone(): Observable<T>;
  74553. /**
  74554. * Does this observable handles observer registered with a given mask
  74555. * @param mask defines the mask to be tested
  74556. * @return whether or not one observer registered with the given mask is handeled
  74557. **/
  74558. hasSpecificMask(mask?: number): boolean;
  74559. }
  74560. }
  74561. declare module BABYLON {
  74562. /**
  74563. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  74564. * Babylon.js
  74565. */
  74566. export class DomManagement {
  74567. /**
  74568. * Checks if the window object exists
  74569. * @returns true if the window object exists
  74570. */
  74571. static IsWindowObjectExist(): boolean;
  74572. /**
  74573. * Checks if the navigator object exists
  74574. * @returns true if the navigator object exists
  74575. */
  74576. static IsNavigatorAvailable(): boolean;
  74577. /**
  74578. * Check if the document object exists
  74579. * @returns true if the document object exists
  74580. */
  74581. static IsDocumentAvailable(): boolean;
  74582. /**
  74583. * Extracts text content from a DOM element hierarchy
  74584. * @param element defines the root element
  74585. * @returns a string
  74586. */
  74587. static GetDOMTextContent(element: HTMLElement): string;
  74588. }
  74589. }
  74590. declare module BABYLON {
  74591. /**
  74592. * Logger used througouht the application to allow configuration of
  74593. * the log level required for the messages.
  74594. */
  74595. export class Logger {
  74596. /**
  74597. * No log
  74598. */
  74599. static readonly NoneLogLevel: number;
  74600. /**
  74601. * Only message logs
  74602. */
  74603. static readonly MessageLogLevel: number;
  74604. /**
  74605. * Only warning logs
  74606. */
  74607. static readonly WarningLogLevel: number;
  74608. /**
  74609. * Only error logs
  74610. */
  74611. static readonly ErrorLogLevel: number;
  74612. /**
  74613. * All logs
  74614. */
  74615. static readonly AllLogLevel: number;
  74616. private static _LogCache;
  74617. /**
  74618. * Gets a value indicating the number of loading errors
  74619. * @ignorenaming
  74620. */
  74621. static errorsCount: number;
  74622. /**
  74623. * Callback called when a new log is added
  74624. */
  74625. static OnNewCacheEntry: (entry: string) => void;
  74626. private static _AddLogEntry;
  74627. private static _FormatMessage;
  74628. private static _LogDisabled;
  74629. private static _LogEnabled;
  74630. private static _WarnDisabled;
  74631. private static _WarnEnabled;
  74632. private static _ErrorDisabled;
  74633. private static _ErrorEnabled;
  74634. /**
  74635. * Log a message to the console
  74636. */
  74637. static Log: (message: string) => void;
  74638. /**
  74639. * Write a warning message to the console
  74640. */
  74641. static Warn: (message: string) => void;
  74642. /**
  74643. * Write an error message to the console
  74644. */
  74645. static Error: (message: string) => void;
  74646. /**
  74647. * Gets current log cache (list of logs)
  74648. */
  74649. static get LogCache(): string;
  74650. /**
  74651. * Clears the log cache
  74652. */
  74653. static ClearLogCache(): void;
  74654. /**
  74655. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  74656. */
  74657. static set LogLevels(level: number);
  74658. }
  74659. }
  74660. declare module BABYLON {
  74661. /** @hidden */
  74662. export class _TypeStore {
  74663. /** @hidden */
  74664. static RegisteredTypes: {
  74665. [key: string]: Object;
  74666. };
  74667. /** @hidden */
  74668. static GetClass(fqdn: string): any;
  74669. }
  74670. }
  74671. declare module BABYLON {
  74672. /**
  74673. * Helper to manipulate strings
  74674. */
  74675. export class StringTools {
  74676. /**
  74677. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  74678. * @param str Source string
  74679. * @param suffix Suffix to search for in the source string
  74680. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74681. */
  74682. static EndsWith(str: string, suffix: string): boolean;
  74683. /**
  74684. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  74685. * @param str Source string
  74686. * @param suffix Suffix to search for in the source string
  74687. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  74688. */
  74689. static StartsWith(str: string, suffix: string): boolean;
  74690. /**
  74691. * Decodes a buffer into a string
  74692. * @param buffer The buffer to decode
  74693. * @returns The decoded string
  74694. */
  74695. static Decode(buffer: Uint8Array | Uint16Array): string;
  74696. /**
  74697. * Encode a buffer to a base64 string
  74698. * @param buffer defines the buffer to encode
  74699. * @returns the encoded string
  74700. */
  74701. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  74702. /**
  74703. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  74704. * @param num the number to convert and pad
  74705. * @param length the expected length of the string
  74706. * @returns the padded string
  74707. */
  74708. static PadNumber(num: number, length: number): string;
  74709. }
  74710. }
  74711. declare module BABYLON {
  74712. /**
  74713. * Class containing a set of static utilities functions for deep copy.
  74714. */
  74715. export class DeepCopier {
  74716. /**
  74717. * Tries to copy an object by duplicating every property
  74718. * @param source defines the source object
  74719. * @param destination defines the target object
  74720. * @param doNotCopyList defines a list of properties to avoid
  74721. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  74722. */
  74723. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  74724. }
  74725. }
  74726. declare module BABYLON {
  74727. /**
  74728. * Class containing a set of static utilities functions for precision date
  74729. */
  74730. export class PrecisionDate {
  74731. /**
  74732. * Gets either window.performance.now() if supported or Date.now() else
  74733. */
  74734. static get Now(): number;
  74735. }
  74736. }
  74737. declare module BABYLON {
  74738. /** @hidden */
  74739. export class _DevTools {
  74740. static WarnImport(name: string): string;
  74741. }
  74742. }
  74743. declare module BABYLON {
  74744. /**
  74745. * Interface used to define the mechanism to get data from the network
  74746. */
  74747. export interface IWebRequest {
  74748. /**
  74749. * Returns client's response url
  74750. */
  74751. responseURL: string;
  74752. /**
  74753. * Returns client's status
  74754. */
  74755. status: number;
  74756. /**
  74757. * Returns client's status as a text
  74758. */
  74759. statusText: string;
  74760. }
  74761. }
  74762. declare module BABYLON {
  74763. /**
  74764. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  74765. */
  74766. export class WebRequest implements IWebRequest {
  74767. private _xhr;
  74768. /**
  74769. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  74770. * i.e. when loading files, where the server/service expects an Authorization header
  74771. */
  74772. static CustomRequestHeaders: {
  74773. [key: string]: string;
  74774. };
  74775. /**
  74776. * Add callback functions in this array to update all the requests before they get sent to the network
  74777. */
  74778. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  74779. private _injectCustomRequestHeaders;
  74780. /**
  74781. * Gets or sets a function to be called when loading progress changes
  74782. */
  74783. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  74784. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  74785. /**
  74786. * Returns client's state
  74787. */
  74788. get readyState(): number;
  74789. /**
  74790. * Returns client's status
  74791. */
  74792. get status(): number;
  74793. /**
  74794. * Returns client's status as a text
  74795. */
  74796. get statusText(): string;
  74797. /**
  74798. * Returns client's response
  74799. */
  74800. get response(): any;
  74801. /**
  74802. * Returns client's response url
  74803. */
  74804. get responseURL(): string;
  74805. /**
  74806. * Returns client's response as text
  74807. */
  74808. get responseText(): string;
  74809. /**
  74810. * Gets or sets the expected response type
  74811. */
  74812. get responseType(): XMLHttpRequestResponseType;
  74813. set responseType(value: XMLHttpRequestResponseType);
  74814. /** @hidden */
  74815. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  74816. /** @hidden */
  74817. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  74818. /**
  74819. * Cancels any network activity
  74820. */
  74821. abort(): void;
  74822. /**
  74823. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  74824. * @param body defines an optional request body
  74825. */
  74826. send(body?: Document | BodyInit | null): void;
  74827. /**
  74828. * Sets the request method, request URL
  74829. * @param method defines the method to use (GET, POST, etc..)
  74830. * @param url defines the url to connect with
  74831. */
  74832. open(method: string, url: string): void;
  74833. /**
  74834. * Sets the value of a request header.
  74835. * @param name The name of the header whose value is to be set
  74836. * @param value The value to set as the body of the header
  74837. */
  74838. setRequestHeader(name: string, value: string): void;
  74839. /**
  74840. * Get the string containing the text of a particular header's value.
  74841. * @param name The name of the header
  74842. * @returns The string containing the text of the given header name
  74843. */
  74844. getResponseHeader(name: string): Nullable<string>;
  74845. }
  74846. }
  74847. declare module BABYLON {
  74848. /**
  74849. * File request interface
  74850. */
  74851. export interface IFileRequest {
  74852. /**
  74853. * Raised when the request is complete (success or error).
  74854. */
  74855. onCompleteObservable: Observable<IFileRequest>;
  74856. /**
  74857. * Aborts the request for a file.
  74858. */
  74859. abort: () => void;
  74860. }
  74861. }
  74862. declare module BABYLON {
  74863. /**
  74864. * Define options used to create a render target texture
  74865. */
  74866. export class RenderTargetCreationOptions {
  74867. /**
  74868. * Specifies is mipmaps must be generated
  74869. */
  74870. generateMipMaps?: boolean;
  74871. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  74872. generateDepthBuffer?: boolean;
  74873. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  74874. generateStencilBuffer?: boolean;
  74875. /** Defines texture type (int by default) */
  74876. type?: number;
  74877. /** Defines sampling mode (trilinear by default) */
  74878. samplingMode?: number;
  74879. /** Defines format (RGBA by default) */
  74880. format?: number;
  74881. }
  74882. }
  74883. declare module BABYLON {
  74884. /** Defines the cross module used constants to avoid circular dependncies */
  74885. export class Constants {
  74886. /** Defines that alpha blending is disabled */
  74887. static readonly ALPHA_DISABLE: number;
  74888. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  74889. static readonly ALPHA_ADD: number;
  74890. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  74891. static readonly ALPHA_COMBINE: number;
  74892. /** Defines that alpha blending is DEST - SRC * DEST */
  74893. static readonly ALPHA_SUBTRACT: number;
  74894. /** Defines that alpha blending is SRC * DEST */
  74895. static readonly ALPHA_MULTIPLY: number;
  74896. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  74897. static readonly ALPHA_MAXIMIZED: number;
  74898. /** Defines that alpha blending is SRC + DEST */
  74899. static readonly ALPHA_ONEONE: number;
  74900. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  74901. static readonly ALPHA_PREMULTIPLIED: number;
  74902. /**
  74903. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  74904. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  74905. */
  74906. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  74907. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  74908. static readonly ALPHA_INTERPOLATE: number;
  74909. /**
  74910. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  74911. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  74912. */
  74913. static readonly ALPHA_SCREENMODE: number;
  74914. /**
  74915. * Defines that alpha blending is SRC + DST
  74916. * Alpha will be set to SRC ALPHA + DST ALPHA
  74917. */
  74918. static readonly ALPHA_ONEONE_ONEONE: number;
  74919. /**
  74920. * Defines that alpha blending is SRC * DST ALPHA + DST
  74921. * Alpha will be set to 0
  74922. */
  74923. static readonly ALPHA_ALPHATOCOLOR: number;
  74924. /**
  74925. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74926. */
  74927. static readonly ALPHA_REVERSEONEMINUS: number;
  74928. /**
  74929. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  74930. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  74931. */
  74932. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  74933. /**
  74934. * Defines that alpha blending is SRC + DST
  74935. * Alpha will be set to SRC ALPHA
  74936. */
  74937. static readonly ALPHA_ONEONE_ONEZERO: number;
  74938. /**
  74939. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  74940. * Alpha will be set to DST ALPHA
  74941. */
  74942. static readonly ALPHA_EXCLUSION: number;
  74943. /** Defines that alpha blending equation a SUM */
  74944. static readonly ALPHA_EQUATION_ADD: number;
  74945. /** Defines that alpha blending equation a SUBSTRACTION */
  74946. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  74947. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  74948. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  74949. /** Defines that alpha blending equation a MAX operation */
  74950. static readonly ALPHA_EQUATION_MAX: number;
  74951. /** Defines that alpha blending equation a MIN operation */
  74952. static readonly ALPHA_EQUATION_MIN: number;
  74953. /**
  74954. * Defines that alpha blending equation a DARKEN operation:
  74955. * It takes the min of the src and sums the alpha channels.
  74956. */
  74957. static readonly ALPHA_EQUATION_DARKEN: number;
  74958. /** Defines that the ressource is not delayed*/
  74959. static readonly DELAYLOADSTATE_NONE: number;
  74960. /** Defines that the ressource was successfully delay loaded */
  74961. static readonly DELAYLOADSTATE_LOADED: number;
  74962. /** Defines that the ressource is currently delay loading */
  74963. static readonly DELAYLOADSTATE_LOADING: number;
  74964. /** Defines that the ressource is delayed and has not started loading */
  74965. static readonly DELAYLOADSTATE_NOTLOADED: number;
  74966. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  74967. static readonly NEVER: number;
  74968. /** 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 */
  74969. static readonly ALWAYS: number;
  74970. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  74971. static readonly LESS: number;
  74972. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  74973. static readonly EQUAL: number;
  74974. /** 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 */
  74975. static readonly LEQUAL: number;
  74976. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  74977. static readonly GREATER: number;
  74978. /** 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 */
  74979. static readonly GEQUAL: number;
  74980. /** 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 */
  74981. static readonly NOTEQUAL: number;
  74982. /** Passed to stencilOperation to specify that stencil value must be kept */
  74983. static readonly KEEP: number;
  74984. /** Passed to stencilOperation to specify that stencil value must be replaced */
  74985. static readonly REPLACE: number;
  74986. /** Passed to stencilOperation to specify that stencil value must be incremented */
  74987. static readonly INCR: number;
  74988. /** Passed to stencilOperation to specify that stencil value must be decremented */
  74989. static readonly DECR: number;
  74990. /** Passed to stencilOperation to specify that stencil value must be inverted */
  74991. static readonly INVERT: number;
  74992. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  74993. static readonly INCR_WRAP: number;
  74994. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  74995. static readonly DECR_WRAP: number;
  74996. /** Texture is not repeating outside of 0..1 UVs */
  74997. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  74998. /** Texture is repeating outside of 0..1 UVs */
  74999. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  75000. /** Texture is repeating and mirrored */
  75001. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  75002. /** ALPHA */
  75003. static readonly TEXTUREFORMAT_ALPHA: number;
  75004. /** LUMINANCE */
  75005. static readonly TEXTUREFORMAT_LUMINANCE: number;
  75006. /** LUMINANCE_ALPHA */
  75007. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  75008. /** RGB */
  75009. static readonly TEXTUREFORMAT_RGB: number;
  75010. /** RGBA */
  75011. static readonly TEXTUREFORMAT_RGBA: number;
  75012. /** RED */
  75013. static readonly TEXTUREFORMAT_RED: number;
  75014. /** RED (2nd reference) */
  75015. static readonly TEXTUREFORMAT_R: number;
  75016. /** RG */
  75017. static readonly TEXTUREFORMAT_RG: number;
  75018. /** RED_INTEGER */
  75019. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  75020. /** RED_INTEGER (2nd reference) */
  75021. static readonly TEXTUREFORMAT_R_INTEGER: number;
  75022. /** RG_INTEGER */
  75023. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  75024. /** RGB_INTEGER */
  75025. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  75026. /** RGBA_INTEGER */
  75027. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  75028. /** UNSIGNED_BYTE */
  75029. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  75030. /** UNSIGNED_BYTE (2nd reference) */
  75031. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  75032. /** FLOAT */
  75033. static readonly TEXTURETYPE_FLOAT: number;
  75034. /** HALF_FLOAT */
  75035. static readonly TEXTURETYPE_HALF_FLOAT: number;
  75036. /** BYTE */
  75037. static readonly TEXTURETYPE_BYTE: number;
  75038. /** SHORT */
  75039. static readonly TEXTURETYPE_SHORT: number;
  75040. /** UNSIGNED_SHORT */
  75041. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  75042. /** INT */
  75043. static readonly TEXTURETYPE_INT: number;
  75044. /** UNSIGNED_INT */
  75045. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  75046. /** UNSIGNED_SHORT_4_4_4_4 */
  75047. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  75048. /** UNSIGNED_SHORT_5_5_5_1 */
  75049. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  75050. /** UNSIGNED_SHORT_5_6_5 */
  75051. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  75052. /** UNSIGNED_INT_2_10_10_10_REV */
  75053. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  75054. /** UNSIGNED_INT_24_8 */
  75055. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  75056. /** UNSIGNED_INT_10F_11F_11F_REV */
  75057. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  75058. /** UNSIGNED_INT_5_9_9_9_REV */
  75059. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  75060. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  75061. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  75062. /** nearest is mag = nearest and min = nearest and no mip */
  75063. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  75064. /** mag = nearest and min = nearest and mip = none */
  75065. static readonly TEXTURE_NEAREST_NEAREST: number;
  75066. /** Bilinear is mag = linear and min = linear and no mip */
  75067. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  75068. /** mag = linear and min = linear and mip = none */
  75069. static readonly TEXTURE_LINEAR_LINEAR: number;
  75070. /** Trilinear is mag = linear and min = linear and mip = linear */
  75071. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  75072. /** Trilinear is mag = linear and min = linear and mip = linear */
  75073. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  75074. /** mag = nearest and min = nearest and mip = nearest */
  75075. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  75076. /** mag = nearest and min = linear and mip = nearest */
  75077. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  75078. /** mag = nearest and min = linear and mip = linear */
  75079. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  75080. /** mag = nearest and min = linear and mip = none */
  75081. static readonly TEXTURE_NEAREST_LINEAR: number;
  75082. /** nearest is mag = nearest and min = nearest and mip = linear */
  75083. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  75084. /** mag = linear and min = nearest and mip = nearest */
  75085. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  75086. /** mag = linear and min = nearest and mip = linear */
  75087. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  75088. /** Bilinear is mag = linear and min = linear and mip = nearest */
  75089. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  75090. /** mag = linear and min = nearest and mip = none */
  75091. static readonly TEXTURE_LINEAR_NEAREST: number;
  75092. /** Explicit coordinates mode */
  75093. static readonly TEXTURE_EXPLICIT_MODE: number;
  75094. /** Spherical coordinates mode */
  75095. static readonly TEXTURE_SPHERICAL_MODE: number;
  75096. /** Planar coordinates mode */
  75097. static readonly TEXTURE_PLANAR_MODE: number;
  75098. /** Cubic coordinates mode */
  75099. static readonly TEXTURE_CUBIC_MODE: number;
  75100. /** Projection coordinates mode */
  75101. static readonly TEXTURE_PROJECTION_MODE: number;
  75102. /** Skybox coordinates mode */
  75103. static readonly TEXTURE_SKYBOX_MODE: number;
  75104. /** Inverse Cubic coordinates mode */
  75105. static readonly TEXTURE_INVCUBIC_MODE: number;
  75106. /** Equirectangular coordinates mode */
  75107. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  75108. /** Equirectangular Fixed coordinates mode */
  75109. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  75110. /** Equirectangular Fixed Mirrored coordinates mode */
  75111. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  75112. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  75113. static readonly SCALEMODE_FLOOR: number;
  75114. /** Defines that texture rescaling will look for the nearest power of 2 size */
  75115. static readonly SCALEMODE_NEAREST: number;
  75116. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  75117. static readonly SCALEMODE_CEILING: number;
  75118. /**
  75119. * The dirty texture flag value
  75120. */
  75121. static readonly MATERIAL_TextureDirtyFlag: number;
  75122. /**
  75123. * The dirty light flag value
  75124. */
  75125. static readonly MATERIAL_LightDirtyFlag: number;
  75126. /**
  75127. * The dirty fresnel flag value
  75128. */
  75129. static readonly MATERIAL_FresnelDirtyFlag: number;
  75130. /**
  75131. * The dirty attribute flag value
  75132. */
  75133. static readonly MATERIAL_AttributesDirtyFlag: number;
  75134. /**
  75135. * The dirty misc flag value
  75136. */
  75137. static readonly MATERIAL_MiscDirtyFlag: number;
  75138. /**
  75139. * The all dirty flag value
  75140. */
  75141. static readonly MATERIAL_AllDirtyFlag: number;
  75142. /**
  75143. * Returns the triangle fill mode
  75144. */
  75145. static readonly MATERIAL_TriangleFillMode: number;
  75146. /**
  75147. * Returns the wireframe mode
  75148. */
  75149. static readonly MATERIAL_WireFrameFillMode: number;
  75150. /**
  75151. * Returns the point fill mode
  75152. */
  75153. static readonly MATERIAL_PointFillMode: number;
  75154. /**
  75155. * Returns the point list draw mode
  75156. */
  75157. static readonly MATERIAL_PointListDrawMode: number;
  75158. /**
  75159. * Returns the line list draw mode
  75160. */
  75161. static readonly MATERIAL_LineListDrawMode: number;
  75162. /**
  75163. * Returns the line loop draw mode
  75164. */
  75165. static readonly MATERIAL_LineLoopDrawMode: number;
  75166. /**
  75167. * Returns the line strip draw mode
  75168. */
  75169. static readonly MATERIAL_LineStripDrawMode: number;
  75170. /**
  75171. * Returns the triangle strip draw mode
  75172. */
  75173. static readonly MATERIAL_TriangleStripDrawMode: number;
  75174. /**
  75175. * Returns the triangle fan draw mode
  75176. */
  75177. static readonly MATERIAL_TriangleFanDrawMode: number;
  75178. /**
  75179. * Stores the clock-wise side orientation
  75180. */
  75181. static readonly MATERIAL_ClockWiseSideOrientation: number;
  75182. /**
  75183. * Stores the counter clock-wise side orientation
  75184. */
  75185. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  75186. /**
  75187. * Nothing
  75188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75189. */
  75190. static readonly ACTION_NothingTrigger: number;
  75191. /**
  75192. * On pick
  75193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75194. */
  75195. static readonly ACTION_OnPickTrigger: number;
  75196. /**
  75197. * On left pick
  75198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75199. */
  75200. static readonly ACTION_OnLeftPickTrigger: number;
  75201. /**
  75202. * On right pick
  75203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75204. */
  75205. static readonly ACTION_OnRightPickTrigger: number;
  75206. /**
  75207. * On center pick
  75208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75209. */
  75210. static readonly ACTION_OnCenterPickTrigger: number;
  75211. /**
  75212. * On pick down
  75213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75214. */
  75215. static readonly ACTION_OnPickDownTrigger: number;
  75216. /**
  75217. * On double pick
  75218. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75219. */
  75220. static readonly ACTION_OnDoublePickTrigger: number;
  75221. /**
  75222. * On pick up
  75223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75224. */
  75225. static readonly ACTION_OnPickUpTrigger: number;
  75226. /**
  75227. * On pick out.
  75228. * This trigger will only be raised if you also declared a OnPickDown
  75229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75230. */
  75231. static readonly ACTION_OnPickOutTrigger: number;
  75232. /**
  75233. * On long press
  75234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75235. */
  75236. static readonly ACTION_OnLongPressTrigger: number;
  75237. /**
  75238. * On pointer over
  75239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75240. */
  75241. static readonly ACTION_OnPointerOverTrigger: number;
  75242. /**
  75243. * On pointer out
  75244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75245. */
  75246. static readonly ACTION_OnPointerOutTrigger: number;
  75247. /**
  75248. * On every frame
  75249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75250. */
  75251. static readonly ACTION_OnEveryFrameTrigger: number;
  75252. /**
  75253. * On intersection enter
  75254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75255. */
  75256. static readonly ACTION_OnIntersectionEnterTrigger: number;
  75257. /**
  75258. * On intersection exit
  75259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75260. */
  75261. static readonly ACTION_OnIntersectionExitTrigger: number;
  75262. /**
  75263. * On key down
  75264. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75265. */
  75266. static readonly ACTION_OnKeyDownTrigger: number;
  75267. /**
  75268. * On key up
  75269. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  75270. */
  75271. static readonly ACTION_OnKeyUpTrigger: number;
  75272. /**
  75273. * Billboard mode will only apply to Y axis
  75274. */
  75275. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  75276. /**
  75277. * Billboard mode will apply to all axes
  75278. */
  75279. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  75280. /**
  75281. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  75282. */
  75283. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  75284. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  75285. * Test order :
  75286. * Is the bounding sphere outside the frustum ?
  75287. * If not, are the bounding box vertices outside the frustum ?
  75288. * It not, then the cullable object is in the frustum.
  75289. */
  75290. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  75291. /** Culling strategy : Bounding Sphere Only.
  75292. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  75293. * It's also less accurate than the standard because some not visible objects can still be selected.
  75294. * Test : is the bounding sphere outside the frustum ?
  75295. * If not, then the cullable object is in the frustum.
  75296. */
  75297. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  75298. /** Culling strategy : Optimistic Inclusion.
  75299. * This in an inclusion test first, then the standard exclusion test.
  75300. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  75301. * 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.
  75302. * Anyway, it's as accurate as the standard strategy.
  75303. * Test :
  75304. * Is the cullable object bounding sphere center in the frustum ?
  75305. * If not, apply the default culling strategy.
  75306. */
  75307. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  75308. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  75309. * This in an inclusion test first, then the bounding sphere only exclusion test.
  75310. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  75311. * 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.
  75312. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  75313. * Test :
  75314. * Is the cullable object bounding sphere center in the frustum ?
  75315. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  75316. */
  75317. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  75318. /**
  75319. * No logging while loading
  75320. */
  75321. static readonly SCENELOADER_NO_LOGGING: number;
  75322. /**
  75323. * Minimal logging while loading
  75324. */
  75325. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  75326. /**
  75327. * Summary logging while loading
  75328. */
  75329. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  75330. /**
  75331. * Detailled logging while loading
  75332. */
  75333. static readonly SCENELOADER_DETAILED_LOGGING: number;
  75334. }
  75335. }
  75336. declare module BABYLON {
  75337. /**
  75338. * This represents the required contract to create a new type of texture loader.
  75339. */
  75340. export interface IInternalTextureLoader {
  75341. /**
  75342. * Defines wether the loader supports cascade loading the different faces.
  75343. */
  75344. supportCascades: boolean;
  75345. /**
  75346. * This returns if the loader support the current file information.
  75347. * @param extension defines the file extension of the file being loaded
  75348. * @returns true if the loader can load the specified file
  75349. */
  75350. canLoad(extension: string): boolean;
  75351. /**
  75352. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  75353. * @param data contains the texture data
  75354. * @param texture defines the BabylonJS internal texture
  75355. * @param createPolynomials will be true if polynomials have been requested
  75356. * @param onLoad defines the callback to trigger once the texture is ready
  75357. * @param onError defines the callback to trigger in case of error
  75358. */
  75359. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  75360. /**
  75361. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  75362. * @param data contains the texture data
  75363. * @param texture defines the BabylonJS internal texture
  75364. * @param callback defines the method to call once ready to upload
  75365. */
  75366. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  75367. }
  75368. }
  75369. declare module BABYLON {
  75370. /**
  75371. * Class used to store and describe the pipeline context associated with an effect
  75372. */
  75373. export interface IPipelineContext {
  75374. /**
  75375. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  75376. */
  75377. isAsync: boolean;
  75378. /**
  75379. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  75380. */
  75381. isReady: boolean;
  75382. /** @hidden */
  75383. _getVertexShaderCode(): string | null;
  75384. /** @hidden */
  75385. _getFragmentShaderCode(): string | null;
  75386. /** @hidden */
  75387. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  75388. }
  75389. }
  75390. declare module BABYLON {
  75391. /**
  75392. * Class used to store gfx data (like WebGLBuffer)
  75393. */
  75394. export class DataBuffer {
  75395. /**
  75396. * Gets or sets the number of objects referencing this buffer
  75397. */
  75398. references: number;
  75399. /** Gets or sets the size of the underlying buffer */
  75400. capacity: number;
  75401. /**
  75402. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  75403. */
  75404. is32Bits: boolean;
  75405. /**
  75406. * Gets the underlying buffer
  75407. */
  75408. get underlyingResource(): any;
  75409. }
  75410. }
  75411. declare module BABYLON {
  75412. /** @hidden */
  75413. export interface IShaderProcessor {
  75414. attributeProcessor?: (attribute: string) => string;
  75415. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  75416. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  75417. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  75418. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  75419. lineProcessor?: (line: string, isFragment: boolean) => string;
  75420. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75421. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  75422. }
  75423. }
  75424. declare module BABYLON {
  75425. /** @hidden */
  75426. export interface ProcessingOptions {
  75427. defines: string[];
  75428. indexParameters: any;
  75429. isFragment: boolean;
  75430. shouldUseHighPrecisionShader: boolean;
  75431. supportsUniformBuffers: boolean;
  75432. shadersRepository: string;
  75433. includesShadersStore: {
  75434. [key: string]: string;
  75435. };
  75436. processor?: IShaderProcessor;
  75437. version: string;
  75438. platformName: string;
  75439. lookForClosingBracketForUniformBuffer?: boolean;
  75440. }
  75441. }
  75442. declare module BABYLON {
  75443. /** @hidden */
  75444. export class ShaderCodeNode {
  75445. line: string;
  75446. children: ShaderCodeNode[];
  75447. additionalDefineKey?: string;
  75448. additionalDefineValue?: string;
  75449. isValid(preprocessors: {
  75450. [key: string]: string;
  75451. }): boolean;
  75452. process(preprocessors: {
  75453. [key: string]: string;
  75454. }, options: ProcessingOptions): string;
  75455. }
  75456. }
  75457. declare module BABYLON {
  75458. /** @hidden */
  75459. export class ShaderCodeCursor {
  75460. private _lines;
  75461. lineIndex: number;
  75462. get currentLine(): string;
  75463. get canRead(): boolean;
  75464. set lines(value: string[]);
  75465. }
  75466. }
  75467. declare module BABYLON {
  75468. /** @hidden */
  75469. export class ShaderCodeConditionNode extends ShaderCodeNode {
  75470. process(preprocessors: {
  75471. [key: string]: string;
  75472. }, options: ProcessingOptions): string;
  75473. }
  75474. }
  75475. declare module BABYLON {
  75476. /** @hidden */
  75477. export class ShaderDefineExpression {
  75478. isTrue(preprocessors: {
  75479. [key: string]: string;
  75480. }): boolean;
  75481. private static _OperatorPriority;
  75482. private static _Stack;
  75483. static postfixToInfix(postfix: string[]): string;
  75484. static infixToPostfix(infix: string): string[];
  75485. }
  75486. }
  75487. declare module BABYLON {
  75488. /** @hidden */
  75489. export class ShaderCodeTestNode extends ShaderCodeNode {
  75490. testExpression: ShaderDefineExpression;
  75491. isValid(preprocessors: {
  75492. [key: string]: string;
  75493. }): boolean;
  75494. }
  75495. }
  75496. declare module BABYLON {
  75497. /** @hidden */
  75498. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  75499. define: string;
  75500. not: boolean;
  75501. constructor(define: string, not?: boolean);
  75502. isTrue(preprocessors: {
  75503. [key: string]: string;
  75504. }): boolean;
  75505. }
  75506. }
  75507. declare module BABYLON {
  75508. /** @hidden */
  75509. export class ShaderDefineOrOperator 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 ShaderDefineAndOperator extends ShaderDefineExpression {
  75520. leftOperand: ShaderDefineExpression;
  75521. rightOperand: ShaderDefineExpression;
  75522. isTrue(preprocessors: {
  75523. [key: string]: string;
  75524. }): boolean;
  75525. }
  75526. }
  75527. declare module BABYLON {
  75528. /** @hidden */
  75529. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  75530. define: string;
  75531. operand: string;
  75532. testValue: string;
  75533. constructor(define: string, operand: string, testValue: string);
  75534. isTrue(preprocessors: {
  75535. [key: string]: string;
  75536. }): boolean;
  75537. }
  75538. }
  75539. declare module BABYLON {
  75540. /**
  75541. * Class used to enable access to offline support
  75542. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  75543. */
  75544. export interface IOfflineProvider {
  75545. /**
  75546. * Gets a boolean indicating if scene must be saved in the database
  75547. */
  75548. enableSceneOffline: boolean;
  75549. /**
  75550. * Gets a boolean indicating if textures must be saved in the database
  75551. */
  75552. enableTexturesOffline: boolean;
  75553. /**
  75554. * Open the offline support and make it available
  75555. * @param successCallback defines the callback to call on success
  75556. * @param errorCallback defines the callback to call on error
  75557. */
  75558. open(successCallback: () => void, errorCallback: () => void): void;
  75559. /**
  75560. * Loads an image from the offline support
  75561. * @param url defines the url to load from
  75562. * @param image defines the target DOM image
  75563. */
  75564. loadImage(url: string, image: HTMLImageElement): void;
  75565. /**
  75566. * Loads a file from offline support
  75567. * @param url defines the URL to load from
  75568. * @param sceneLoaded defines a callback to call on success
  75569. * @param progressCallBack defines a callback to call when progress changed
  75570. * @param errorCallback defines a callback to call on error
  75571. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  75572. */
  75573. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  75574. }
  75575. }
  75576. declare module BABYLON {
  75577. /**
  75578. * Class used to help managing file picking and drag'n'drop
  75579. * File Storage
  75580. */
  75581. export class FilesInputStore {
  75582. /**
  75583. * List of files ready to be loaded
  75584. */
  75585. static FilesToLoad: {
  75586. [key: string]: File;
  75587. };
  75588. }
  75589. }
  75590. declare module BABYLON {
  75591. /**
  75592. * Class used to define a retry strategy when error happens while loading assets
  75593. */
  75594. export class RetryStrategy {
  75595. /**
  75596. * Function used to defines an exponential back off strategy
  75597. * @param maxRetries defines the maximum number of retries (3 by default)
  75598. * @param baseInterval defines the interval between retries
  75599. * @returns the strategy function to use
  75600. */
  75601. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  75602. }
  75603. }
  75604. declare module BABYLON {
  75605. /**
  75606. * @ignore
  75607. * Application error to support additional information when loading a file
  75608. */
  75609. export abstract class BaseError extends Error {
  75610. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  75611. }
  75612. }
  75613. declare module BABYLON {
  75614. /** @ignore */
  75615. export class LoadFileError extends BaseError {
  75616. request?: WebRequest;
  75617. file?: File;
  75618. /**
  75619. * Creates a new LoadFileError
  75620. * @param message defines the message of the error
  75621. * @param request defines the optional web request
  75622. * @param file defines the optional file
  75623. */
  75624. constructor(message: string, object?: WebRequest | File);
  75625. }
  75626. /** @ignore */
  75627. export class RequestFileError extends BaseError {
  75628. request: WebRequest;
  75629. /**
  75630. * Creates a new LoadFileError
  75631. * @param message defines the message of the error
  75632. * @param request defines the optional web request
  75633. */
  75634. constructor(message: string, request: WebRequest);
  75635. }
  75636. /** @ignore */
  75637. export class ReadFileError extends BaseError {
  75638. file: File;
  75639. /**
  75640. * Creates a new ReadFileError
  75641. * @param message defines the message of the error
  75642. * @param file defines the optional file
  75643. */
  75644. constructor(message: string, file: File);
  75645. }
  75646. /**
  75647. * @hidden
  75648. */
  75649. export class FileTools {
  75650. /**
  75651. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  75652. */
  75653. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  75654. /**
  75655. * Gets or sets the base URL to use to load assets
  75656. */
  75657. static BaseUrl: string;
  75658. /**
  75659. * Default behaviour for cors in the application.
  75660. * It can be a string if the expected behavior is identical in the entire app.
  75661. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  75662. */
  75663. static CorsBehavior: string | ((url: string | string[]) => string);
  75664. /**
  75665. * Gets or sets a function used to pre-process url before using them to load assets
  75666. */
  75667. static PreprocessUrl: (url: string) => string;
  75668. /**
  75669. * Removes unwanted characters from an url
  75670. * @param url defines the url to clean
  75671. * @returns the cleaned url
  75672. */
  75673. private static _CleanUrl;
  75674. /**
  75675. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  75676. * @param url define the url we are trying
  75677. * @param element define the dom element where to configure the cors policy
  75678. */
  75679. static SetCorsBehavior(url: string | string[], element: {
  75680. crossOrigin: string | null;
  75681. }): void;
  75682. /**
  75683. * Loads an image as an HTMLImageElement.
  75684. * @param input url string, ArrayBuffer, or Blob to load
  75685. * @param onLoad callback called when the image successfully loads
  75686. * @param onError callback called when the image fails to load
  75687. * @param offlineProvider offline provider for caching
  75688. * @param mimeType optional mime type
  75689. * @returns the HTMLImageElement of the loaded image
  75690. */
  75691. 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>;
  75692. /**
  75693. * Reads a file from a File object
  75694. * @param file defines the file to load
  75695. * @param onSuccess defines the callback to call when data is loaded
  75696. * @param onProgress defines the callback to call during loading process
  75697. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  75698. * @param onError defines the callback to call when an error occurs
  75699. * @returns a file request object
  75700. */
  75701. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  75702. /**
  75703. * Loads a file from a url
  75704. * @param url url to load
  75705. * @param onSuccess callback called when the file successfully loads
  75706. * @param onProgress callback called while file is loading (if the server supports this mode)
  75707. * @param offlineProvider defines the offline provider for caching
  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. * @returns a file request object
  75711. */
  75712. 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;
  75713. /**
  75714. * Loads a file
  75715. * @param url url to load
  75716. * @param onSuccess callback called when the file successfully loads
  75717. * @param onProgress callback called while file is loading (if the server supports this mode)
  75718. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75719. * @param onError callback called when the file fails to load
  75720. * @param onOpened callback called when the web request is opened
  75721. * @returns a file request object
  75722. */
  75723. 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;
  75724. /**
  75725. * Checks if the loaded document was accessed via `file:`-Protocol.
  75726. * @returns boolean
  75727. */
  75728. static IsFileURL(): boolean;
  75729. }
  75730. }
  75731. declare module BABYLON {
  75732. /** @hidden */
  75733. export class ShaderProcessor {
  75734. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  75735. private static _ProcessPrecision;
  75736. private static _ExtractOperation;
  75737. private static _BuildSubExpression;
  75738. private static _BuildExpression;
  75739. private static _MoveCursorWithinIf;
  75740. private static _MoveCursor;
  75741. private static _EvaluatePreProcessors;
  75742. private static _PreparePreProcessors;
  75743. private static _ProcessShaderConversion;
  75744. private static _ProcessIncludes;
  75745. /**
  75746. * Loads a file from a url
  75747. * @param url url to load
  75748. * @param onSuccess callback called when the file successfully loads
  75749. * @param onProgress callback called while file is loading (if the server supports this mode)
  75750. * @param offlineProvider defines the offline provider for caching
  75751. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  75752. * @param onError callback called when the file fails to load
  75753. * @returns a file request object
  75754. * @hidden
  75755. */
  75756. 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;
  75757. }
  75758. }
  75759. declare module BABYLON {
  75760. /**
  75761. * @hidden
  75762. */
  75763. export interface IColor4Like {
  75764. r: float;
  75765. g: float;
  75766. b: float;
  75767. a: float;
  75768. }
  75769. /**
  75770. * @hidden
  75771. */
  75772. export interface IColor3Like {
  75773. r: float;
  75774. g: float;
  75775. b: float;
  75776. }
  75777. /**
  75778. * @hidden
  75779. */
  75780. export interface IVector4Like {
  75781. x: float;
  75782. y: float;
  75783. z: float;
  75784. w: float;
  75785. }
  75786. /**
  75787. * @hidden
  75788. */
  75789. export interface IVector3Like {
  75790. x: float;
  75791. y: float;
  75792. z: float;
  75793. }
  75794. /**
  75795. * @hidden
  75796. */
  75797. export interface IVector2Like {
  75798. x: float;
  75799. y: float;
  75800. }
  75801. /**
  75802. * @hidden
  75803. */
  75804. export interface IMatrixLike {
  75805. toArray(): DeepImmutable<Float32Array>;
  75806. updateFlag: int;
  75807. }
  75808. /**
  75809. * @hidden
  75810. */
  75811. export interface IViewportLike {
  75812. x: float;
  75813. y: float;
  75814. width: float;
  75815. height: float;
  75816. }
  75817. /**
  75818. * @hidden
  75819. */
  75820. export interface IPlaneLike {
  75821. normal: IVector3Like;
  75822. d: float;
  75823. normalize(): void;
  75824. }
  75825. }
  75826. declare module BABYLON {
  75827. /**
  75828. * Interface used to define common properties for effect fallbacks
  75829. */
  75830. export interface IEffectFallbacks {
  75831. /**
  75832. * Removes the defines that should be removed when falling back.
  75833. * @param currentDefines defines the current define statements for the shader.
  75834. * @param effect defines the current effect we try to compile
  75835. * @returns The resulting defines with defines of the current rank removed.
  75836. */
  75837. reduce(currentDefines: string, effect: Effect): string;
  75838. /**
  75839. * Removes the fallback from the bound mesh.
  75840. */
  75841. unBindMesh(): void;
  75842. /**
  75843. * Checks to see if more fallbacks are still availible.
  75844. */
  75845. hasMoreFallbacks: boolean;
  75846. }
  75847. }
  75848. declare module BABYLON {
  75849. /**
  75850. * Class used to evalaute queries containing `and` and `or` operators
  75851. */
  75852. export class AndOrNotEvaluator {
  75853. /**
  75854. * Evaluate a query
  75855. * @param query defines the query to evaluate
  75856. * @param evaluateCallback defines the callback used to filter result
  75857. * @returns true if the query matches
  75858. */
  75859. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  75860. private static _HandleParenthesisContent;
  75861. private static _SimplifyNegation;
  75862. }
  75863. }
  75864. declare module BABYLON {
  75865. /**
  75866. * Class used to store custom tags
  75867. */
  75868. export class Tags {
  75869. /**
  75870. * Adds support for tags on the given object
  75871. * @param obj defines the object to use
  75872. */
  75873. static EnableFor(obj: any): void;
  75874. /**
  75875. * Removes tags support
  75876. * @param obj defines the object to use
  75877. */
  75878. static DisableFor(obj: any): void;
  75879. /**
  75880. * Gets a boolean indicating if the given object has tags
  75881. * @param obj defines the object to use
  75882. * @returns a boolean
  75883. */
  75884. static HasTags(obj: any): boolean;
  75885. /**
  75886. * Gets the tags available on a given object
  75887. * @param obj defines the object to use
  75888. * @param asString defines if the tags must be returned as a string instead of an array of strings
  75889. * @returns the tags
  75890. */
  75891. static GetTags(obj: any, asString?: boolean): any;
  75892. /**
  75893. * Adds tags to an object
  75894. * @param obj defines the object to use
  75895. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  75896. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  75897. */
  75898. static AddTagsTo(obj: any, tagsString: string): void;
  75899. /**
  75900. * @hidden
  75901. */
  75902. static _AddTagTo(obj: any, tag: string): void;
  75903. /**
  75904. * Removes specific tags from a specific object
  75905. * @param obj defines the object to use
  75906. * @param tagsString defines the tags to remove
  75907. */
  75908. static RemoveTagsFrom(obj: any, tagsString: string): void;
  75909. /**
  75910. * @hidden
  75911. */
  75912. static _RemoveTagFrom(obj: any, tag: string): void;
  75913. /**
  75914. * Defines if tags hosted on an object match a given query
  75915. * @param obj defines the object to use
  75916. * @param tagsQuery defines the tag query
  75917. * @returns a boolean
  75918. */
  75919. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  75920. }
  75921. }
  75922. declare module BABYLON {
  75923. /**
  75924. * Scalar computation library
  75925. */
  75926. export class Scalar {
  75927. /**
  75928. * Two pi constants convenient for computation.
  75929. */
  75930. static TwoPi: number;
  75931. /**
  75932. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75933. * @param a number
  75934. * @param b number
  75935. * @param epsilon (default = 1.401298E-45)
  75936. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  75937. */
  75938. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  75939. /**
  75940. * Returns a string : the upper case translation of the number i to hexadecimal.
  75941. * @param i number
  75942. * @returns the upper case translation of the number i to hexadecimal.
  75943. */
  75944. static ToHex(i: number): string;
  75945. /**
  75946. * Returns -1 if value is negative and +1 is value is positive.
  75947. * @param value the value
  75948. * @returns the value itself if it's equal to zero.
  75949. */
  75950. static Sign(value: number): number;
  75951. /**
  75952. * Returns the value itself if it's between min and max.
  75953. * Returns min if the value is lower than min.
  75954. * Returns max if the value is greater than max.
  75955. * @param value the value to clmap
  75956. * @param min the min value to clamp to (default: 0)
  75957. * @param max the max value to clamp to (default: 1)
  75958. * @returns the clamped value
  75959. */
  75960. static Clamp(value: number, min?: number, max?: number): number;
  75961. /**
  75962. * the log2 of value.
  75963. * @param value the value to compute log2 of
  75964. * @returns the log2 of value.
  75965. */
  75966. static Log2(value: number): number;
  75967. /**
  75968. * Loops the value, so that it is never larger than length and never smaller than 0.
  75969. *
  75970. * This is similar to the modulo operator but it works with floating point numbers.
  75971. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  75972. * With t = 5 and length = 2.5, the result would be 0.0.
  75973. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  75974. * @param value the value
  75975. * @param length the length
  75976. * @returns the looped value
  75977. */
  75978. static Repeat(value: number, length: number): number;
  75979. /**
  75980. * Normalize the value between 0.0 and 1.0 using min and max values
  75981. * @param value value to normalize
  75982. * @param min max to normalize between
  75983. * @param max min to normalize between
  75984. * @returns the normalized value
  75985. */
  75986. static Normalize(value: number, min: number, max: number): number;
  75987. /**
  75988. * Denormalize the value from 0.0 and 1.0 using min and max values
  75989. * @param normalized value to denormalize
  75990. * @param min max to denormalize between
  75991. * @param max min to denormalize between
  75992. * @returns the denormalized value
  75993. */
  75994. static Denormalize(normalized: number, min: number, max: number): number;
  75995. /**
  75996. * Calculates the shortest difference between two given angles given in degrees.
  75997. * @param current current angle in degrees
  75998. * @param target target angle in degrees
  75999. * @returns the delta
  76000. */
  76001. static DeltaAngle(current: number, target: number): number;
  76002. /**
  76003. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  76004. * @param tx value
  76005. * @param length length
  76006. * @returns The returned value will move back and forth between 0 and length
  76007. */
  76008. static PingPong(tx: number, length: number): number;
  76009. /**
  76010. * Interpolates between min and max with smoothing at the limits.
  76011. *
  76012. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  76013. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  76014. * @param from from
  76015. * @param to to
  76016. * @param tx value
  76017. * @returns the smooth stepped value
  76018. */
  76019. static SmoothStep(from: number, to: number, tx: number): number;
  76020. /**
  76021. * Moves a value current towards target.
  76022. *
  76023. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  76024. * Negative values of maxDelta pushes the value away from target.
  76025. * @param current current value
  76026. * @param target target value
  76027. * @param maxDelta max distance to move
  76028. * @returns resulting value
  76029. */
  76030. static MoveTowards(current: number, target: number, maxDelta: number): number;
  76031. /**
  76032. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76033. *
  76034. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  76035. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  76036. * @param current current value
  76037. * @param target target value
  76038. * @param maxDelta max distance to move
  76039. * @returns resulting angle
  76040. */
  76041. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  76042. /**
  76043. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  76044. * @param start start value
  76045. * @param end target value
  76046. * @param amount amount to lerp between
  76047. * @returns the lerped value
  76048. */
  76049. static Lerp(start: number, end: number, amount: number): number;
  76050. /**
  76051. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  76052. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  76053. * @param start start value
  76054. * @param end target value
  76055. * @param amount amount to lerp between
  76056. * @returns the lerped value
  76057. */
  76058. static LerpAngle(start: number, end: number, amount: number): number;
  76059. /**
  76060. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  76061. * @param a start value
  76062. * @param b target value
  76063. * @param value value between a and b
  76064. * @returns the inverseLerp value
  76065. */
  76066. static InverseLerp(a: number, b: number, value: number): number;
  76067. /**
  76068. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  76069. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  76070. * @param value1 spline value
  76071. * @param tangent1 spline value
  76072. * @param value2 spline value
  76073. * @param tangent2 spline value
  76074. * @param amount input value
  76075. * @returns hermite result
  76076. */
  76077. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  76078. /**
  76079. * Returns a random float number between and min and max values
  76080. * @param min min value of random
  76081. * @param max max value of random
  76082. * @returns random value
  76083. */
  76084. static RandomRange(min: number, max: number): number;
  76085. /**
  76086. * This function returns percentage of a number in a given range.
  76087. *
  76088. * RangeToPercent(40,20,60) will return 0.5 (50%)
  76089. * RangeToPercent(34,0,100) will return 0.34 (34%)
  76090. * @param number to convert to percentage
  76091. * @param min min range
  76092. * @param max max range
  76093. * @returns the percentage
  76094. */
  76095. static RangeToPercent(number: number, min: number, max: number): number;
  76096. /**
  76097. * This function returns number that corresponds to the percentage in a given range.
  76098. *
  76099. * PercentToRange(0.34,0,100) will return 34.
  76100. * @param percent to convert to number
  76101. * @param min min range
  76102. * @param max max range
  76103. * @returns the number
  76104. */
  76105. static PercentToRange(percent: number, min: number, max: number): number;
  76106. /**
  76107. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  76108. * @param angle The angle to normalize in radian.
  76109. * @return The converted angle.
  76110. */
  76111. static NormalizeRadians(angle: number): number;
  76112. }
  76113. }
  76114. declare module BABYLON {
  76115. /**
  76116. * Constant used to convert a value to gamma space
  76117. * @ignorenaming
  76118. */
  76119. export const ToGammaSpace: number;
  76120. /**
  76121. * Constant used to convert a value to linear space
  76122. * @ignorenaming
  76123. */
  76124. export const ToLinearSpace = 2.2;
  76125. /**
  76126. * Constant used to define the minimal number value in Babylon.js
  76127. * @ignorenaming
  76128. */
  76129. let Epsilon: number;
  76130. }
  76131. declare module BABYLON {
  76132. /**
  76133. * Class used to represent a viewport on screen
  76134. */
  76135. export class Viewport {
  76136. /** viewport left coordinate */
  76137. x: number;
  76138. /** viewport top coordinate */
  76139. y: number;
  76140. /**viewport width */
  76141. width: number;
  76142. /** viewport height */
  76143. height: number;
  76144. /**
  76145. * Creates a Viewport object located at (x, y) and sized (width, height)
  76146. * @param x defines viewport left coordinate
  76147. * @param y defines viewport top coordinate
  76148. * @param width defines the viewport width
  76149. * @param height defines the viewport height
  76150. */
  76151. constructor(
  76152. /** viewport left coordinate */
  76153. x: number,
  76154. /** viewport top coordinate */
  76155. y: number,
  76156. /**viewport width */
  76157. width: number,
  76158. /** viewport height */
  76159. height: number);
  76160. /**
  76161. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  76162. * @param renderWidth defines the rendering width
  76163. * @param renderHeight defines the rendering height
  76164. * @returns a new Viewport
  76165. */
  76166. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  76167. /**
  76168. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  76169. * @param renderWidth defines the rendering width
  76170. * @param renderHeight defines the rendering height
  76171. * @param ref defines the target viewport
  76172. * @returns the current viewport
  76173. */
  76174. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  76175. /**
  76176. * Returns a new Viewport copied from the current one
  76177. * @returns a new Viewport
  76178. */
  76179. clone(): Viewport;
  76180. }
  76181. }
  76182. declare module BABYLON {
  76183. /**
  76184. * Class containing a set of static utilities functions for arrays.
  76185. */
  76186. export class ArrayTools {
  76187. /**
  76188. * Returns an array of the given size filled with element built from the given constructor and the paramters
  76189. * @param size the number of element to construct and put in the array
  76190. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  76191. * @returns a new array filled with new objects
  76192. */
  76193. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  76194. }
  76195. }
  76196. declare module BABYLON {
  76197. /**
  76198. * Class representing a vector containing 2 coordinates
  76199. */
  76200. export class Vector2 {
  76201. /** defines the first coordinate */
  76202. x: number;
  76203. /** defines the second coordinate */
  76204. y: number;
  76205. /**
  76206. * Creates a new Vector2 from the given x and y coordinates
  76207. * @param x defines the first coordinate
  76208. * @param y defines the second coordinate
  76209. */
  76210. constructor(
  76211. /** defines the first coordinate */
  76212. x?: number,
  76213. /** defines the second coordinate */
  76214. y?: number);
  76215. /**
  76216. * Gets a string with the Vector2 coordinates
  76217. * @returns a string with the Vector2 coordinates
  76218. */
  76219. toString(): string;
  76220. /**
  76221. * Gets class name
  76222. * @returns the string "Vector2"
  76223. */
  76224. getClassName(): string;
  76225. /**
  76226. * Gets current vector hash code
  76227. * @returns the Vector2 hash code as a number
  76228. */
  76229. getHashCode(): number;
  76230. /**
  76231. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  76232. * @param array defines the source array
  76233. * @param index defines the offset in source array
  76234. * @returns the current Vector2
  76235. */
  76236. toArray(array: FloatArray, index?: number): Vector2;
  76237. /**
  76238. * Copy the current vector to an array
  76239. * @returns a new array with 2 elements: the Vector2 coordinates.
  76240. */
  76241. asArray(): number[];
  76242. /**
  76243. * Sets the Vector2 coordinates with the given Vector2 coordinates
  76244. * @param source defines the source Vector2
  76245. * @returns the current updated Vector2
  76246. */
  76247. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  76248. /**
  76249. * Sets the Vector2 coordinates with the given floats
  76250. * @param x defines the first coordinate
  76251. * @param y defines the second coordinate
  76252. * @returns the current updated Vector2
  76253. */
  76254. copyFromFloats(x: number, y: number): Vector2;
  76255. /**
  76256. * Sets the Vector2 coordinates with the given floats
  76257. * @param x defines the first coordinate
  76258. * @param y defines the second coordinate
  76259. * @returns the current updated Vector2
  76260. */
  76261. set(x: number, y: number): Vector2;
  76262. /**
  76263. * Add another vector with the current one
  76264. * @param otherVector defines the other vector
  76265. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  76266. */
  76267. add(otherVector: DeepImmutable<Vector2>): Vector2;
  76268. /**
  76269. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  76270. * @param otherVector defines the other vector
  76271. * @param result defines the target vector
  76272. * @returns the unmodified current Vector2
  76273. */
  76274. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76275. /**
  76276. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  76277. * @param otherVector defines the other vector
  76278. * @returns the current updated Vector2
  76279. */
  76280. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76281. /**
  76282. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  76283. * @param otherVector defines the other vector
  76284. * @returns a new Vector2
  76285. */
  76286. addVector3(otherVector: Vector3): Vector2;
  76287. /**
  76288. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  76289. * @param otherVector defines the other vector
  76290. * @returns a new Vector2
  76291. */
  76292. subtract(otherVector: Vector2): Vector2;
  76293. /**
  76294. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  76295. * @param otherVector defines the other vector
  76296. * @param result defines the target vector
  76297. * @returns the unmodified current Vector2
  76298. */
  76299. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76300. /**
  76301. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  76302. * @param otherVector defines the other vector
  76303. * @returns the current updated Vector2
  76304. */
  76305. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76306. /**
  76307. * Multiplies in place the current Vector2 coordinates by the given ones
  76308. * @param otherVector defines the other vector
  76309. * @returns the current updated Vector2
  76310. */
  76311. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76312. /**
  76313. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  76314. * @param otherVector defines the other vector
  76315. * @returns a new Vector2
  76316. */
  76317. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  76318. /**
  76319. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  76320. * @param otherVector defines the other vector
  76321. * @param result defines the target vector
  76322. * @returns the unmodified current Vector2
  76323. */
  76324. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76325. /**
  76326. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  76327. * @param x defines the first coordinate
  76328. * @param y defines the second coordinate
  76329. * @returns a new Vector2
  76330. */
  76331. multiplyByFloats(x: number, y: number): Vector2;
  76332. /**
  76333. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  76334. * @param otherVector defines the other vector
  76335. * @returns a new Vector2
  76336. */
  76337. divide(otherVector: Vector2): Vector2;
  76338. /**
  76339. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  76340. * @param otherVector defines the other vector
  76341. * @param result defines the target vector
  76342. * @returns the unmodified current Vector2
  76343. */
  76344. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  76345. /**
  76346. * Divides the current Vector2 coordinates by the given ones
  76347. * @param otherVector defines the other vector
  76348. * @returns the current updated Vector2
  76349. */
  76350. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  76351. /**
  76352. * Gets a new Vector2 with current Vector2 negated coordinates
  76353. * @returns a new Vector2
  76354. */
  76355. negate(): Vector2;
  76356. /**
  76357. * Negate this vector in place
  76358. * @returns this
  76359. */
  76360. negateInPlace(): Vector2;
  76361. /**
  76362. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  76363. * @param result defines the Vector3 object where to store the result
  76364. * @returns the current Vector2
  76365. */
  76366. negateToRef(result: Vector2): Vector2;
  76367. /**
  76368. * Multiply the Vector2 coordinates by scale
  76369. * @param scale defines the scaling factor
  76370. * @returns the current updated Vector2
  76371. */
  76372. scaleInPlace(scale: number): Vector2;
  76373. /**
  76374. * Returns a new Vector2 scaled by "scale" from the current Vector2
  76375. * @param scale defines the scaling factor
  76376. * @returns a new Vector2
  76377. */
  76378. scale(scale: number): Vector2;
  76379. /**
  76380. * Scale the current Vector2 values by a factor to a given Vector2
  76381. * @param scale defines the scale factor
  76382. * @param result defines the Vector2 object where to store the result
  76383. * @returns the unmodified current Vector2
  76384. */
  76385. scaleToRef(scale: number, result: Vector2): Vector2;
  76386. /**
  76387. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  76388. * @param scale defines the scale factor
  76389. * @param result defines the Vector2 object where to store the result
  76390. * @returns the unmodified current Vector2
  76391. */
  76392. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  76393. /**
  76394. * Gets a boolean if two vectors are equals
  76395. * @param otherVector defines the other vector
  76396. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  76397. */
  76398. equals(otherVector: DeepImmutable<Vector2>): boolean;
  76399. /**
  76400. * Gets a boolean if two vectors are equals (using an epsilon value)
  76401. * @param otherVector defines the other vector
  76402. * @param epsilon defines the minimal distance to consider equality
  76403. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  76404. */
  76405. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  76406. /**
  76407. * Gets a new Vector2 from current Vector2 floored values
  76408. * @returns a new Vector2
  76409. */
  76410. floor(): Vector2;
  76411. /**
  76412. * Gets a new Vector2 from current Vector2 floored values
  76413. * @returns a new Vector2
  76414. */
  76415. fract(): Vector2;
  76416. /**
  76417. * Gets the length of the vector
  76418. * @returns the vector length (float)
  76419. */
  76420. length(): number;
  76421. /**
  76422. * Gets the vector squared length
  76423. * @returns the vector squared length (float)
  76424. */
  76425. lengthSquared(): number;
  76426. /**
  76427. * Normalize the vector
  76428. * @returns the current updated Vector2
  76429. */
  76430. normalize(): Vector2;
  76431. /**
  76432. * Gets a new Vector2 copied from the Vector2
  76433. * @returns a new Vector2
  76434. */
  76435. clone(): Vector2;
  76436. /**
  76437. * Gets a new Vector2(0, 0)
  76438. * @returns a new Vector2
  76439. */
  76440. static Zero(): Vector2;
  76441. /**
  76442. * Gets a new Vector2(1, 1)
  76443. * @returns a new Vector2
  76444. */
  76445. static One(): Vector2;
  76446. /**
  76447. * Gets a new Vector2 set from the given index element of the given array
  76448. * @param array defines the data source
  76449. * @param offset defines the offset in the data source
  76450. * @returns a new Vector2
  76451. */
  76452. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  76453. /**
  76454. * Sets "result" from the given index element of the given array
  76455. * @param array defines the data source
  76456. * @param offset defines the offset in the data source
  76457. * @param result defines the target vector
  76458. */
  76459. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  76460. /**
  76461. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  76462. * @param value1 defines 1st point of control
  76463. * @param value2 defines 2nd point of control
  76464. * @param value3 defines 3rd point of control
  76465. * @param value4 defines 4th point of control
  76466. * @param amount defines the interpolation factor
  76467. * @returns a new Vector2
  76468. */
  76469. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  76470. /**
  76471. * 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".
  76472. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  76473. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  76474. * @param value defines the value to clamp
  76475. * @param min defines the lower limit
  76476. * @param max defines the upper limit
  76477. * @returns a new Vector2
  76478. */
  76479. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  76480. /**
  76481. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  76482. * @param value1 defines the 1st control point
  76483. * @param tangent1 defines the outgoing tangent
  76484. * @param value2 defines the 2nd control point
  76485. * @param tangent2 defines the incoming tangent
  76486. * @param amount defines the interpolation factor
  76487. * @returns a new Vector2
  76488. */
  76489. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  76490. /**
  76491. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  76492. * @param start defines the start vector
  76493. * @param end defines the end vector
  76494. * @param amount defines the interpolation factor
  76495. * @returns a new Vector2
  76496. */
  76497. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  76498. /**
  76499. * Gets the dot product of the vector "left" and the vector "right"
  76500. * @param left defines first vector
  76501. * @param right defines second vector
  76502. * @returns the dot product (float)
  76503. */
  76504. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  76505. /**
  76506. * Returns a new Vector2 equal to the normalized given vector
  76507. * @param vector defines the vector to normalize
  76508. * @returns a new Vector2
  76509. */
  76510. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  76511. /**
  76512. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  76513. * @param left defines 1st vector
  76514. * @param right defines 2nd vector
  76515. * @returns a new Vector2
  76516. */
  76517. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76518. /**
  76519. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  76520. * @param left defines 1st vector
  76521. * @param right defines 2nd vector
  76522. * @returns a new Vector2
  76523. */
  76524. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  76525. /**
  76526. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  76527. * @param vector defines the vector to transform
  76528. * @param transformation defines the matrix to apply
  76529. * @returns a new Vector2
  76530. */
  76531. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  76532. /**
  76533. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  76534. * @param vector defines the vector to transform
  76535. * @param transformation defines the matrix to apply
  76536. * @param result defines the target vector
  76537. */
  76538. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  76539. /**
  76540. * Determines if a given vector is included in a triangle
  76541. * @param p defines the vector to test
  76542. * @param p0 defines 1st triangle point
  76543. * @param p1 defines 2nd triangle point
  76544. * @param p2 defines 3rd triangle point
  76545. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  76546. */
  76547. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  76548. /**
  76549. * Gets the distance between the vectors "value1" and "value2"
  76550. * @param value1 defines first vector
  76551. * @param value2 defines second vector
  76552. * @returns the distance between vectors
  76553. */
  76554. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76555. /**
  76556. * Returns the squared distance between the vectors "value1" and "value2"
  76557. * @param value1 defines first vector
  76558. * @param value2 defines second vector
  76559. * @returns the squared distance between vectors
  76560. */
  76561. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  76562. /**
  76563. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  76564. * @param value1 defines first vector
  76565. * @param value2 defines second vector
  76566. * @returns a new Vector2
  76567. */
  76568. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  76569. /**
  76570. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  76571. * @param p defines the middle point
  76572. * @param segA defines one point of the segment
  76573. * @param segB defines the other point of the segment
  76574. * @returns the shortest distance
  76575. */
  76576. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  76577. }
  76578. /**
  76579. * Class used to store (x,y,z) vector representation
  76580. * A Vector3 is the main object used in 3D geometry
  76581. * It can represent etiher the coordinates of a point the space, either a direction
  76582. * Reminder: js uses a left handed forward facing system
  76583. */
  76584. export class Vector3 {
  76585. /**
  76586. * Defines the first coordinates (on X axis)
  76587. */
  76588. x: number;
  76589. /**
  76590. * Defines the second coordinates (on Y axis)
  76591. */
  76592. y: number;
  76593. /**
  76594. * Defines the third coordinates (on Z axis)
  76595. */
  76596. z: number;
  76597. private static _UpReadOnly;
  76598. private static _ZeroReadOnly;
  76599. /**
  76600. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  76601. * @param x defines the first coordinates (on X axis)
  76602. * @param y defines the second coordinates (on Y axis)
  76603. * @param z defines the third coordinates (on Z axis)
  76604. */
  76605. constructor(
  76606. /**
  76607. * Defines the first coordinates (on X axis)
  76608. */
  76609. x?: number,
  76610. /**
  76611. * Defines the second coordinates (on Y axis)
  76612. */
  76613. y?: number,
  76614. /**
  76615. * Defines the third coordinates (on Z axis)
  76616. */
  76617. z?: number);
  76618. /**
  76619. * Creates a string representation of the Vector3
  76620. * @returns a string with the Vector3 coordinates.
  76621. */
  76622. toString(): string;
  76623. /**
  76624. * Gets the class name
  76625. * @returns the string "Vector3"
  76626. */
  76627. getClassName(): string;
  76628. /**
  76629. * Creates the Vector3 hash code
  76630. * @returns a number which tends to be unique between Vector3 instances
  76631. */
  76632. getHashCode(): number;
  76633. /**
  76634. * Creates an array containing three elements : the coordinates of the Vector3
  76635. * @returns a new array of numbers
  76636. */
  76637. asArray(): number[];
  76638. /**
  76639. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  76640. * @param array defines the destination array
  76641. * @param index defines the offset in the destination array
  76642. * @returns the current Vector3
  76643. */
  76644. toArray(array: FloatArray, index?: number): Vector3;
  76645. /**
  76646. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  76647. * @returns a new Quaternion object, computed from the Vector3 coordinates
  76648. */
  76649. toQuaternion(): Quaternion;
  76650. /**
  76651. * Adds the given vector to the current Vector3
  76652. * @param otherVector defines the second operand
  76653. * @returns the current updated Vector3
  76654. */
  76655. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76656. /**
  76657. * Adds the given coordinates to the current Vector3
  76658. * @param x defines the x coordinate of the operand
  76659. * @param y defines the y coordinate of the operand
  76660. * @param z defines the z coordinate of the operand
  76661. * @returns the current updated Vector3
  76662. */
  76663. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76664. /**
  76665. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  76666. * @param otherVector defines the second operand
  76667. * @returns the resulting Vector3
  76668. */
  76669. add(otherVector: DeepImmutable<Vector3>): Vector3;
  76670. /**
  76671. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  76672. * @param otherVector defines the second operand
  76673. * @param result defines the Vector3 object where to store the result
  76674. * @returns the current Vector3
  76675. */
  76676. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76677. /**
  76678. * Subtract the given vector from the current Vector3
  76679. * @param otherVector defines the second operand
  76680. * @returns the current updated Vector3
  76681. */
  76682. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76683. /**
  76684. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  76685. * @param otherVector defines the second operand
  76686. * @returns the resulting Vector3
  76687. */
  76688. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  76689. /**
  76690. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  76691. * @param otherVector defines the second operand
  76692. * @param result defines the Vector3 object where to store the result
  76693. * @returns the current Vector3
  76694. */
  76695. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76696. /**
  76697. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  76698. * @param x defines the x coordinate of the operand
  76699. * @param y defines the y coordinate of the operand
  76700. * @param z defines the z coordinate of the operand
  76701. * @returns the resulting Vector3
  76702. */
  76703. subtractFromFloats(x: number, y: number, z: number): Vector3;
  76704. /**
  76705. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  76706. * @param x defines the x coordinate of the operand
  76707. * @param y defines the y coordinate of the operand
  76708. * @param z defines the z coordinate of the operand
  76709. * @param result defines the Vector3 object where to store the result
  76710. * @returns the current Vector3
  76711. */
  76712. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  76713. /**
  76714. * Gets a new Vector3 set with the current Vector3 negated coordinates
  76715. * @returns a new Vector3
  76716. */
  76717. negate(): Vector3;
  76718. /**
  76719. * Negate this vector in place
  76720. * @returns this
  76721. */
  76722. negateInPlace(): Vector3;
  76723. /**
  76724. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  76725. * @param result defines the Vector3 object where to store the result
  76726. * @returns the current Vector3
  76727. */
  76728. negateToRef(result: Vector3): Vector3;
  76729. /**
  76730. * Multiplies the Vector3 coordinates by the float "scale"
  76731. * @param scale defines the multiplier factor
  76732. * @returns the current updated Vector3
  76733. */
  76734. scaleInPlace(scale: number): Vector3;
  76735. /**
  76736. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  76737. * @param scale defines the multiplier factor
  76738. * @returns a new Vector3
  76739. */
  76740. scale(scale: number): Vector3;
  76741. /**
  76742. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  76743. * @param scale defines the multiplier factor
  76744. * @param result defines the Vector3 object where to store the result
  76745. * @returns the current Vector3
  76746. */
  76747. scaleToRef(scale: number, result: Vector3): Vector3;
  76748. /**
  76749. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  76750. * @param scale defines the scale factor
  76751. * @param result defines the Vector3 object where to store the result
  76752. * @returns the unmodified current Vector3
  76753. */
  76754. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  76755. /**
  76756. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  76757. * @param otherVector defines the second operand
  76758. * @returns true if both vectors are equals
  76759. */
  76760. equals(otherVector: DeepImmutable<Vector3>): boolean;
  76761. /**
  76762. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  76763. * @param otherVector defines the second operand
  76764. * @param epsilon defines the minimal distance to define values as equals
  76765. * @returns true if both vectors are distant less than epsilon
  76766. */
  76767. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  76768. /**
  76769. * Returns true if the current Vector3 coordinates equals the given floats
  76770. * @param x defines the x coordinate of the operand
  76771. * @param y defines the y coordinate of the operand
  76772. * @param z defines the z coordinate of the operand
  76773. * @returns true if both vectors are equals
  76774. */
  76775. equalsToFloats(x: number, y: number, z: number): boolean;
  76776. /**
  76777. * Multiplies the current Vector3 coordinates by the given ones
  76778. * @param otherVector defines the second operand
  76779. * @returns the current updated Vector3
  76780. */
  76781. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  76782. /**
  76783. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  76784. * @param otherVector defines the second operand
  76785. * @returns the new Vector3
  76786. */
  76787. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  76788. /**
  76789. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  76790. * @param otherVector defines the second operand
  76791. * @param result defines the Vector3 object where to store the result
  76792. * @returns the current Vector3
  76793. */
  76794. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76795. /**
  76796. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  76797. * @param x defines the x coordinate of the operand
  76798. * @param y defines the y coordinate of the operand
  76799. * @param z defines the z coordinate of the operand
  76800. * @returns the new Vector3
  76801. */
  76802. multiplyByFloats(x: number, y: number, z: number): Vector3;
  76803. /**
  76804. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  76805. * @param otherVector defines the second operand
  76806. * @returns the new Vector3
  76807. */
  76808. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  76809. /**
  76810. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  76811. * @param otherVector defines the second operand
  76812. * @param result defines the Vector3 object where to store the result
  76813. * @returns the current Vector3
  76814. */
  76815. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  76816. /**
  76817. * Divides the current Vector3 coordinates by the given ones.
  76818. * @param otherVector defines the second operand
  76819. * @returns the current updated Vector3
  76820. */
  76821. divideInPlace(otherVector: Vector3): Vector3;
  76822. /**
  76823. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  76824. * @param other defines the second operand
  76825. * @returns the current updated Vector3
  76826. */
  76827. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76828. /**
  76829. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  76830. * @param other defines the second operand
  76831. * @returns the current updated Vector3
  76832. */
  76833. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  76834. /**
  76835. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  76836. * @param x defines the x coordinate of the operand
  76837. * @param y defines the y coordinate of the operand
  76838. * @param z defines the z coordinate of the operand
  76839. * @returns the current updated Vector3
  76840. */
  76841. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76842. /**
  76843. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  76844. * @param x defines the x coordinate of the operand
  76845. * @param y defines the y coordinate of the operand
  76846. * @param z defines the z coordinate of the operand
  76847. * @returns the current updated Vector3
  76848. */
  76849. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  76850. /**
  76851. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  76852. * Check if is non uniform within a certain amount of decimal places to account for this
  76853. * @param epsilon the amount the values can differ
  76854. * @returns if the the vector is non uniform to a certain number of decimal places
  76855. */
  76856. isNonUniformWithinEpsilon(epsilon: number): boolean;
  76857. /**
  76858. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  76859. */
  76860. get isNonUniform(): boolean;
  76861. /**
  76862. * Gets a new Vector3 from current Vector3 floored values
  76863. * @returns a new Vector3
  76864. */
  76865. floor(): Vector3;
  76866. /**
  76867. * Gets a new Vector3 from current Vector3 floored values
  76868. * @returns a new Vector3
  76869. */
  76870. fract(): Vector3;
  76871. /**
  76872. * Gets the length of the Vector3
  76873. * @returns the length of the Vector3
  76874. */
  76875. length(): number;
  76876. /**
  76877. * Gets the squared length of the Vector3
  76878. * @returns squared length of the Vector3
  76879. */
  76880. lengthSquared(): number;
  76881. /**
  76882. * Normalize the current Vector3.
  76883. * Please note that this is an in place operation.
  76884. * @returns the current updated Vector3
  76885. */
  76886. normalize(): Vector3;
  76887. /**
  76888. * Reorders the x y z properties of the vector in place
  76889. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  76890. * @returns the current updated vector
  76891. */
  76892. reorderInPlace(order: string): this;
  76893. /**
  76894. * Rotates the vector around 0,0,0 by a quaternion
  76895. * @param quaternion the rotation quaternion
  76896. * @param result vector to store the result
  76897. * @returns the resulting vector
  76898. */
  76899. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  76900. /**
  76901. * Rotates a vector around a given point
  76902. * @param quaternion the rotation quaternion
  76903. * @param point the point to rotate around
  76904. * @param result vector to store the result
  76905. * @returns the resulting vector
  76906. */
  76907. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  76908. /**
  76909. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  76910. * The cross product is then orthogonal to both current and "other"
  76911. * @param other defines the right operand
  76912. * @returns the cross product
  76913. */
  76914. cross(other: Vector3): Vector3;
  76915. /**
  76916. * Normalize the current Vector3 with the given input length.
  76917. * Please note that this is an in place operation.
  76918. * @param len the length of the vector
  76919. * @returns the current updated Vector3
  76920. */
  76921. normalizeFromLength(len: number): Vector3;
  76922. /**
  76923. * Normalize the current Vector3 to a new vector
  76924. * @returns the new Vector3
  76925. */
  76926. normalizeToNew(): Vector3;
  76927. /**
  76928. * Normalize the current Vector3 to the reference
  76929. * @param reference define the Vector3 to update
  76930. * @returns the updated Vector3
  76931. */
  76932. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  76933. /**
  76934. * Creates a new Vector3 copied from the current Vector3
  76935. * @returns the new Vector3
  76936. */
  76937. clone(): Vector3;
  76938. /**
  76939. * Copies the given vector coordinates to the current Vector3 ones
  76940. * @param source defines the source Vector3
  76941. * @returns the current updated Vector3
  76942. */
  76943. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  76944. /**
  76945. * Copies the given floats to the current Vector3 coordinates
  76946. * @param x defines the x coordinate of the operand
  76947. * @param y defines the y coordinate of the operand
  76948. * @param z defines the z coordinate of the operand
  76949. * @returns the current updated Vector3
  76950. */
  76951. copyFromFloats(x: number, y: number, z: number): Vector3;
  76952. /**
  76953. * Copies the given floats to the current Vector3 coordinates
  76954. * @param x defines the x coordinate of the operand
  76955. * @param y defines the y coordinate of the operand
  76956. * @param z defines the z coordinate of the operand
  76957. * @returns the current updated Vector3
  76958. */
  76959. set(x: number, y: number, z: number): Vector3;
  76960. /**
  76961. * Copies the given float to the current Vector3 coordinates
  76962. * @param v defines the x, y and z coordinates of the operand
  76963. * @returns the current updated Vector3
  76964. */
  76965. setAll(v: number): Vector3;
  76966. /**
  76967. * Get the clip factor between two vectors
  76968. * @param vector0 defines the first operand
  76969. * @param vector1 defines the second operand
  76970. * @param axis defines the axis to use
  76971. * @param size defines the size along the axis
  76972. * @returns the clip factor
  76973. */
  76974. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  76975. /**
  76976. * Get angle between two vectors
  76977. * @param vector0 angle between vector0 and vector1
  76978. * @param vector1 angle between vector0 and vector1
  76979. * @param normal direction of the normal
  76980. * @return the angle between vector0 and vector1
  76981. */
  76982. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  76983. /**
  76984. * Returns a new Vector3 set from the index "offset" of the given array
  76985. * @param array defines the source array
  76986. * @param offset defines the offset in the source array
  76987. * @returns the new Vector3
  76988. */
  76989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  76990. /**
  76991. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  76992. * @param array defines the source array
  76993. * @param offset defines the offset in the source array
  76994. * @returns the new Vector3
  76995. * @deprecated Please use FromArray instead.
  76996. */
  76997. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  76998. /**
  76999. * Sets the given vector "result" with the element values from the index "offset" of the given array
  77000. * @param array defines the source array
  77001. * @param offset defines the offset in the source array
  77002. * @param result defines the Vector3 where to store the result
  77003. */
  77004. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  77005. /**
  77006. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  77007. * @param array defines the source array
  77008. * @param offset defines the offset in the source array
  77009. * @param result defines the Vector3 where to store the result
  77010. * @deprecated Please use FromArrayToRef instead.
  77011. */
  77012. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  77013. /**
  77014. * Sets the given vector "result" with the given floats.
  77015. * @param x defines the x coordinate of the source
  77016. * @param y defines the y coordinate of the source
  77017. * @param z defines the z coordinate of the source
  77018. * @param result defines the Vector3 where to store the result
  77019. */
  77020. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  77021. /**
  77022. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  77023. * @returns a new empty Vector3
  77024. */
  77025. static Zero(): Vector3;
  77026. /**
  77027. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  77028. * @returns a new unit Vector3
  77029. */
  77030. static One(): Vector3;
  77031. /**
  77032. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  77033. * @returns a new up Vector3
  77034. */
  77035. static Up(): Vector3;
  77036. /**
  77037. * Gets a up Vector3 that must not be updated
  77038. */
  77039. static get UpReadOnly(): DeepImmutable<Vector3>;
  77040. /**
  77041. * Gets a zero Vector3 that must not be updated
  77042. */
  77043. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  77044. /**
  77045. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  77046. * @returns a new down Vector3
  77047. */
  77048. static Down(): Vector3;
  77049. /**
  77050. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  77051. * @returns a new forward Vector3
  77052. */
  77053. static Forward(): Vector3;
  77054. /**
  77055. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  77056. * @returns a new forward Vector3
  77057. */
  77058. static Backward(): Vector3;
  77059. /**
  77060. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  77061. * @returns a new right Vector3
  77062. */
  77063. static Right(): Vector3;
  77064. /**
  77065. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  77066. * @returns a new left Vector3
  77067. */
  77068. static Left(): Vector3;
  77069. /**
  77070. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  77071. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77072. * @param vector defines the Vector3 to transform
  77073. * @param transformation defines the transformation matrix
  77074. * @returns the transformed Vector3
  77075. */
  77076. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77077. /**
  77078. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  77079. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  77080. * @param vector defines the Vector3 to transform
  77081. * @param transformation defines the transformation matrix
  77082. * @param result defines the Vector3 where to store the result
  77083. */
  77084. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77085. /**
  77086. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  77087. * This method computes tranformed coordinates only, not transformed direction vectors
  77088. * @param x define the x coordinate of the source vector
  77089. * @param y define the y coordinate of the source vector
  77090. * @param z define the z coordinate of the source vector
  77091. * @param transformation defines the transformation matrix
  77092. * @param result defines the Vector3 where to store the result
  77093. */
  77094. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77095. /**
  77096. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  77097. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77098. * @param vector defines the Vector3 to transform
  77099. * @param transformation defines the transformation matrix
  77100. * @returns the new Vector3
  77101. */
  77102. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  77103. /**
  77104. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  77105. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77106. * @param vector defines the Vector3 to transform
  77107. * @param transformation defines the transformation matrix
  77108. * @param result defines the Vector3 where to store the result
  77109. */
  77110. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77111. /**
  77112. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  77113. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  77114. * @param x define the x coordinate of the source vector
  77115. * @param y define the y coordinate of the source vector
  77116. * @param z define the z coordinate of the source vector
  77117. * @param transformation defines the transformation matrix
  77118. * @param result defines the Vector3 where to store the result
  77119. */
  77120. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  77121. /**
  77122. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  77123. * @param value1 defines the first control point
  77124. * @param value2 defines the second control point
  77125. * @param value3 defines the third control point
  77126. * @param value4 defines the fourth control point
  77127. * @param amount defines the amount on the spline to use
  77128. * @returns the new Vector3
  77129. */
  77130. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  77131. /**
  77132. * 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"
  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. * @returns the new Vector3
  77139. */
  77140. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  77141. /**
  77142. * 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"
  77143. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  77144. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  77145. * @param value defines the current value
  77146. * @param min defines the lower range value
  77147. * @param max defines the upper range value
  77148. * @param result defines the Vector3 where to store the result
  77149. */
  77150. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  77151. /**
  77152. * Checks if a given vector is inside a specific range
  77153. * @param v defines the vector to test
  77154. * @param min defines the minimum range
  77155. * @param max defines the maximum range
  77156. */
  77157. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  77158. /**
  77159. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  77160. * @param value1 defines the first control point
  77161. * @param tangent1 defines the first tangent vector
  77162. * @param value2 defines the second control point
  77163. * @param tangent2 defines the second tangent vector
  77164. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  77165. * @returns the new Vector3
  77166. */
  77167. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  77168. /**
  77169. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  77170. * @param start defines the start value
  77171. * @param end defines the end value
  77172. * @param amount max defines amount between both (between 0 and 1)
  77173. * @returns the new Vector3
  77174. */
  77175. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  77176. /**
  77177. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  77178. * @param start defines the start value
  77179. * @param end defines the end value
  77180. * @param amount max defines amount between both (between 0 and 1)
  77181. * @param result defines the Vector3 where to store the result
  77182. */
  77183. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  77184. /**
  77185. * Returns the dot product (float) between the vectors "left" and "right"
  77186. * @param left defines the left operand
  77187. * @param right defines the right operand
  77188. * @returns the dot product
  77189. */
  77190. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  77191. /**
  77192. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  77193. * The cross product is then orthogonal to both "left" and "right"
  77194. * @param left defines the left operand
  77195. * @param right defines the right operand
  77196. * @returns the cross product
  77197. */
  77198. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77199. /**
  77200. * Sets the given vector "result" with the cross product of "left" and "right"
  77201. * The cross product is then orthogonal to both "left" and "right"
  77202. * @param left defines the left operand
  77203. * @param right defines the right operand
  77204. * @param result defines the Vector3 where to store the result
  77205. */
  77206. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  77207. /**
  77208. * Returns a new Vector3 as the normalization of the given vector
  77209. * @param vector defines the Vector3 to normalize
  77210. * @returns the new Vector3
  77211. */
  77212. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  77213. /**
  77214. * Sets the given vector "result" with the normalization of the given first vector
  77215. * @param vector defines the Vector3 to normalize
  77216. * @param result defines the Vector3 where to store the result
  77217. */
  77218. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  77219. /**
  77220. * Project a Vector3 onto screen space
  77221. * @param vector defines the Vector3 to project
  77222. * @param world defines the world matrix to use
  77223. * @param transform defines the transform (view x projection) matrix to use
  77224. * @param viewport defines the screen viewport to use
  77225. * @returns the new Vector3
  77226. */
  77227. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  77228. /** @hidden */
  77229. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  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 transform defines the transform (view x projection) matrix to use
  77237. * @returns the new Vector3
  77238. */
  77239. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  77240. /**
  77241. * Unproject from screen space to object space
  77242. * @param source defines the screen space Vector3 to use
  77243. * @param viewportWidth defines the current width of the viewport
  77244. * @param viewportHeight defines the current height of the viewport
  77245. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77246. * @param view defines the view matrix to use
  77247. * @param projection defines the projection matrix to use
  77248. * @returns the new Vector3
  77249. */
  77250. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  77251. /**
  77252. * Unproject from screen space to object space
  77253. * @param source defines the screen space Vector3 to use
  77254. * @param viewportWidth defines the current width of the viewport
  77255. * @param viewportHeight defines the current height of the viewport
  77256. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77257. * @param view defines the view matrix to use
  77258. * @param projection defines the projection matrix to use
  77259. * @param result defines the Vector3 where to store the result
  77260. */
  77261. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77262. /**
  77263. * Unproject from screen space to object space
  77264. * @param sourceX defines the screen space x coordinate to use
  77265. * @param sourceY defines the screen space y coordinate to use
  77266. * @param sourceZ defines the screen space z coordinate to use
  77267. * @param viewportWidth defines the current width of the viewport
  77268. * @param viewportHeight defines the current height of the viewport
  77269. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  77270. * @param view defines the view matrix to use
  77271. * @param projection defines the projection matrix to use
  77272. * @param result defines the Vector3 where to store the result
  77273. */
  77274. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  77275. /**
  77276. * Gets the minimal coordinate values between two Vector3
  77277. * @param left defines the first operand
  77278. * @param right defines the second operand
  77279. * @returns the new Vector3
  77280. */
  77281. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77282. /**
  77283. * Gets the maximal coordinate values between two Vector3
  77284. * @param left defines the first operand
  77285. * @param right defines the second operand
  77286. * @returns the new Vector3
  77287. */
  77288. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  77289. /**
  77290. * Returns the distance between the vectors "value1" and "value2"
  77291. * @param value1 defines the first operand
  77292. * @param value2 defines the second operand
  77293. * @returns the distance
  77294. */
  77295. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77296. /**
  77297. * Returns the squared distance between the vectors "value1" and "value2"
  77298. * @param value1 defines the first operand
  77299. * @param value2 defines the second operand
  77300. * @returns the squared distance
  77301. */
  77302. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  77303. /**
  77304. * Returns a new Vector3 located at the center between "value1" and "value2"
  77305. * @param value1 defines the first operand
  77306. * @param value2 defines the second operand
  77307. * @returns the new Vector3
  77308. */
  77309. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  77310. /**
  77311. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  77312. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  77313. * to something in order to rotate it from its local system to the given target system
  77314. * Note: axis1, axis2 and axis3 are normalized during this operation
  77315. * @param axis1 defines the first axis
  77316. * @param axis2 defines the second axis
  77317. * @param axis3 defines the third axis
  77318. * @returns a new Vector3
  77319. */
  77320. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  77321. /**
  77322. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  77323. * @param axis1 defines the first axis
  77324. * @param axis2 defines the second axis
  77325. * @param axis3 defines the third axis
  77326. * @param ref defines the Vector3 where to store the result
  77327. */
  77328. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  77329. }
  77330. /**
  77331. * Vector4 class created for EulerAngle class conversion to Quaternion
  77332. */
  77333. export class Vector4 {
  77334. /** x value of the vector */
  77335. x: number;
  77336. /** y value of the vector */
  77337. y: number;
  77338. /** z value of the vector */
  77339. z: number;
  77340. /** w value of the vector */
  77341. w: number;
  77342. /**
  77343. * Creates a Vector4 object from the given floats.
  77344. * @param x x value of the vector
  77345. * @param y y value of the vector
  77346. * @param z z value of the vector
  77347. * @param w w value of the vector
  77348. */
  77349. constructor(
  77350. /** x value of the vector */
  77351. x: number,
  77352. /** y value of the vector */
  77353. y: number,
  77354. /** z value of the vector */
  77355. z: number,
  77356. /** w value of the vector */
  77357. w: number);
  77358. /**
  77359. * Returns the string with the Vector4 coordinates.
  77360. * @returns a string containing all the vector values
  77361. */
  77362. toString(): string;
  77363. /**
  77364. * Returns the string "Vector4".
  77365. * @returns "Vector4"
  77366. */
  77367. getClassName(): string;
  77368. /**
  77369. * Returns the Vector4 hash code.
  77370. * @returns a unique hash code
  77371. */
  77372. getHashCode(): number;
  77373. /**
  77374. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  77375. * @returns the resulting array
  77376. */
  77377. asArray(): number[];
  77378. /**
  77379. * Populates the given array from the given index with the Vector4 coordinates.
  77380. * @param array array to populate
  77381. * @param index index of the array to start at (default: 0)
  77382. * @returns the Vector4.
  77383. */
  77384. toArray(array: FloatArray, index?: number): Vector4;
  77385. /**
  77386. * Adds the given vector to the current Vector4.
  77387. * @param otherVector the vector to add
  77388. * @returns the updated Vector4.
  77389. */
  77390. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77391. /**
  77392. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  77393. * @param otherVector the vector to add
  77394. * @returns the resulting vector
  77395. */
  77396. add(otherVector: DeepImmutable<Vector4>): Vector4;
  77397. /**
  77398. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  77399. * @param otherVector the vector to add
  77400. * @param result the vector to store the result
  77401. * @returns the current Vector4.
  77402. */
  77403. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77404. /**
  77405. * Subtract in place the given vector from the current Vector4.
  77406. * @param otherVector the vector to subtract
  77407. * @returns the updated Vector4.
  77408. */
  77409. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77410. /**
  77411. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  77412. * @param otherVector the vector to add
  77413. * @returns the new vector with the result
  77414. */
  77415. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  77416. /**
  77417. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  77418. * @param otherVector the vector to subtract
  77419. * @param result the vector to store the result
  77420. * @returns the current Vector4.
  77421. */
  77422. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77423. /**
  77424. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77425. */
  77426. /**
  77427. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77428. * @param x value to subtract
  77429. * @param y value to subtract
  77430. * @param z value to subtract
  77431. * @param w value to subtract
  77432. * @returns new vector containing the result
  77433. */
  77434. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77435. /**
  77436. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  77437. * @param x value to subtract
  77438. * @param y value to subtract
  77439. * @param z value to subtract
  77440. * @param w value to subtract
  77441. * @param result the vector to store the result in
  77442. * @returns the current Vector4.
  77443. */
  77444. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  77445. /**
  77446. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  77447. * @returns a new vector with the negated values
  77448. */
  77449. negate(): Vector4;
  77450. /**
  77451. * Negate this vector in place
  77452. * @returns this
  77453. */
  77454. negateInPlace(): Vector4;
  77455. /**
  77456. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  77457. * @param result defines the Vector3 object where to store the result
  77458. * @returns the current Vector4
  77459. */
  77460. negateToRef(result: Vector4): Vector4;
  77461. /**
  77462. * Multiplies the current Vector4 coordinates by scale (float).
  77463. * @param scale the number to scale with
  77464. * @returns the updated Vector4.
  77465. */
  77466. scaleInPlace(scale: number): Vector4;
  77467. /**
  77468. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  77469. * @param scale the number to scale with
  77470. * @returns a new vector with the result
  77471. */
  77472. scale(scale: number): Vector4;
  77473. /**
  77474. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  77475. * @param scale the number to scale with
  77476. * @param result a vector to store the result in
  77477. * @returns the current Vector4.
  77478. */
  77479. scaleToRef(scale: number, result: Vector4): Vector4;
  77480. /**
  77481. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  77482. * @param scale defines the scale factor
  77483. * @param result defines the Vector4 object where to store the result
  77484. * @returns the unmodified current Vector4
  77485. */
  77486. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  77487. /**
  77488. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  77489. * @param otherVector the vector to compare against
  77490. * @returns true if they are equal
  77491. */
  77492. equals(otherVector: DeepImmutable<Vector4>): boolean;
  77493. /**
  77494. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  77495. * @param otherVector vector to compare against
  77496. * @param epsilon (Default: very small number)
  77497. * @returns true if they are equal
  77498. */
  77499. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  77500. /**
  77501. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  77502. * @param x x value to compare against
  77503. * @param y y value to compare against
  77504. * @param z z value to compare against
  77505. * @param w w value to compare against
  77506. * @returns true if equal
  77507. */
  77508. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  77509. /**
  77510. * Multiplies in place the current Vector4 by the given one.
  77511. * @param otherVector vector to multiple with
  77512. * @returns the updated Vector4.
  77513. */
  77514. multiplyInPlace(otherVector: Vector4): Vector4;
  77515. /**
  77516. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  77517. * @param otherVector vector to multiple with
  77518. * @returns resulting new vector
  77519. */
  77520. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  77521. /**
  77522. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  77523. * @param otherVector vector to multiple with
  77524. * @param result vector to store the result
  77525. * @returns the current Vector4.
  77526. */
  77527. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77528. /**
  77529. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  77530. * @param x x value multiply with
  77531. * @param y y value multiply with
  77532. * @param z z value multiply with
  77533. * @param w w value multiply with
  77534. * @returns resulting new vector
  77535. */
  77536. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  77537. /**
  77538. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  77539. * @param otherVector vector to devide with
  77540. * @returns resulting new vector
  77541. */
  77542. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  77543. /**
  77544. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  77545. * @param otherVector vector to devide with
  77546. * @param result vector to store the result
  77547. * @returns the current Vector4.
  77548. */
  77549. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  77550. /**
  77551. * Divides the current Vector3 coordinates by the given ones.
  77552. * @param otherVector vector to devide with
  77553. * @returns the updated Vector3.
  77554. */
  77555. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  77556. /**
  77557. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  77558. * @param other defines the second operand
  77559. * @returns the current updated Vector4
  77560. */
  77561. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77562. /**
  77563. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  77564. * @param other defines the second operand
  77565. * @returns the current updated Vector4
  77566. */
  77567. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  77568. /**
  77569. * Gets a new Vector4 from current Vector4 floored values
  77570. * @returns a new Vector4
  77571. */
  77572. floor(): Vector4;
  77573. /**
  77574. * Gets a new Vector4 from current Vector3 floored values
  77575. * @returns a new Vector4
  77576. */
  77577. fract(): Vector4;
  77578. /**
  77579. * Returns the Vector4 length (float).
  77580. * @returns the length
  77581. */
  77582. length(): number;
  77583. /**
  77584. * Returns the Vector4 squared length (float).
  77585. * @returns the length squared
  77586. */
  77587. lengthSquared(): number;
  77588. /**
  77589. * Normalizes in place the Vector4.
  77590. * @returns the updated Vector4.
  77591. */
  77592. normalize(): Vector4;
  77593. /**
  77594. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  77595. * @returns this converted to a new vector3
  77596. */
  77597. toVector3(): Vector3;
  77598. /**
  77599. * Returns a new Vector4 copied from the current one.
  77600. * @returns the new cloned vector
  77601. */
  77602. clone(): Vector4;
  77603. /**
  77604. * Updates the current Vector4 with the given one coordinates.
  77605. * @param source the source vector to copy from
  77606. * @returns the updated Vector4.
  77607. */
  77608. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  77609. /**
  77610. * Updates the current Vector4 coordinates with the given floats.
  77611. * @param x float to copy from
  77612. * @param y float to copy from
  77613. * @param z float to copy from
  77614. * @param w float to copy from
  77615. * @returns the updated Vector4.
  77616. */
  77617. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  77618. /**
  77619. * Updates the current Vector4 coordinates with the given floats.
  77620. * @param x float to set from
  77621. * @param y float to set from
  77622. * @param z float to set from
  77623. * @param w float to set from
  77624. * @returns the updated Vector4.
  77625. */
  77626. set(x: number, y: number, z: number, w: number): Vector4;
  77627. /**
  77628. * Copies the given float to the current Vector3 coordinates
  77629. * @param v defines the x, y, z and w coordinates of the operand
  77630. * @returns the current updated Vector3
  77631. */
  77632. setAll(v: number): Vector4;
  77633. /**
  77634. * Returns a new Vector4 set from the starting index of the given array.
  77635. * @param array the array to pull values from
  77636. * @param offset the offset into the array to start at
  77637. * @returns the new vector
  77638. */
  77639. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  77640. /**
  77641. * Updates the given vector "result" from the starting index of the given array.
  77642. * @param array the array to pull values from
  77643. * @param offset the offset into the array to start at
  77644. * @param result the vector to store the result in
  77645. */
  77646. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  77647. /**
  77648. * Updates the given vector "result" from the starting index of the given Float32Array.
  77649. * @param array the array to pull values from
  77650. * @param offset the offset into the array to start at
  77651. * @param result the vector to store the result in
  77652. */
  77653. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  77654. /**
  77655. * Updates the given vector "result" coordinates from the given floats.
  77656. * @param x float to set from
  77657. * @param y float to set from
  77658. * @param z float to set from
  77659. * @param w float to set from
  77660. * @param result the vector to the floats in
  77661. */
  77662. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  77663. /**
  77664. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  77665. * @returns the new vector
  77666. */
  77667. static Zero(): Vector4;
  77668. /**
  77669. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  77670. * @returns the new vector
  77671. */
  77672. static One(): Vector4;
  77673. /**
  77674. * Returns a new normalized Vector4 from the given one.
  77675. * @param vector the vector to normalize
  77676. * @returns the vector
  77677. */
  77678. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  77679. /**
  77680. * Updates the given vector "result" from the normalization of the given one.
  77681. * @param vector the vector to normalize
  77682. * @param result the vector to store the result in
  77683. */
  77684. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  77685. /**
  77686. * Returns a vector with the minimum values from the left and right vectors
  77687. * @param left left vector to minimize
  77688. * @param right right vector to minimize
  77689. * @returns a new vector with the minimum of the left and right vector values
  77690. */
  77691. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77692. /**
  77693. * Returns a vector with the maximum values from the left and right vectors
  77694. * @param left left vector to maximize
  77695. * @param right right vector to maximize
  77696. * @returns a new vector with the maximum of the left and right vector values
  77697. */
  77698. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  77699. /**
  77700. * Returns the distance (float) between the vectors "value1" and "value2".
  77701. * @param value1 value to calulate the distance between
  77702. * @param value2 value to calulate the distance between
  77703. * @return the distance between the two vectors
  77704. */
  77705. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77706. /**
  77707. * Returns the squared distance (float) between the vectors "value1" and "value2".
  77708. * @param value1 value to calulate the distance between
  77709. * @param value2 value to calulate the distance between
  77710. * @return the distance between the two vectors squared
  77711. */
  77712. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  77713. /**
  77714. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  77715. * @param value1 value to calulate the center between
  77716. * @param value2 value to calulate the center between
  77717. * @return the center between the two vectors
  77718. */
  77719. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  77720. /**
  77721. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  77722. * This methods computes transformed normalized direction vectors only.
  77723. * @param vector the vector to transform
  77724. * @param transformation the transformation matrix to apply
  77725. * @returns the new vector
  77726. */
  77727. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  77728. /**
  77729. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  77730. * This methods computes transformed normalized direction vectors only.
  77731. * @param vector the vector to transform
  77732. * @param transformation the transformation matrix to apply
  77733. * @param result the vector to store the result in
  77734. */
  77735. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77736. /**
  77737. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  77738. * This methods computes transformed normalized direction vectors only.
  77739. * @param x value to transform
  77740. * @param y value to transform
  77741. * @param z value to transform
  77742. * @param w value to transform
  77743. * @param transformation the transformation matrix to apply
  77744. * @param result the vector to store the results in
  77745. */
  77746. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  77747. /**
  77748. * Creates a new Vector4 from a Vector3
  77749. * @param source defines the source data
  77750. * @param w defines the 4th component (default is 0)
  77751. * @returns a new Vector4
  77752. */
  77753. static FromVector3(source: Vector3, w?: number): Vector4;
  77754. }
  77755. /**
  77756. * Class used to store quaternion data
  77757. * @see https://en.wikipedia.org/wiki/Quaternion
  77758. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  77759. */
  77760. export class Quaternion {
  77761. /** defines the first component (0 by default) */
  77762. x: number;
  77763. /** defines the second component (0 by default) */
  77764. y: number;
  77765. /** defines the third component (0 by default) */
  77766. z: number;
  77767. /** defines the fourth component (1.0 by default) */
  77768. w: number;
  77769. /**
  77770. * Creates a new Quaternion from the given floats
  77771. * @param x defines the first component (0 by default)
  77772. * @param y defines the second component (0 by default)
  77773. * @param z defines the third component (0 by default)
  77774. * @param w defines the fourth component (1.0 by default)
  77775. */
  77776. constructor(
  77777. /** defines the first component (0 by default) */
  77778. x?: number,
  77779. /** defines the second component (0 by default) */
  77780. y?: number,
  77781. /** defines the third component (0 by default) */
  77782. z?: number,
  77783. /** defines the fourth component (1.0 by default) */
  77784. w?: number);
  77785. /**
  77786. * Gets a string representation for the current quaternion
  77787. * @returns a string with the Quaternion coordinates
  77788. */
  77789. toString(): string;
  77790. /**
  77791. * Gets the class name of the quaternion
  77792. * @returns the string "Quaternion"
  77793. */
  77794. getClassName(): string;
  77795. /**
  77796. * Gets a hash code for this quaternion
  77797. * @returns the quaternion hash code
  77798. */
  77799. getHashCode(): number;
  77800. /**
  77801. * Copy the quaternion to an array
  77802. * @returns a new array populated with 4 elements from the quaternion coordinates
  77803. */
  77804. asArray(): number[];
  77805. /**
  77806. * Check if two quaternions are equals
  77807. * @param otherQuaternion defines the second operand
  77808. * @return true if the current quaternion and the given one coordinates are strictly equals
  77809. */
  77810. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  77811. /**
  77812. * Gets a boolean if two quaternions are equals (using an epsilon value)
  77813. * @param otherQuaternion defines the other quaternion
  77814. * @param epsilon defines the minimal distance to consider equality
  77815. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  77816. */
  77817. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  77818. /**
  77819. * Clone the current quaternion
  77820. * @returns a new quaternion copied from the current one
  77821. */
  77822. clone(): Quaternion;
  77823. /**
  77824. * Copy a quaternion to the current one
  77825. * @param other defines the other quaternion
  77826. * @returns the updated current quaternion
  77827. */
  77828. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  77829. /**
  77830. * Updates the current quaternion with the given float coordinates
  77831. * @param x defines the x coordinate
  77832. * @param y defines the y coordinate
  77833. * @param z defines the z coordinate
  77834. * @param w defines the w coordinate
  77835. * @returns the updated current quaternion
  77836. */
  77837. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  77838. /**
  77839. * Updates the current quaternion from the given float coordinates
  77840. * @param x defines the x coordinate
  77841. * @param y defines the y coordinate
  77842. * @param z defines the z coordinate
  77843. * @param w defines the w coordinate
  77844. * @returns the updated current quaternion
  77845. */
  77846. set(x: number, y: number, z: number, w: number): Quaternion;
  77847. /**
  77848. * Adds two quaternions
  77849. * @param other defines the second operand
  77850. * @returns a new quaternion as the addition result of the given one and the current quaternion
  77851. */
  77852. add(other: DeepImmutable<Quaternion>): Quaternion;
  77853. /**
  77854. * Add a quaternion to the current one
  77855. * @param other defines the quaternion to add
  77856. * @returns the current quaternion
  77857. */
  77858. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  77859. /**
  77860. * Subtract two quaternions
  77861. * @param other defines the second operand
  77862. * @returns a new quaternion as the subtraction result of the given one from the current one
  77863. */
  77864. subtract(other: Quaternion): Quaternion;
  77865. /**
  77866. * Multiplies the current quaternion by a scale factor
  77867. * @param value defines the scale factor
  77868. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  77869. */
  77870. scale(value: number): Quaternion;
  77871. /**
  77872. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  77873. * @param scale defines the scale factor
  77874. * @param result defines the Quaternion object where to store the result
  77875. * @returns the unmodified current quaternion
  77876. */
  77877. scaleToRef(scale: number, result: Quaternion): Quaternion;
  77878. /**
  77879. * Multiplies in place the current quaternion by a scale factor
  77880. * @param value defines the scale factor
  77881. * @returns the current modified quaternion
  77882. */
  77883. scaleInPlace(value: number): Quaternion;
  77884. /**
  77885. * Scale the current quaternion values by a factor and add the result to a given quaternion
  77886. * @param scale defines the scale factor
  77887. * @param result defines the Quaternion object where to store the result
  77888. * @returns the unmodified current quaternion
  77889. */
  77890. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  77891. /**
  77892. * Multiplies two quaternions
  77893. * @param q1 defines the second operand
  77894. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  77895. */
  77896. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  77897. /**
  77898. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  77899. * @param q1 defines the second operand
  77900. * @param result defines the target quaternion
  77901. * @returns the current quaternion
  77902. */
  77903. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  77904. /**
  77905. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  77906. * @param q1 defines the second operand
  77907. * @returns the currentupdated quaternion
  77908. */
  77909. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  77910. /**
  77911. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  77912. * @param ref defines the target quaternion
  77913. * @returns the current quaternion
  77914. */
  77915. conjugateToRef(ref: Quaternion): Quaternion;
  77916. /**
  77917. * Conjugates in place (1-q) the current quaternion
  77918. * @returns the current updated quaternion
  77919. */
  77920. conjugateInPlace(): Quaternion;
  77921. /**
  77922. * Conjugates in place (1-q) the current quaternion
  77923. * @returns a new quaternion
  77924. */
  77925. conjugate(): Quaternion;
  77926. /**
  77927. * Gets length of current quaternion
  77928. * @returns the quaternion length (float)
  77929. */
  77930. length(): number;
  77931. /**
  77932. * Normalize in place the current quaternion
  77933. * @returns the current updated quaternion
  77934. */
  77935. normalize(): Quaternion;
  77936. /**
  77937. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  77938. * @param order is a reserved parameter and is ignore for now
  77939. * @returns a new Vector3 containing the Euler angles
  77940. */
  77941. toEulerAngles(order?: string): Vector3;
  77942. /**
  77943. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  77944. * @param result defines the vector which will be filled with the Euler angles
  77945. * @param order is a reserved parameter and is ignore for now
  77946. * @returns the current unchanged quaternion
  77947. */
  77948. toEulerAnglesToRef(result: Vector3): Quaternion;
  77949. /**
  77950. * Updates the given rotation matrix with the current quaternion values
  77951. * @param result defines the target matrix
  77952. * @returns the current unchanged quaternion
  77953. */
  77954. toRotationMatrix(result: Matrix): Quaternion;
  77955. /**
  77956. * Updates the current quaternion from the given rotation matrix values
  77957. * @param matrix defines the source matrix
  77958. * @returns the current updated quaternion
  77959. */
  77960. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77961. /**
  77962. * Creates a new quaternion from a rotation matrix
  77963. * @param matrix defines the source matrix
  77964. * @returns a new quaternion created from the given rotation matrix values
  77965. */
  77966. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  77967. /**
  77968. * Updates the given quaternion with the given rotation matrix values
  77969. * @param matrix defines the source matrix
  77970. * @param result defines the target quaternion
  77971. */
  77972. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  77973. /**
  77974. * Returns the dot product (float) between the quaternions "left" and "right"
  77975. * @param left defines the left operand
  77976. * @param right defines the right operand
  77977. * @returns the dot product
  77978. */
  77979. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  77980. /**
  77981. * Checks if the two quaternions are close to each other
  77982. * @param quat0 defines the first quaternion to check
  77983. * @param quat1 defines the second quaternion to check
  77984. * @returns true if the two quaternions are close to each other
  77985. */
  77986. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  77987. /**
  77988. * Creates an empty quaternion
  77989. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  77990. */
  77991. static Zero(): Quaternion;
  77992. /**
  77993. * Inverse a given quaternion
  77994. * @param q defines the source quaternion
  77995. * @returns a new quaternion as the inverted current quaternion
  77996. */
  77997. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  77998. /**
  77999. * Inverse a given quaternion
  78000. * @param q defines the source quaternion
  78001. * @param result the quaternion the result will be stored in
  78002. * @returns the result quaternion
  78003. */
  78004. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  78005. /**
  78006. * Creates an identity quaternion
  78007. * @returns the identity quaternion
  78008. */
  78009. static Identity(): Quaternion;
  78010. /**
  78011. * Gets a boolean indicating if the given quaternion is identity
  78012. * @param quaternion defines the quaternion to check
  78013. * @returns true if the quaternion is identity
  78014. */
  78015. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  78016. /**
  78017. * Creates a quaternion from a rotation around an axis
  78018. * @param axis defines the axis to use
  78019. * @param angle defines the angle to use
  78020. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  78021. */
  78022. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  78023. /**
  78024. * Creates a rotation around an axis and stores it into the given quaternion
  78025. * @param axis defines the axis to use
  78026. * @param angle defines the angle to use
  78027. * @param result defines the target quaternion
  78028. * @returns the target quaternion
  78029. */
  78030. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  78031. /**
  78032. * Creates a new quaternion from data stored into an array
  78033. * @param array defines the data source
  78034. * @param offset defines the offset in the source array where the data starts
  78035. * @returns a new quaternion
  78036. */
  78037. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  78038. /**
  78039. * Updates the given quaternion "result" from the starting index of the given array.
  78040. * @param array the array to pull values from
  78041. * @param offset the offset into the array to start at
  78042. * @param result the quaternion to store the result in
  78043. */
  78044. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  78045. /**
  78046. * Create a quaternion from Euler rotation angles
  78047. * @param x Pitch
  78048. * @param y Yaw
  78049. * @param z Roll
  78050. * @returns the new Quaternion
  78051. */
  78052. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  78053. /**
  78054. * Updates a quaternion from Euler rotation angles
  78055. * @param x Pitch
  78056. * @param y Yaw
  78057. * @param z Roll
  78058. * @param result the quaternion to store the result
  78059. * @returns the updated quaternion
  78060. */
  78061. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  78062. /**
  78063. * Create a quaternion from Euler rotation vector
  78064. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78065. * @returns the new Quaternion
  78066. */
  78067. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  78068. /**
  78069. * Updates a quaternion from Euler rotation vector
  78070. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  78071. * @param result the quaternion to store the result
  78072. * @returns the updated quaternion
  78073. */
  78074. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  78075. /**
  78076. * Creates a new quaternion from the given Euler float angles (y, x, z)
  78077. * @param yaw defines the rotation around Y axis
  78078. * @param pitch defines the rotation around X axis
  78079. * @param roll defines the rotation around Z axis
  78080. * @returns the new quaternion
  78081. */
  78082. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  78083. /**
  78084. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  78085. * @param yaw defines the rotation around Y axis
  78086. * @param pitch defines the rotation around X axis
  78087. * @param roll defines the rotation around Z axis
  78088. * @param result defines the target quaternion
  78089. */
  78090. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  78091. /**
  78092. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  78093. * @param alpha defines the rotation around first axis
  78094. * @param beta defines the rotation around second axis
  78095. * @param gamma defines the rotation around third axis
  78096. * @returns the new quaternion
  78097. */
  78098. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  78099. /**
  78100. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  78101. * @param alpha defines the rotation around first axis
  78102. * @param beta defines the rotation around second axis
  78103. * @param gamma defines the rotation around third axis
  78104. * @param result defines the target quaternion
  78105. */
  78106. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  78107. /**
  78108. * 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)
  78109. * @param axis1 defines the first axis
  78110. * @param axis2 defines the second axis
  78111. * @param axis3 defines the third axis
  78112. * @returns the new quaternion
  78113. */
  78114. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  78115. /**
  78116. * 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
  78117. * @param axis1 defines the first axis
  78118. * @param axis2 defines the second axis
  78119. * @param axis3 defines the third axis
  78120. * @param ref defines the target quaternion
  78121. */
  78122. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  78123. /**
  78124. * Interpolates between two quaternions
  78125. * @param left defines first quaternion
  78126. * @param right defines second quaternion
  78127. * @param amount defines the gradient to use
  78128. * @returns the new interpolated quaternion
  78129. */
  78130. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78131. /**
  78132. * Interpolates between two quaternions and stores it into a target quaternion
  78133. * @param left defines first quaternion
  78134. * @param right defines second quaternion
  78135. * @param amount defines the gradient to use
  78136. * @param result defines the target quaternion
  78137. */
  78138. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  78139. /**
  78140. * Interpolate between two quaternions using Hermite interpolation
  78141. * @param value1 defines first quaternion
  78142. * @param tangent1 defines the incoming tangent
  78143. * @param value2 defines second quaternion
  78144. * @param tangent2 defines the outgoing tangent
  78145. * @param amount defines the target quaternion
  78146. * @returns the new interpolated quaternion
  78147. */
  78148. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  78149. }
  78150. /**
  78151. * Class used to store matrix data (4x4)
  78152. */
  78153. export class Matrix {
  78154. private static _updateFlagSeed;
  78155. private static _identityReadOnly;
  78156. private _isIdentity;
  78157. private _isIdentityDirty;
  78158. private _isIdentity3x2;
  78159. private _isIdentity3x2Dirty;
  78160. /**
  78161. * Gets the update flag of the matrix which is an unique number for the matrix.
  78162. * It will be incremented every time the matrix data change.
  78163. * You can use it to speed the comparison between two versions of the same matrix.
  78164. */
  78165. updateFlag: number;
  78166. private readonly _m;
  78167. /**
  78168. * Gets the internal data of the matrix
  78169. */
  78170. get m(): DeepImmutable<Float32Array>;
  78171. /** @hidden */
  78172. _markAsUpdated(): void;
  78173. /** @hidden */
  78174. private _updateIdentityStatus;
  78175. /**
  78176. * Creates an empty matrix (filled with zeros)
  78177. */
  78178. constructor();
  78179. /**
  78180. * Check if the current matrix is identity
  78181. * @returns true is the matrix is the identity matrix
  78182. */
  78183. isIdentity(): boolean;
  78184. /**
  78185. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  78186. * @returns true is the matrix is the identity matrix
  78187. */
  78188. isIdentityAs3x2(): boolean;
  78189. /**
  78190. * Gets the determinant of the matrix
  78191. * @returns the matrix determinant
  78192. */
  78193. determinant(): number;
  78194. /**
  78195. * Returns the matrix as a Float32Array
  78196. * @returns the matrix underlying array
  78197. */
  78198. toArray(): DeepImmutable<Float32Array>;
  78199. /**
  78200. * Returns the matrix as a Float32Array
  78201. * @returns the matrix underlying array.
  78202. */
  78203. asArray(): DeepImmutable<Float32Array>;
  78204. /**
  78205. * Inverts the current matrix in place
  78206. * @returns the current inverted matrix
  78207. */
  78208. invert(): Matrix;
  78209. /**
  78210. * Sets all the matrix elements to zero
  78211. * @returns the current matrix
  78212. */
  78213. reset(): Matrix;
  78214. /**
  78215. * Adds the current matrix with a second one
  78216. * @param other defines the matrix to add
  78217. * @returns a new matrix as the addition of the current matrix and the given one
  78218. */
  78219. add(other: DeepImmutable<Matrix>): Matrix;
  78220. /**
  78221. * Sets the given matrix "result" to the addition of the current matrix and the given one
  78222. * @param other defines the matrix to add
  78223. * @param result defines the target matrix
  78224. * @returns the current matrix
  78225. */
  78226. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78227. /**
  78228. * Adds in place the given matrix to the current matrix
  78229. * @param other defines the second operand
  78230. * @returns the current updated matrix
  78231. */
  78232. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  78233. /**
  78234. * Sets the given matrix to the current inverted Matrix
  78235. * @param other defines the target matrix
  78236. * @returns the unmodified current matrix
  78237. */
  78238. invertToRef(other: Matrix): Matrix;
  78239. /**
  78240. * add a value at the specified position in the current Matrix
  78241. * @param index the index of the value within the matrix. between 0 and 15.
  78242. * @param value the value to be added
  78243. * @returns the current updated matrix
  78244. */
  78245. addAtIndex(index: number, value: number): Matrix;
  78246. /**
  78247. * mutiply the specified position in the current Matrix by a value
  78248. * @param index the index of the value within the matrix. between 0 and 15.
  78249. * @param value the value to be added
  78250. * @returns the current updated matrix
  78251. */
  78252. multiplyAtIndex(index: number, value: number): Matrix;
  78253. /**
  78254. * Inserts the translation vector (using 3 floats) in the current matrix
  78255. * @param x defines the 1st component of the translation
  78256. * @param y defines the 2nd component of the translation
  78257. * @param z defines the 3rd component of the translation
  78258. * @returns the current updated matrix
  78259. */
  78260. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78261. /**
  78262. * Adds the translation vector (using 3 floats) in the current matrix
  78263. * @param x defines the 1st component of the translation
  78264. * @param y defines the 2nd component of the translation
  78265. * @param z defines the 3rd component of the translation
  78266. * @returns the current updated matrix
  78267. */
  78268. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  78269. /**
  78270. * Inserts the translation vector in the current matrix
  78271. * @param vector3 defines the translation to insert
  78272. * @returns the current updated matrix
  78273. */
  78274. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  78275. /**
  78276. * Gets the translation value of the current matrix
  78277. * @returns a new Vector3 as the extracted translation from the matrix
  78278. */
  78279. getTranslation(): Vector3;
  78280. /**
  78281. * Fill a Vector3 with the extracted translation from the matrix
  78282. * @param result defines the Vector3 where to store the translation
  78283. * @returns the current matrix
  78284. */
  78285. getTranslationToRef(result: Vector3): Matrix;
  78286. /**
  78287. * Remove rotation and scaling part from the matrix
  78288. * @returns the updated matrix
  78289. */
  78290. removeRotationAndScaling(): Matrix;
  78291. /**
  78292. * Multiply two matrices
  78293. * @param other defines the second operand
  78294. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  78295. */
  78296. multiply(other: DeepImmutable<Matrix>): Matrix;
  78297. /**
  78298. * Copy the current matrix from the given one
  78299. * @param other defines the source matrix
  78300. * @returns the current updated matrix
  78301. */
  78302. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  78303. /**
  78304. * Populates the given array from the starting index with the current matrix values
  78305. * @param array defines the target array
  78306. * @param offset defines the offset in the target array where to start storing values
  78307. * @returns the current matrix
  78308. */
  78309. copyToArray(array: Float32Array, offset?: number): Matrix;
  78310. /**
  78311. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  78312. * @param other defines the second operand
  78313. * @param result defines the matrix where to store the multiplication
  78314. * @returns the current matrix
  78315. */
  78316. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  78317. /**
  78318. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  78319. * @param other defines the second operand
  78320. * @param result defines the array where to store the multiplication
  78321. * @param offset defines the offset in the target array where to start storing values
  78322. * @returns the current matrix
  78323. */
  78324. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  78325. /**
  78326. * Check equality between this matrix and a second one
  78327. * @param value defines the second matrix to compare
  78328. * @returns true is the current matrix and the given one values are strictly equal
  78329. */
  78330. equals(value: DeepImmutable<Matrix>): boolean;
  78331. /**
  78332. * Clone the current matrix
  78333. * @returns a new matrix from the current matrix
  78334. */
  78335. clone(): Matrix;
  78336. /**
  78337. * Returns the name of the current matrix class
  78338. * @returns the string "Matrix"
  78339. */
  78340. getClassName(): string;
  78341. /**
  78342. * Gets the hash code of the current matrix
  78343. * @returns the hash code
  78344. */
  78345. getHashCode(): number;
  78346. /**
  78347. * Decomposes the current Matrix into a translation, rotation and scaling components
  78348. * @param scale defines the scale vector3 given as a reference to update
  78349. * @param rotation defines the rotation quaternion given as a reference to update
  78350. * @param translation defines the translation vector3 given as a reference to update
  78351. * @returns true if operation was successful
  78352. */
  78353. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  78354. /**
  78355. * Gets specific row of the matrix
  78356. * @param index defines the number of the row to get
  78357. * @returns the index-th row of the current matrix as a new Vector4
  78358. */
  78359. getRow(index: number): Nullable<Vector4>;
  78360. /**
  78361. * Sets the index-th row of the current matrix to the vector4 values
  78362. * @param index defines the number of the row to set
  78363. * @param row defines the target vector4
  78364. * @returns the updated current matrix
  78365. */
  78366. setRow(index: number, row: Vector4): Matrix;
  78367. /**
  78368. * Compute the transpose of the matrix
  78369. * @returns the new transposed matrix
  78370. */
  78371. transpose(): Matrix;
  78372. /**
  78373. * Compute the transpose of the matrix and store it in a given matrix
  78374. * @param result defines the target matrix
  78375. * @returns the current matrix
  78376. */
  78377. transposeToRef(result: Matrix): Matrix;
  78378. /**
  78379. * Sets the index-th row of the current matrix with the given 4 x float values
  78380. * @param index defines the row index
  78381. * @param x defines the x component to set
  78382. * @param y defines the y component to set
  78383. * @param z defines the z component to set
  78384. * @param w defines the w component to set
  78385. * @returns the updated current matrix
  78386. */
  78387. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  78388. /**
  78389. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  78390. * @param scale defines the scale factor
  78391. * @returns a new matrix
  78392. */
  78393. scale(scale: number): Matrix;
  78394. /**
  78395. * Scale the current matrix values by a factor to a given result matrix
  78396. * @param scale defines the scale factor
  78397. * @param result defines the matrix to store the result
  78398. * @returns the current matrix
  78399. */
  78400. scaleToRef(scale: number, result: Matrix): Matrix;
  78401. /**
  78402. * Scale the current matrix values by a factor and add the result to a given matrix
  78403. * @param scale defines the scale factor
  78404. * @param result defines the Matrix to store the result
  78405. * @returns the current matrix
  78406. */
  78407. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  78408. /**
  78409. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  78410. * @param ref matrix to store the result
  78411. */
  78412. toNormalMatrix(ref: Matrix): void;
  78413. /**
  78414. * Gets only rotation part of the current matrix
  78415. * @returns a new matrix sets to the extracted rotation matrix from the current one
  78416. */
  78417. getRotationMatrix(): Matrix;
  78418. /**
  78419. * Extracts the rotation matrix from the current one and sets it as the given "result"
  78420. * @param result defines the target matrix to store data to
  78421. * @returns the current matrix
  78422. */
  78423. getRotationMatrixToRef(result: Matrix): Matrix;
  78424. /**
  78425. * Toggles model matrix from being right handed to left handed in place and vice versa
  78426. */
  78427. toggleModelMatrixHandInPlace(): void;
  78428. /**
  78429. * Toggles projection matrix from being right handed to left handed in place and vice versa
  78430. */
  78431. toggleProjectionMatrixHandInPlace(): void;
  78432. /**
  78433. * Creates a matrix from an array
  78434. * @param array defines the source array
  78435. * @param offset defines an offset in the source array
  78436. * @returns a new Matrix set from the starting index of the given array
  78437. */
  78438. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  78439. /**
  78440. * Copy the content of an array into a given matrix
  78441. * @param array defines the source array
  78442. * @param offset defines an offset in the source array
  78443. * @param result defines the target matrix
  78444. */
  78445. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  78446. /**
  78447. * Stores an array into a matrix after having multiplied each component by a given factor
  78448. * @param array defines the source array
  78449. * @param offset defines the offset in the source array
  78450. * @param scale defines the scaling factor
  78451. * @param result defines the target matrix
  78452. */
  78453. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  78454. /**
  78455. * Gets an identity matrix that must not be updated
  78456. */
  78457. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  78458. /**
  78459. * Stores a list of values (16) inside a given matrix
  78460. * @param initialM11 defines 1st value of 1st row
  78461. * @param initialM12 defines 2nd value of 1st row
  78462. * @param initialM13 defines 3rd value of 1st row
  78463. * @param initialM14 defines 4th value of 1st row
  78464. * @param initialM21 defines 1st value of 2nd row
  78465. * @param initialM22 defines 2nd value of 2nd row
  78466. * @param initialM23 defines 3rd value of 2nd row
  78467. * @param initialM24 defines 4th value of 2nd row
  78468. * @param initialM31 defines 1st value of 3rd row
  78469. * @param initialM32 defines 2nd value of 3rd row
  78470. * @param initialM33 defines 3rd value of 3rd row
  78471. * @param initialM34 defines 4th value of 3rd row
  78472. * @param initialM41 defines 1st value of 4th row
  78473. * @param initialM42 defines 2nd value of 4th row
  78474. * @param initialM43 defines 3rd value of 4th row
  78475. * @param initialM44 defines 4th value of 4th row
  78476. * @param result defines the target matrix
  78477. */
  78478. 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;
  78479. /**
  78480. * Creates new matrix from a list of values (16)
  78481. * @param initialM11 defines 1st value of 1st row
  78482. * @param initialM12 defines 2nd value of 1st row
  78483. * @param initialM13 defines 3rd value of 1st row
  78484. * @param initialM14 defines 4th value of 1st row
  78485. * @param initialM21 defines 1st value of 2nd row
  78486. * @param initialM22 defines 2nd value of 2nd row
  78487. * @param initialM23 defines 3rd value of 2nd row
  78488. * @param initialM24 defines 4th value of 2nd row
  78489. * @param initialM31 defines 1st value of 3rd row
  78490. * @param initialM32 defines 2nd value of 3rd row
  78491. * @param initialM33 defines 3rd value of 3rd row
  78492. * @param initialM34 defines 4th value of 3rd row
  78493. * @param initialM41 defines 1st value of 4th row
  78494. * @param initialM42 defines 2nd value of 4th row
  78495. * @param initialM43 defines 3rd value of 4th row
  78496. * @param initialM44 defines 4th value of 4th row
  78497. * @returns the new matrix
  78498. */
  78499. 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;
  78500. /**
  78501. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78502. * @param scale defines the scale vector3
  78503. * @param rotation defines the rotation quaternion
  78504. * @param translation defines the translation vector3
  78505. * @returns a new matrix
  78506. */
  78507. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  78508. /**
  78509. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  78510. * @param scale defines the scale vector3
  78511. * @param rotation defines the rotation quaternion
  78512. * @param translation defines the translation vector3
  78513. * @param result defines the target matrix
  78514. */
  78515. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  78516. /**
  78517. * Creates a new identity matrix
  78518. * @returns a new identity matrix
  78519. */
  78520. static Identity(): Matrix;
  78521. /**
  78522. * Creates a new identity matrix and stores the result in a given matrix
  78523. * @param result defines the target matrix
  78524. */
  78525. static IdentityToRef(result: Matrix): void;
  78526. /**
  78527. * Creates a new zero matrix
  78528. * @returns a new zero matrix
  78529. */
  78530. static Zero(): Matrix;
  78531. /**
  78532. * Creates a new rotation matrix for "angle" radians around the X axis
  78533. * @param angle defines the angle (in radians) to use
  78534. * @return the new matrix
  78535. */
  78536. static RotationX(angle: number): Matrix;
  78537. /**
  78538. * Creates a new matrix as the invert of a given matrix
  78539. * @param source defines the source matrix
  78540. * @returns the new matrix
  78541. */
  78542. static Invert(source: DeepImmutable<Matrix>): Matrix;
  78543. /**
  78544. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  78545. * @param angle defines the angle (in radians) to use
  78546. * @param result defines the target matrix
  78547. */
  78548. static RotationXToRef(angle: number, result: Matrix): void;
  78549. /**
  78550. * Creates a new rotation matrix for "angle" radians around the Y axis
  78551. * @param angle defines the angle (in radians) to use
  78552. * @return the new matrix
  78553. */
  78554. static RotationY(angle: number): Matrix;
  78555. /**
  78556. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  78557. * @param angle defines the angle (in radians) to use
  78558. * @param result defines the target matrix
  78559. */
  78560. static RotationYToRef(angle: number, result: Matrix): void;
  78561. /**
  78562. * Creates a new rotation matrix for "angle" radians around the Z axis
  78563. * @param angle defines the angle (in radians) to use
  78564. * @return the new matrix
  78565. */
  78566. static RotationZ(angle: number): Matrix;
  78567. /**
  78568. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  78569. * @param angle defines the angle (in radians) to use
  78570. * @param result defines the target matrix
  78571. */
  78572. static RotationZToRef(angle: number, result: Matrix): void;
  78573. /**
  78574. * Creates a new rotation matrix for "angle" radians around the given axis
  78575. * @param axis defines the axis to use
  78576. * @param angle defines the angle (in radians) to use
  78577. * @return the new matrix
  78578. */
  78579. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  78580. /**
  78581. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  78582. * @param axis defines the axis to use
  78583. * @param angle defines the angle (in radians) to use
  78584. * @param result defines the target matrix
  78585. */
  78586. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  78587. /**
  78588. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  78589. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  78590. * @param from defines the vector to align
  78591. * @param to defines the vector to align to
  78592. * @param result defines the target matrix
  78593. */
  78594. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  78595. /**
  78596. * Creates a rotation matrix
  78597. * @param yaw defines the yaw angle in radians (Y axis)
  78598. * @param pitch defines the pitch angle in radians (X axis)
  78599. * @param roll defines the roll angle in radians (X axis)
  78600. * @returns the new rotation matrix
  78601. */
  78602. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  78603. /**
  78604. * Creates a rotation matrix and stores it in a given matrix
  78605. * @param yaw defines the yaw angle in radians (Y axis)
  78606. * @param pitch defines the pitch angle in radians (X axis)
  78607. * @param roll defines the roll angle in radians (X axis)
  78608. * @param result defines the target matrix
  78609. */
  78610. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  78611. /**
  78612. * Creates a scaling matrix
  78613. * @param x defines the scale factor on X axis
  78614. * @param y defines the scale factor on Y axis
  78615. * @param z defines the scale factor on Z axis
  78616. * @returns the new matrix
  78617. */
  78618. static Scaling(x: number, y: number, z: number): Matrix;
  78619. /**
  78620. * Creates a scaling matrix and stores it in a given matrix
  78621. * @param x defines the scale factor on X axis
  78622. * @param y defines the scale factor on Y axis
  78623. * @param z defines the scale factor on Z axis
  78624. * @param result defines the target matrix
  78625. */
  78626. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  78627. /**
  78628. * Creates a translation matrix
  78629. * @param x defines the translation on X axis
  78630. * @param y defines the translation on Y axis
  78631. * @param z defines the translationon Z axis
  78632. * @returns the new matrix
  78633. */
  78634. static Translation(x: number, y: number, z: number): Matrix;
  78635. /**
  78636. * Creates a translation matrix and stores it in a given matrix
  78637. * @param x defines the translation on X axis
  78638. * @param y defines the translation on Y axis
  78639. * @param z defines the translationon Z axis
  78640. * @param result defines the target matrix
  78641. */
  78642. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  78643. /**
  78644. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78645. * @param startValue defines the start value
  78646. * @param endValue defines the end value
  78647. * @param gradient defines the gradient factor
  78648. * @returns the new matrix
  78649. */
  78650. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78651. /**
  78652. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  78653. * @param startValue defines the start value
  78654. * @param endValue defines the end value
  78655. * @param gradient defines the gradient factor
  78656. * @param result defines the Matrix object where to store data
  78657. */
  78658. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78659. /**
  78660. * Builds a new matrix whose values are computed by:
  78661. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78662. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78663. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78664. * @param startValue defines the first matrix
  78665. * @param endValue defines the second matrix
  78666. * @param gradient defines the gradient between the two matrices
  78667. * @returns the new matrix
  78668. */
  78669. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  78670. /**
  78671. * Update a matrix to values which are computed by:
  78672. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  78673. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  78674. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  78675. * @param startValue defines the first matrix
  78676. * @param endValue defines the second matrix
  78677. * @param gradient defines the gradient between the two matrices
  78678. * @param result defines the target matrix
  78679. */
  78680. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  78681. /**
  78682. * 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"
  78683. * This function works in left handed mode
  78684. * @param eye defines the final position of the entity
  78685. * @param target defines where the entity should look at
  78686. * @param up defines the up vector for the entity
  78687. * @returns the new matrix
  78688. */
  78689. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78690. /**
  78691. * 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".
  78692. * This function works in left handed mode
  78693. * @param eye defines the final position of the entity
  78694. * @param target defines where the entity should look at
  78695. * @param up defines the up vector for the entity
  78696. * @param result defines the target matrix
  78697. */
  78698. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78699. /**
  78700. * 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"
  78701. * This function works in right handed mode
  78702. * @param eye defines the final position of the entity
  78703. * @param target defines where the entity should look at
  78704. * @param up defines the up vector for the entity
  78705. * @returns the new matrix
  78706. */
  78707. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  78708. /**
  78709. * 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".
  78710. * This function works in right handed mode
  78711. * @param eye defines the final position of the entity
  78712. * @param target defines where the entity should look at
  78713. * @param up defines the up vector for the entity
  78714. * @param result defines the target matrix
  78715. */
  78716. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  78717. /**
  78718. * Create a left-handed orthographic projection matrix
  78719. * @param width defines the viewport width
  78720. * @param height defines the viewport height
  78721. * @param znear defines the near clip plane
  78722. * @param zfar defines the far clip plane
  78723. * @returns a new matrix as a left-handed orthographic projection matrix
  78724. */
  78725. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78726. /**
  78727. * Store a left-handed orthographic projection to a given matrix
  78728. * @param width defines the viewport width
  78729. * @param height defines the viewport height
  78730. * @param znear defines the near clip plane
  78731. * @param zfar defines the far clip plane
  78732. * @param result defines the target matrix
  78733. */
  78734. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  78735. /**
  78736. * Create a left-handed orthographic projection matrix
  78737. * @param left defines the viewport left coordinate
  78738. * @param right defines the viewport right coordinate
  78739. * @param bottom defines the viewport bottom coordinate
  78740. * @param top defines the viewport top coordinate
  78741. * @param znear defines the near clip plane
  78742. * @param zfar defines the far clip plane
  78743. * @returns a new matrix as a left-handed orthographic projection matrix
  78744. */
  78745. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78746. /**
  78747. * Stores a left-handed orthographic projection into a given matrix
  78748. * @param left defines the viewport left coordinate
  78749. * @param right defines the viewport right coordinate
  78750. * @param bottom defines the viewport bottom coordinate
  78751. * @param top defines the viewport top coordinate
  78752. * @param znear defines the near clip plane
  78753. * @param zfar defines the far clip plane
  78754. * @param result defines the target matrix
  78755. */
  78756. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78757. /**
  78758. * Creates a right-handed orthographic projection matrix
  78759. * @param left defines the viewport left coordinate
  78760. * @param right defines the viewport right coordinate
  78761. * @param bottom defines the viewport bottom coordinate
  78762. * @param top defines the viewport top coordinate
  78763. * @param znear defines the near clip plane
  78764. * @param zfar defines the far clip plane
  78765. * @returns a new matrix as a right-handed orthographic projection matrix
  78766. */
  78767. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  78768. /**
  78769. * Stores a right-handed orthographic projection into a given matrix
  78770. * @param left defines the viewport left coordinate
  78771. * @param right defines the viewport right coordinate
  78772. * @param bottom defines the viewport bottom coordinate
  78773. * @param top defines the viewport top coordinate
  78774. * @param znear defines the near clip plane
  78775. * @param zfar defines the far clip plane
  78776. * @param result defines the target matrix
  78777. */
  78778. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  78779. /**
  78780. * Creates a left-handed perspective projection matrix
  78781. * @param width defines the viewport width
  78782. * @param height defines the viewport height
  78783. * @param znear defines the near clip plane
  78784. * @param zfar defines the far clip plane
  78785. * @returns a new matrix as a left-handed perspective projection matrix
  78786. */
  78787. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  78788. /**
  78789. * Creates a left-handed perspective projection matrix
  78790. * @param fov defines the horizontal field of view
  78791. * @param aspect defines the aspect ratio
  78792. * @param znear defines the near clip plane
  78793. * @param zfar defines the far clip plane
  78794. * @returns a new matrix as a left-handed perspective projection matrix
  78795. */
  78796. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  78797. /**
  78798. * Stores a left-handed perspective projection into a given matrix
  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 defines the far clip plane
  78803. * @param result defines the target matrix
  78804. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78805. */
  78806. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78807. /**
  78808. * Stores a left-handed perspective projection into a given matrix with depth reversed
  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 not used as infinity is used as far clip
  78813. * @param result defines the target matrix
  78814. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78815. */
  78816. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78817. /**
  78818. * Creates a right-handed perspective projection matrix
  78819. * @param fov defines the horizontal field of view
  78820. * @param aspect defines the aspect ratio
  78821. * @param znear defines the near clip plane
  78822. * @param zfar defines the far clip plane
  78823. * @returns a new matrix as a right-handed perspective projection matrix
  78824. */
  78825. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  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 defines the far clip plane
  78832. * @param result defines the target matrix
  78833. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78834. */
  78835. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78836. /**
  78837. * Stores a right-handed perspective projection into a given matrix
  78838. * @param fov defines the horizontal field of view
  78839. * @param aspect defines the aspect ratio
  78840. * @param znear defines the near clip plane
  78841. * @param zfar not used as infinity is used as far clip
  78842. * @param result defines the target matrix
  78843. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  78844. */
  78845. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  78846. /**
  78847. * Stores a perspective projection for WebVR info a given matrix
  78848. * @param fov defines the field of view
  78849. * @param znear defines the near clip plane
  78850. * @param zfar defines the far clip plane
  78851. * @param result defines the target matrix
  78852. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  78853. */
  78854. static PerspectiveFovWebVRToRef(fov: {
  78855. upDegrees: number;
  78856. downDegrees: number;
  78857. leftDegrees: number;
  78858. rightDegrees: number;
  78859. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  78860. /**
  78861. * Computes a complete transformation matrix
  78862. * @param viewport defines the viewport to use
  78863. * @param world defines the world matrix
  78864. * @param view defines the view matrix
  78865. * @param projection defines the projection matrix
  78866. * @param zmin defines the near clip plane
  78867. * @param zmax defines the far clip plane
  78868. * @returns the transformation matrix
  78869. */
  78870. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  78871. /**
  78872. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  78873. * @param matrix defines the matrix to use
  78874. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  78875. */
  78876. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  78877. /**
  78878. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  78879. * @param matrix defines the matrix to use
  78880. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  78881. */
  78882. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  78883. /**
  78884. * Compute the transpose of a given matrix
  78885. * @param matrix defines the matrix to transpose
  78886. * @returns the new matrix
  78887. */
  78888. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  78889. /**
  78890. * Compute the transpose of a matrix and store it in a target matrix
  78891. * @param matrix defines the matrix to transpose
  78892. * @param result defines the target matrix
  78893. */
  78894. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  78895. /**
  78896. * Computes a reflection matrix from a plane
  78897. * @param plane defines the reflection plane
  78898. * @returns a new matrix
  78899. */
  78900. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  78901. /**
  78902. * Computes a reflection matrix from a plane
  78903. * @param plane defines the reflection plane
  78904. * @param result defines the target matrix
  78905. */
  78906. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  78907. /**
  78908. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  78909. * @param xaxis defines the value of the 1st axis
  78910. * @param yaxis defines the value of the 2nd axis
  78911. * @param zaxis defines the value of the 3rd axis
  78912. * @param result defines the target matrix
  78913. */
  78914. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  78915. /**
  78916. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  78917. * @param quat defines the quaternion to use
  78918. * @param result defines the target matrix
  78919. */
  78920. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  78921. }
  78922. /**
  78923. * @hidden
  78924. */
  78925. export class TmpVectors {
  78926. static Vector2: Vector2[];
  78927. static Vector3: Vector3[];
  78928. static Vector4: Vector4[];
  78929. static Quaternion: Quaternion[];
  78930. static Matrix: Matrix[];
  78931. }
  78932. }
  78933. declare module BABYLON {
  78934. /**
  78935. * Defines potential orientation for back face culling
  78936. */
  78937. export enum Orientation {
  78938. /**
  78939. * Clockwise
  78940. */
  78941. CW = 0,
  78942. /** Counter clockwise */
  78943. CCW = 1
  78944. }
  78945. /** Class used to represent a Bezier curve */
  78946. export class BezierCurve {
  78947. /**
  78948. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  78949. * @param t defines the time
  78950. * @param x1 defines the left coordinate on X axis
  78951. * @param y1 defines the left coordinate on Y axis
  78952. * @param x2 defines the right coordinate on X axis
  78953. * @param y2 defines the right coordinate on Y axis
  78954. * @returns the interpolated value
  78955. */
  78956. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  78957. }
  78958. /**
  78959. * Defines angle representation
  78960. */
  78961. export class Angle {
  78962. private _radians;
  78963. /**
  78964. * Creates an Angle object of "radians" radians (float).
  78965. * @param radians the angle in radians
  78966. */
  78967. constructor(radians: number);
  78968. /**
  78969. * Get value in degrees
  78970. * @returns the Angle value in degrees (float)
  78971. */
  78972. degrees(): number;
  78973. /**
  78974. * Get value in radians
  78975. * @returns the Angle value in radians (float)
  78976. */
  78977. radians(): number;
  78978. /**
  78979. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  78980. * @param a defines first vector
  78981. * @param b defines second vector
  78982. * @returns a new Angle
  78983. */
  78984. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  78985. /**
  78986. * Gets a new Angle object from the given float in radians
  78987. * @param radians defines the angle value in radians
  78988. * @returns a new Angle
  78989. */
  78990. static FromRadians(radians: number): Angle;
  78991. /**
  78992. * Gets a new Angle object from the given float in degrees
  78993. * @param degrees defines the angle value in degrees
  78994. * @returns a new Angle
  78995. */
  78996. static FromDegrees(degrees: number): Angle;
  78997. }
  78998. /**
  78999. * This represents an arc in a 2d space.
  79000. */
  79001. export class Arc2 {
  79002. /** Defines the start point of the arc */
  79003. startPoint: Vector2;
  79004. /** Defines the mid point of the arc */
  79005. midPoint: Vector2;
  79006. /** Defines the end point of the arc */
  79007. endPoint: Vector2;
  79008. /**
  79009. * Defines the center point of the arc.
  79010. */
  79011. centerPoint: Vector2;
  79012. /**
  79013. * Defines the radius of the arc.
  79014. */
  79015. radius: number;
  79016. /**
  79017. * Defines the angle of the arc (from mid point to end point).
  79018. */
  79019. angle: Angle;
  79020. /**
  79021. * Defines the start angle of the arc (from start point to middle point).
  79022. */
  79023. startAngle: Angle;
  79024. /**
  79025. * Defines the orientation of the arc (clock wise/counter clock wise).
  79026. */
  79027. orientation: Orientation;
  79028. /**
  79029. * Creates an Arc object from the three given points : start, middle and end.
  79030. * @param startPoint Defines the start point of the arc
  79031. * @param midPoint Defines the midlle point of the arc
  79032. * @param endPoint Defines the end point of the arc
  79033. */
  79034. constructor(
  79035. /** Defines the start point of the arc */
  79036. startPoint: Vector2,
  79037. /** Defines the mid point of the arc */
  79038. midPoint: Vector2,
  79039. /** Defines the end point of the arc */
  79040. endPoint: Vector2);
  79041. }
  79042. /**
  79043. * Represents a 2D path made up of multiple 2D points
  79044. */
  79045. export class Path2 {
  79046. private _points;
  79047. private _length;
  79048. /**
  79049. * If the path start and end point are the same
  79050. */
  79051. closed: boolean;
  79052. /**
  79053. * Creates a Path2 object from the starting 2D coordinates x and y.
  79054. * @param x the starting points x value
  79055. * @param y the starting points y value
  79056. */
  79057. constructor(x: number, y: number);
  79058. /**
  79059. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  79060. * @param x the added points x value
  79061. * @param y the added points y value
  79062. * @returns the updated Path2.
  79063. */
  79064. addLineTo(x: number, y: number): Path2;
  79065. /**
  79066. * 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.
  79067. * @param midX middle point x value
  79068. * @param midY middle point y value
  79069. * @param endX end point x value
  79070. * @param endY end point y value
  79071. * @param numberOfSegments (default: 36)
  79072. * @returns the updated Path2.
  79073. */
  79074. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  79075. /**
  79076. * Closes the Path2.
  79077. * @returns the Path2.
  79078. */
  79079. close(): Path2;
  79080. /**
  79081. * Gets the sum of the distance between each sequential point in the path
  79082. * @returns the Path2 total length (float).
  79083. */
  79084. length(): number;
  79085. /**
  79086. * Gets the points which construct the path
  79087. * @returns the Path2 internal array of points.
  79088. */
  79089. getPoints(): Vector2[];
  79090. /**
  79091. * Retreives the point at the distance aways from the starting point
  79092. * @param normalizedLengthPosition the length along the path to retreive the point from
  79093. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  79094. */
  79095. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  79096. /**
  79097. * Creates a new path starting from an x and y position
  79098. * @param x starting x value
  79099. * @param y starting y value
  79100. * @returns a new Path2 starting at the coordinates (x, y).
  79101. */
  79102. static StartingAt(x: number, y: number): Path2;
  79103. }
  79104. /**
  79105. * Represents a 3D path made up of multiple 3D points
  79106. */
  79107. export class Path3D {
  79108. /**
  79109. * an array of Vector3, the curve axis of the Path3D
  79110. */
  79111. path: Vector3[];
  79112. private _curve;
  79113. private _distances;
  79114. private _tangents;
  79115. private _normals;
  79116. private _binormals;
  79117. private _raw;
  79118. private _alignTangentsWithPath;
  79119. private readonly _pointAtData;
  79120. /**
  79121. * new Path3D(path, normal, raw)
  79122. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  79123. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  79124. * @param path an array of Vector3, the curve axis of the Path3D
  79125. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  79126. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  79127. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  79128. */
  79129. constructor(
  79130. /**
  79131. * an array of Vector3, the curve axis of the Path3D
  79132. */
  79133. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  79134. /**
  79135. * Returns the Path3D array of successive Vector3 designing its curve.
  79136. * @returns the Path3D array of successive Vector3 designing its curve.
  79137. */
  79138. getCurve(): Vector3[];
  79139. /**
  79140. * Returns the Path3D array of successive Vector3 designing its curve.
  79141. * @returns the Path3D array of successive Vector3 designing its curve.
  79142. */
  79143. getPoints(): Vector3[];
  79144. /**
  79145. * @returns the computed length (float) of the path.
  79146. */
  79147. length(): number;
  79148. /**
  79149. * Returns an array populated with tangent vectors on each Path3D curve point.
  79150. * @returns an array populated with tangent vectors on each Path3D curve point.
  79151. */
  79152. getTangents(): Vector3[];
  79153. /**
  79154. * Returns an array populated with normal vectors on each Path3D curve point.
  79155. * @returns an array populated with normal vectors on each Path3D curve point.
  79156. */
  79157. getNormals(): Vector3[];
  79158. /**
  79159. * Returns an array populated with binormal vectors on each Path3D curve point.
  79160. * @returns an array populated with binormal vectors on each Path3D curve point.
  79161. */
  79162. getBinormals(): Vector3[];
  79163. /**
  79164. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  79165. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  79166. */
  79167. getDistances(): number[];
  79168. /**
  79169. * Returns an interpolated point along this path
  79170. * @param position the position of the point along this path, from 0.0 to 1.0
  79171. * @returns a new Vector3 as the point
  79172. */
  79173. getPointAt(position: number): Vector3;
  79174. /**
  79175. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79176. * @param position the position of the point along this path, from 0.0 to 1.0
  79177. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  79178. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  79179. */
  79180. getTangentAt(position: number, interpolated?: boolean): Vector3;
  79181. /**
  79182. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  79183. * @param position the position of the point along this path, from 0.0 to 1.0
  79184. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  79185. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  79186. */
  79187. getNormalAt(position: number, interpolated?: boolean): Vector3;
  79188. /**
  79189. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  79190. * @param position the position of the point along this path, from 0.0 to 1.0
  79191. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  79192. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  79193. */
  79194. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  79195. /**
  79196. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  79197. * @param position the position of the point along this path, from 0.0 to 1.0
  79198. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  79199. */
  79200. getDistanceAt(position: number): number;
  79201. /**
  79202. * Returns the array index of the previous point of an interpolated point along this path
  79203. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79204. * @returns the array index
  79205. */
  79206. getPreviousPointIndexAt(position: number): number;
  79207. /**
  79208. * 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)
  79209. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  79210. * @returns the sub position
  79211. */
  79212. getSubPositionAt(position: number): number;
  79213. /**
  79214. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  79215. * @param target the vector of which to get the closest position to
  79216. * @returns the position of the closest virtual point on this path to the target vector
  79217. */
  79218. getClosestPositionTo(target: Vector3): number;
  79219. /**
  79220. * Returns a sub path (slice) of this path
  79221. * @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
  79222. * @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
  79223. * @returns a sub path (slice) of this path
  79224. */
  79225. slice(start?: number, end?: number): Path3D;
  79226. /**
  79227. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  79228. * @param path path which all values are copied into the curves points
  79229. * @param firstNormal which should be projected onto the curve
  79230. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  79231. * @returns the same object updated.
  79232. */
  79233. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  79234. private _compute;
  79235. private _getFirstNonNullVector;
  79236. private _getLastNonNullVector;
  79237. private _normalVector;
  79238. /**
  79239. * Updates the point at data for an interpolated point along this curve
  79240. * @param position the position of the point along this curve, from 0.0 to 1.0
  79241. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  79242. * @returns the (updated) point at data
  79243. */
  79244. private _updatePointAtData;
  79245. /**
  79246. * Updates the point at data from the specified parameters
  79247. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  79248. * @param point the interpolated point
  79249. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  79250. */
  79251. private _setPointAtData;
  79252. /**
  79253. * Updates the point at interpolation matrix for the tangents, normals and binormals
  79254. */
  79255. private _updateInterpolationMatrix;
  79256. }
  79257. /**
  79258. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79259. * A Curve3 is designed from a series of successive Vector3.
  79260. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  79261. */
  79262. export class Curve3 {
  79263. private _points;
  79264. private _length;
  79265. /**
  79266. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  79267. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  79268. * @param v1 (Vector3) the control point
  79269. * @param v2 (Vector3) the end point of the Quadratic Bezier
  79270. * @param nbPoints (integer) the wanted number of points in the curve
  79271. * @returns the created Curve3
  79272. */
  79273. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79274. /**
  79275. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  79276. * @param v0 (Vector3) the origin point of the Cubic Bezier
  79277. * @param v1 (Vector3) the first control point
  79278. * @param v2 (Vector3) the second control point
  79279. * @param v3 (Vector3) the end point of the Cubic Bezier
  79280. * @param nbPoints (integer) the wanted number of points in the curve
  79281. * @returns the created Curve3
  79282. */
  79283. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79284. /**
  79285. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  79286. * @param p1 (Vector3) the origin point of the Hermite Spline
  79287. * @param t1 (Vector3) the tangent vector at the origin point
  79288. * @param p2 (Vector3) the end point of the Hermite Spline
  79289. * @param t2 (Vector3) the tangent vector at the end point
  79290. * @param nbPoints (integer) the wanted number of points in the curve
  79291. * @returns the created Curve3
  79292. */
  79293. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  79294. /**
  79295. * Returns a Curve3 object along a CatmullRom Spline curve :
  79296. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  79297. * @param nbPoints (integer) the wanted number of points between each curve control points
  79298. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  79299. * @returns the created Curve3
  79300. */
  79301. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  79302. /**
  79303. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  79304. * A Curve3 is designed from a series of successive Vector3.
  79305. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  79306. * @param points points which make up the curve
  79307. */
  79308. constructor(points: Vector3[]);
  79309. /**
  79310. * @returns the Curve3 stored array of successive Vector3
  79311. */
  79312. getPoints(): Vector3[];
  79313. /**
  79314. * @returns the computed length (float) of the curve.
  79315. */
  79316. length(): number;
  79317. /**
  79318. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  79319. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  79320. * curveA and curveB keep unchanged.
  79321. * @param curve the curve to continue from this curve
  79322. * @returns the newly constructed curve
  79323. */
  79324. continue(curve: DeepImmutable<Curve3>): Curve3;
  79325. private _computeLength;
  79326. }
  79327. }
  79328. declare module BABYLON {
  79329. /**
  79330. * This represents the main contract an easing function should follow.
  79331. * Easing functions are used throughout the animation system.
  79332. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79333. */
  79334. export interface IEasingFunction {
  79335. /**
  79336. * Given an input gradient between 0 and 1, this returns the corrseponding value
  79337. * of the easing function.
  79338. * The link below provides some of the most common examples of easing functions.
  79339. * @see https://easings.net/
  79340. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79341. * @returns the corresponding value on the curve defined by the easing function
  79342. */
  79343. ease(gradient: number): number;
  79344. }
  79345. /**
  79346. * Base class used for every default easing function.
  79347. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79348. */
  79349. export class EasingFunction implements IEasingFunction {
  79350. /**
  79351. * Interpolation follows the mathematical formula associated with the easing function.
  79352. */
  79353. static readonly EASINGMODE_EASEIN: number;
  79354. /**
  79355. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  79356. */
  79357. static readonly EASINGMODE_EASEOUT: number;
  79358. /**
  79359. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  79360. */
  79361. static readonly EASINGMODE_EASEINOUT: number;
  79362. private _easingMode;
  79363. /**
  79364. * Sets the easing mode of the current function.
  79365. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  79366. */
  79367. setEasingMode(easingMode: number): void;
  79368. /**
  79369. * Gets the current easing mode.
  79370. * @returns the easing mode
  79371. */
  79372. getEasingMode(): number;
  79373. /**
  79374. * @hidden
  79375. */
  79376. easeInCore(gradient: number): number;
  79377. /**
  79378. * Given an input gradient between 0 and 1, this returns the corresponding value
  79379. * of the easing function.
  79380. * @param gradient Defines the value between 0 and 1 we want the easing value for
  79381. * @returns the corresponding value on the curve defined by the easing function
  79382. */
  79383. ease(gradient: number): number;
  79384. }
  79385. /**
  79386. * Easing function with a circle shape (see link below).
  79387. * @see https://easings.net/#easeInCirc
  79388. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79389. */
  79390. export class CircleEase extends EasingFunction implements IEasingFunction {
  79391. /** @hidden */
  79392. easeInCore(gradient: number): number;
  79393. }
  79394. /**
  79395. * Easing function with a ease back shape (see link below).
  79396. * @see https://easings.net/#easeInBack
  79397. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79398. */
  79399. export class BackEase extends EasingFunction implements IEasingFunction {
  79400. /** Defines the amplitude of the function */
  79401. amplitude: number;
  79402. /**
  79403. * Instantiates a back ease easing
  79404. * @see https://easings.net/#easeInBack
  79405. * @param amplitude Defines the amplitude of the function
  79406. */
  79407. constructor(
  79408. /** Defines the amplitude of the function */
  79409. amplitude?: number);
  79410. /** @hidden */
  79411. easeInCore(gradient: number): number;
  79412. }
  79413. /**
  79414. * Easing function with a bouncing shape (see link below).
  79415. * @see https://easings.net/#easeInBounce
  79416. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79417. */
  79418. export class BounceEase extends EasingFunction implements IEasingFunction {
  79419. /** Defines the number of bounces */
  79420. bounces: number;
  79421. /** Defines the amplitude of the bounce */
  79422. bounciness: number;
  79423. /**
  79424. * Instantiates a bounce easing
  79425. * @see https://easings.net/#easeInBounce
  79426. * @param bounces Defines the number of bounces
  79427. * @param bounciness Defines the amplitude of the bounce
  79428. */
  79429. constructor(
  79430. /** Defines the number of bounces */
  79431. bounces?: number,
  79432. /** Defines the amplitude of the bounce */
  79433. bounciness?: number);
  79434. /** @hidden */
  79435. easeInCore(gradient: number): number;
  79436. }
  79437. /**
  79438. * Easing function with a power of 3 shape (see link below).
  79439. * @see https://easings.net/#easeInCubic
  79440. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79441. */
  79442. export class CubicEase extends EasingFunction implements IEasingFunction {
  79443. /** @hidden */
  79444. easeInCore(gradient: number): number;
  79445. }
  79446. /**
  79447. * Easing function with an elastic shape (see link below).
  79448. * @see https://easings.net/#easeInElastic
  79449. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79450. */
  79451. export class ElasticEase extends EasingFunction implements IEasingFunction {
  79452. /** Defines the number of oscillations*/
  79453. oscillations: number;
  79454. /** Defines the amplitude of the oscillations*/
  79455. springiness: number;
  79456. /**
  79457. * Instantiates an elastic easing function
  79458. * @see https://easings.net/#easeInElastic
  79459. * @param oscillations Defines the number of oscillations
  79460. * @param springiness Defines the amplitude of the oscillations
  79461. */
  79462. constructor(
  79463. /** Defines the number of oscillations*/
  79464. oscillations?: number,
  79465. /** Defines the amplitude of the oscillations*/
  79466. springiness?: number);
  79467. /** @hidden */
  79468. easeInCore(gradient: number): number;
  79469. }
  79470. /**
  79471. * Easing function with an exponential shape (see link below).
  79472. * @see https://easings.net/#easeInExpo
  79473. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79474. */
  79475. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  79476. /** Defines the exponent of the function */
  79477. exponent: number;
  79478. /**
  79479. * Instantiates an exponential easing function
  79480. * @see https://easings.net/#easeInExpo
  79481. * @param exponent Defines the exponent of the function
  79482. */
  79483. constructor(
  79484. /** Defines the exponent of the function */
  79485. exponent?: number);
  79486. /** @hidden */
  79487. easeInCore(gradient: number): number;
  79488. }
  79489. /**
  79490. * Easing function with a power shape (see link below).
  79491. * @see https://easings.net/#easeInQuad
  79492. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79493. */
  79494. export class PowerEase extends EasingFunction implements IEasingFunction {
  79495. /** Defines the power of the function */
  79496. power: number;
  79497. /**
  79498. * Instantiates an power base easing function
  79499. * @see https://easings.net/#easeInQuad
  79500. * @param power Defines the power of the function
  79501. */
  79502. constructor(
  79503. /** Defines the power of the function */
  79504. power?: number);
  79505. /** @hidden */
  79506. easeInCore(gradient: number): number;
  79507. }
  79508. /**
  79509. * Easing function with a power of 2 shape (see link below).
  79510. * @see https://easings.net/#easeInQuad
  79511. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79512. */
  79513. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  79514. /** @hidden */
  79515. easeInCore(gradient: number): number;
  79516. }
  79517. /**
  79518. * Easing function with a power of 4 shape (see link below).
  79519. * @see https://easings.net/#easeInQuart
  79520. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79521. */
  79522. export class QuarticEase extends EasingFunction implements IEasingFunction {
  79523. /** @hidden */
  79524. easeInCore(gradient: number): number;
  79525. }
  79526. /**
  79527. * Easing function with a power of 5 shape (see link below).
  79528. * @see https://easings.net/#easeInQuint
  79529. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79530. */
  79531. export class QuinticEase extends EasingFunction implements IEasingFunction {
  79532. /** @hidden */
  79533. easeInCore(gradient: number): number;
  79534. }
  79535. /**
  79536. * Easing function with a sin shape (see link below).
  79537. * @see https://easings.net/#easeInSine
  79538. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79539. */
  79540. export class SineEase extends EasingFunction implements IEasingFunction {
  79541. /** @hidden */
  79542. easeInCore(gradient: number): number;
  79543. }
  79544. /**
  79545. * Easing function with a bezier shape (see link below).
  79546. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79547. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  79548. */
  79549. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  79550. /** Defines the x component of the start tangent in the bezier curve */
  79551. x1: number;
  79552. /** Defines the y component of the start tangent in the bezier curve */
  79553. y1: number;
  79554. /** Defines the x component of the end tangent in the bezier curve */
  79555. x2: number;
  79556. /** Defines the y component of the end tangent in the bezier curve */
  79557. y2: number;
  79558. /**
  79559. * Instantiates a bezier function
  79560. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  79561. * @param x1 Defines the x component of the start tangent in the bezier curve
  79562. * @param y1 Defines the y component of the start tangent in the bezier curve
  79563. * @param x2 Defines the x component of the end tangent in the bezier curve
  79564. * @param y2 Defines the y component of the end tangent in the bezier curve
  79565. */
  79566. constructor(
  79567. /** Defines the x component of the start tangent in the bezier curve */
  79568. x1?: number,
  79569. /** Defines the y component of the start tangent in the bezier curve */
  79570. y1?: number,
  79571. /** Defines the x component of the end tangent in the bezier curve */
  79572. x2?: number,
  79573. /** Defines the y component of the end tangent in the bezier curve */
  79574. y2?: number);
  79575. /** @hidden */
  79576. easeInCore(gradient: number): number;
  79577. }
  79578. }
  79579. declare module BABYLON {
  79580. /**
  79581. * Class used to hold a RBG color
  79582. */
  79583. export class Color3 {
  79584. /**
  79585. * Defines the red component (between 0 and 1, default is 0)
  79586. */
  79587. r: number;
  79588. /**
  79589. * Defines the green component (between 0 and 1, default is 0)
  79590. */
  79591. g: number;
  79592. /**
  79593. * Defines the blue component (between 0 and 1, default is 0)
  79594. */
  79595. b: number;
  79596. /**
  79597. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  79598. * @param r defines the red component (between 0 and 1, default is 0)
  79599. * @param g defines the green component (between 0 and 1, default is 0)
  79600. * @param b defines the blue component (between 0 and 1, default is 0)
  79601. */
  79602. constructor(
  79603. /**
  79604. * Defines the red component (between 0 and 1, default is 0)
  79605. */
  79606. r?: number,
  79607. /**
  79608. * Defines the green component (between 0 and 1, default is 0)
  79609. */
  79610. g?: number,
  79611. /**
  79612. * Defines the blue component (between 0 and 1, default is 0)
  79613. */
  79614. b?: number);
  79615. /**
  79616. * Creates a string with the Color3 current values
  79617. * @returns the string representation of the Color3 object
  79618. */
  79619. toString(): string;
  79620. /**
  79621. * Returns the string "Color3"
  79622. * @returns "Color3"
  79623. */
  79624. getClassName(): string;
  79625. /**
  79626. * Compute the Color3 hash code
  79627. * @returns an unique number that can be used to hash Color3 objects
  79628. */
  79629. getHashCode(): number;
  79630. /**
  79631. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  79632. * @param array defines the array where to store the r,g,b components
  79633. * @param index defines an optional index in the target array to define where to start storing values
  79634. * @returns the current Color3 object
  79635. */
  79636. toArray(array: FloatArray, index?: number): Color3;
  79637. /**
  79638. * Returns a new Color4 object from the current Color3 and the given alpha
  79639. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  79640. * @returns a new Color4 object
  79641. */
  79642. toColor4(alpha?: number): Color4;
  79643. /**
  79644. * Returns a new array populated with 3 numeric elements : red, green and blue values
  79645. * @returns the new array
  79646. */
  79647. asArray(): number[];
  79648. /**
  79649. * Returns the luminance value
  79650. * @returns a float value
  79651. */
  79652. toLuminance(): number;
  79653. /**
  79654. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  79655. * @param otherColor defines the second operand
  79656. * @returns the new Color3 object
  79657. */
  79658. multiply(otherColor: DeepImmutable<Color3>): Color3;
  79659. /**
  79660. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  79661. * @param otherColor defines the second operand
  79662. * @param result defines the Color3 object where to store the result
  79663. * @returns the current Color3
  79664. */
  79665. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79666. /**
  79667. * Determines equality between Color3 objects
  79668. * @param otherColor defines the second operand
  79669. * @returns true if the rgb values are equal to the given ones
  79670. */
  79671. equals(otherColor: DeepImmutable<Color3>): boolean;
  79672. /**
  79673. * Determines equality between the current Color3 object and a set of r,b,g values
  79674. * @param r defines the red component to check
  79675. * @param g defines the green component to check
  79676. * @param b defines the blue component to check
  79677. * @returns true if the rgb values are equal to the given ones
  79678. */
  79679. equalsFloats(r: number, g: number, b: number): boolean;
  79680. /**
  79681. * Multiplies in place each rgb value by scale
  79682. * @param scale defines the scaling factor
  79683. * @returns the updated Color3
  79684. */
  79685. scale(scale: number): Color3;
  79686. /**
  79687. * Multiplies the rgb values by scale and stores the result into "result"
  79688. * @param scale defines the scaling factor
  79689. * @param result defines the Color3 object where to store the result
  79690. * @returns the unmodified current Color3
  79691. */
  79692. scaleToRef(scale: number, result: Color3): Color3;
  79693. /**
  79694. * Scale the current Color3 values by a factor and add the result to a given Color3
  79695. * @param scale defines the scale factor
  79696. * @param result defines color to store the result into
  79697. * @returns the unmodified current Color3
  79698. */
  79699. scaleAndAddToRef(scale: number, result: Color3): Color3;
  79700. /**
  79701. * Clamps the rgb values by the min and max values and stores the result into "result"
  79702. * @param min defines minimum clamping value (default is 0)
  79703. * @param max defines maximum clamping value (default is 1)
  79704. * @param result defines color to store the result into
  79705. * @returns the original Color3
  79706. */
  79707. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  79708. /**
  79709. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  79710. * @param otherColor defines the second operand
  79711. * @returns the new Color3
  79712. */
  79713. add(otherColor: DeepImmutable<Color3>): Color3;
  79714. /**
  79715. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  79716. * @param otherColor defines the second operand
  79717. * @param result defines Color3 object to store the result into
  79718. * @returns the unmodified current Color3
  79719. */
  79720. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79721. /**
  79722. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  79723. * @param otherColor defines the second operand
  79724. * @returns the new Color3
  79725. */
  79726. subtract(otherColor: DeepImmutable<Color3>): Color3;
  79727. /**
  79728. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  79729. * @param otherColor defines the second operand
  79730. * @param result defines Color3 object to store the result into
  79731. * @returns the unmodified current Color3
  79732. */
  79733. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  79734. /**
  79735. * Copy the current object
  79736. * @returns a new Color3 copied the current one
  79737. */
  79738. clone(): Color3;
  79739. /**
  79740. * Copies the rgb values from the source in the current Color3
  79741. * @param source defines the source Color3 object
  79742. * @returns the updated Color3 object
  79743. */
  79744. copyFrom(source: DeepImmutable<Color3>): Color3;
  79745. /**
  79746. * Updates the Color3 rgb values from the given floats
  79747. * @param r defines the red component to read from
  79748. * @param g defines the green component to read from
  79749. * @param b defines the blue component to read from
  79750. * @returns the current Color3 object
  79751. */
  79752. copyFromFloats(r: number, g: number, b: number): Color3;
  79753. /**
  79754. * Updates the Color3 rgb values from the given floats
  79755. * @param r defines the red component to read from
  79756. * @param g defines the green component to read from
  79757. * @param b defines the blue component to read from
  79758. * @returns the current Color3 object
  79759. */
  79760. set(r: number, g: number, b: number): Color3;
  79761. /**
  79762. * Compute the Color3 hexadecimal code as a string
  79763. * @returns a string containing the hexadecimal representation of the Color3 object
  79764. */
  79765. toHexString(): string;
  79766. /**
  79767. * Computes a new Color3 converted from the current one to linear space
  79768. * @returns a new Color3 object
  79769. */
  79770. toLinearSpace(): Color3;
  79771. /**
  79772. * Converts current color in rgb space to HSV values
  79773. * @returns a new color3 representing the HSV values
  79774. */
  79775. toHSV(): Color3;
  79776. /**
  79777. * Converts current color in rgb space to HSV values
  79778. * @param result defines the Color3 where to store the HSV values
  79779. */
  79780. toHSVToRef(result: Color3): void;
  79781. /**
  79782. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  79783. * @param convertedColor defines the Color3 object where to store the linear space version
  79784. * @returns the unmodified Color3
  79785. */
  79786. toLinearSpaceToRef(convertedColor: Color3): Color3;
  79787. /**
  79788. * Computes a new Color3 converted from the current one to gamma space
  79789. * @returns a new Color3 object
  79790. */
  79791. toGammaSpace(): Color3;
  79792. /**
  79793. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  79794. * @param convertedColor defines the Color3 object where to store the gamma space version
  79795. * @returns the unmodified Color3
  79796. */
  79797. toGammaSpaceToRef(convertedColor: Color3): Color3;
  79798. private static _BlackReadOnly;
  79799. /**
  79800. * Convert Hue, saturation and value to a Color3 (RGB)
  79801. * @param hue defines the hue
  79802. * @param saturation defines the saturation
  79803. * @param value defines the value
  79804. * @param result defines the Color3 where to store the RGB values
  79805. */
  79806. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  79807. /**
  79808. * Creates a new Color3 from the string containing valid hexadecimal values
  79809. * @param hex defines a string containing valid hexadecimal values
  79810. * @returns a new Color3 object
  79811. */
  79812. static FromHexString(hex: string): Color3;
  79813. /**
  79814. * Creates a new Color3 from the starting index of the given array
  79815. * @param array defines the source array
  79816. * @param offset defines an offset in the source array
  79817. * @returns a new Color3 object
  79818. */
  79819. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  79820. /**
  79821. * Creates a new Color3 from integer values (< 256)
  79822. * @param r defines the red component to read from (value between 0 and 255)
  79823. * @param g defines the green component to read from (value between 0 and 255)
  79824. * @param b defines the blue component to read from (value between 0 and 255)
  79825. * @returns a new Color3 object
  79826. */
  79827. static FromInts(r: number, g: number, b: number): Color3;
  79828. /**
  79829. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79830. * @param start defines the start Color3 value
  79831. * @param end defines the end Color3 value
  79832. * @param amount defines the gradient value between start and end
  79833. * @returns a new Color3 object
  79834. */
  79835. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  79836. /**
  79837. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  79838. * @param left defines the start value
  79839. * @param right defines the end value
  79840. * @param amount defines the gradient factor
  79841. * @param result defines the Color3 object where to store the result
  79842. */
  79843. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  79844. /**
  79845. * Returns a Color3 value containing a red color
  79846. * @returns a new Color3 object
  79847. */
  79848. static Red(): Color3;
  79849. /**
  79850. * Returns a Color3 value containing a green color
  79851. * @returns a new Color3 object
  79852. */
  79853. static Green(): Color3;
  79854. /**
  79855. * Returns a Color3 value containing a blue color
  79856. * @returns a new Color3 object
  79857. */
  79858. static Blue(): Color3;
  79859. /**
  79860. * Returns a Color3 value containing a black color
  79861. * @returns a new Color3 object
  79862. */
  79863. static Black(): Color3;
  79864. /**
  79865. * Gets a Color3 value containing a black color that must not be updated
  79866. */
  79867. static get BlackReadOnly(): DeepImmutable<Color3>;
  79868. /**
  79869. * Returns a Color3 value containing a white color
  79870. * @returns a new Color3 object
  79871. */
  79872. static White(): Color3;
  79873. /**
  79874. * Returns a Color3 value containing a purple color
  79875. * @returns a new Color3 object
  79876. */
  79877. static Purple(): Color3;
  79878. /**
  79879. * Returns a Color3 value containing a magenta color
  79880. * @returns a new Color3 object
  79881. */
  79882. static Magenta(): Color3;
  79883. /**
  79884. * Returns a Color3 value containing a yellow color
  79885. * @returns a new Color3 object
  79886. */
  79887. static Yellow(): Color3;
  79888. /**
  79889. * Returns a Color3 value containing a gray color
  79890. * @returns a new Color3 object
  79891. */
  79892. static Gray(): Color3;
  79893. /**
  79894. * Returns a Color3 value containing a teal color
  79895. * @returns a new Color3 object
  79896. */
  79897. static Teal(): Color3;
  79898. /**
  79899. * Returns a Color3 value containing a random color
  79900. * @returns a new Color3 object
  79901. */
  79902. static Random(): Color3;
  79903. }
  79904. /**
  79905. * Class used to hold a RBGA color
  79906. */
  79907. export class Color4 {
  79908. /**
  79909. * Defines the red component (between 0 and 1, default is 0)
  79910. */
  79911. r: number;
  79912. /**
  79913. * Defines the green component (between 0 and 1, default is 0)
  79914. */
  79915. g: number;
  79916. /**
  79917. * Defines the blue component (between 0 and 1, default is 0)
  79918. */
  79919. b: number;
  79920. /**
  79921. * Defines the alpha component (between 0 and 1, default is 1)
  79922. */
  79923. a: number;
  79924. /**
  79925. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  79926. * @param r defines the red component (between 0 and 1, default is 0)
  79927. * @param g defines the green component (between 0 and 1, default is 0)
  79928. * @param b defines the blue component (between 0 and 1, default is 0)
  79929. * @param a defines the alpha component (between 0 and 1, default is 1)
  79930. */
  79931. constructor(
  79932. /**
  79933. * Defines the red component (between 0 and 1, default is 0)
  79934. */
  79935. r?: number,
  79936. /**
  79937. * Defines the green component (between 0 and 1, default is 0)
  79938. */
  79939. g?: number,
  79940. /**
  79941. * Defines the blue component (between 0 and 1, default is 0)
  79942. */
  79943. b?: number,
  79944. /**
  79945. * Defines the alpha component (between 0 and 1, default is 1)
  79946. */
  79947. a?: number);
  79948. /**
  79949. * Adds in place the given Color4 values to the current Color4 object
  79950. * @param right defines the second operand
  79951. * @returns the current updated Color4 object
  79952. */
  79953. addInPlace(right: DeepImmutable<Color4>): Color4;
  79954. /**
  79955. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  79956. * @returns the new array
  79957. */
  79958. asArray(): number[];
  79959. /**
  79960. * Stores from the starting index in the given array the Color4 successive values
  79961. * @param array defines the array where to store the r,g,b components
  79962. * @param index defines an optional index in the target array to define where to start storing values
  79963. * @returns the current Color4 object
  79964. */
  79965. toArray(array: number[], index?: number): Color4;
  79966. /**
  79967. * Determines equality between Color4 objects
  79968. * @param otherColor defines the second operand
  79969. * @returns true if the rgba values are equal to the given ones
  79970. */
  79971. equals(otherColor: DeepImmutable<Color4>): boolean;
  79972. /**
  79973. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  79974. * @param right defines the second operand
  79975. * @returns a new Color4 object
  79976. */
  79977. add(right: DeepImmutable<Color4>): Color4;
  79978. /**
  79979. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  79980. * @param right defines the second operand
  79981. * @returns a new Color4 object
  79982. */
  79983. subtract(right: DeepImmutable<Color4>): Color4;
  79984. /**
  79985. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  79986. * @param right defines the second operand
  79987. * @param result defines the Color4 object where to store the result
  79988. * @returns the current Color4 object
  79989. */
  79990. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  79991. /**
  79992. * Creates a new Color4 with the current Color4 values multiplied by scale
  79993. * @param scale defines the scaling factor to apply
  79994. * @returns a new Color4 object
  79995. */
  79996. scale(scale: number): Color4;
  79997. /**
  79998. * Multiplies the current Color4 values by scale and stores the result in "result"
  79999. * @param scale defines the scaling factor to apply
  80000. * @param result defines the Color4 object where to store the result
  80001. * @returns the current unmodified Color4
  80002. */
  80003. scaleToRef(scale: number, result: Color4): Color4;
  80004. /**
  80005. * Scale the current Color4 values by a factor and add the result to a given Color4
  80006. * @param scale defines the scale factor
  80007. * @param result defines the Color4 object where to store the result
  80008. * @returns the unmodified current Color4
  80009. */
  80010. scaleAndAddToRef(scale: number, result: Color4): Color4;
  80011. /**
  80012. * Clamps the rgb values by the min and max values and stores the result into "result"
  80013. * @param min defines minimum clamping value (default is 0)
  80014. * @param max defines maximum clamping value (default is 1)
  80015. * @param result defines color to store the result into.
  80016. * @returns the cuurent Color4
  80017. */
  80018. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  80019. /**
  80020. * Multipy an Color4 value by another and return a new Color4 object
  80021. * @param color defines the Color4 value to multiply by
  80022. * @returns a new Color4 object
  80023. */
  80024. multiply(color: Color4): Color4;
  80025. /**
  80026. * Multipy a Color4 value by another and push the result in a reference value
  80027. * @param color defines the Color4 value to multiply by
  80028. * @param result defines the Color4 to fill the result in
  80029. * @returns the result Color4
  80030. */
  80031. multiplyToRef(color: Color4, result: Color4): Color4;
  80032. /**
  80033. * Creates a string with the Color4 current values
  80034. * @returns the string representation of the Color4 object
  80035. */
  80036. toString(): string;
  80037. /**
  80038. * Returns the string "Color4"
  80039. * @returns "Color4"
  80040. */
  80041. getClassName(): string;
  80042. /**
  80043. * Compute the Color4 hash code
  80044. * @returns an unique number that can be used to hash Color4 objects
  80045. */
  80046. getHashCode(): number;
  80047. /**
  80048. * Creates a new Color4 copied from the current one
  80049. * @returns a new Color4 object
  80050. */
  80051. clone(): Color4;
  80052. /**
  80053. * Copies the given Color4 values into the current one
  80054. * @param source defines the source Color4 object
  80055. * @returns the current updated Color4 object
  80056. */
  80057. copyFrom(source: Color4): Color4;
  80058. /**
  80059. * Copies the given float values into the current one
  80060. * @param r defines the red component to read from
  80061. * @param g defines the green component to read from
  80062. * @param b defines the blue component to read from
  80063. * @param a defines the alpha component to read from
  80064. * @returns the current updated Color4 object
  80065. */
  80066. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  80067. /**
  80068. * Copies the given float values into the current one
  80069. * @param r defines the red component to read from
  80070. * @param g defines the green component to read from
  80071. * @param b defines the blue component to read from
  80072. * @param a defines the alpha component to read from
  80073. * @returns the current updated Color4 object
  80074. */
  80075. set(r: number, g: number, b: number, a: number): Color4;
  80076. /**
  80077. * Compute the Color4 hexadecimal code as a string
  80078. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  80079. * @returns a string containing the hexadecimal representation of the Color4 object
  80080. */
  80081. toHexString(returnAsColor3?: boolean): string;
  80082. /**
  80083. * Computes a new Color4 converted from the current one to linear space
  80084. * @returns a new Color4 object
  80085. */
  80086. toLinearSpace(): Color4;
  80087. /**
  80088. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  80089. * @param convertedColor defines the Color4 object where to store the linear space version
  80090. * @returns the unmodified Color4
  80091. */
  80092. toLinearSpaceToRef(convertedColor: Color4): Color4;
  80093. /**
  80094. * Computes a new Color4 converted from the current one to gamma space
  80095. * @returns a new Color4 object
  80096. */
  80097. toGammaSpace(): Color4;
  80098. /**
  80099. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  80100. * @param convertedColor defines the Color4 object where to store the gamma space version
  80101. * @returns the unmodified Color4
  80102. */
  80103. toGammaSpaceToRef(convertedColor: Color4): Color4;
  80104. /**
  80105. * Creates a new Color4 from the string containing valid hexadecimal values
  80106. * @param hex defines a string containing valid hexadecimal values
  80107. * @returns a new Color4 object
  80108. */
  80109. static FromHexString(hex: string): Color4;
  80110. /**
  80111. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80112. * @param left defines the start value
  80113. * @param right defines the end value
  80114. * @param amount defines the gradient factor
  80115. * @returns a new Color4 object
  80116. */
  80117. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  80118. /**
  80119. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  80120. * @param left defines the start value
  80121. * @param right defines the end value
  80122. * @param amount defines the gradient factor
  80123. * @param result defines the Color4 object where to store data
  80124. */
  80125. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  80126. /**
  80127. * Creates a new Color4 from a Color3 and an alpha value
  80128. * @param color3 defines the source Color3 to read from
  80129. * @param alpha defines the alpha component (1.0 by default)
  80130. * @returns a new Color4 object
  80131. */
  80132. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  80133. /**
  80134. * Creates a new Color4 from the starting index element of the given array
  80135. * @param array defines the source array to read from
  80136. * @param offset defines the offset in the source array
  80137. * @returns a new Color4 object
  80138. */
  80139. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  80140. /**
  80141. * Creates a new Color3 from integer values (< 256)
  80142. * @param r defines the red component to read from (value between 0 and 255)
  80143. * @param g defines the green component to read from (value between 0 and 255)
  80144. * @param b defines the blue component to read from (value between 0 and 255)
  80145. * @param a defines the alpha component to read from (value between 0 and 255)
  80146. * @returns a new Color3 object
  80147. */
  80148. static FromInts(r: number, g: number, b: number, a: number): Color4;
  80149. /**
  80150. * Check the content of a given array and convert it to an array containing RGBA data
  80151. * If the original array was already containing count * 4 values then it is returned directly
  80152. * @param colors defines the array to check
  80153. * @param count defines the number of RGBA data to expect
  80154. * @returns an array containing count * 4 values (RGBA)
  80155. */
  80156. static CheckColors4(colors: number[], count: number): number[];
  80157. }
  80158. /**
  80159. * @hidden
  80160. */
  80161. export class TmpColors {
  80162. static Color3: Color3[];
  80163. static Color4: Color4[];
  80164. }
  80165. }
  80166. declare module BABYLON {
  80167. /**
  80168. * Defines an interface which represents an animation key frame
  80169. */
  80170. export interface IAnimationKey {
  80171. /**
  80172. * Frame of the key frame
  80173. */
  80174. frame: number;
  80175. /**
  80176. * Value at the specifies key frame
  80177. */
  80178. value: any;
  80179. /**
  80180. * The input tangent for the cubic hermite spline
  80181. */
  80182. inTangent?: any;
  80183. /**
  80184. * The output tangent for the cubic hermite spline
  80185. */
  80186. outTangent?: any;
  80187. /**
  80188. * The animation interpolation type
  80189. */
  80190. interpolation?: AnimationKeyInterpolation;
  80191. }
  80192. /**
  80193. * Enum for the animation key frame interpolation type
  80194. */
  80195. export enum AnimationKeyInterpolation {
  80196. /**
  80197. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  80198. */
  80199. STEP = 1
  80200. }
  80201. }
  80202. declare module BABYLON {
  80203. /**
  80204. * Represents the range of an animation
  80205. */
  80206. export class AnimationRange {
  80207. /**The name of the animation range**/
  80208. name: string;
  80209. /**The starting frame of the animation */
  80210. from: number;
  80211. /**The ending frame of the animation*/
  80212. to: number;
  80213. /**
  80214. * Initializes the range of an animation
  80215. * @param name The name of the animation range
  80216. * @param from The starting frame of the animation
  80217. * @param to The ending frame of the animation
  80218. */
  80219. constructor(
  80220. /**The name of the animation range**/
  80221. name: string,
  80222. /**The starting frame of the animation */
  80223. from: number,
  80224. /**The ending frame of the animation*/
  80225. to: number);
  80226. /**
  80227. * Makes a copy of the animation range
  80228. * @returns A copy of the animation range
  80229. */
  80230. clone(): AnimationRange;
  80231. }
  80232. }
  80233. declare module BABYLON {
  80234. /**
  80235. * Composed of a frame, and an action function
  80236. */
  80237. export class AnimationEvent {
  80238. /** The frame for which the event is triggered **/
  80239. frame: number;
  80240. /** The event to perform when triggered **/
  80241. action: (currentFrame: number) => void;
  80242. /** Specifies if the event should be triggered only once**/
  80243. onlyOnce?: boolean | undefined;
  80244. /**
  80245. * Specifies if the animation event is done
  80246. */
  80247. isDone: boolean;
  80248. /**
  80249. * Initializes the animation event
  80250. * @param frame The frame for which the event is triggered
  80251. * @param action The event to perform when triggered
  80252. * @param onlyOnce Specifies if the event should be triggered only once
  80253. */
  80254. constructor(
  80255. /** The frame for which the event is triggered **/
  80256. frame: number,
  80257. /** The event to perform when triggered **/
  80258. action: (currentFrame: number) => void,
  80259. /** Specifies if the event should be triggered only once**/
  80260. onlyOnce?: boolean | undefined);
  80261. /** @hidden */
  80262. _clone(): AnimationEvent;
  80263. }
  80264. }
  80265. declare module BABYLON {
  80266. /**
  80267. * Interface used to define a behavior
  80268. */
  80269. export interface Behavior<T> {
  80270. /** gets or sets behavior's name */
  80271. name: string;
  80272. /**
  80273. * Function called when the behavior needs to be initialized (after attaching it to a target)
  80274. */
  80275. init(): void;
  80276. /**
  80277. * Called when the behavior is attached to a target
  80278. * @param target defines the target where the behavior is attached to
  80279. */
  80280. attach(target: T): void;
  80281. /**
  80282. * Called when the behavior is detached from its target
  80283. */
  80284. detach(): void;
  80285. }
  80286. /**
  80287. * Interface implemented by classes supporting behaviors
  80288. */
  80289. export interface IBehaviorAware<T> {
  80290. /**
  80291. * Attach a behavior
  80292. * @param behavior defines the behavior to attach
  80293. * @returns the current host
  80294. */
  80295. addBehavior(behavior: Behavior<T>): T;
  80296. /**
  80297. * Remove a behavior from the current object
  80298. * @param behavior defines the behavior to detach
  80299. * @returns the current host
  80300. */
  80301. removeBehavior(behavior: Behavior<T>): T;
  80302. /**
  80303. * Gets a behavior using its name to search
  80304. * @param name defines the name to search
  80305. * @returns the behavior or null if not found
  80306. */
  80307. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  80308. }
  80309. }
  80310. declare module BABYLON {
  80311. /**
  80312. * Defines an array and its length.
  80313. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  80314. */
  80315. export interface ISmartArrayLike<T> {
  80316. /**
  80317. * The data of the array.
  80318. */
  80319. data: Array<T>;
  80320. /**
  80321. * The active length of the array.
  80322. */
  80323. length: number;
  80324. }
  80325. /**
  80326. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80327. */
  80328. export class SmartArray<T> implements ISmartArrayLike<T> {
  80329. /**
  80330. * The full set of data from the array.
  80331. */
  80332. data: Array<T>;
  80333. /**
  80334. * The active length of the array.
  80335. */
  80336. length: number;
  80337. protected _id: number;
  80338. /**
  80339. * Instantiates a Smart Array.
  80340. * @param capacity defines the default capacity of the array.
  80341. */
  80342. constructor(capacity: number);
  80343. /**
  80344. * Pushes a value at the end of the active data.
  80345. * @param value defines the object to push in the array.
  80346. */
  80347. push(value: T): void;
  80348. /**
  80349. * Iterates over the active data and apply the lambda to them.
  80350. * @param func defines the action to apply on each value.
  80351. */
  80352. forEach(func: (content: T) => void): void;
  80353. /**
  80354. * Sorts the full sets of data.
  80355. * @param compareFn defines the comparison function to apply.
  80356. */
  80357. sort(compareFn: (a: T, b: T) => number): void;
  80358. /**
  80359. * Resets the active data to an empty array.
  80360. */
  80361. reset(): void;
  80362. /**
  80363. * Releases all the data from the array as well as the array.
  80364. */
  80365. dispose(): void;
  80366. /**
  80367. * Concats the active data with a given array.
  80368. * @param array defines the data to concatenate with.
  80369. */
  80370. concat(array: any): void;
  80371. /**
  80372. * Returns the position of a value in the active data.
  80373. * @param value defines the value to find the index for
  80374. * @returns the index if found in the active data otherwise -1
  80375. */
  80376. indexOf(value: T): number;
  80377. /**
  80378. * Returns whether an element is part of the active data.
  80379. * @param value defines the value to look for
  80380. * @returns true if found in the active data otherwise false
  80381. */
  80382. contains(value: T): boolean;
  80383. private static _GlobalId;
  80384. }
  80385. /**
  80386. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  80387. * The data in this array can only be present once
  80388. */
  80389. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  80390. private _duplicateId;
  80391. /**
  80392. * Pushes a value at the end of the active data.
  80393. * THIS DOES NOT PREVENT DUPPLICATE DATA
  80394. * @param value defines the object to push in the array.
  80395. */
  80396. push(value: T): void;
  80397. /**
  80398. * Pushes a value at the end of the active data.
  80399. * If the data is already present, it won t be added again
  80400. * @param value defines the object to push in the array.
  80401. * @returns true if added false if it was already present
  80402. */
  80403. pushNoDuplicate(value: T): boolean;
  80404. /**
  80405. * Resets the active data to an empty array.
  80406. */
  80407. reset(): void;
  80408. /**
  80409. * Concats the active data with a given array.
  80410. * This ensures no dupplicate will be present in the result.
  80411. * @param array defines the data to concatenate with.
  80412. */
  80413. concatWithNoDuplicate(array: any): void;
  80414. }
  80415. }
  80416. declare module BABYLON {
  80417. /**
  80418. * @ignore
  80419. * This is a list of all the different input types that are available in the application.
  80420. * Fo instance: ArcRotateCameraGamepadInput...
  80421. */
  80422. export var CameraInputTypes: {};
  80423. /**
  80424. * This is the contract to implement in order to create a new input class.
  80425. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  80426. */
  80427. export interface ICameraInput<TCamera extends Camera> {
  80428. /**
  80429. * Defines the camera the input is attached to.
  80430. */
  80431. camera: Nullable<TCamera>;
  80432. /**
  80433. * Gets the class name of the current intput.
  80434. * @returns the class name
  80435. */
  80436. getClassName(): string;
  80437. /**
  80438. * Get the friendly name associated with the input class.
  80439. * @returns the input friendly name
  80440. */
  80441. getSimpleName(): string;
  80442. /**
  80443. * Attach the input controls to a specific dom element to get the input from.
  80444. * @param element Defines the element the controls should be listened from
  80445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80446. */
  80447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  80448. /**
  80449. * Detach the current controls from the specified dom element.
  80450. * @param element Defines the element to stop listening the inputs from
  80451. */
  80452. detachControl(element: Nullable<HTMLElement>): void;
  80453. /**
  80454. * Update the current camera state depending on the inputs that have been used this frame.
  80455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80456. */
  80457. checkInputs?: () => void;
  80458. }
  80459. /**
  80460. * Represents a map of input types to input instance or input index to input instance.
  80461. */
  80462. export interface CameraInputsMap<TCamera extends Camera> {
  80463. /**
  80464. * Accessor to the input by input type.
  80465. */
  80466. [name: string]: ICameraInput<TCamera>;
  80467. /**
  80468. * Accessor to the input by input index.
  80469. */
  80470. [idx: number]: ICameraInput<TCamera>;
  80471. }
  80472. /**
  80473. * This represents the input manager used within a camera.
  80474. * It helps dealing with all the different kind of input attached to a camera.
  80475. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80476. */
  80477. export class CameraInputsManager<TCamera extends Camera> {
  80478. /**
  80479. * Defines the list of inputs attahed to the camera.
  80480. */
  80481. attached: CameraInputsMap<TCamera>;
  80482. /**
  80483. * Defines the dom element the camera is collecting inputs from.
  80484. * This is null if the controls have not been attached.
  80485. */
  80486. attachedElement: Nullable<HTMLElement>;
  80487. /**
  80488. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80489. */
  80490. noPreventDefault: boolean;
  80491. /**
  80492. * Defined the camera the input manager belongs to.
  80493. */
  80494. camera: TCamera;
  80495. /**
  80496. * Update the current camera state depending on the inputs that have been used this frame.
  80497. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  80498. */
  80499. checkInputs: () => void;
  80500. /**
  80501. * Instantiate a new Camera Input Manager.
  80502. * @param camera Defines the camera the input manager blongs to
  80503. */
  80504. constructor(camera: TCamera);
  80505. /**
  80506. * Add an input method to a camera
  80507. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  80508. * @param input camera input method
  80509. */
  80510. add(input: ICameraInput<TCamera>): void;
  80511. /**
  80512. * Remove a specific input method from a camera
  80513. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  80514. * @param inputToRemove camera input method
  80515. */
  80516. remove(inputToRemove: ICameraInput<TCamera>): void;
  80517. /**
  80518. * Remove a specific input type from a camera
  80519. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  80520. * @param inputType the type of the input to remove
  80521. */
  80522. removeByType(inputType: string): void;
  80523. private _addCheckInputs;
  80524. /**
  80525. * Attach the input controls to the currently attached dom element to listen the events from.
  80526. * @param input Defines the input to attach
  80527. */
  80528. attachInput(input: ICameraInput<TCamera>): void;
  80529. /**
  80530. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  80531. * @param element Defines the dom element to collect the events from
  80532. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  80533. */
  80534. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  80535. /**
  80536. * Detach the current manager inputs controls from a specific dom element.
  80537. * @param element Defines the dom element to collect the events from
  80538. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  80539. */
  80540. detachElement(element: HTMLElement, disconnect?: boolean): void;
  80541. /**
  80542. * Rebuild the dynamic inputCheck function from the current list of
  80543. * defined inputs in the manager.
  80544. */
  80545. rebuildInputCheck(): void;
  80546. /**
  80547. * Remove all attached input methods from a camera
  80548. */
  80549. clear(): void;
  80550. /**
  80551. * Serialize the current input manager attached to a camera.
  80552. * This ensures than once parsed,
  80553. * the input associated to the camera will be identical to the current ones
  80554. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  80555. */
  80556. serialize(serializedCamera: any): void;
  80557. /**
  80558. * Parses an input manager serialized JSON to restore the previous list of inputs
  80559. * and states associated to a camera.
  80560. * @param parsedCamera Defines the JSON to parse
  80561. */
  80562. parse(parsedCamera: any): void;
  80563. }
  80564. }
  80565. declare module BABYLON {
  80566. /**
  80567. * Class used to store data that will be store in GPU memory
  80568. */
  80569. export class Buffer {
  80570. private _engine;
  80571. private _buffer;
  80572. /** @hidden */
  80573. _data: Nullable<DataArray>;
  80574. private _updatable;
  80575. private _instanced;
  80576. private _divisor;
  80577. /**
  80578. * Gets the byte stride.
  80579. */
  80580. readonly byteStride: number;
  80581. /**
  80582. * Constructor
  80583. * @param engine the engine
  80584. * @param data the data to use for this buffer
  80585. * @param updatable whether the data is updatable
  80586. * @param stride the stride (optional)
  80587. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80588. * @param instanced whether the buffer is instanced (optional)
  80589. * @param useBytes set to true if the stride in in bytes (optional)
  80590. * @param divisor sets an optional divisor for instances (1 by default)
  80591. */
  80592. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  80593. /**
  80594. * Create a new VertexBuffer based on the current buffer
  80595. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80596. * @param offset defines offset in the buffer (0 by default)
  80597. * @param size defines the size in floats of attributes (position is 3 for instance)
  80598. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80599. * @param instanced defines if the vertex buffer contains indexed data
  80600. * @param useBytes defines if the offset and stride are in bytes *
  80601. * @param divisor sets an optional divisor for instances (1 by default)
  80602. * @returns the new vertex buffer
  80603. */
  80604. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  80605. /**
  80606. * Gets a boolean indicating if the Buffer is updatable?
  80607. * @returns true if the buffer is updatable
  80608. */
  80609. isUpdatable(): boolean;
  80610. /**
  80611. * Gets current buffer's data
  80612. * @returns a DataArray or null
  80613. */
  80614. getData(): Nullable<DataArray>;
  80615. /**
  80616. * Gets underlying native buffer
  80617. * @returns underlying native buffer
  80618. */
  80619. getBuffer(): Nullable<DataBuffer>;
  80620. /**
  80621. * Gets the stride in float32 units (i.e. byte stride / 4).
  80622. * May not be an integer if the byte stride is not divisible by 4.
  80623. * @returns the stride in float32 units
  80624. * @deprecated Please use byteStride instead.
  80625. */
  80626. getStrideSize(): number;
  80627. /**
  80628. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80629. * @param data defines the data to store
  80630. */
  80631. create(data?: Nullable<DataArray>): void;
  80632. /** @hidden */
  80633. _rebuild(): void;
  80634. /**
  80635. * Update current buffer data
  80636. * @param data defines the data to store
  80637. */
  80638. update(data: DataArray): void;
  80639. /**
  80640. * Updates the data directly.
  80641. * @param data the new data
  80642. * @param offset the new offset
  80643. * @param vertexCount the vertex count (optional)
  80644. * @param useBytes set to true if the offset is in bytes
  80645. */
  80646. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  80647. /**
  80648. * Release all resources
  80649. */
  80650. dispose(): void;
  80651. }
  80652. /**
  80653. * Specialized buffer used to store vertex data
  80654. */
  80655. export class VertexBuffer {
  80656. /** @hidden */
  80657. _buffer: Buffer;
  80658. private _kind;
  80659. private _size;
  80660. private _ownsBuffer;
  80661. private _instanced;
  80662. private _instanceDivisor;
  80663. /**
  80664. * The byte type.
  80665. */
  80666. static readonly BYTE: number;
  80667. /**
  80668. * The unsigned byte type.
  80669. */
  80670. static readonly UNSIGNED_BYTE: number;
  80671. /**
  80672. * The short type.
  80673. */
  80674. static readonly SHORT: number;
  80675. /**
  80676. * The unsigned short type.
  80677. */
  80678. static readonly UNSIGNED_SHORT: number;
  80679. /**
  80680. * The integer type.
  80681. */
  80682. static readonly INT: number;
  80683. /**
  80684. * The unsigned integer type.
  80685. */
  80686. static readonly UNSIGNED_INT: number;
  80687. /**
  80688. * The float type.
  80689. */
  80690. static readonly FLOAT: number;
  80691. /**
  80692. * Gets or sets the instance divisor when in instanced mode
  80693. */
  80694. get instanceDivisor(): number;
  80695. set instanceDivisor(value: number);
  80696. /**
  80697. * Gets the byte stride.
  80698. */
  80699. readonly byteStride: number;
  80700. /**
  80701. * Gets the byte offset.
  80702. */
  80703. readonly byteOffset: number;
  80704. /**
  80705. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  80706. */
  80707. readonly normalized: boolean;
  80708. /**
  80709. * Gets the data type of each component in the array.
  80710. */
  80711. readonly type: number;
  80712. /**
  80713. * Constructor
  80714. * @param engine the engine
  80715. * @param data the data to use for this vertex buffer
  80716. * @param kind the vertex buffer kind
  80717. * @param updatable whether the data is updatable
  80718. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80719. * @param stride the stride (optional)
  80720. * @param instanced whether the buffer is instanced (optional)
  80721. * @param offset the offset of the data (optional)
  80722. * @param size the number of components (optional)
  80723. * @param type the type of the component (optional)
  80724. * @param normalized whether the data contains normalized data (optional)
  80725. * @param useBytes set to true if stride and offset are in bytes (optional)
  80726. * @param divisor defines the instance divisor to use (1 by default)
  80727. */
  80728. 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);
  80729. /** @hidden */
  80730. _rebuild(): void;
  80731. /**
  80732. * Returns the kind of the VertexBuffer (string)
  80733. * @returns a string
  80734. */
  80735. getKind(): string;
  80736. /**
  80737. * Gets a boolean indicating if the VertexBuffer is updatable?
  80738. * @returns true if the buffer is updatable
  80739. */
  80740. isUpdatable(): boolean;
  80741. /**
  80742. * Gets current buffer's data
  80743. * @returns a DataArray or null
  80744. */
  80745. getData(): Nullable<DataArray>;
  80746. /**
  80747. * Gets underlying native buffer
  80748. * @returns underlying native buffer
  80749. */
  80750. getBuffer(): Nullable<DataBuffer>;
  80751. /**
  80752. * Gets the stride in float32 units (i.e. byte stride / 4).
  80753. * May not be an integer if the byte stride is not divisible by 4.
  80754. * @returns the stride in float32 units
  80755. * @deprecated Please use byteStride instead.
  80756. */
  80757. getStrideSize(): number;
  80758. /**
  80759. * Returns the offset as a multiple of the type byte length.
  80760. * @returns the offset in bytes
  80761. * @deprecated Please use byteOffset instead.
  80762. */
  80763. getOffset(): number;
  80764. /**
  80765. * Returns the number of components per vertex attribute (integer)
  80766. * @returns the size in float
  80767. */
  80768. getSize(): number;
  80769. /**
  80770. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  80771. * @returns true if this buffer is instanced
  80772. */
  80773. getIsInstanced(): boolean;
  80774. /**
  80775. * Returns the instancing divisor, zero for non-instanced (integer).
  80776. * @returns a number
  80777. */
  80778. getInstanceDivisor(): number;
  80779. /**
  80780. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80781. * @param data defines the data to store
  80782. */
  80783. create(data?: DataArray): void;
  80784. /**
  80785. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  80786. * This function will create a new buffer if the current one is not updatable
  80787. * @param data defines the data to store
  80788. */
  80789. update(data: DataArray): void;
  80790. /**
  80791. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  80792. * Returns the directly updated WebGLBuffer.
  80793. * @param data the new data
  80794. * @param offset the new offset
  80795. * @param useBytes set to true if the offset is in bytes
  80796. */
  80797. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  80798. /**
  80799. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  80800. */
  80801. dispose(): void;
  80802. /**
  80803. * Enumerates each value of this vertex buffer as numbers.
  80804. * @param count the number of values to enumerate
  80805. * @param callback the callback function called for each value
  80806. */
  80807. forEach(count: number, callback: (value: number, index: number) => void): void;
  80808. /**
  80809. * Positions
  80810. */
  80811. static readonly PositionKind: string;
  80812. /**
  80813. * Normals
  80814. */
  80815. static readonly NormalKind: string;
  80816. /**
  80817. * Tangents
  80818. */
  80819. static readonly TangentKind: string;
  80820. /**
  80821. * Texture coordinates
  80822. */
  80823. static readonly UVKind: string;
  80824. /**
  80825. * Texture coordinates 2
  80826. */
  80827. static readonly UV2Kind: string;
  80828. /**
  80829. * Texture coordinates 3
  80830. */
  80831. static readonly UV3Kind: string;
  80832. /**
  80833. * Texture coordinates 4
  80834. */
  80835. static readonly UV4Kind: string;
  80836. /**
  80837. * Texture coordinates 5
  80838. */
  80839. static readonly UV5Kind: string;
  80840. /**
  80841. * Texture coordinates 6
  80842. */
  80843. static readonly UV6Kind: string;
  80844. /**
  80845. * Colors
  80846. */
  80847. static readonly ColorKind: string;
  80848. /**
  80849. * Matrix indices (for bones)
  80850. */
  80851. static readonly MatricesIndicesKind: string;
  80852. /**
  80853. * Matrix weights (for bones)
  80854. */
  80855. static readonly MatricesWeightsKind: string;
  80856. /**
  80857. * Additional matrix indices (for bones)
  80858. */
  80859. static readonly MatricesIndicesExtraKind: string;
  80860. /**
  80861. * Additional matrix weights (for bones)
  80862. */
  80863. static readonly MatricesWeightsExtraKind: string;
  80864. /**
  80865. * Deduces the stride given a kind.
  80866. * @param kind The kind string to deduce
  80867. * @returns The deduced stride
  80868. */
  80869. static DeduceStride(kind: string): number;
  80870. /**
  80871. * Gets the byte length of the given type.
  80872. * @param type the type
  80873. * @returns the number of bytes
  80874. */
  80875. static GetTypeByteLength(type: number): number;
  80876. /**
  80877. * Enumerates each value of the given parameters as numbers.
  80878. * @param data the data to enumerate
  80879. * @param byteOffset the byte offset of the data
  80880. * @param byteStride the byte stride of the data
  80881. * @param componentCount the number of components per element
  80882. * @param componentType the type of the component
  80883. * @param count the number of values to enumerate
  80884. * @param normalized whether the data is normalized
  80885. * @param callback the callback function called for each value
  80886. */
  80887. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  80888. private static _GetFloatValue;
  80889. }
  80890. }
  80891. declare module BABYLON {
  80892. /**
  80893. * @hidden
  80894. */
  80895. export class IntersectionInfo {
  80896. bu: Nullable<number>;
  80897. bv: Nullable<number>;
  80898. distance: number;
  80899. faceId: number;
  80900. subMeshId: number;
  80901. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  80902. }
  80903. }
  80904. declare module BABYLON {
  80905. /**
  80906. * Represens a plane by the equation ax + by + cz + d = 0
  80907. */
  80908. export class Plane {
  80909. private static _TmpMatrix;
  80910. /**
  80911. * Normal of the plane (a,b,c)
  80912. */
  80913. normal: Vector3;
  80914. /**
  80915. * d component of the plane
  80916. */
  80917. d: number;
  80918. /**
  80919. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  80920. * @param a a component of the plane
  80921. * @param b b component of the plane
  80922. * @param c c component of the plane
  80923. * @param d d component of the plane
  80924. */
  80925. constructor(a: number, b: number, c: number, d: number);
  80926. /**
  80927. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  80928. */
  80929. asArray(): number[];
  80930. /**
  80931. * @returns a new plane copied from the current Plane.
  80932. */
  80933. clone(): Plane;
  80934. /**
  80935. * @returns the string "Plane".
  80936. */
  80937. getClassName(): string;
  80938. /**
  80939. * @returns the Plane hash code.
  80940. */
  80941. getHashCode(): number;
  80942. /**
  80943. * Normalize the current Plane in place.
  80944. * @returns the updated Plane.
  80945. */
  80946. normalize(): Plane;
  80947. /**
  80948. * Applies a transformation the plane and returns the result
  80949. * @param transformation the transformation matrix to be applied to the plane
  80950. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  80951. */
  80952. transform(transformation: DeepImmutable<Matrix>): Plane;
  80953. /**
  80954. * Calcualtte the dot product between the point and the plane normal
  80955. * @param point point to calculate the dot product with
  80956. * @returns the dot product (float) of the point coordinates and the plane normal.
  80957. */
  80958. dotCoordinate(point: DeepImmutable<Vector3>): number;
  80959. /**
  80960. * Updates the current Plane from the plane defined by the three given points.
  80961. * @param point1 one of the points used to contruct the plane
  80962. * @param point2 one of the points used to contruct the plane
  80963. * @param point3 one of the points used to contruct the plane
  80964. * @returns the updated Plane.
  80965. */
  80966. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80967. /**
  80968. * Checks if the plane is facing a given direction
  80969. * @param direction the direction to check if the plane is facing
  80970. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  80971. * @returns True is the vector "direction" is the same side than the plane normal.
  80972. */
  80973. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  80974. /**
  80975. * Calculates the distance to a point
  80976. * @param point point to calculate distance to
  80977. * @returns the signed distance (float) from the given point to the Plane.
  80978. */
  80979. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  80980. /**
  80981. * Creates a plane from an array
  80982. * @param array the array to create a plane from
  80983. * @returns a new Plane from the given array.
  80984. */
  80985. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  80986. /**
  80987. * Creates a plane from three points
  80988. * @param point1 point used to create the plane
  80989. * @param point2 point used to create the plane
  80990. * @param point3 point used to create the plane
  80991. * @returns a new Plane defined by the three given points.
  80992. */
  80993. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  80994. /**
  80995. * Creates a plane from an origin point and a normal
  80996. * @param origin origin of the plane to be constructed
  80997. * @param normal normal of the plane to be constructed
  80998. * @returns a new Plane the normal vector to this plane at the given origin point.
  80999. * Note : the vector "normal" is updated because normalized.
  81000. */
  81001. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  81002. /**
  81003. * Calculates the distance from a plane and a point
  81004. * @param origin origin of the plane to be constructed
  81005. * @param normal normal of the plane to be constructed
  81006. * @param point point to calculate distance to
  81007. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  81008. */
  81009. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  81010. }
  81011. }
  81012. declare module BABYLON {
  81013. /**
  81014. * Class used to store bounding sphere information
  81015. */
  81016. export class BoundingSphere {
  81017. /**
  81018. * Gets the center of the bounding sphere in local space
  81019. */
  81020. readonly center: Vector3;
  81021. /**
  81022. * Radius of the bounding sphere in local space
  81023. */
  81024. radius: number;
  81025. /**
  81026. * Gets the center of the bounding sphere in world space
  81027. */
  81028. readonly centerWorld: Vector3;
  81029. /**
  81030. * Radius of the bounding sphere in world space
  81031. */
  81032. radiusWorld: number;
  81033. /**
  81034. * Gets the minimum vector in local space
  81035. */
  81036. readonly minimum: Vector3;
  81037. /**
  81038. * Gets the maximum vector in local space
  81039. */
  81040. readonly maximum: Vector3;
  81041. private _worldMatrix;
  81042. private static readonly TmpVector3;
  81043. /**
  81044. * Creates a new bounding sphere
  81045. * @param min defines the minimum vector (in local space)
  81046. * @param max defines the maximum vector (in local space)
  81047. * @param worldMatrix defines the new world matrix
  81048. */
  81049. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81050. /**
  81051. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  81052. * @param min defines the new minimum vector (in local space)
  81053. * @param max defines the new maximum vector (in local space)
  81054. * @param worldMatrix defines the new world matrix
  81055. */
  81056. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81057. /**
  81058. * Scale the current bounding sphere by applying a scale factor
  81059. * @param factor defines the scale factor to apply
  81060. * @returns the current bounding box
  81061. */
  81062. scale(factor: number): BoundingSphere;
  81063. /**
  81064. * Gets the world matrix of the bounding box
  81065. * @returns a matrix
  81066. */
  81067. getWorldMatrix(): DeepImmutable<Matrix>;
  81068. /** @hidden */
  81069. _update(worldMatrix: DeepImmutable<Matrix>): void;
  81070. /**
  81071. * Tests if the bounding sphere is intersecting the frustum planes
  81072. * @param frustumPlanes defines the frustum planes to test
  81073. * @returns true if there is an intersection
  81074. */
  81075. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81076. /**
  81077. * Tests if the bounding sphere center is in between the frustum planes.
  81078. * Used for optimistic fast inclusion.
  81079. * @param frustumPlanes defines the frustum planes to test
  81080. * @returns true if the sphere center is in between the frustum planes
  81081. */
  81082. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81083. /**
  81084. * Tests if a point is inside the bounding sphere
  81085. * @param point defines the point to test
  81086. * @returns true if the point is inside the bounding sphere
  81087. */
  81088. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81089. /**
  81090. * Checks if two sphere intersct
  81091. * @param sphere0 sphere 0
  81092. * @param sphere1 sphere 1
  81093. * @returns true if the speres intersect
  81094. */
  81095. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  81096. }
  81097. }
  81098. declare module BABYLON {
  81099. /**
  81100. * Class used to store bounding box information
  81101. */
  81102. export class BoundingBox implements ICullable {
  81103. /**
  81104. * Gets the 8 vectors representing the bounding box in local space
  81105. */
  81106. readonly vectors: Vector3[];
  81107. /**
  81108. * Gets the center of the bounding box in local space
  81109. */
  81110. readonly center: Vector3;
  81111. /**
  81112. * Gets the center of the bounding box in world space
  81113. */
  81114. readonly centerWorld: Vector3;
  81115. /**
  81116. * Gets the extend size in local space
  81117. */
  81118. readonly extendSize: Vector3;
  81119. /**
  81120. * Gets the extend size in world space
  81121. */
  81122. readonly extendSizeWorld: Vector3;
  81123. /**
  81124. * Gets the OBB (object bounding box) directions
  81125. */
  81126. readonly directions: Vector3[];
  81127. /**
  81128. * Gets the 8 vectors representing the bounding box in world space
  81129. */
  81130. readonly vectorsWorld: Vector3[];
  81131. /**
  81132. * Gets the minimum vector in world space
  81133. */
  81134. readonly minimumWorld: Vector3;
  81135. /**
  81136. * Gets the maximum vector in world space
  81137. */
  81138. readonly maximumWorld: Vector3;
  81139. /**
  81140. * Gets the minimum vector in local space
  81141. */
  81142. readonly minimum: Vector3;
  81143. /**
  81144. * Gets the maximum vector in local space
  81145. */
  81146. readonly maximum: Vector3;
  81147. private _worldMatrix;
  81148. private static readonly TmpVector3;
  81149. /**
  81150. * @hidden
  81151. */
  81152. _tag: number;
  81153. /**
  81154. * Creates a new bounding box
  81155. * @param min defines the minimum vector (in local space)
  81156. * @param max defines the maximum vector (in local space)
  81157. * @param worldMatrix defines the new world matrix
  81158. */
  81159. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81160. /**
  81161. * Recreates the entire bounding box from scratch as if we call the constructor in place
  81162. * @param min defines the new minimum vector (in local space)
  81163. * @param max defines the new maximum vector (in local space)
  81164. * @param worldMatrix defines the new world matrix
  81165. */
  81166. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81167. /**
  81168. * Scale the current bounding box by applying a scale factor
  81169. * @param factor defines the scale factor to apply
  81170. * @returns the current bounding box
  81171. */
  81172. scale(factor: number): BoundingBox;
  81173. /**
  81174. * Gets the world matrix of the bounding box
  81175. * @returns a matrix
  81176. */
  81177. getWorldMatrix(): DeepImmutable<Matrix>;
  81178. /** @hidden */
  81179. _update(world: DeepImmutable<Matrix>): void;
  81180. /**
  81181. * Tests if the bounding box is intersecting the frustum planes
  81182. * @param frustumPlanes defines the frustum planes to test
  81183. * @returns true if there is an intersection
  81184. */
  81185. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81186. /**
  81187. * Tests if the bounding box is entirely inside the frustum planes
  81188. * @param frustumPlanes defines the frustum planes to test
  81189. * @returns true if there is an inclusion
  81190. */
  81191. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81192. /**
  81193. * Tests if a point is inside the bounding box
  81194. * @param point defines the point to test
  81195. * @returns true if the point is inside the bounding box
  81196. */
  81197. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81198. /**
  81199. * Tests if the bounding box intersects with a bounding sphere
  81200. * @param sphere defines the sphere to test
  81201. * @returns true if there is an intersection
  81202. */
  81203. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  81204. /**
  81205. * Tests if the bounding box intersects with a box defined by a min and max vectors
  81206. * @param min defines the min vector to use
  81207. * @param max defines the max vector to use
  81208. * @returns true if there is an intersection
  81209. */
  81210. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  81211. /**
  81212. * Tests if two bounding boxes are intersections
  81213. * @param box0 defines the first box to test
  81214. * @param box1 defines the second box to test
  81215. * @returns true if there is an intersection
  81216. */
  81217. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  81218. /**
  81219. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  81220. * @param minPoint defines the minimum vector of the bounding box
  81221. * @param maxPoint defines the maximum vector of the bounding box
  81222. * @param sphereCenter defines the sphere center
  81223. * @param sphereRadius defines the sphere radius
  81224. * @returns true if there is an intersection
  81225. */
  81226. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  81227. /**
  81228. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  81229. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81230. * @param frustumPlanes defines the frustum planes to test
  81231. * @return true if there is an inclusion
  81232. */
  81233. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81234. /**
  81235. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  81236. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  81237. * @param frustumPlanes defines the frustum planes to test
  81238. * @return true if there is an intersection
  81239. */
  81240. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81241. }
  81242. }
  81243. declare module BABYLON {
  81244. /** @hidden */
  81245. export class Collider {
  81246. /** Define if a collision was found */
  81247. collisionFound: boolean;
  81248. /**
  81249. * Define last intersection point in local space
  81250. */
  81251. intersectionPoint: Vector3;
  81252. /**
  81253. * Define last collided mesh
  81254. */
  81255. collidedMesh: Nullable<AbstractMesh>;
  81256. private _collisionPoint;
  81257. private _planeIntersectionPoint;
  81258. private _tempVector;
  81259. private _tempVector2;
  81260. private _tempVector3;
  81261. private _tempVector4;
  81262. private _edge;
  81263. private _baseToVertex;
  81264. private _destinationPoint;
  81265. private _slidePlaneNormal;
  81266. private _displacementVector;
  81267. /** @hidden */
  81268. _radius: Vector3;
  81269. /** @hidden */
  81270. _retry: number;
  81271. private _velocity;
  81272. private _basePoint;
  81273. private _epsilon;
  81274. /** @hidden */
  81275. _velocityWorldLength: number;
  81276. /** @hidden */
  81277. _basePointWorld: Vector3;
  81278. private _velocityWorld;
  81279. private _normalizedVelocity;
  81280. /** @hidden */
  81281. _initialVelocity: Vector3;
  81282. /** @hidden */
  81283. _initialPosition: Vector3;
  81284. private _nearestDistance;
  81285. private _collisionMask;
  81286. get collisionMask(): number;
  81287. set collisionMask(mask: number);
  81288. /**
  81289. * Gets the plane normal used to compute the sliding response (in local space)
  81290. */
  81291. get slidePlaneNormal(): Vector3;
  81292. /** @hidden */
  81293. _initialize(source: Vector3, dir: Vector3, e: number): void;
  81294. /** @hidden */
  81295. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  81296. /** @hidden */
  81297. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  81298. /** @hidden */
  81299. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81300. /** @hidden */
  81301. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  81302. /** @hidden */
  81303. _getResponse(pos: Vector3, vel: Vector3): void;
  81304. }
  81305. }
  81306. declare module BABYLON {
  81307. /**
  81308. * Interface for cullable objects
  81309. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  81310. */
  81311. export interface ICullable {
  81312. /**
  81313. * Checks if the object or part of the object is in the frustum
  81314. * @param frustumPlanes Camera near/planes
  81315. * @returns true if the object is in frustum otherwise false
  81316. */
  81317. isInFrustum(frustumPlanes: Plane[]): boolean;
  81318. /**
  81319. * Checks if a cullable object (mesh...) is in the camera frustum
  81320. * Unlike isInFrustum this cheks the full bounding box
  81321. * @param frustumPlanes Camera near/planes
  81322. * @returns true if the object is in frustum otherwise false
  81323. */
  81324. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81325. }
  81326. /**
  81327. * Info for a bounding data of a mesh
  81328. */
  81329. export class BoundingInfo implements ICullable {
  81330. /**
  81331. * Bounding box for the mesh
  81332. */
  81333. readonly boundingBox: BoundingBox;
  81334. /**
  81335. * Bounding sphere for the mesh
  81336. */
  81337. readonly boundingSphere: BoundingSphere;
  81338. private _isLocked;
  81339. private static readonly TmpVector3;
  81340. /**
  81341. * Constructs bounding info
  81342. * @param minimum min vector of the bounding box/sphere
  81343. * @param maximum max vector of the bounding box/sphere
  81344. * @param worldMatrix defines the new world matrix
  81345. */
  81346. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  81347. /**
  81348. * Recreates the entire bounding info from scratch as if we call the constructor in place
  81349. * @param min defines the new minimum vector (in local space)
  81350. * @param max defines the new maximum vector (in local space)
  81351. * @param worldMatrix defines the new world matrix
  81352. */
  81353. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  81354. /**
  81355. * min vector of the bounding box/sphere
  81356. */
  81357. get minimum(): Vector3;
  81358. /**
  81359. * max vector of the bounding box/sphere
  81360. */
  81361. get maximum(): Vector3;
  81362. /**
  81363. * If the info is locked and won't be updated to avoid perf overhead
  81364. */
  81365. get isLocked(): boolean;
  81366. set isLocked(value: boolean);
  81367. /**
  81368. * Updates the bounding sphere and box
  81369. * @param world world matrix to be used to update
  81370. */
  81371. update(world: DeepImmutable<Matrix>): void;
  81372. /**
  81373. * Recreate the bounding info to be centered around a specific point given a specific extend.
  81374. * @param center New center of the bounding info
  81375. * @param extend New extend of the bounding info
  81376. * @returns the current bounding info
  81377. */
  81378. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  81379. /**
  81380. * Scale the current bounding info by applying a scale factor
  81381. * @param factor defines the scale factor to apply
  81382. * @returns the current bounding info
  81383. */
  81384. scale(factor: number): BoundingInfo;
  81385. /**
  81386. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  81387. * @param frustumPlanes defines the frustum to test
  81388. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  81389. * @returns true if the bounding info is in the frustum planes
  81390. */
  81391. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  81392. /**
  81393. * Gets the world distance between the min and max points of the bounding box
  81394. */
  81395. get diagonalLength(): number;
  81396. /**
  81397. * Checks if a cullable object (mesh...) is in the camera frustum
  81398. * Unlike isInFrustum this cheks the full bounding box
  81399. * @param frustumPlanes Camera near/planes
  81400. * @returns true if the object is in frustum otherwise false
  81401. */
  81402. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  81403. /** @hidden */
  81404. _checkCollision(collider: Collider): boolean;
  81405. /**
  81406. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  81407. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81408. * @param point the point to check intersection with
  81409. * @returns if the point intersects
  81410. */
  81411. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  81412. /**
  81413. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  81414. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  81415. * @param boundingInfo the bounding info to check intersection with
  81416. * @param precise if the intersection should be done using OBB
  81417. * @returns if the bounding info intersects
  81418. */
  81419. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  81420. }
  81421. }
  81422. declare module BABYLON {
  81423. /**
  81424. * Extracts minimum and maximum values from a list of indexed positions
  81425. * @param positions defines the positions to use
  81426. * @param indices defines the indices to the positions
  81427. * @param indexStart defines the start index
  81428. * @param indexCount defines the end index
  81429. * @param bias defines bias value to add to the result
  81430. * @return minimum and maximum values
  81431. */
  81432. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  81433. minimum: Vector3;
  81434. maximum: Vector3;
  81435. };
  81436. /**
  81437. * Extracts minimum and maximum values from a list of positions
  81438. * @param positions defines the positions to use
  81439. * @param start defines the start index in the positions array
  81440. * @param count defines the number of positions to handle
  81441. * @param bias defines bias value to add to the result
  81442. * @param stride defines the stride size to use (distance between two positions in the positions array)
  81443. * @return minimum and maximum values
  81444. */
  81445. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  81446. minimum: Vector3;
  81447. maximum: Vector3;
  81448. };
  81449. }
  81450. declare module BABYLON {
  81451. /** @hidden */
  81452. export class WebGLDataBuffer extends DataBuffer {
  81453. private _buffer;
  81454. constructor(resource: WebGLBuffer);
  81455. get underlyingResource(): any;
  81456. }
  81457. }
  81458. declare module BABYLON {
  81459. /** @hidden */
  81460. export class WebGLPipelineContext implements IPipelineContext {
  81461. engine: ThinEngine;
  81462. program: Nullable<WebGLProgram>;
  81463. context?: WebGLRenderingContext;
  81464. vertexShader?: WebGLShader;
  81465. fragmentShader?: WebGLShader;
  81466. isParallelCompiled: boolean;
  81467. onCompiled?: () => void;
  81468. transformFeedback?: WebGLTransformFeedback | null;
  81469. vertexCompilationError: Nullable<string>;
  81470. fragmentCompilationError: Nullable<string>;
  81471. programLinkError: Nullable<string>;
  81472. programValidationError: Nullable<string>;
  81473. get isAsync(): boolean;
  81474. get isReady(): boolean;
  81475. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  81476. _getVertexShaderCode(): string | null;
  81477. _getFragmentShaderCode(): string | null;
  81478. }
  81479. }
  81480. declare module BABYLON {
  81481. interface ThinEngine {
  81482. /**
  81483. * Create an uniform buffer
  81484. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81485. * @param elements defines the content of the uniform buffer
  81486. * @returns the webGL uniform buffer
  81487. */
  81488. createUniformBuffer(elements: FloatArray): DataBuffer;
  81489. /**
  81490. * Create a dynamic uniform buffer
  81491. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81492. * @param elements defines the content of the uniform buffer
  81493. * @returns the webGL uniform buffer
  81494. */
  81495. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  81496. /**
  81497. * Update an existing uniform buffer
  81498. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  81499. * @param uniformBuffer defines the target uniform buffer
  81500. * @param elements defines the content to update
  81501. * @param offset defines the offset in the uniform buffer where update should start
  81502. * @param count defines the size of the data to update
  81503. */
  81504. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  81505. /**
  81506. * Bind an uniform buffer to the current webGL context
  81507. * @param buffer defines the buffer to bind
  81508. */
  81509. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  81510. /**
  81511. * Bind a buffer to the current webGL context at a given location
  81512. * @param buffer defines the buffer to bind
  81513. * @param location defines the index where to bind the buffer
  81514. */
  81515. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  81516. /**
  81517. * Bind a specific block at a given index in a specific shader program
  81518. * @param pipelineContext defines the pipeline context to use
  81519. * @param blockName defines the block name
  81520. * @param index defines the index where to bind the block
  81521. */
  81522. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  81523. }
  81524. }
  81525. declare module BABYLON {
  81526. /**
  81527. * Uniform buffer objects.
  81528. *
  81529. * Handles blocks of uniform on the GPU.
  81530. *
  81531. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81532. *
  81533. * For more information, please refer to :
  81534. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81535. */
  81536. export class UniformBuffer {
  81537. private _engine;
  81538. private _buffer;
  81539. private _data;
  81540. private _bufferData;
  81541. private _dynamic?;
  81542. private _uniformLocations;
  81543. private _uniformSizes;
  81544. private _uniformLocationPointer;
  81545. private _needSync;
  81546. private _noUBO;
  81547. private _currentEffect;
  81548. /** @hidden */
  81549. _alreadyBound: boolean;
  81550. private static _MAX_UNIFORM_SIZE;
  81551. private static _tempBuffer;
  81552. /**
  81553. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  81554. * This is dynamic to allow compat with webgl 1 and 2.
  81555. * You will need to pass the name of the uniform as well as the value.
  81556. */
  81557. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  81558. /**
  81559. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  81560. * This is dynamic to allow compat with webgl 1 and 2.
  81561. * You will need to pass the name of the uniform as well as the value.
  81562. */
  81563. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  81564. /**
  81565. * Lambda to Update a single float in a uniform buffer.
  81566. * This is dynamic to allow compat with webgl 1 and 2.
  81567. * You will need to pass the name of the uniform as well as the value.
  81568. */
  81569. updateFloat: (name: string, x: number) => void;
  81570. /**
  81571. * Lambda to Update a vec2 of float in a uniform buffer.
  81572. * This is dynamic to allow compat with webgl 1 and 2.
  81573. * You will need to pass the name of the uniform as well as the value.
  81574. */
  81575. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  81576. /**
  81577. * Lambda to Update a vec3 of float in a uniform buffer.
  81578. * This is dynamic to allow compat with webgl 1 and 2.
  81579. * You will need to pass the name of the uniform as well as the value.
  81580. */
  81581. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  81582. /**
  81583. * Lambda to Update a vec4 of float in a uniform buffer.
  81584. * This is dynamic to allow compat with webgl 1 and 2.
  81585. * You will need to pass the name of the uniform as well as the value.
  81586. */
  81587. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  81588. /**
  81589. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  81590. * This is dynamic to allow compat with webgl 1 and 2.
  81591. * You will need to pass the name of the uniform as well as the value.
  81592. */
  81593. updateMatrix: (name: string, mat: Matrix) => void;
  81594. /**
  81595. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  81596. * This is dynamic to allow compat with webgl 1 and 2.
  81597. * You will need to pass the name of the uniform as well as the value.
  81598. */
  81599. updateVector3: (name: string, vector: Vector3) => void;
  81600. /**
  81601. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  81602. * This is dynamic to allow compat with webgl 1 and 2.
  81603. * You will need to pass the name of the uniform as well as the value.
  81604. */
  81605. updateVector4: (name: string, vector: Vector4) => void;
  81606. /**
  81607. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  81608. * This is dynamic to allow compat with webgl 1 and 2.
  81609. * You will need to pass the name of the uniform as well as the value.
  81610. */
  81611. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  81612. /**
  81613. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  81614. * This is dynamic to allow compat with webgl 1 and 2.
  81615. * You will need to pass the name of the uniform as well as the value.
  81616. */
  81617. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  81618. /**
  81619. * Instantiates a new Uniform buffer objects.
  81620. *
  81621. * Handles blocks of uniform on the GPU.
  81622. *
  81623. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  81624. *
  81625. * For more information, please refer to :
  81626. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  81627. * @param engine Define the engine the buffer is associated with
  81628. * @param data Define the data contained in the buffer
  81629. * @param dynamic Define if the buffer is updatable
  81630. */
  81631. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  81632. /**
  81633. * Indicates if the buffer is using the WebGL2 UBO implementation,
  81634. * or just falling back on setUniformXXX calls.
  81635. */
  81636. get useUbo(): boolean;
  81637. /**
  81638. * Indicates if the WebGL underlying uniform buffer is in sync
  81639. * with the javascript cache data.
  81640. */
  81641. get isSync(): boolean;
  81642. /**
  81643. * Indicates if the WebGL underlying uniform buffer is dynamic.
  81644. * Also, a dynamic UniformBuffer will disable cache verification and always
  81645. * update the underlying WebGL uniform buffer to the GPU.
  81646. * @returns if Dynamic, otherwise false
  81647. */
  81648. isDynamic(): boolean;
  81649. /**
  81650. * The data cache on JS side.
  81651. * @returns the underlying data as a float array
  81652. */
  81653. getData(): Float32Array;
  81654. /**
  81655. * The underlying WebGL Uniform buffer.
  81656. * @returns the webgl buffer
  81657. */
  81658. getBuffer(): Nullable<DataBuffer>;
  81659. /**
  81660. * std140 layout specifies how to align data within an UBO structure.
  81661. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  81662. * for specs.
  81663. */
  81664. private _fillAlignment;
  81665. /**
  81666. * Adds an uniform in the buffer.
  81667. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  81668. * for the layout to be correct !
  81669. * @param name Name of the uniform, as used in the uniform block in the shader.
  81670. * @param size Data size, or data directly.
  81671. */
  81672. addUniform(name: string, size: number | number[]): void;
  81673. /**
  81674. * Adds a Matrix 4x4 to the uniform buffer.
  81675. * @param name Name of the uniform, as used in the uniform block in the shader.
  81676. * @param mat A 4x4 matrix.
  81677. */
  81678. addMatrix(name: string, mat: Matrix): void;
  81679. /**
  81680. * Adds a vec2 to the uniform buffer.
  81681. * @param name Name of the uniform, as used in the uniform block in the shader.
  81682. * @param x Define the x component value of the vec2
  81683. * @param y Define the y component value of the vec2
  81684. */
  81685. addFloat2(name: string, x: number, y: number): void;
  81686. /**
  81687. * Adds a vec3 to the uniform buffer.
  81688. * @param name Name of the uniform, as used in the uniform block in the shader.
  81689. * @param x Define the x component value of the vec3
  81690. * @param y Define the y component value of the vec3
  81691. * @param z Define the z component value of the vec3
  81692. */
  81693. addFloat3(name: string, x: number, y: number, z: number): void;
  81694. /**
  81695. * Adds a vec3 to the uniform buffer.
  81696. * @param name Name of the uniform, as used in the uniform block in the shader.
  81697. * @param color Define the vec3 from a Color
  81698. */
  81699. addColor3(name: string, color: Color3): void;
  81700. /**
  81701. * Adds a vec4 to the uniform buffer.
  81702. * @param name Name of the uniform, as used in the uniform block in the shader.
  81703. * @param color Define the rgb components from a Color
  81704. * @param alpha Define the a component of the vec4
  81705. */
  81706. addColor4(name: string, color: Color3, alpha: number): void;
  81707. /**
  81708. * Adds a vec3 to the uniform buffer.
  81709. * @param name Name of the uniform, as used in the uniform block in the shader.
  81710. * @param vector Define the vec3 components from a Vector
  81711. */
  81712. addVector3(name: string, vector: Vector3): void;
  81713. /**
  81714. * Adds a Matrix 3x3 to the uniform buffer.
  81715. * @param name Name of the uniform, as used in the uniform block in the shader.
  81716. */
  81717. addMatrix3x3(name: string): void;
  81718. /**
  81719. * Adds a Matrix 2x2 to the uniform buffer.
  81720. * @param name Name of the uniform, as used in the uniform block in the shader.
  81721. */
  81722. addMatrix2x2(name: string): void;
  81723. /**
  81724. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  81725. */
  81726. create(): void;
  81727. /** @hidden */
  81728. _rebuild(): void;
  81729. /**
  81730. * Updates the WebGL Uniform Buffer on the GPU.
  81731. * If the `dynamic` flag is set to true, no cache comparison is done.
  81732. * Otherwise, the buffer will be updated only if the cache differs.
  81733. */
  81734. update(): void;
  81735. /**
  81736. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  81737. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81738. * @param data Define the flattened data
  81739. * @param size Define the size of the data.
  81740. */
  81741. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  81742. private _valueCache;
  81743. private _cacheMatrix;
  81744. private _updateMatrix3x3ForUniform;
  81745. private _updateMatrix3x3ForEffect;
  81746. private _updateMatrix2x2ForEffect;
  81747. private _updateMatrix2x2ForUniform;
  81748. private _updateFloatForEffect;
  81749. private _updateFloatForUniform;
  81750. private _updateFloat2ForEffect;
  81751. private _updateFloat2ForUniform;
  81752. private _updateFloat3ForEffect;
  81753. private _updateFloat3ForUniform;
  81754. private _updateFloat4ForEffect;
  81755. private _updateFloat4ForUniform;
  81756. private _updateMatrixForEffect;
  81757. private _updateMatrixForUniform;
  81758. private _updateVector3ForEffect;
  81759. private _updateVector3ForUniform;
  81760. private _updateVector4ForEffect;
  81761. private _updateVector4ForUniform;
  81762. private _updateColor3ForEffect;
  81763. private _updateColor3ForUniform;
  81764. private _updateColor4ForEffect;
  81765. private _updateColor4ForUniform;
  81766. /**
  81767. * Sets a sampler uniform on the effect.
  81768. * @param name Define the name of the sampler.
  81769. * @param texture Define the texture to set in the sampler
  81770. */
  81771. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  81772. /**
  81773. * Directly updates the value of the uniform in the cache AND on the GPU.
  81774. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  81775. * @param data Define the flattened data
  81776. */
  81777. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  81778. /**
  81779. * Binds this uniform buffer to an effect.
  81780. * @param effect Define the effect to bind the buffer to
  81781. * @param name Name of the uniform block in the shader.
  81782. */
  81783. bindToEffect(effect: Effect, name: string): void;
  81784. /**
  81785. * Disposes the uniform buffer.
  81786. */
  81787. dispose(): void;
  81788. }
  81789. }
  81790. declare module BABYLON {
  81791. /**
  81792. * Enum that determines the text-wrapping mode to use.
  81793. */
  81794. export enum InspectableType {
  81795. /**
  81796. * Checkbox for booleans
  81797. */
  81798. Checkbox = 0,
  81799. /**
  81800. * Sliders for numbers
  81801. */
  81802. Slider = 1,
  81803. /**
  81804. * Vector3
  81805. */
  81806. Vector3 = 2,
  81807. /**
  81808. * Quaternions
  81809. */
  81810. Quaternion = 3,
  81811. /**
  81812. * Color3
  81813. */
  81814. Color3 = 4,
  81815. /**
  81816. * String
  81817. */
  81818. String = 5
  81819. }
  81820. /**
  81821. * Interface used to define custom inspectable properties.
  81822. * This interface is used by the inspector to display custom property grids
  81823. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81824. */
  81825. export interface IInspectable {
  81826. /**
  81827. * Gets the label to display
  81828. */
  81829. label: string;
  81830. /**
  81831. * Gets the name of the property to edit
  81832. */
  81833. propertyName: string;
  81834. /**
  81835. * Gets the type of the editor to use
  81836. */
  81837. type: InspectableType;
  81838. /**
  81839. * Gets the minimum value of the property when using in "slider" mode
  81840. */
  81841. min?: number;
  81842. /**
  81843. * Gets the maximum value of the property when using in "slider" mode
  81844. */
  81845. max?: number;
  81846. /**
  81847. * Gets the setp to use when using in "slider" mode
  81848. */
  81849. step?: number;
  81850. }
  81851. }
  81852. declare module BABYLON {
  81853. /**
  81854. * Class used to provide helper for timing
  81855. */
  81856. export class TimingTools {
  81857. /**
  81858. * Polyfill for setImmediate
  81859. * @param action defines the action to execute after the current execution block
  81860. */
  81861. static SetImmediate(action: () => void): void;
  81862. }
  81863. }
  81864. declare module BABYLON {
  81865. /**
  81866. * Class used to enable instatition of objects by class name
  81867. */
  81868. export class InstantiationTools {
  81869. /**
  81870. * Use this object to register external classes like custom textures or material
  81871. * to allow the laoders to instantiate them
  81872. */
  81873. static RegisteredExternalClasses: {
  81874. [key: string]: Object;
  81875. };
  81876. /**
  81877. * Tries to instantiate a new object from a given class name
  81878. * @param className defines the class name to instantiate
  81879. * @returns the new object or null if the system was not able to do the instantiation
  81880. */
  81881. static Instantiate(className: string): any;
  81882. }
  81883. }
  81884. declare module BABYLON {
  81885. /**
  81886. * Define options used to create a depth texture
  81887. */
  81888. export class DepthTextureCreationOptions {
  81889. /** Specifies whether or not a stencil should be allocated in the texture */
  81890. generateStencil?: boolean;
  81891. /** Specifies whether or not bilinear filtering is enable on the texture */
  81892. bilinearFiltering?: boolean;
  81893. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  81894. comparisonFunction?: number;
  81895. /** Specifies if the created texture is a cube texture */
  81896. isCube?: boolean;
  81897. }
  81898. }
  81899. declare module BABYLON {
  81900. interface ThinEngine {
  81901. /**
  81902. * Creates a depth stencil cube texture.
  81903. * This is only available in WebGL 2.
  81904. * @param size The size of face edge in the cube texture.
  81905. * @param options The options defining the cube texture.
  81906. * @returns The cube texture
  81907. */
  81908. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  81909. /**
  81910. * Creates a cube texture
  81911. * @param rootUrl defines the url where the files to load is located
  81912. * @param scene defines the current scene
  81913. * @param files defines the list of files to load (1 per face)
  81914. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81915. * @param onLoad defines an optional callback raised when the texture is loaded
  81916. * @param onError defines an optional callback raised if there is an issue to load the texture
  81917. * @param format defines the format of the data
  81918. * @param forcedExtension defines the extension to use to pick the right loader
  81919. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81920. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81921. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81922. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  81923. * @returns the cube texture as an InternalTexture
  81924. */
  81925. 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;
  81926. /**
  81927. * Creates a cube texture
  81928. * @param rootUrl defines the url where the files to load is located
  81929. * @param scene defines the current scene
  81930. * @param files defines the list of files to load (1 per face)
  81931. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81932. * @param onLoad defines an optional callback raised when the texture is loaded
  81933. * @param onError defines an optional callback raised if there is an issue to load the texture
  81934. * @param format defines the format of the data
  81935. * @param forcedExtension defines the extension to use to pick the right loader
  81936. * @returns the cube texture as an InternalTexture
  81937. */
  81938. 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;
  81939. /**
  81940. * Creates a cube texture
  81941. * @param rootUrl defines the url where the files to load is located
  81942. * @param scene defines the current scene
  81943. * @param files defines the list of files to load (1 per face)
  81944. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  81945. * @param onLoad defines an optional callback raised when the texture is loaded
  81946. * @param onError defines an optional callback raised if there is an issue to load the texture
  81947. * @param format defines the format of the data
  81948. * @param forcedExtension defines the extension to use to pick the right loader
  81949. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  81950. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  81951. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  81952. * @returns the cube texture as an InternalTexture
  81953. */
  81954. 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;
  81955. /** @hidden */
  81956. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  81957. /** @hidden */
  81958. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  81959. /** @hidden */
  81960. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81961. /** @hidden */
  81962. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  81963. /**
  81964. * @hidden
  81965. */
  81966. _setCubeMapTextureParams(loadMipmap: boolean): void;
  81967. }
  81968. }
  81969. declare module BABYLON {
  81970. /**
  81971. * Class for creating a cube texture
  81972. */
  81973. export class CubeTexture extends BaseTexture {
  81974. private _delayedOnLoad;
  81975. /**
  81976. * Observable triggered once the texture has been loaded.
  81977. */
  81978. onLoadObservable: Observable<CubeTexture>;
  81979. /**
  81980. * The url of the texture
  81981. */
  81982. url: string;
  81983. /**
  81984. * Gets or sets the center of the bounding box associated with the cube texture.
  81985. * It must define where the camera used to render the texture was set
  81986. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  81987. */
  81988. boundingBoxPosition: Vector3;
  81989. private _boundingBoxSize;
  81990. /**
  81991. * Gets or sets the size of the bounding box associated with the cube texture
  81992. * When defined, the cubemap will switch to local mode
  81993. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  81994. * @example https://www.babylonjs-playground.com/#RNASML
  81995. */
  81996. set boundingBoxSize(value: Vector3);
  81997. /**
  81998. * Returns the bounding box size
  81999. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  82000. */
  82001. get boundingBoxSize(): Vector3;
  82002. protected _rotationY: number;
  82003. /**
  82004. * Sets texture matrix rotation angle around Y axis in radians.
  82005. */
  82006. set rotationY(value: number);
  82007. /**
  82008. * Gets texture matrix rotation angle around Y axis radians.
  82009. */
  82010. get rotationY(): number;
  82011. /**
  82012. * Are mip maps generated for this texture or not.
  82013. */
  82014. get noMipmap(): boolean;
  82015. private _noMipmap;
  82016. private _files;
  82017. protected _forcedExtension: Nullable<string>;
  82018. private _extensions;
  82019. private _textureMatrix;
  82020. private _format;
  82021. private _createPolynomials;
  82022. /** @hidden */
  82023. _prefiltered: boolean;
  82024. /**
  82025. * Creates a cube texture from an array of image urls
  82026. * @param files defines an array of image urls
  82027. * @param scene defines the hosting scene
  82028. * @param noMipmap specifies if mip maps are not used
  82029. * @returns a cube texture
  82030. */
  82031. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  82032. /**
  82033. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  82034. * @param url defines the url of the prefiltered texture
  82035. * @param scene defines the scene the texture is attached to
  82036. * @param forcedExtension defines the extension of the file if different from the url
  82037. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82038. * @return the prefiltered texture
  82039. */
  82040. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  82041. /**
  82042. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  82043. * as prefiltered data.
  82044. * @param rootUrl defines the url of the texture or the root name of the six images
  82045. * @param scene defines the scene the texture is attached to
  82046. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  82047. * @param noMipmap defines if mipmaps should be created or not
  82048. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  82049. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  82050. * @param onError defines a callback triggered in case of error during load
  82051. * @param format defines the internal format to use for the texture once loaded
  82052. * @param prefiltered defines whether or not the texture is created from prefiltered data
  82053. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  82054. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  82055. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  82056. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  82057. * @return the cube texture
  82058. */
  82059. 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);
  82060. /**
  82061. * Gets a boolean indicating if the cube texture contains prefiltered mips (used to simulate roughness with PBR)
  82062. */
  82063. get isPrefiltered(): boolean;
  82064. /**
  82065. * Get the current class name of the texture useful for serialization or dynamic coding.
  82066. * @returns "CubeTexture"
  82067. */
  82068. getClassName(): string;
  82069. /**
  82070. * Update the url (and optional buffer) of this texture if url was null during construction.
  82071. * @param url the url of the texture
  82072. * @param forcedExtension defines the extension to use
  82073. * @param onLoad callback called when the texture is loaded (defaults to null)
  82074. * @param prefiltered Defines whether the updated texture is prefiltered or not
  82075. */
  82076. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  82077. /**
  82078. * Delays loading of the cube texture
  82079. * @param forcedExtension defines the extension to use
  82080. */
  82081. delayLoad(forcedExtension?: string): void;
  82082. /**
  82083. * Returns the reflection texture matrix
  82084. * @returns the reflection texture matrix
  82085. */
  82086. getReflectionTextureMatrix(): Matrix;
  82087. /**
  82088. * Sets the reflection texture matrix
  82089. * @param value Reflection texture matrix
  82090. */
  82091. setReflectionTextureMatrix(value: Matrix): void;
  82092. /**
  82093. * Parses text to create a cube texture
  82094. * @param parsedTexture define the serialized text to read from
  82095. * @param scene defines the hosting scene
  82096. * @param rootUrl defines the root url of the cube texture
  82097. * @returns a cube texture
  82098. */
  82099. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  82100. /**
  82101. * Makes a clone, or deep copy, of the cube texture
  82102. * @returns a new cube texture
  82103. */
  82104. clone(): CubeTexture;
  82105. }
  82106. }
  82107. declare module BABYLON {
  82108. /**
  82109. * Manages the defines for the Material
  82110. */
  82111. export class MaterialDefines {
  82112. /** @hidden */
  82113. protected _keys: string[];
  82114. private _isDirty;
  82115. /** @hidden */
  82116. _renderId: number;
  82117. /** @hidden */
  82118. _areLightsDirty: boolean;
  82119. /** @hidden */
  82120. _areLightsDisposed: boolean;
  82121. /** @hidden */
  82122. _areAttributesDirty: boolean;
  82123. /** @hidden */
  82124. _areTexturesDirty: boolean;
  82125. /** @hidden */
  82126. _areFresnelDirty: boolean;
  82127. /** @hidden */
  82128. _areMiscDirty: boolean;
  82129. /** @hidden */
  82130. _areImageProcessingDirty: boolean;
  82131. /** @hidden */
  82132. _normals: boolean;
  82133. /** @hidden */
  82134. _uvs: boolean;
  82135. /** @hidden */
  82136. _needNormals: boolean;
  82137. /** @hidden */
  82138. _needUVs: boolean;
  82139. [id: string]: any;
  82140. /**
  82141. * Specifies if the material needs to be re-calculated
  82142. */
  82143. get isDirty(): boolean;
  82144. /**
  82145. * Marks the material to indicate that it has been re-calculated
  82146. */
  82147. markAsProcessed(): void;
  82148. /**
  82149. * Marks the material to indicate that it needs to be re-calculated
  82150. */
  82151. markAsUnprocessed(): void;
  82152. /**
  82153. * Marks the material to indicate all of its defines need to be re-calculated
  82154. */
  82155. markAllAsDirty(): void;
  82156. /**
  82157. * Marks the material to indicate that image processing needs to be re-calculated
  82158. */
  82159. markAsImageProcessingDirty(): void;
  82160. /**
  82161. * Marks the material to indicate the lights need to be re-calculated
  82162. * @param disposed Defines whether the light is dirty due to dispose or not
  82163. */
  82164. markAsLightDirty(disposed?: boolean): void;
  82165. /**
  82166. * Marks the attribute state as changed
  82167. */
  82168. markAsAttributesDirty(): void;
  82169. /**
  82170. * Marks the texture state as changed
  82171. */
  82172. markAsTexturesDirty(): void;
  82173. /**
  82174. * Marks the fresnel state as changed
  82175. */
  82176. markAsFresnelDirty(): void;
  82177. /**
  82178. * Marks the misc state as changed
  82179. */
  82180. markAsMiscDirty(): void;
  82181. /**
  82182. * Rebuilds the material defines
  82183. */
  82184. rebuild(): void;
  82185. /**
  82186. * Specifies if two material defines are equal
  82187. * @param other - A material define instance to compare to
  82188. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  82189. */
  82190. isEqual(other: MaterialDefines): boolean;
  82191. /**
  82192. * Clones this instance's defines to another instance
  82193. * @param other - material defines to clone values to
  82194. */
  82195. cloneTo(other: MaterialDefines): void;
  82196. /**
  82197. * Resets the material define values
  82198. */
  82199. reset(): void;
  82200. /**
  82201. * Converts the material define values to a string
  82202. * @returns - String of material define information
  82203. */
  82204. toString(): string;
  82205. }
  82206. }
  82207. declare module BABYLON {
  82208. /**
  82209. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  82210. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  82211. * 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;
  82212. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  82213. */
  82214. export class ColorCurves {
  82215. private _dirty;
  82216. private _tempColor;
  82217. private _globalCurve;
  82218. private _highlightsCurve;
  82219. private _midtonesCurve;
  82220. private _shadowsCurve;
  82221. private _positiveCurve;
  82222. private _negativeCurve;
  82223. private _globalHue;
  82224. private _globalDensity;
  82225. private _globalSaturation;
  82226. private _globalExposure;
  82227. /**
  82228. * Gets the global Hue value.
  82229. * 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).
  82230. */
  82231. get globalHue(): number;
  82232. /**
  82233. * Sets the global Hue value.
  82234. * 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).
  82235. */
  82236. set globalHue(value: number);
  82237. /**
  82238. * Gets the global Density value.
  82239. * 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.
  82240. * Values less than zero provide a filter of opposite hue.
  82241. */
  82242. get globalDensity(): number;
  82243. /**
  82244. * Sets the global Density value.
  82245. * 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.
  82246. * Values less than zero provide a filter of opposite hue.
  82247. */
  82248. set globalDensity(value: number);
  82249. /**
  82250. * Gets the global Saturation 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 saturation and negative values decrease saturation.
  82252. */
  82253. get globalSaturation(): number;
  82254. /**
  82255. * Sets the global Saturation 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 saturation and negative values decrease saturation.
  82257. */
  82258. set globalSaturation(value: number);
  82259. /**
  82260. * Gets the global Exposure value.
  82261. * 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.
  82262. */
  82263. get globalExposure(): number;
  82264. /**
  82265. * Sets the global Exposure value.
  82266. * 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.
  82267. */
  82268. set globalExposure(value: number);
  82269. private _highlightsHue;
  82270. private _highlightsDensity;
  82271. private _highlightsSaturation;
  82272. private _highlightsExposure;
  82273. /**
  82274. * Gets the highlights Hue value.
  82275. * 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).
  82276. */
  82277. get highlightsHue(): number;
  82278. /**
  82279. * Sets the highlights Hue value.
  82280. * 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).
  82281. */
  82282. set highlightsHue(value: number);
  82283. /**
  82284. * Gets the highlights Density value.
  82285. * 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.
  82286. * Values less than zero provide a filter of opposite hue.
  82287. */
  82288. get highlightsDensity(): number;
  82289. /**
  82290. * Sets the highlights Density value.
  82291. * 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.
  82292. * Values less than zero provide a filter of opposite hue.
  82293. */
  82294. set highlightsDensity(value: number);
  82295. /**
  82296. * Gets the highlights Saturation 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 saturation and negative values decrease saturation.
  82298. */
  82299. get highlightsSaturation(): number;
  82300. /**
  82301. * Sets the highlights Saturation 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 saturation and negative values decrease saturation.
  82303. */
  82304. set highlightsSaturation(value: number);
  82305. /**
  82306. * Gets the highlights Exposure value.
  82307. * 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.
  82308. */
  82309. get highlightsExposure(): number;
  82310. /**
  82311. * Sets the highlights Exposure value.
  82312. * 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.
  82313. */
  82314. set highlightsExposure(value: number);
  82315. private _midtonesHue;
  82316. private _midtonesDensity;
  82317. private _midtonesSaturation;
  82318. private _midtonesExposure;
  82319. /**
  82320. * Gets the midtones Hue value.
  82321. * 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).
  82322. */
  82323. get midtonesHue(): number;
  82324. /**
  82325. * Sets the midtones Hue value.
  82326. * 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).
  82327. */
  82328. set midtonesHue(value: number);
  82329. /**
  82330. * Gets the midtones Density value.
  82331. * 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.
  82332. * Values less than zero provide a filter of opposite hue.
  82333. */
  82334. get midtonesDensity(): number;
  82335. /**
  82336. * Sets the midtones Density value.
  82337. * 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.
  82338. * Values less than zero provide a filter of opposite hue.
  82339. */
  82340. set midtonesDensity(value: number);
  82341. /**
  82342. * Gets the midtones Saturation 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 saturation and negative values decrease saturation.
  82344. */
  82345. get midtonesSaturation(): number;
  82346. /**
  82347. * Sets the midtones Saturation 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 saturation and negative values decrease saturation.
  82349. */
  82350. set midtonesSaturation(value: number);
  82351. /**
  82352. * Gets the midtones Exposure value.
  82353. * 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.
  82354. */
  82355. get midtonesExposure(): number;
  82356. /**
  82357. * Sets the midtones Exposure value.
  82358. * 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.
  82359. */
  82360. set midtonesExposure(value: number);
  82361. private _shadowsHue;
  82362. private _shadowsDensity;
  82363. private _shadowsSaturation;
  82364. private _shadowsExposure;
  82365. /**
  82366. * Gets the shadows Hue value.
  82367. * 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).
  82368. */
  82369. get shadowsHue(): number;
  82370. /**
  82371. * Sets the shadows Hue value.
  82372. * 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).
  82373. */
  82374. set shadowsHue(value: number);
  82375. /**
  82376. * Gets the shadows Density value.
  82377. * 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.
  82378. * Values less than zero provide a filter of opposite hue.
  82379. */
  82380. get shadowsDensity(): number;
  82381. /**
  82382. * Sets the shadows Density value.
  82383. * 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.
  82384. * Values less than zero provide a filter of opposite hue.
  82385. */
  82386. set shadowsDensity(value: number);
  82387. /**
  82388. * Gets the shadows Saturation 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 saturation and negative values decrease saturation.
  82390. */
  82391. get shadowsSaturation(): number;
  82392. /**
  82393. * Sets the shadows Saturation 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 saturation and negative values decrease saturation.
  82395. */
  82396. set shadowsSaturation(value: number);
  82397. /**
  82398. * Gets the shadows Exposure value.
  82399. * 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.
  82400. */
  82401. get shadowsExposure(): number;
  82402. /**
  82403. * Sets the shadows Exposure value.
  82404. * 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.
  82405. */
  82406. set shadowsExposure(value: number);
  82407. /**
  82408. * Returns the class name
  82409. * @returns The class name
  82410. */
  82411. getClassName(): string;
  82412. /**
  82413. * Binds the color curves to the shader.
  82414. * @param colorCurves The color curve to bind
  82415. * @param effect The effect to bind to
  82416. * @param positiveUniform The positive uniform shader parameter
  82417. * @param neutralUniform The neutral uniform shader parameter
  82418. * @param negativeUniform The negative uniform shader parameter
  82419. */
  82420. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  82421. /**
  82422. * Prepare the list of uniforms associated with the ColorCurves effects.
  82423. * @param uniformsList The list of uniforms used in the effect
  82424. */
  82425. static PrepareUniforms(uniformsList: string[]): void;
  82426. /**
  82427. * Returns color grading data based on a hue, density, saturation and exposure value.
  82428. * @param filterHue The hue of the color filter.
  82429. * @param filterDensity The density of the color filter.
  82430. * @param saturation The saturation.
  82431. * @param exposure The exposure.
  82432. * @param result The result data container.
  82433. */
  82434. private getColorGradingDataToRef;
  82435. /**
  82436. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  82437. * @param value The input slider value in range [-100,100].
  82438. * @returns Adjusted value.
  82439. */
  82440. private static applyColorGradingSliderNonlinear;
  82441. /**
  82442. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  82443. * @param hue The hue (H) input.
  82444. * @param saturation The saturation (S) input.
  82445. * @param brightness The brightness (B) input.
  82446. * @result An RGBA color represented as Vector4.
  82447. */
  82448. private static fromHSBToRef;
  82449. /**
  82450. * Returns a value clamped between min and max
  82451. * @param value The value to clamp
  82452. * @param min The minimum of value
  82453. * @param max The maximum of value
  82454. * @returns The clamped value.
  82455. */
  82456. private static clamp;
  82457. /**
  82458. * Clones the current color curve instance.
  82459. * @return The cloned curves
  82460. */
  82461. clone(): ColorCurves;
  82462. /**
  82463. * Serializes the current color curve instance to a json representation.
  82464. * @return a JSON representation
  82465. */
  82466. serialize(): any;
  82467. /**
  82468. * Parses the color curve from a json representation.
  82469. * @param source the JSON source to parse
  82470. * @return The parsed curves
  82471. */
  82472. static Parse(source: any): ColorCurves;
  82473. }
  82474. }
  82475. declare module BABYLON {
  82476. /**
  82477. * Interface to follow in your material defines to integrate easily the
  82478. * Image proccessing functions.
  82479. * @hidden
  82480. */
  82481. export interface IImageProcessingConfigurationDefines {
  82482. IMAGEPROCESSING: boolean;
  82483. VIGNETTE: boolean;
  82484. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82485. VIGNETTEBLENDMODEOPAQUE: boolean;
  82486. TONEMAPPING: boolean;
  82487. TONEMAPPING_ACES: boolean;
  82488. CONTRAST: boolean;
  82489. EXPOSURE: boolean;
  82490. COLORCURVES: boolean;
  82491. COLORGRADING: boolean;
  82492. COLORGRADING3D: boolean;
  82493. SAMPLER3DGREENDEPTH: boolean;
  82494. SAMPLER3DBGRMAP: boolean;
  82495. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82496. }
  82497. /**
  82498. * @hidden
  82499. */
  82500. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  82501. IMAGEPROCESSING: boolean;
  82502. VIGNETTE: boolean;
  82503. VIGNETTEBLENDMODEMULTIPLY: boolean;
  82504. VIGNETTEBLENDMODEOPAQUE: boolean;
  82505. TONEMAPPING: boolean;
  82506. TONEMAPPING_ACES: boolean;
  82507. CONTRAST: boolean;
  82508. COLORCURVES: boolean;
  82509. COLORGRADING: boolean;
  82510. COLORGRADING3D: boolean;
  82511. SAMPLER3DGREENDEPTH: boolean;
  82512. SAMPLER3DBGRMAP: boolean;
  82513. IMAGEPROCESSINGPOSTPROCESS: boolean;
  82514. EXPOSURE: boolean;
  82515. constructor();
  82516. }
  82517. /**
  82518. * This groups together the common properties used for image processing either in direct forward pass
  82519. * or through post processing effect depending on the use of the image processing pipeline in your scene
  82520. * or not.
  82521. */
  82522. export class ImageProcessingConfiguration {
  82523. /**
  82524. * Default tone mapping applied in BabylonJS.
  82525. */
  82526. static readonly TONEMAPPING_STANDARD: number;
  82527. /**
  82528. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  82529. * to other engines rendering to increase portability.
  82530. */
  82531. static readonly TONEMAPPING_ACES: number;
  82532. /**
  82533. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  82534. */
  82535. colorCurves: Nullable<ColorCurves>;
  82536. private _colorCurvesEnabled;
  82537. /**
  82538. * Gets wether the color curves effect is enabled.
  82539. */
  82540. get colorCurvesEnabled(): boolean;
  82541. /**
  82542. * Sets wether the color curves effect is enabled.
  82543. */
  82544. set colorCurvesEnabled(value: boolean);
  82545. private _colorGradingTexture;
  82546. /**
  82547. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82548. */
  82549. get colorGradingTexture(): Nullable<BaseTexture>;
  82550. /**
  82551. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  82552. */
  82553. set colorGradingTexture(value: Nullable<BaseTexture>);
  82554. private _colorGradingEnabled;
  82555. /**
  82556. * Gets wether the color grading effect is enabled.
  82557. */
  82558. get colorGradingEnabled(): boolean;
  82559. /**
  82560. * Sets wether the color grading effect is enabled.
  82561. */
  82562. set colorGradingEnabled(value: boolean);
  82563. private _colorGradingWithGreenDepth;
  82564. /**
  82565. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  82566. */
  82567. get colorGradingWithGreenDepth(): boolean;
  82568. /**
  82569. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  82570. */
  82571. set colorGradingWithGreenDepth(value: boolean);
  82572. private _colorGradingBGR;
  82573. /**
  82574. * Gets wether the color grading texture contains BGR values.
  82575. */
  82576. get colorGradingBGR(): boolean;
  82577. /**
  82578. * Sets wether the color grading texture contains BGR values.
  82579. */
  82580. set colorGradingBGR(value: boolean);
  82581. /** @hidden */
  82582. _exposure: number;
  82583. /**
  82584. * Gets the Exposure used in the effect.
  82585. */
  82586. get exposure(): number;
  82587. /**
  82588. * Sets the Exposure used in the effect.
  82589. */
  82590. set exposure(value: number);
  82591. private _toneMappingEnabled;
  82592. /**
  82593. * Gets wether the tone mapping effect is enabled.
  82594. */
  82595. get toneMappingEnabled(): boolean;
  82596. /**
  82597. * Sets wether the tone mapping effect is enabled.
  82598. */
  82599. set toneMappingEnabled(value: boolean);
  82600. private _toneMappingType;
  82601. /**
  82602. * Gets the type of tone mapping effect.
  82603. */
  82604. get toneMappingType(): number;
  82605. /**
  82606. * Sets the type of tone mapping effect used in BabylonJS.
  82607. */
  82608. set toneMappingType(value: number);
  82609. protected _contrast: number;
  82610. /**
  82611. * Gets the contrast used in the effect.
  82612. */
  82613. get contrast(): number;
  82614. /**
  82615. * Sets the contrast used in the effect.
  82616. */
  82617. set contrast(value: number);
  82618. /**
  82619. * Vignette stretch size.
  82620. */
  82621. vignetteStretch: number;
  82622. /**
  82623. * Vignette centre X Offset.
  82624. */
  82625. vignetteCentreX: number;
  82626. /**
  82627. * Vignette centre Y Offset.
  82628. */
  82629. vignetteCentreY: number;
  82630. /**
  82631. * Vignette weight or intensity of the vignette effect.
  82632. */
  82633. vignetteWeight: number;
  82634. /**
  82635. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  82636. * if vignetteEnabled is set to true.
  82637. */
  82638. vignetteColor: Color4;
  82639. /**
  82640. * Camera field of view used by the Vignette effect.
  82641. */
  82642. vignetteCameraFov: number;
  82643. private _vignetteBlendMode;
  82644. /**
  82645. * Gets the vignette blend mode allowing different kind of effect.
  82646. */
  82647. get vignetteBlendMode(): number;
  82648. /**
  82649. * Sets the vignette blend mode allowing different kind of effect.
  82650. */
  82651. set vignetteBlendMode(value: number);
  82652. private _vignetteEnabled;
  82653. /**
  82654. * Gets wether the vignette effect is enabled.
  82655. */
  82656. get vignetteEnabled(): boolean;
  82657. /**
  82658. * Sets wether the vignette effect is enabled.
  82659. */
  82660. set vignetteEnabled(value: boolean);
  82661. private _applyByPostProcess;
  82662. /**
  82663. * Gets wether the image processing is applied through a post process or not.
  82664. */
  82665. get applyByPostProcess(): boolean;
  82666. /**
  82667. * Sets wether the image processing is applied through a post process or not.
  82668. */
  82669. set applyByPostProcess(value: boolean);
  82670. private _isEnabled;
  82671. /**
  82672. * Gets wether the image processing is enabled or not.
  82673. */
  82674. get isEnabled(): boolean;
  82675. /**
  82676. * Sets wether the image processing is enabled or not.
  82677. */
  82678. set isEnabled(value: boolean);
  82679. /**
  82680. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  82681. */
  82682. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  82683. /**
  82684. * Method called each time the image processing information changes requires to recompile the effect.
  82685. */
  82686. protected _updateParameters(): void;
  82687. /**
  82688. * Gets the current class name.
  82689. * @return "ImageProcessingConfiguration"
  82690. */
  82691. getClassName(): string;
  82692. /**
  82693. * Prepare the list of uniforms associated with the Image Processing effects.
  82694. * @param uniforms The list of uniforms used in the effect
  82695. * @param defines the list of defines currently in use
  82696. */
  82697. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  82698. /**
  82699. * Prepare the list of samplers associated with the Image Processing effects.
  82700. * @param samplersList The list of uniforms used in the effect
  82701. * @param defines the list of defines currently in use
  82702. */
  82703. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  82704. /**
  82705. * Prepare the list of defines associated to the shader.
  82706. * @param defines the list of defines to complete
  82707. * @param forPostProcess Define if we are currently in post process mode or not
  82708. */
  82709. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  82710. /**
  82711. * Returns true if all the image processing information are ready.
  82712. * @returns True if ready, otherwise, false
  82713. */
  82714. isReady(): boolean;
  82715. /**
  82716. * Binds the image processing to the shader.
  82717. * @param effect The effect to bind to
  82718. * @param overrideAspectRatio Override the aspect ratio of the effect
  82719. */
  82720. bind(effect: Effect, overrideAspectRatio?: number): void;
  82721. /**
  82722. * Clones the current image processing instance.
  82723. * @return The cloned image processing
  82724. */
  82725. clone(): ImageProcessingConfiguration;
  82726. /**
  82727. * Serializes the current image processing instance to a json representation.
  82728. * @return a JSON representation
  82729. */
  82730. serialize(): any;
  82731. /**
  82732. * Parses the image processing from a json representation.
  82733. * @param source the JSON source to parse
  82734. * @return The parsed image processing
  82735. */
  82736. static Parse(source: any): ImageProcessingConfiguration;
  82737. private static _VIGNETTEMODE_MULTIPLY;
  82738. private static _VIGNETTEMODE_OPAQUE;
  82739. /**
  82740. * Used to apply the vignette as a mix with the pixel color.
  82741. */
  82742. static get VIGNETTEMODE_MULTIPLY(): number;
  82743. /**
  82744. * Used to apply the vignette as a replacement of the pixel color.
  82745. */
  82746. static get VIGNETTEMODE_OPAQUE(): number;
  82747. }
  82748. }
  82749. declare module BABYLON {
  82750. /** @hidden */
  82751. export var postprocessVertexShader: {
  82752. name: string;
  82753. shader: string;
  82754. };
  82755. }
  82756. declare module BABYLON {
  82757. interface ThinEngine {
  82758. /**
  82759. * Creates a new render target texture
  82760. * @param size defines the size of the texture
  82761. * @param options defines the options used to create the texture
  82762. * @returns a new render target texture stored in an InternalTexture
  82763. */
  82764. createRenderTargetTexture(size: number | {
  82765. width: number;
  82766. height: number;
  82767. layers?: number;
  82768. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  82769. /**
  82770. * Creates a depth stencil texture.
  82771. * This is only available in WebGL 2 or with the depth texture extension available.
  82772. * @param size The size of face edge in the texture.
  82773. * @param options The options defining the texture.
  82774. * @returns The texture
  82775. */
  82776. createDepthStencilTexture(size: number | {
  82777. width: number;
  82778. height: number;
  82779. layers?: number;
  82780. }, options: DepthTextureCreationOptions): InternalTexture;
  82781. /** @hidden */
  82782. _createDepthStencilTexture(size: number | {
  82783. width: number;
  82784. height: number;
  82785. layers?: number;
  82786. }, options: DepthTextureCreationOptions): InternalTexture;
  82787. }
  82788. }
  82789. declare module BABYLON {
  82790. /** Defines supported spaces */
  82791. export enum Space {
  82792. /** Local (object) space */
  82793. LOCAL = 0,
  82794. /** World space */
  82795. WORLD = 1,
  82796. /** Bone space */
  82797. BONE = 2
  82798. }
  82799. /** Defines the 3 main axes */
  82800. export class Axis {
  82801. /** X axis */
  82802. static X: Vector3;
  82803. /** Y axis */
  82804. static Y: Vector3;
  82805. /** Z axis */
  82806. static Z: Vector3;
  82807. }
  82808. }
  82809. declare module BABYLON {
  82810. /**
  82811. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  82812. * This is the base of the follow, arc rotate cameras and Free camera
  82813. * @see http://doc.babylonjs.com/features/cameras
  82814. */
  82815. export class TargetCamera extends Camera {
  82816. private static _RigCamTransformMatrix;
  82817. private static _TargetTransformMatrix;
  82818. private static _TargetFocalPoint;
  82819. /**
  82820. * Define the current direction the camera is moving to
  82821. */
  82822. cameraDirection: Vector3;
  82823. /**
  82824. * Define the current rotation the camera is rotating to
  82825. */
  82826. cameraRotation: Vector2;
  82827. /**
  82828. * When set, the up vector of the camera will be updated by the rotation of the camera
  82829. */
  82830. updateUpVectorFromRotation: boolean;
  82831. private _tmpQuaternion;
  82832. /**
  82833. * Define the current rotation of the camera
  82834. */
  82835. rotation: Vector3;
  82836. /**
  82837. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  82838. */
  82839. rotationQuaternion: Quaternion;
  82840. /**
  82841. * Define the current speed of the camera
  82842. */
  82843. speed: number;
  82844. /**
  82845. * Add constraint to the camera to prevent it to move freely in all directions and
  82846. * around all axis.
  82847. */
  82848. noRotationConstraint: boolean;
  82849. /**
  82850. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  82851. * panning
  82852. */
  82853. invertRotation: boolean;
  82854. /**
  82855. * Speed multiplier for inverse camera panning
  82856. */
  82857. inverseRotationSpeed: number;
  82858. /**
  82859. * Define the current target of the camera as an object or a position.
  82860. */
  82861. lockedTarget: any;
  82862. /** @hidden */
  82863. _currentTarget: Vector3;
  82864. /** @hidden */
  82865. _initialFocalDistance: number;
  82866. /** @hidden */
  82867. _viewMatrix: Matrix;
  82868. /** @hidden */
  82869. _camMatrix: Matrix;
  82870. /** @hidden */
  82871. _cameraTransformMatrix: Matrix;
  82872. /** @hidden */
  82873. _cameraRotationMatrix: Matrix;
  82874. /** @hidden */
  82875. _referencePoint: Vector3;
  82876. /** @hidden */
  82877. _transformedReferencePoint: Vector3;
  82878. protected _globalCurrentTarget: Vector3;
  82879. protected _globalCurrentUpVector: Vector3;
  82880. /** @hidden */
  82881. _reset: () => void;
  82882. private _defaultUp;
  82883. /**
  82884. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  82885. * This is the base of the follow, arc rotate cameras and Free camera
  82886. * @see http://doc.babylonjs.com/features/cameras
  82887. * @param name Defines the name of the camera in the scene
  82888. * @param position Defines the start position of the camera in the scene
  82889. * @param scene Defines the scene the camera belongs to
  82890. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  82891. */
  82892. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  82893. /**
  82894. * Gets the position in front of the camera at a given distance.
  82895. * @param distance The distance from the camera we want the position to be
  82896. * @returns the position
  82897. */
  82898. getFrontPosition(distance: number): Vector3;
  82899. /** @hidden */
  82900. _getLockedTargetPosition(): Nullable<Vector3>;
  82901. private _storedPosition;
  82902. private _storedRotation;
  82903. private _storedRotationQuaternion;
  82904. /**
  82905. * Store current camera state of the camera (fov, position, rotation, etc..)
  82906. * @returns the camera
  82907. */
  82908. storeState(): Camera;
  82909. /**
  82910. * Restored camera state. You must call storeState() first
  82911. * @returns whether it was successful or not
  82912. * @hidden
  82913. */
  82914. _restoreStateValues(): boolean;
  82915. /** @hidden */
  82916. _initCache(): void;
  82917. /** @hidden */
  82918. _updateCache(ignoreParentClass?: boolean): void;
  82919. /** @hidden */
  82920. _isSynchronizedViewMatrix(): boolean;
  82921. /** @hidden */
  82922. _computeLocalCameraSpeed(): number;
  82923. /**
  82924. * Defines the target the camera should look at.
  82925. * @param target Defines the new target as a Vector or a mesh
  82926. */
  82927. setTarget(target: Vector3): void;
  82928. /**
  82929. * Return the current target position of the camera. This value is expressed in local space.
  82930. * @returns the target position
  82931. */
  82932. getTarget(): Vector3;
  82933. /** @hidden */
  82934. _decideIfNeedsToMove(): boolean;
  82935. /** @hidden */
  82936. _updatePosition(): void;
  82937. /** @hidden */
  82938. _checkInputs(): void;
  82939. protected _updateCameraRotationMatrix(): void;
  82940. /**
  82941. * 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)
  82942. * @returns the current camera
  82943. */
  82944. private _rotateUpVectorWithCameraRotationMatrix;
  82945. private _cachedRotationZ;
  82946. private _cachedQuaternionRotationZ;
  82947. /** @hidden */
  82948. _getViewMatrix(): Matrix;
  82949. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  82950. /**
  82951. * @hidden
  82952. */
  82953. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  82954. /**
  82955. * @hidden
  82956. */
  82957. _updateRigCameras(): void;
  82958. private _getRigCamPositionAndTarget;
  82959. /**
  82960. * Gets the current object class name.
  82961. * @return the class name
  82962. */
  82963. getClassName(): string;
  82964. }
  82965. }
  82966. declare module BABYLON {
  82967. /**
  82968. * Gather the list of keyboard event types as constants.
  82969. */
  82970. export class KeyboardEventTypes {
  82971. /**
  82972. * The keydown event is fired when a key becomes active (pressed).
  82973. */
  82974. static readonly KEYDOWN: number;
  82975. /**
  82976. * The keyup event is fired when a key has been released.
  82977. */
  82978. static readonly KEYUP: number;
  82979. }
  82980. /**
  82981. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82982. */
  82983. export class KeyboardInfo {
  82984. /**
  82985. * Defines the type of event (KeyboardEventTypes)
  82986. */
  82987. type: number;
  82988. /**
  82989. * Defines the related dom event
  82990. */
  82991. event: KeyboardEvent;
  82992. /**
  82993. * Instantiates a new keyboard info.
  82994. * This class is used to store keyboard related info for the onKeyboardObservable event.
  82995. * @param type Defines the type of event (KeyboardEventTypes)
  82996. * @param event Defines the related dom event
  82997. */
  82998. constructor(
  82999. /**
  83000. * Defines the type of event (KeyboardEventTypes)
  83001. */
  83002. type: number,
  83003. /**
  83004. * Defines the related dom event
  83005. */
  83006. event: KeyboardEvent);
  83007. }
  83008. /**
  83009. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83010. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  83011. */
  83012. export class KeyboardInfoPre extends KeyboardInfo {
  83013. /**
  83014. * Defines the type of event (KeyboardEventTypes)
  83015. */
  83016. type: number;
  83017. /**
  83018. * Defines the related dom event
  83019. */
  83020. event: KeyboardEvent;
  83021. /**
  83022. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  83023. */
  83024. skipOnPointerObservable: boolean;
  83025. /**
  83026. * Instantiates a new keyboard pre info.
  83027. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  83028. * @param type Defines the type of event (KeyboardEventTypes)
  83029. * @param event Defines the related dom event
  83030. */
  83031. constructor(
  83032. /**
  83033. * Defines the type of event (KeyboardEventTypes)
  83034. */
  83035. type: number,
  83036. /**
  83037. * Defines the related dom event
  83038. */
  83039. event: KeyboardEvent);
  83040. }
  83041. }
  83042. declare module BABYLON {
  83043. /**
  83044. * Manage the keyboard inputs to control the movement of a free camera.
  83045. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  83046. */
  83047. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  83048. /**
  83049. * Defines the camera the input is attached to.
  83050. */
  83051. camera: FreeCamera;
  83052. /**
  83053. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  83054. */
  83055. keysUp: number[];
  83056. /**
  83057. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  83058. */
  83059. keysUpward: number[];
  83060. /**
  83061. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  83062. */
  83063. keysDown: number[];
  83064. /**
  83065. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  83066. */
  83067. keysDownward: number[];
  83068. /**
  83069. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  83070. */
  83071. keysLeft: number[];
  83072. /**
  83073. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  83074. */
  83075. keysRight: number[];
  83076. private _keys;
  83077. private _onCanvasBlurObserver;
  83078. private _onKeyboardObserver;
  83079. private _engine;
  83080. private _scene;
  83081. /**
  83082. * Attach the input controls to a specific dom element to get the input from.
  83083. * @param element Defines the element the controls should be listened from
  83084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  83085. */
  83086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  83087. /**
  83088. * Detach the current controls from the specified dom element.
  83089. * @param element Defines the element to stop listening the inputs from
  83090. */
  83091. detachControl(element: Nullable<HTMLElement>): void;
  83092. /**
  83093. * Update the current camera state depending on the inputs that have been used this frame.
  83094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  83095. */
  83096. checkInputs(): void;
  83097. /**
  83098. * Gets the class name of the current intput.
  83099. * @returns the class name
  83100. */
  83101. getClassName(): string;
  83102. /** @hidden */
  83103. _onLostFocus(): void;
  83104. /**
  83105. * Get the friendly name associated with the input class.
  83106. * @returns the input friendly name
  83107. */
  83108. getSimpleName(): string;
  83109. }
  83110. }
  83111. declare module BABYLON {
  83112. /**
  83113. * Interface describing all the common properties and methods a shadow light needs to implement.
  83114. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  83115. * as well as binding the different shadow properties to the effects.
  83116. */
  83117. export interface IShadowLight extends Light {
  83118. /**
  83119. * The light id in the scene (used in scene.findLighById for instance)
  83120. */
  83121. id: string;
  83122. /**
  83123. * The position the shdow will be casted from.
  83124. */
  83125. position: Vector3;
  83126. /**
  83127. * In 2d mode (needCube being false), the direction used to cast the shadow.
  83128. */
  83129. direction: Vector3;
  83130. /**
  83131. * The transformed position. Position of the light in world space taking parenting in account.
  83132. */
  83133. transformedPosition: Vector3;
  83134. /**
  83135. * The transformed direction. Direction of the light in world space taking parenting in account.
  83136. */
  83137. transformedDirection: Vector3;
  83138. /**
  83139. * The friendly name of the light in the scene.
  83140. */
  83141. name: string;
  83142. /**
  83143. * Defines the shadow projection clipping minimum z value.
  83144. */
  83145. shadowMinZ: number;
  83146. /**
  83147. * Defines the shadow projection clipping maximum z value.
  83148. */
  83149. shadowMaxZ: number;
  83150. /**
  83151. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83152. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83153. */
  83154. computeTransformedInformation(): boolean;
  83155. /**
  83156. * Gets the scene the light belongs to.
  83157. * @returns The scene
  83158. */
  83159. getScene(): Scene;
  83160. /**
  83161. * Callback defining a custom Projection Matrix Builder.
  83162. * This can be used to override the default projection matrix computation.
  83163. */
  83164. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83165. /**
  83166. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83167. * @param matrix The materix to updated with the projection information
  83168. * @param viewMatrix The transform matrix of the light
  83169. * @param renderList The list of mesh to render in the map
  83170. * @returns The current light
  83171. */
  83172. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83173. /**
  83174. * Gets the current depth scale used in ESM.
  83175. * @returns The scale
  83176. */
  83177. getDepthScale(): number;
  83178. /**
  83179. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83180. * @returns true if a cube texture needs to be use
  83181. */
  83182. needCube(): boolean;
  83183. /**
  83184. * Detects if the projection matrix requires to be recomputed this frame.
  83185. * @returns true if it requires to be recomputed otherwise, false.
  83186. */
  83187. needProjectionMatrixCompute(): boolean;
  83188. /**
  83189. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83190. */
  83191. forceProjectionMatrixCompute(): void;
  83192. /**
  83193. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83194. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83195. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83196. */
  83197. getShadowDirection(faceIndex?: number): Vector3;
  83198. /**
  83199. * Gets the minZ used for shadow according to both the scene and the light.
  83200. * @param activeCamera The camera we are returning the min for
  83201. * @returns the depth min z
  83202. */
  83203. getDepthMinZ(activeCamera: Camera): number;
  83204. /**
  83205. * Gets the maxZ used for shadow according to both the scene and the light.
  83206. * @param activeCamera The camera we are returning the max for
  83207. * @returns the depth max z
  83208. */
  83209. getDepthMaxZ(activeCamera: Camera): number;
  83210. }
  83211. /**
  83212. * Base implementation IShadowLight
  83213. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  83214. */
  83215. export abstract class ShadowLight extends Light implements IShadowLight {
  83216. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  83217. protected _position: Vector3;
  83218. protected _setPosition(value: Vector3): void;
  83219. /**
  83220. * Sets the position the shadow will be casted from. Also use as the light position for both
  83221. * point and spot lights.
  83222. */
  83223. get position(): Vector3;
  83224. /**
  83225. * Sets the position the shadow will be casted from. Also use as the light position for both
  83226. * point and spot lights.
  83227. */
  83228. set position(value: Vector3);
  83229. protected _direction: Vector3;
  83230. protected _setDirection(value: Vector3): void;
  83231. /**
  83232. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  83233. * Also use as the light direction on spot and directional lights.
  83234. */
  83235. get direction(): Vector3;
  83236. /**
  83237. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  83238. * Also use as the light direction on spot and directional lights.
  83239. */
  83240. set direction(value: Vector3);
  83241. protected _shadowMinZ: number;
  83242. /**
  83243. * Gets the shadow projection clipping minimum z value.
  83244. */
  83245. get shadowMinZ(): number;
  83246. /**
  83247. * Sets the shadow projection clipping minimum z value.
  83248. */
  83249. set shadowMinZ(value: number);
  83250. protected _shadowMaxZ: number;
  83251. /**
  83252. * Sets the shadow projection clipping maximum z value.
  83253. */
  83254. get shadowMaxZ(): number;
  83255. /**
  83256. * Gets the shadow projection clipping maximum z value.
  83257. */
  83258. set shadowMaxZ(value: number);
  83259. /**
  83260. * Callback defining a custom Projection Matrix Builder.
  83261. * This can be used to override the default projection matrix computation.
  83262. */
  83263. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  83264. /**
  83265. * The transformed position. Position of the light in world space taking parenting in account.
  83266. */
  83267. transformedPosition: Vector3;
  83268. /**
  83269. * The transformed direction. Direction of the light in world space taking parenting in account.
  83270. */
  83271. transformedDirection: Vector3;
  83272. private _needProjectionMatrixCompute;
  83273. /**
  83274. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  83275. * @returns true if the information has been computed, false if it does not need to (no parenting)
  83276. */
  83277. computeTransformedInformation(): boolean;
  83278. /**
  83279. * Return the depth scale used for the shadow map.
  83280. * @returns the depth scale.
  83281. */
  83282. getDepthScale(): number;
  83283. /**
  83284. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  83285. * @param faceIndex The index of the face we are computed the direction to generate shadow
  83286. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  83287. */
  83288. getShadowDirection(faceIndex?: number): Vector3;
  83289. /**
  83290. * Returns the ShadowLight absolute position in the World.
  83291. * @returns the position vector in world space
  83292. */
  83293. getAbsolutePosition(): Vector3;
  83294. /**
  83295. * Sets the ShadowLight direction toward the passed target.
  83296. * @param target The point to target in local space
  83297. * @returns the updated ShadowLight direction
  83298. */
  83299. setDirectionToTarget(target: Vector3): Vector3;
  83300. /**
  83301. * Returns the light rotation in euler definition.
  83302. * @returns the x y z rotation in local space.
  83303. */
  83304. getRotation(): Vector3;
  83305. /**
  83306. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  83307. * @returns true if a cube texture needs to be use
  83308. */
  83309. needCube(): boolean;
  83310. /**
  83311. * Detects if the projection matrix requires to be recomputed this frame.
  83312. * @returns true if it requires to be recomputed otherwise, false.
  83313. */
  83314. needProjectionMatrixCompute(): boolean;
  83315. /**
  83316. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  83317. */
  83318. forceProjectionMatrixCompute(): void;
  83319. /** @hidden */
  83320. _initCache(): void;
  83321. /** @hidden */
  83322. _isSynchronized(): boolean;
  83323. /**
  83324. * Computes the world matrix of the node
  83325. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  83326. * @returns the world matrix
  83327. */
  83328. computeWorldMatrix(force?: boolean): Matrix;
  83329. /**
  83330. * Gets the minZ used for shadow according to both the scene and the light.
  83331. * @param activeCamera The camera we are returning the min for
  83332. * @returns the depth min z
  83333. */
  83334. getDepthMinZ(activeCamera: Camera): number;
  83335. /**
  83336. * Gets the maxZ used for shadow according to both the scene and the light.
  83337. * @param activeCamera The camera we are returning the max for
  83338. * @returns the depth max z
  83339. */
  83340. getDepthMaxZ(activeCamera: Camera): number;
  83341. /**
  83342. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  83343. * @param matrix The materix to updated with the projection information
  83344. * @param viewMatrix The transform matrix of the light
  83345. * @param renderList The list of mesh to render in the map
  83346. * @returns The current light
  83347. */
  83348. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  83349. }
  83350. }
  83351. declare module BABYLON {
  83352. /**
  83353. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  83354. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  83355. */
  83356. export class EffectFallbacks implements IEffectFallbacks {
  83357. private _defines;
  83358. private _currentRank;
  83359. private _maxRank;
  83360. private _mesh;
  83361. /**
  83362. * Removes the fallback from the bound mesh.
  83363. */
  83364. unBindMesh(): void;
  83365. /**
  83366. * Adds a fallback on the specified property.
  83367. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83368. * @param define The name of the define in the shader
  83369. */
  83370. addFallback(rank: number, define: string): void;
  83371. /**
  83372. * Sets the mesh to use CPU skinning when needing to fallback.
  83373. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  83374. * @param mesh The mesh to use the fallbacks.
  83375. */
  83376. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  83377. /**
  83378. * Checks to see if more fallbacks are still availible.
  83379. */
  83380. get hasMoreFallbacks(): boolean;
  83381. /**
  83382. * Removes the defines that should be removed when falling back.
  83383. * @param currentDefines defines the current define statements for the shader.
  83384. * @param effect defines the current effect we try to compile
  83385. * @returns The resulting defines with defines of the current rank removed.
  83386. */
  83387. reduce(currentDefines: string, effect: Effect): string;
  83388. }
  83389. }
  83390. declare module BABYLON {
  83391. /**
  83392. * "Static Class" containing the most commonly used helper while dealing with material for
  83393. * rendering purpose.
  83394. *
  83395. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  83396. *
  83397. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  83398. */
  83399. export class MaterialHelper {
  83400. /**
  83401. * Bind the current view position to an effect.
  83402. * @param effect The effect to be bound
  83403. * @param scene The scene the eyes position is used from
  83404. */
  83405. static BindEyePosition(effect: Effect, scene: Scene): void;
  83406. /**
  83407. * Helps preparing the defines values about the UVs in used in the effect.
  83408. * UVs are shared as much as we can accross channels in the shaders.
  83409. * @param texture The texture we are preparing the UVs for
  83410. * @param defines The defines to update
  83411. * @param key The channel key "diffuse", "specular"... used in the shader
  83412. */
  83413. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  83414. /**
  83415. * Binds a texture matrix value to its corrsponding uniform
  83416. * @param texture The texture to bind the matrix for
  83417. * @param uniformBuffer The uniform buffer receivin the data
  83418. * @param key The channel key "diffuse", "specular"... used in the shader
  83419. */
  83420. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  83421. /**
  83422. * Gets the current status of the fog (should it be enabled?)
  83423. * @param mesh defines the mesh to evaluate for fog support
  83424. * @param scene defines the hosting scene
  83425. * @returns true if fog must be enabled
  83426. */
  83427. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  83428. /**
  83429. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  83430. * @param mesh defines the current mesh
  83431. * @param scene defines the current scene
  83432. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  83433. * @param pointsCloud defines if point cloud rendering has to be turned on
  83434. * @param fogEnabled defines if fog has to be turned on
  83435. * @param alphaTest defines if alpha testing has to be turned on
  83436. * @param defines defines the current list of defines
  83437. */
  83438. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  83439. /**
  83440. * Helper used to prepare the list of defines associated with frame values for shader compilation
  83441. * @param scene defines the current scene
  83442. * @param engine defines the current engine
  83443. * @param defines specifies the list of active defines
  83444. * @param useInstances defines if instances have to be turned on
  83445. * @param useClipPlane defines if clip plane have to be turned on
  83446. */
  83447. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  83448. /**
  83449. * Prepares the defines for bones
  83450. * @param mesh The mesh containing the geometry data we will draw
  83451. * @param defines The defines to update
  83452. */
  83453. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  83454. /**
  83455. * Prepares the defines for morph targets
  83456. * @param mesh The mesh containing the geometry data we will draw
  83457. * @param defines The defines to update
  83458. */
  83459. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  83460. /**
  83461. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  83462. * @param mesh The mesh containing the geometry data we will draw
  83463. * @param defines The defines to update
  83464. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  83465. * @param useBones Precise whether bones should be used or not (override mesh info)
  83466. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  83467. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  83468. * @returns false if defines are considered not dirty and have not been checked
  83469. */
  83470. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  83471. /**
  83472. * Prepares the defines related to multiview
  83473. * @param scene The scene we are intending to draw
  83474. * @param defines The defines to update
  83475. */
  83476. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  83477. /**
  83478. * Prepares the defines related to the light information passed in parameter
  83479. * @param scene The scene we are intending to draw
  83480. * @param mesh The mesh the effect is compiling for
  83481. * @param light The light the effect is compiling for
  83482. * @param lightIndex The index of the light
  83483. * @param defines The defines to update
  83484. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83485. * @param state Defines the current state regarding what is needed (normals, etc...)
  83486. */
  83487. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  83488. needNormals: boolean;
  83489. needRebuild: boolean;
  83490. shadowEnabled: boolean;
  83491. specularEnabled: boolean;
  83492. lightmapMode: boolean;
  83493. }): void;
  83494. /**
  83495. * Prepares the defines related to the light information passed in parameter
  83496. * @param scene The scene we are intending to draw
  83497. * @param mesh The mesh the effect is compiling for
  83498. * @param defines The defines to update
  83499. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  83500. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  83501. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  83502. * @returns true if normals will be required for the rest of the effect
  83503. */
  83504. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  83505. /**
  83506. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  83507. * @param lightIndex defines the light index
  83508. * @param uniformsList The uniform list
  83509. * @param samplersList The sampler list
  83510. * @param projectedLightTexture defines if projected texture must be used
  83511. * @param uniformBuffersList defines an optional list of uniform buffers
  83512. */
  83513. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  83514. /**
  83515. * Prepares the uniforms and samplers list to be used in the effect
  83516. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  83517. * @param samplersList The sampler list
  83518. * @param defines The defines helping in the list generation
  83519. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  83520. */
  83521. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  83522. /**
  83523. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  83524. * @param defines The defines to update while falling back
  83525. * @param fallbacks The authorized effect fallbacks
  83526. * @param maxSimultaneousLights The maximum number of lights allowed
  83527. * @param rank the current rank of the Effect
  83528. * @returns The newly affected rank
  83529. */
  83530. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  83531. private static _TmpMorphInfluencers;
  83532. /**
  83533. * Prepares the list of attributes required for morph targets according to the effect defines.
  83534. * @param attribs The current list of supported attribs
  83535. * @param mesh The mesh to prepare the morph targets attributes for
  83536. * @param influencers The number of influencers
  83537. */
  83538. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  83539. /**
  83540. * Prepares the list of attributes required for morph targets according to the effect defines.
  83541. * @param attribs The current list of supported attribs
  83542. * @param mesh The mesh to prepare the morph targets attributes for
  83543. * @param defines The current Defines of the effect
  83544. */
  83545. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  83546. /**
  83547. * Prepares the list of attributes required for bones according to the effect defines.
  83548. * @param attribs The current list of supported attribs
  83549. * @param mesh The mesh to prepare the bones attributes for
  83550. * @param defines The current Defines of the effect
  83551. * @param fallbacks The current efffect fallback strategy
  83552. */
  83553. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  83554. /**
  83555. * Check and prepare the list of attributes required for instances according to the effect defines.
  83556. * @param attribs The current list of supported attribs
  83557. * @param defines The current MaterialDefines of the effect
  83558. */
  83559. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  83560. /**
  83561. * Add the list of attributes required for instances to the attribs array.
  83562. * @param attribs The current list of supported attribs
  83563. */
  83564. static PushAttributesForInstances(attribs: string[]): void;
  83565. /**
  83566. * Binds the light information to the effect.
  83567. * @param light The light containing the generator
  83568. * @param effect The effect we are binding the data to
  83569. * @param lightIndex The light index in the effect used to render
  83570. */
  83571. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  83572. /**
  83573. * Binds the lights information from the scene to the effect for the given mesh.
  83574. * @param light Light to bind
  83575. * @param lightIndex Light index
  83576. * @param scene The scene where the light belongs to
  83577. * @param effect The effect we are binding the data to
  83578. * @param useSpecular Defines if specular is supported
  83579. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83580. */
  83581. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  83582. /**
  83583. * Binds the lights information from the scene to the effect for the given mesh.
  83584. * @param scene The scene the lights belongs to
  83585. * @param mesh The mesh we are binding the information to render
  83586. * @param effect The effect we are binding the data to
  83587. * @param defines The generated defines for the effect
  83588. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  83589. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  83590. */
  83591. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  83592. private static _tempFogColor;
  83593. /**
  83594. * Binds the fog information from the scene to the effect for the given mesh.
  83595. * @param scene The scene the lights belongs to
  83596. * @param mesh The mesh we are binding the information to render
  83597. * @param effect The effect we are binding the data to
  83598. * @param linearSpace Defines if the fog effect is applied in linear space
  83599. */
  83600. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  83601. /**
  83602. * Binds the bones information from the mesh to the effect.
  83603. * @param mesh The mesh we are binding the information to render
  83604. * @param effect The effect we are binding the data to
  83605. */
  83606. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  83607. /**
  83608. * Binds the morph targets information from the mesh to the effect.
  83609. * @param abstractMesh The mesh we are binding the information to render
  83610. * @param effect The effect we are binding the data to
  83611. */
  83612. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  83613. /**
  83614. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  83615. * @param defines The generated defines used in the effect
  83616. * @param effect The effect we are binding the data to
  83617. * @param scene The scene we are willing to render with logarithmic scale for
  83618. */
  83619. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  83620. /**
  83621. * Binds the clip plane information from the scene to the effect.
  83622. * @param scene The scene the clip plane information are extracted from
  83623. * @param effect The effect we are binding the data to
  83624. */
  83625. static BindClipPlane(effect: Effect, scene: Scene): void;
  83626. }
  83627. }
  83628. declare module BABYLON {
  83629. /** @hidden */
  83630. export var packingFunctions: {
  83631. name: string;
  83632. shader: string;
  83633. };
  83634. }
  83635. declare module BABYLON {
  83636. /** @hidden */
  83637. export var clipPlaneFragmentDeclaration: {
  83638. name: string;
  83639. shader: string;
  83640. };
  83641. }
  83642. declare module BABYLON {
  83643. /** @hidden */
  83644. export var clipPlaneFragment: {
  83645. name: string;
  83646. shader: string;
  83647. };
  83648. }
  83649. declare module BABYLON {
  83650. /** @hidden */
  83651. export var shadowMapPixelShader: {
  83652. name: string;
  83653. shader: string;
  83654. };
  83655. }
  83656. declare module BABYLON {
  83657. /** @hidden */
  83658. export var bonesDeclaration: {
  83659. name: string;
  83660. shader: string;
  83661. };
  83662. }
  83663. declare module BABYLON {
  83664. /** @hidden */
  83665. export var morphTargetsVertexGlobalDeclaration: {
  83666. name: string;
  83667. shader: string;
  83668. };
  83669. }
  83670. declare module BABYLON {
  83671. /** @hidden */
  83672. export var morphTargetsVertexDeclaration: {
  83673. name: string;
  83674. shader: string;
  83675. };
  83676. }
  83677. declare module BABYLON {
  83678. /** @hidden */
  83679. export var instancesDeclaration: {
  83680. name: string;
  83681. shader: string;
  83682. };
  83683. }
  83684. declare module BABYLON {
  83685. /** @hidden */
  83686. export var helperFunctions: {
  83687. name: string;
  83688. shader: string;
  83689. };
  83690. }
  83691. declare module BABYLON {
  83692. /** @hidden */
  83693. export var clipPlaneVertexDeclaration: {
  83694. name: string;
  83695. shader: string;
  83696. };
  83697. }
  83698. declare module BABYLON {
  83699. /** @hidden */
  83700. export var morphTargetsVertex: {
  83701. name: string;
  83702. shader: string;
  83703. };
  83704. }
  83705. declare module BABYLON {
  83706. /** @hidden */
  83707. export var instancesVertex: {
  83708. name: string;
  83709. shader: string;
  83710. };
  83711. }
  83712. declare module BABYLON {
  83713. /** @hidden */
  83714. export var bonesVertex: {
  83715. name: string;
  83716. shader: string;
  83717. };
  83718. }
  83719. declare module BABYLON {
  83720. /** @hidden */
  83721. export var clipPlaneVertex: {
  83722. name: string;
  83723. shader: string;
  83724. };
  83725. }
  83726. declare module BABYLON {
  83727. /** @hidden */
  83728. export var shadowMapVertexShader: {
  83729. name: string;
  83730. shader: string;
  83731. };
  83732. }
  83733. declare module BABYLON {
  83734. /** @hidden */
  83735. export var depthBoxBlurPixelShader: {
  83736. name: string;
  83737. shader: string;
  83738. };
  83739. }
  83740. declare module BABYLON {
  83741. /**
  83742. * Class representing a ray with position and direction
  83743. */
  83744. export class Ray {
  83745. /** origin point */
  83746. origin: Vector3;
  83747. /** direction */
  83748. direction: Vector3;
  83749. /** length of the ray */
  83750. length: number;
  83751. private static readonly TmpVector3;
  83752. private _tmpRay;
  83753. /**
  83754. * Creates a new ray
  83755. * @param origin origin point
  83756. * @param direction direction
  83757. * @param length length of the ray
  83758. */
  83759. constructor(
  83760. /** origin point */
  83761. origin: Vector3,
  83762. /** direction */
  83763. direction: Vector3,
  83764. /** length of the ray */
  83765. length?: number);
  83766. /**
  83767. * Checks if the ray intersects a box
  83768. * @param minimum bound of the box
  83769. * @param maximum bound of the box
  83770. * @param intersectionTreshold extra extend to be added to the box in all direction
  83771. * @returns if the box was hit
  83772. */
  83773. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  83774. /**
  83775. * Checks if the ray intersects a box
  83776. * @param box the bounding box to check
  83777. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  83778. * @returns if the box was hit
  83779. */
  83780. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  83781. /**
  83782. * If the ray hits a sphere
  83783. * @param sphere the bounding sphere to check
  83784. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  83785. * @returns true if it hits the sphere
  83786. */
  83787. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  83788. /**
  83789. * If the ray hits a triange
  83790. * @param vertex0 triangle vertex
  83791. * @param vertex1 triangle vertex
  83792. * @param vertex2 triangle vertex
  83793. * @returns intersection information if hit
  83794. */
  83795. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  83796. /**
  83797. * Checks if ray intersects a plane
  83798. * @param plane the plane to check
  83799. * @returns the distance away it was hit
  83800. */
  83801. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  83802. /**
  83803. * Calculate the intercept of a ray on a given axis
  83804. * @param axis to check 'x' | 'y' | 'z'
  83805. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  83806. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  83807. */
  83808. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  83809. /**
  83810. * Checks if ray intersects a mesh
  83811. * @param mesh the mesh to check
  83812. * @param fastCheck if only the bounding box should checked
  83813. * @returns picking info of the intersecton
  83814. */
  83815. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  83816. /**
  83817. * Checks if ray intersects a mesh
  83818. * @param meshes the meshes to check
  83819. * @param fastCheck if only the bounding box should checked
  83820. * @param results array to store result in
  83821. * @returns Array of picking infos
  83822. */
  83823. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  83824. private _comparePickingInfo;
  83825. private static smallnum;
  83826. private static rayl;
  83827. /**
  83828. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  83829. * @param sega the first point of the segment to test the intersection against
  83830. * @param segb the second point of the segment to test the intersection against
  83831. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  83832. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  83833. */
  83834. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  83835. /**
  83836. * Update the ray from viewport position
  83837. * @param x position
  83838. * @param y y position
  83839. * @param viewportWidth viewport width
  83840. * @param viewportHeight viewport height
  83841. * @param world world matrix
  83842. * @param view view matrix
  83843. * @param projection projection matrix
  83844. * @returns this ray updated
  83845. */
  83846. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83847. /**
  83848. * Creates a ray with origin and direction of 0,0,0
  83849. * @returns the new ray
  83850. */
  83851. static Zero(): Ray;
  83852. /**
  83853. * Creates a new ray from screen space and viewport
  83854. * @param x position
  83855. * @param y y position
  83856. * @param viewportWidth viewport width
  83857. * @param viewportHeight viewport height
  83858. * @param world world matrix
  83859. * @param view view matrix
  83860. * @param projection projection matrix
  83861. * @returns new ray
  83862. */
  83863. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  83864. /**
  83865. * 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
  83866. * transformed to the given world matrix.
  83867. * @param origin The origin point
  83868. * @param end The end point
  83869. * @param world a matrix to transform the ray to. Default is the identity matrix.
  83870. * @returns the new ray
  83871. */
  83872. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  83873. /**
  83874. * Transforms a ray by a matrix
  83875. * @param ray ray to transform
  83876. * @param matrix matrix to apply
  83877. * @returns the resulting new ray
  83878. */
  83879. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  83880. /**
  83881. * Transforms a ray by a matrix
  83882. * @param ray ray to transform
  83883. * @param matrix matrix to apply
  83884. * @param result ray to store result in
  83885. */
  83886. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  83887. /**
  83888. * Unproject a ray from screen space to object space
  83889. * @param sourceX defines the screen space x coordinate to use
  83890. * @param sourceY defines the screen space y coordinate to use
  83891. * @param viewportWidth defines the current width of the viewport
  83892. * @param viewportHeight defines the current height of the viewport
  83893. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83894. * @param view defines the view matrix to use
  83895. * @param projection defines the projection matrix to use
  83896. */
  83897. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  83898. }
  83899. /**
  83900. * Type used to define predicate used to select faces when a mesh intersection is detected
  83901. */
  83902. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  83903. interface Scene {
  83904. /** @hidden */
  83905. _tempPickingRay: Nullable<Ray>;
  83906. /** @hidden */
  83907. _cachedRayForTransform: Ray;
  83908. /** @hidden */
  83909. _pickWithRayInverseMatrix: Matrix;
  83910. /** @hidden */
  83911. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  83912. /** @hidden */
  83913. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  83914. }
  83915. }
  83916. declare module BABYLON {
  83917. /**
  83918. * Groups all the scene component constants in one place to ease maintenance.
  83919. * @hidden
  83920. */
  83921. export class SceneComponentConstants {
  83922. static readonly NAME_EFFECTLAYER: string;
  83923. static readonly NAME_LAYER: string;
  83924. static readonly NAME_LENSFLARESYSTEM: string;
  83925. static readonly NAME_BOUNDINGBOXRENDERER: string;
  83926. static readonly NAME_PARTICLESYSTEM: string;
  83927. static readonly NAME_GAMEPAD: string;
  83928. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  83929. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  83930. static readonly NAME_DEPTHRENDERER: string;
  83931. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  83932. static readonly NAME_SPRITE: string;
  83933. static readonly NAME_OUTLINERENDERER: string;
  83934. static readonly NAME_PROCEDURALTEXTURE: string;
  83935. static readonly NAME_SHADOWGENERATOR: string;
  83936. static readonly NAME_OCTREE: string;
  83937. static readonly NAME_PHYSICSENGINE: string;
  83938. static readonly NAME_AUDIO: string;
  83939. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  83940. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83941. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  83942. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  83943. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  83944. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  83945. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  83946. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  83947. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  83948. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  83949. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  83950. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  83951. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  83952. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  83953. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  83954. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  83955. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  83956. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  83957. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  83958. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  83959. static readonly STEP_AFTERRENDER_AUDIO: number;
  83960. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  83961. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  83962. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  83963. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  83964. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  83965. static readonly STEP_POINTERMOVE_SPRITE: number;
  83966. static readonly STEP_POINTERDOWN_SPRITE: number;
  83967. static readonly STEP_POINTERUP_SPRITE: number;
  83968. }
  83969. /**
  83970. * This represents a scene component.
  83971. *
  83972. * This is used to decouple the dependency the scene is having on the different workloads like
  83973. * layers, post processes...
  83974. */
  83975. export interface ISceneComponent {
  83976. /**
  83977. * The name of the component. Each component must have a unique name.
  83978. */
  83979. name: string;
  83980. /**
  83981. * The scene the component belongs to.
  83982. */
  83983. scene: Scene;
  83984. /**
  83985. * Register the component to one instance of a scene.
  83986. */
  83987. register(): void;
  83988. /**
  83989. * Rebuilds the elements related to this component in case of
  83990. * context lost for instance.
  83991. */
  83992. rebuild(): void;
  83993. /**
  83994. * Disposes the component and the associated ressources.
  83995. */
  83996. dispose(): void;
  83997. }
  83998. /**
  83999. * This represents a SERIALIZABLE scene component.
  84000. *
  84001. * This extends Scene Component to add Serialization methods on top.
  84002. */
  84003. export interface ISceneSerializableComponent extends ISceneComponent {
  84004. /**
  84005. * Adds all the elements from the container to the scene
  84006. * @param container the container holding the elements
  84007. */
  84008. addFromContainer(container: AbstractScene): void;
  84009. /**
  84010. * Removes all the elements in the container from the scene
  84011. * @param container contains the elements to remove
  84012. * @param dispose if the removed element should be disposed (default: false)
  84013. */
  84014. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  84015. /**
  84016. * Serializes the component data to the specified json object
  84017. * @param serializationObject The object to serialize to
  84018. */
  84019. serialize(serializationObject: any): void;
  84020. }
  84021. /**
  84022. * Strong typing of a Mesh related stage step action
  84023. */
  84024. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  84025. /**
  84026. * Strong typing of a Evaluate Sub Mesh related stage step action
  84027. */
  84028. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  84029. /**
  84030. * Strong typing of a Active Mesh related stage step action
  84031. */
  84032. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  84033. /**
  84034. * Strong typing of a Camera related stage step action
  84035. */
  84036. export type CameraStageAction = (camera: Camera) => void;
  84037. /**
  84038. * Strong typing of a Camera Frame buffer related stage step action
  84039. */
  84040. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  84041. /**
  84042. * Strong typing of a Render Target related stage step action
  84043. */
  84044. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  84045. /**
  84046. * Strong typing of a RenderingGroup related stage step action
  84047. */
  84048. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  84049. /**
  84050. * Strong typing of a Mesh Render related stage step action
  84051. */
  84052. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  84053. /**
  84054. * Strong typing of a simple stage step action
  84055. */
  84056. export type SimpleStageAction = () => void;
  84057. /**
  84058. * Strong typing of a render target action.
  84059. */
  84060. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  84061. /**
  84062. * Strong typing of a pointer move action.
  84063. */
  84064. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  84065. /**
  84066. * Strong typing of a pointer up/down action.
  84067. */
  84068. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  84069. /**
  84070. * Representation of a stage in the scene (Basically a list of ordered steps)
  84071. * @hidden
  84072. */
  84073. export class Stage<T extends Function> extends Array<{
  84074. index: number;
  84075. component: ISceneComponent;
  84076. action: T;
  84077. }> {
  84078. /**
  84079. * Hide ctor from the rest of the world.
  84080. * @param items The items to add.
  84081. */
  84082. private constructor();
  84083. /**
  84084. * Creates a new Stage.
  84085. * @returns A new instance of a Stage
  84086. */
  84087. static Create<T extends Function>(): Stage<T>;
  84088. /**
  84089. * Registers a step in an ordered way in the targeted stage.
  84090. * @param index Defines the position to register the step in
  84091. * @param component Defines the component attached to the step
  84092. * @param action Defines the action to launch during the step
  84093. */
  84094. registerStep(index: number, component: ISceneComponent, action: T): void;
  84095. /**
  84096. * Clears all the steps from the stage.
  84097. */
  84098. clear(): void;
  84099. }
  84100. }
  84101. declare module BABYLON {
  84102. interface Scene {
  84103. /** @hidden */
  84104. _pointerOverSprite: Nullable<Sprite>;
  84105. /** @hidden */
  84106. _pickedDownSprite: Nullable<Sprite>;
  84107. /** @hidden */
  84108. _tempSpritePickingRay: Nullable<Ray>;
  84109. /**
  84110. * All of the sprite managers added to this scene
  84111. * @see http://doc.babylonjs.com/babylon101/sprites
  84112. */
  84113. spriteManagers: Array<ISpriteManager>;
  84114. /**
  84115. * An event triggered when sprites rendering is about to start
  84116. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84117. */
  84118. onBeforeSpritesRenderingObservable: Observable<Scene>;
  84119. /**
  84120. * An event triggered when sprites rendering is done
  84121. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  84122. */
  84123. onAfterSpritesRenderingObservable: Observable<Scene>;
  84124. /** @hidden */
  84125. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84126. /** Launch a ray to try to pick a sprite in the scene
  84127. * @param x position on screen
  84128. * @param y position on screen
  84129. * @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
  84130. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84131. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84132. * @returns a PickingInfo
  84133. */
  84134. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84135. /** Use the given ray to pick a sprite in the scene
  84136. * @param ray The ray (in world space) to use to pick meshes
  84137. * @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
  84138. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  84139. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84140. * @returns a PickingInfo
  84141. */
  84142. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  84143. /** @hidden */
  84144. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84145. /** Launch a ray to try to pick sprites in the scene
  84146. * @param x position on screen
  84147. * @param y position on screen
  84148. * @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
  84149. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  84150. * @returns a PickingInfo array
  84151. */
  84152. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84153. /** Use the given ray to pick sprites in the scene
  84154. * @param ray The ray (in world space) to use to pick meshes
  84155. * @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
  84156. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  84157. * @returns a PickingInfo array
  84158. */
  84159. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  84160. /**
  84161. * Force the sprite under the pointer
  84162. * @param sprite defines the sprite to use
  84163. */
  84164. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  84165. /**
  84166. * Gets the sprite under the pointer
  84167. * @returns a Sprite or null if no sprite is under the pointer
  84168. */
  84169. getPointerOverSprite(): Nullable<Sprite>;
  84170. }
  84171. /**
  84172. * Defines the sprite scene component responsible to manage sprites
  84173. * in a given scene.
  84174. */
  84175. export class SpriteSceneComponent implements ISceneComponent {
  84176. /**
  84177. * The component name helpfull to identify the component in the list of scene components.
  84178. */
  84179. readonly name: string;
  84180. /**
  84181. * The scene the component belongs to.
  84182. */
  84183. scene: Scene;
  84184. /** @hidden */
  84185. private _spritePredicate;
  84186. /**
  84187. * Creates a new instance of the component for the given scene
  84188. * @param scene Defines the scene to register the component in
  84189. */
  84190. constructor(scene: Scene);
  84191. /**
  84192. * Registers the component in a given scene
  84193. */
  84194. register(): void;
  84195. /**
  84196. * Rebuilds the elements related to this component in case of
  84197. * context lost for instance.
  84198. */
  84199. rebuild(): void;
  84200. /**
  84201. * Disposes the component and the associated ressources.
  84202. */
  84203. dispose(): void;
  84204. private _pickSpriteButKeepRay;
  84205. private _pointerMove;
  84206. private _pointerDown;
  84207. private _pointerUp;
  84208. }
  84209. }
  84210. declare module BABYLON {
  84211. /** @hidden */
  84212. export var fogFragmentDeclaration: {
  84213. name: string;
  84214. shader: string;
  84215. };
  84216. }
  84217. declare module BABYLON {
  84218. /** @hidden */
  84219. export var fogFragment: {
  84220. name: string;
  84221. shader: string;
  84222. };
  84223. }
  84224. declare module BABYLON {
  84225. /** @hidden */
  84226. export var spritesPixelShader: {
  84227. name: string;
  84228. shader: string;
  84229. };
  84230. }
  84231. declare module BABYLON {
  84232. /** @hidden */
  84233. export var fogVertexDeclaration: {
  84234. name: string;
  84235. shader: string;
  84236. };
  84237. }
  84238. declare module BABYLON {
  84239. /** @hidden */
  84240. export var spritesVertexShader: {
  84241. name: string;
  84242. shader: string;
  84243. };
  84244. }
  84245. declare module BABYLON {
  84246. /**
  84247. * Defines the minimum interface to fullfil in order to be a sprite manager.
  84248. */
  84249. export interface ISpriteManager extends IDisposable {
  84250. /**
  84251. * Restricts the camera to viewing objects with the same layerMask.
  84252. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  84253. */
  84254. layerMask: number;
  84255. /**
  84256. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  84257. */
  84258. isPickable: boolean;
  84259. /**
  84260. * Specifies the rendering group id for this mesh (0 by default)
  84261. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  84262. */
  84263. renderingGroupId: number;
  84264. /**
  84265. * Defines the list of sprites managed by the manager.
  84266. */
  84267. sprites: Array<Sprite>;
  84268. /**
  84269. * Tests the intersection of a sprite with a specific ray.
  84270. * @param ray The ray we are sending to test the collision
  84271. * @param camera The camera space we are sending rays in
  84272. * @param predicate A predicate allowing excluding sprites from the list of object to test
  84273. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  84274. * @returns picking info or null.
  84275. */
  84276. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84277. /**
  84278. * Intersects the sprites with a ray
  84279. * @param ray defines the ray to intersect with
  84280. * @param camera defines the current active camera
  84281. * @param predicate defines a predicate used to select candidate sprites
  84282. * @returns null if no hit or a PickingInfo array
  84283. */
  84284. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84285. /**
  84286. * Renders the list of sprites on screen.
  84287. */
  84288. render(): void;
  84289. }
  84290. /**
  84291. * Class used to manage multiple sprites on the same spritesheet
  84292. * @see http://doc.babylonjs.com/babylon101/sprites
  84293. */
  84294. export class SpriteManager implements ISpriteManager {
  84295. /** defines the manager's name */
  84296. name: string;
  84297. /** Gets the list of sprites */
  84298. sprites: Sprite[];
  84299. /** Gets or sets the rendering group id (0 by default) */
  84300. renderingGroupId: number;
  84301. /** Gets or sets camera layer mask */
  84302. layerMask: number;
  84303. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  84304. fogEnabled: boolean;
  84305. /** Gets or sets a boolean indicating if the sprites are pickable */
  84306. isPickable: boolean;
  84307. /** Defines the default width of a cell in the spritesheet */
  84308. cellWidth: number;
  84309. /** Defines the default height of a cell in the spritesheet */
  84310. cellHeight: number;
  84311. /** Associative array from JSON sprite data file */
  84312. private _cellData;
  84313. /** Array of sprite names from JSON sprite data file */
  84314. private _spriteMap;
  84315. /** True when packed cell data from JSON file is ready*/
  84316. private _packedAndReady;
  84317. /**
  84318. * An event triggered when the manager is disposed.
  84319. */
  84320. onDisposeObservable: Observable<SpriteManager>;
  84321. private _onDisposeObserver;
  84322. /**
  84323. * Callback called when the manager is disposed
  84324. */
  84325. set onDispose(callback: () => void);
  84326. private _capacity;
  84327. private _fromPacked;
  84328. private _spriteTexture;
  84329. private _epsilon;
  84330. private _scene;
  84331. private _vertexData;
  84332. private _buffer;
  84333. private _vertexBuffers;
  84334. private _indexBuffer;
  84335. private _effectBase;
  84336. private _effectFog;
  84337. /**
  84338. * Gets or sets the spritesheet texture
  84339. */
  84340. get texture(): Texture;
  84341. set texture(value: Texture);
  84342. private _blendMode;
  84343. /**
  84344. * Blend mode use to render the particle, it can be any of
  84345. * the static Constants.ALPHA_x properties provided in this class.
  84346. * Default value is Constants.ALPHA_COMBINE
  84347. */
  84348. get blendMode(): number;
  84349. set blendMode(blendMode: number);
  84350. /** Disables writing to the depth buffer when rendering the sprites.
  84351. * It can be handy to disable depth writing when using textures without alpha channel
  84352. * and setting some specific blend modes.
  84353. */
  84354. disableDepthWrite: boolean;
  84355. /**
  84356. * Creates a new sprite manager
  84357. * @param name defines the manager's name
  84358. * @param imgUrl defines the sprite sheet url
  84359. * @param capacity defines the maximum allowed number of sprites
  84360. * @param cellSize defines the size of a sprite cell
  84361. * @param scene defines the hosting scene
  84362. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  84363. * @param samplingMode defines the smapling mode to use with spritesheet
  84364. * @param fromPacked set to false; do not alter
  84365. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  84366. */
  84367. constructor(
  84368. /** defines the manager's name */
  84369. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  84370. private _makePacked;
  84371. private _appendSpriteVertex;
  84372. /**
  84373. * Intersects the sprites with a ray
  84374. * @param ray defines the ray to intersect with
  84375. * @param camera defines the current active camera
  84376. * @param predicate defines a predicate used to select candidate sprites
  84377. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  84378. * @returns null if no hit or a PickingInfo
  84379. */
  84380. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  84381. /**
  84382. * Intersects the sprites with a ray
  84383. * @param ray defines the ray to intersect with
  84384. * @param camera defines the current active camera
  84385. * @param predicate defines a predicate used to select candidate sprites
  84386. * @returns null if no hit or a PickingInfo array
  84387. */
  84388. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  84389. /**
  84390. * Render all child sprites
  84391. */
  84392. render(): void;
  84393. /**
  84394. * Release associated resources
  84395. */
  84396. dispose(): void;
  84397. }
  84398. }
  84399. declare module BABYLON {
  84400. /** Interface used by value gradients (color, factor, ...) */
  84401. export interface IValueGradient {
  84402. /**
  84403. * Gets or sets the gradient value (between 0 and 1)
  84404. */
  84405. gradient: number;
  84406. }
  84407. /** Class used to store color4 gradient */
  84408. export class ColorGradient implements IValueGradient {
  84409. /**
  84410. * Gets or sets the gradient value (between 0 and 1)
  84411. */
  84412. gradient: number;
  84413. /**
  84414. * Gets or sets first associated color
  84415. */
  84416. color1: Color4;
  84417. /**
  84418. * Gets or sets second associated color
  84419. */
  84420. color2?: Color4 | undefined;
  84421. /**
  84422. * Creates a new color4 gradient
  84423. * @param gradient gets or sets the gradient value (between 0 and 1)
  84424. * @param color1 gets or sets first associated color
  84425. * @param color2 gets or sets first second color
  84426. */
  84427. constructor(
  84428. /**
  84429. * Gets or sets the gradient value (between 0 and 1)
  84430. */
  84431. gradient: number,
  84432. /**
  84433. * Gets or sets first associated color
  84434. */
  84435. color1: Color4,
  84436. /**
  84437. * Gets or sets second associated color
  84438. */
  84439. color2?: Color4 | undefined);
  84440. /**
  84441. * Will get a color picked randomly between color1 and color2.
  84442. * If color2 is undefined then color1 will be used
  84443. * @param result defines the target Color4 to store the result in
  84444. */
  84445. getColorToRef(result: Color4): void;
  84446. }
  84447. /** Class used to store color 3 gradient */
  84448. export class Color3Gradient implements IValueGradient {
  84449. /**
  84450. * Gets or sets the gradient value (between 0 and 1)
  84451. */
  84452. gradient: number;
  84453. /**
  84454. * Gets or sets the associated color
  84455. */
  84456. color: Color3;
  84457. /**
  84458. * Creates a new color3 gradient
  84459. * @param gradient gets or sets the gradient value (between 0 and 1)
  84460. * @param color gets or sets associated color
  84461. */
  84462. constructor(
  84463. /**
  84464. * Gets or sets the gradient value (between 0 and 1)
  84465. */
  84466. gradient: number,
  84467. /**
  84468. * Gets or sets the associated color
  84469. */
  84470. color: Color3);
  84471. }
  84472. /** Class used to store factor gradient */
  84473. export class FactorGradient implements IValueGradient {
  84474. /**
  84475. * Gets or sets the gradient value (between 0 and 1)
  84476. */
  84477. gradient: number;
  84478. /**
  84479. * Gets or sets first associated factor
  84480. */
  84481. factor1: number;
  84482. /**
  84483. * Gets or sets second associated factor
  84484. */
  84485. factor2?: number | undefined;
  84486. /**
  84487. * Creates a new factor gradient
  84488. * @param gradient gets or sets the gradient value (between 0 and 1)
  84489. * @param factor1 gets or sets first associated factor
  84490. * @param factor2 gets or sets second associated factor
  84491. */
  84492. constructor(
  84493. /**
  84494. * Gets or sets the gradient value (between 0 and 1)
  84495. */
  84496. gradient: number,
  84497. /**
  84498. * Gets or sets first associated factor
  84499. */
  84500. factor1: number,
  84501. /**
  84502. * Gets or sets second associated factor
  84503. */
  84504. factor2?: number | undefined);
  84505. /**
  84506. * Will get a number picked randomly between factor1 and factor2.
  84507. * If factor2 is undefined then factor1 will be used
  84508. * @returns the picked number
  84509. */
  84510. getFactor(): number;
  84511. }
  84512. /**
  84513. * Helper used to simplify some generic gradient tasks
  84514. */
  84515. export class GradientHelper {
  84516. /**
  84517. * Gets the current gradient from an array of IValueGradient
  84518. * @param ratio defines the current ratio to get
  84519. * @param gradients defines the array of IValueGradient
  84520. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  84521. */
  84522. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  84523. }
  84524. }
  84525. declare module BABYLON {
  84526. /**
  84527. * Interface for the size containing width and height
  84528. */
  84529. export interface ISize {
  84530. /**
  84531. * Width
  84532. */
  84533. width: number;
  84534. /**
  84535. * Heighht
  84536. */
  84537. height: number;
  84538. }
  84539. /**
  84540. * Size containing widht and height
  84541. */
  84542. export class Size implements ISize {
  84543. /**
  84544. * Width
  84545. */
  84546. width: number;
  84547. /**
  84548. * Height
  84549. */
  84550. height: number;
  84551. /**
  84552. * Creates a Size object from the given width and height (floats).
  84553. * @param width width of the new size
  84554. * @param height height of the new size
  84555. */
  84556. constructor(width: number, height: number);
  84557. /**
  84558. * Returns a string with the Size width and height
  84559. * @returns a string with the Size width and height
  84560. */
  84561. toString(): string;
  84562. /**
  84563. * "Size"
  84564. * @returns the string "Size"
  84565. */
  84566. getClassName(): string;
  84567. /**
  84568. * Returns the Size hash code.
  84569. * @returns a hash code for a unique width and height
  84570. */
  84571. getHashCode(): number;
  84572. /**
  84573. * Updates the current size from the given one.
  84574. * @param src the given size
  84575. */
  84576. copyFrom(src: Size): void;
  84577. /**
  84578. * Updates in place the current Size from the given floats.
  84579. * @param width width of the new size
  84580. * @param height height of the new size
  84581. * @returns the updated Size.
  84582. */
  84583. copyFromFloats(width: number, height: number): Size;
  84584. /**
  84585. * Updates in place the current Size from the given floats.
  84586. * @param width width to set
  84587. * @param height height to set
  84588. * @returns the updated Size.
  84589. */
  84590. set(width: number, height: number): Size;
  84591. /**
  84592. * Multiplies the width and height by numbers
  84593. * @param w factor to multiple the width by
  84594. * @param h factor to multiple the height by
  84595. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  84596. */
  84597. multiplyByFloats(w: number, h: number): Size;
  84598. /**
  84599. * Clones the size
  84600. * @returns a new Size copied from the given one.
  84601. */
  84602. clone(): Size;
  84603. /**
  84604. * True if the current Size and the given one width and height are strictly equal.
  84605. * @param other the other size to compare against
  84606. * @returns True if the current Size and the given one width and height are strictly equal.
  84607. */
  84608. equals(other: Size): boolean;
  84609. /**
  84610. * The surface of the Size : width * height (float).
  84611. */
  84612. get surface(): number;
  84613. /**
  84614. * Create a new size of zero
  84615. * @returns a new Size set to (0.0, 0.0)
  84616. */
  84617. static Zero(): Size;
  84618. /**
  84619. * Sums the width and height of two sizes
  84620. * @param otherSize size to add to this size
  84621. * @returns a new Size set as the addition result of the current Size and the given one.
  84622. */
  84623. add(otherSize: Size): Size;
  84624. /**
  84625. * Subtracts the width and height of two
  84626. * @param otherSize size to subtract to this size
  84627. * @returns a new Size set as the subtraction result of the given one from the current Size.
  84628. */
  84629. subtract(otherSize: Size): Size;
  84630. /**
  84631. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  84632. * @param start starting size to lerp between
  84633. * @param end end size to lerp between
  84634. * @param amount amount to lerp between the start and end values
  84635. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  84636. */
  84637. static Lerp(start: Size, end: Size, amount: number): Size;
  84638. }
  84639. }
  84640. declare module BABYLON {
  84641. interface ThinEngine {
  84642. /**
  84643. * Creates a dynamic texture
  84644. * @param width defines the width of the texture
  84645. * @param height defines the height of the texture
  84646. * @param generateMipMaps defines if the engine should generate the mip levels
  84647. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84648. * @returns the dynamic texture inside an InternalTexture
  84649. */
  84650. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  84651. /**
  84652. * Update the content of a dynamic texture
  84653. * @param texture defines the texture to update
  84654. * @param canvas defines the canvas containing the source
  84655. * @param invertY defines if data must be stored with Y axis inverted
  84656. * @param premulAlpha defines if alpha is stored as premultiplied
  84657. * @param format defines the format of the data
  84658. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  84659. */
  84660. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  84661. }
  84662. }
  84663. declare module BABYLON {
  84664. /**
  84665. * Helper class used to generate a canvas to manipulate images
  84666. */
  84667. export class CanvasGenerator {
  84668. /**
  84669. * Create a new canvas (or offscreen canvas depending on the context)
  84670. * @param width defines the expected width
  84671. * @param height defines the expected height
  84672. * @return a new canvas or offscreen canvas
  84673. */
  84674. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  84675. }
  84676. }
  84677. declare module BABYLON {
  84678. /**
  84679. * A class extending Texture allowing drawing on a texture
  84680. * @see http://doc.babylonjs.com/how_to/dynamictexture
  84681. */
  84682. export class DynamicTexture extends Texture {
  84683. private _generateMipMaps;
  84684. private _canvas;
  84685. private _context;
  84686. private _engine;
  84687. /**
  84688. * Creates a DynamicTexture
  84689. * @param name defines the name of the texture
  84690. * @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
  84691. * @param scene defines the scene where you want the texture
  84692. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  84693. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  84694. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  84695. */
  84696. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  84697. /**
  84698. * Get the current class name of the texture useful for serialization or dynamic coding.
  84699. * @returns "DynamicTexture"
  84700. */
  84701. getClassName(): string;
  84702. /**
  84703. * Gets the current state of canRescale
  84704. */
  84705. get canRescale(): boolean;
  84706. private _recreate;
  84707. /**
  84708. * Scales the texture
  84709. * @param ratio the scale factor to apply to both width and height
  84710. */
  84711. scale(ratio: number): void;
  84712. /**
  84713. * Resizes the texture
  84714. * @param width the new width
  84715. * @param height the new height
  84716. */
  84717. scaleTo(width: number, height: number): void;
  84718. /**
  84719. * Gets the context of the canvas used by the texture
  84720. * @returns the canvas context of the dynamic texture
  84721. */
  84722. getContext(): CanvasRenderingContext2D;
  84723. /**
  84724. * Clears the texture
  84725. */
  84726. clear(): void;
  84727. /**
  84728. * Updates the texture
  84729. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84730. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  84731. */
  84732. update(invertY?: boolean, premulAlpha?: boolean): void;
  84733. /**
  84734. * Draws text onto the texture
  84735. * @param text defines the text to be drawn
  84736. * @param x defines the placement of the text from the left
  84737. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  84738. * @param font defines the font to be used with font-style, font-size, font-name
  84739. * @param color defines the color used for the text
  84740. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  84741. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  84742. * @param update defines whether texture is immediately update (default is true)
  84743. */
  84744. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  84745. /**
  84746. * Clones the texture
  84747. * @returns the clone of the texture.
  84748. */
  84749. clone(): DynamicTexture;
  84750. /**
  84751. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  84752. * @returns a serialized dynamic texture object
  84753. */
  84754. serialize(): any;
  84755. /** @hidden */
  84756. _rebuild(): void;
  84757. }
  84758. }
  84759. declare module BABYLON {
  84760. interface Engine {
  84761. /**
  84762. * Creates a raw texture
  84763. * @param data defines the data to store in the texture
  84764. * @param width defines the width of the texture
  84765. * @param height defines the height of the texture
  84766. * @param format defines the format of the data
  84767. * @param generateMipMaps defines if the engine should generate the mip levels
  84768. * @param invertY defines if data must be stored with Y axis inverted
  84769. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  84770. * @param compression defines the compression used (null by default)
  84771. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84772. * @returns the raw texture inside an InternalTexture
  84773. */
  84774. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  84775. /**
  84776. * Update a raw texture
  84777. * @param texture defines the texture to update
  84778. * @param data defines the data to store in the texture
  84779. * @param format defines the format of the data
  84780. * @param invertY defines if data must be stored with Y axis inverted
  84781. */
  84782. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84783. /**
  84784. * Update a raw texture
  84785. * @param texture defines the texture to update
  84786. * @param data defines the data to store in the texture
  84787. * @param format defines the format of the data
  84788. * @param invertY defines if data must be stored with Y axis inverted
  84789. * @param compression defines the compression used (null by default)
  84790. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84791. */
  84792. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  84793. /**
  84794. * Creates a new raw cube texture
  84795. * @param data defines the array of data to use to create each face
  84796. * @param size defines the size of the textures
  84797. * @param format defines the format of the data
  84798. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84799. * @param generateMipMaps defines if the engine should generate the mip levels
  84800. * @param invertY defines if data must be stored with Y axis inverted
  84801. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84802. * @param compression defines the compression used (null by default)
  84803. * @returns the cube texture as an InternalTexture
  84804. */
  84805. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  84806. /**
  84807. * Update a raw cube texture
  84808. * @param texture defines the texture to udpdate
  84809. * @param data defines the data to store
  84810. * @param format defines the data format
  84811. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84812. * @param invertY defines if data must be stored with Y axis inverted
  84813. */
  84814. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): 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. */
  84824. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  84825. /**
  84826. * Update a raw cube texture
  84827. * @param texture defines the texture to udpdate
  84828. * @param data defines the data to store
  84829. * @param format defines the data format
  84830. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  84831. * @param invertY defines if data must be stored with Y axis inverted
  84832. * @param compression defines the compression used (null by default)
  84833. * @param level defines which level of the texture to update
  84834. */
  84835. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  84836. /**
  84837. * Creates a new raw cube texture from a specified url
  84838. * @param url defines the url where the data is located
  84839. * @param scene defines the current scene
  84840. * @param size defines the size of the textures
  84841. * @param format defines the format of the data
  84842. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84843. * @param noMipmap defines if the engine should avoid generating the mip levels
  84844. * @param callback defines a callback used to extract texture data from loaded data
  84845. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84846. * @param onLoad defines a callback called when texture is loaded
  84847. * @param onError defines a callback called if there is an error
  84848. * @returns the cube texture as an InternalTexture
  84849. */
  84850. 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;
  84851. /**
  84852. * Creates a new raw cube texture from a specified url
  84853. * @param url defines the url where the data is located
  84854. * @param scene defines the current scene
  84855. * @param size defines the size of the textures
  84856. * @param format defines the format of the data
  84857. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  84858. * @param noMipmap defines if the engine should avoid generating the mip levels
  84859. * @param callback defines a callback used to extract texture data from loaded data
  84860. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  84861. * @param onLoad defines a callback called when texture is loaded
  84862. * @param onError defines a callback called if there is an error
  84863. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84864. * @param invertY defines if data must be stored with Y axis inverted
  84865. * @returns the cube texture as an InternalTexture
  84866. */
  84867. 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;
  84868. /**
  84869. * Creates a new raw 3D texture
  84870. * @param data defines the data used to create the texture
  84871. * @param width defines the width of the texture
  84872. * @param height defines the height of the texture
  84873. * @param depth defines the depth of the texture
  84874. * @param format defines the format of the texture
  84875. * @param generateMipMaps defines if the engine must generate mip levels
  84876. * @param invertY defines if data must be stored with Y axis inverted
  84877. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84878. * @param compression defines the compressed used (can be null)
  84879. * @param textureType defines the compressed used (can be null)
  84880. * @returns a new raw 3D texture (stored in an InternalTexture)
  84881. */
  84882. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84883. /**
  84884. * Update a raw 3D texture
  84885. * @param texture defines the texture to update
  84886. * @param data defines the data to store
  84887. * @param format defines the data format
  84888. * @param invertY defines if data must be stored with Y axis inverted
  84889. */
  84890. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84891. /**
  84892. * Update a raw 3D texture
  84893. * @param texture defines the texture to update
  84894. * @param data defines the data to store
  84895. * @param format defines the data format
  84896. * @param invertY defines if data must be stored with Y axis inverted
  84897. * @param compression defines the used compression (can be null)
  84898. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84899. */
  84900. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84901. /**
  84902. * Creates a new raw 2D array texture
  84903. * @param data defines the data used to create the texture
  84904. * @param width defines the width of the texture
  84905. * @param height defines the height of the texture
  84906. * @param depth defines the number of layers of the texture
  84907. * @param format defines the format of the texture
  84908. * @param generateMipMaps defines if the engine must generate mip levels
  84909. * @param invertY defines if data must be stored with Y axis inverted
  84910. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  84911. * @param compression defines the compressed used (can be null)
  84912. * @param textureType defines the compressed used (can be null)
  84913. * @returns a new raw 2D array texture (stored in an InternalTexture)
  84914. */
  84915. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  84916. /**
  84917. * Update a raw 2D array texture
  84918. * @param texture defines the texture to update
  84919. * @param data defines the data to store
  84920. * @param format defines the data format
  84921. * @param invertY defines if data must be stored with Y axis inverted
  84922. */
  84923. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  84924. /**
  84925. * Update a raw 2D array texture
  84926. * @param texture defines the texture to update
  84927. * @param data defines the data to store
  84928. * @param format defines the data format
  84929. * @param invertY defines if data must be stored with Y axis inverted
  84930. * @param compression defines the used compression (can be null)
  84931. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  84932. */
  84933. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  84934. }
  84935. }
  84936. declare module BABYLON {
  84937. /**
  84938. * Raw texture can help creating a texture directly from an array of data.
  84939. * This can be super useful if you either get the data from an uncompressed source or
  84940. * if you wish to create your texture pixel by pixel.
  84941. */
  84942. export class RawTexture extends Texture {
  84943. /**
  84944. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84945. */
  84946. format: number;
  84947. private _engine;
  84948. /**
  84949. * Instantiates a new RawTexture.
  84950. * Raw texture can help creating a texture directly from an array of data.
  84951. * This can be super useful if you either get the data from an uncompressed source or
  84952. * if you wish to create your texture pixel by pixel.
  84953. * @param data define the array of data to use to create the texture
  84954. * @param width define the width of the texture
  84955. * @param height define the height of the texture
  84956. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84957. * @param scene define the scene the texture belongs to
  84958. * @param generateMipMaps define whether mip maps should be generated or not
  84959. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84960. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84961. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  84962. */
  84963. constructor(data: ArrayBufferView, width: number, height: number,
  84964. /**
  84965. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  84966. */
  84967. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  84968. /**
  84969. * Updates the texture underlying data.
  84970. * @param data Define the new data of the texture
  84971. */
  84972. update(data: ArrayBufferView): void;
  84973. /**
  84974. * Creates a luminance texture from some data.
  84975. * @param data Define the texture data
  84976. * @param width Define the width of the texture
  84977. * @param height Define the height of the texture
  84978. * @param scene Define the scene the texture belongs to
  84979. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84980. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84981. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84982. * @returns the luminance texture
  84983. */
  84984. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84985. /**
  84986. * Creates a luminance alpha texture from some data.
  84987. * @param data Define the texture data
  84988. * @param width Define the width of the texture
  84989. * @param height Define the height of the texture
  84990. * @param scene Define the scene the texture belongs to
  84991. * @param generateMipMaps Define whether or not to create mip maps for the texture
  84992. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  84993. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  84994. * @returns the luminance alpha texture
  84995. */
  84996. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  84997. /**
  84998. * Creates an alpha texture from some data.
  84999. * @param data Define the texture data
  85000. * @param width Define the width of the texture
  85001. * @param height Define the height of the texture
  85002. * @param scene Define the scene the texture belongs to
  85003. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85004. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85005. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85006. * @returns the alpha texture
  85007. */
  85008. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  85009. /**
  85010. * Creates a RGB texture from some data.
  85011. * @param data Define the texture data
  85012. * @param width Define the width of the texture
  85013. * @param height Define the height of the texture
  85014. * @param scene Define the scene the texture belongs to
  85015. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85016. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85017. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85018. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85019. * @returns the RGB alpha texture
  85020. */
  85021. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85022. /**
  85023. * Creates a RGBA texture from some data.
  85024. * @param data Define the texture data
  85025. * @param width Define the width of the texture
  85026. * @param height Define the height of the texture
  85027. * @param scene Define the scene the texture belongs to
  85028. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85029. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85030. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85031. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85032. * @returns the RGBA texture
  85033. */
  85034. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85035. /**
  85036. * Creates a R texture from some data.
  85037. * @param data Define the texture data
  85038. * @param width Define the width of the texture
  85039. * @param height Define the height of the texture
  85040. * @param scene Define the scene the texture belongs to
  85041. * @param generateMipMaps Define whether or not to create mip maps for the texture
  85042. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  85043. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  85044. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  85045. * @returns the R texture
  85046. */
  85047. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  85048. }
  85049. }
  85050. declare module BABYLON {
  85051. interface AbstractScene {
  85052. /**
  85053. * The list of procedural textures added to the scene
  85054. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85055. */
  85056. proceduralTextures: Array<ProceduralTexture>;
  85057. }
  85058. /**
  85059. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  85060. * in a given scene.
  85061. */
  85062. export class ProceduralTextureSceneComponent implements ISceneComponent {
  85063. /**
  85064. * The component name helpfull to identify the component in the list of scene components.
  85065. */
  85066. readonly name: string;
  85067. /**
  85068. * The scene the component belongs to.
  85069. */
  85070. scene: Scene;
  85071. /**
  85072. * Creates a new instance of the component for the given scene
  85073. * @param scene Defines the scene to register the component in
  85074. */
  85075. constructor(scene: Scene);
  85076. /**
  85077. * Registers the component in a given scene
  85078. */
  85079. register(): void;
  85080. /**
  85081. * Rebuilds the elements related to this component in case of
  85082. * context lost for instance.
  85083. */
  85084. rebuild(): void;
  85085. /**
  85086. * Disposes the component and the associated ressources.
  85087. */
  85088. dispose(): void;
  85089. private _beforeClear;
  85090. }
  85091. }
  85092. declare module BABYLON {
  85093. interface ThinEngine {
  85094. /**
  85095. * Creates a new render target cube texture
  85096. * @param size defines the size of the texture
  85097. * @param options defines the options used to create the texture
  85098. * @returns a new render target cube texture stored in an InternalTexture
  85099. */
  85100. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  85101. }
  85102. }
  85103. declare module BABYLON {
  85104. /** @hidden */
  85105. export var proceduralVertexShader: {
  85106. name: string;
  85107. shader: string;
  85108. };
  85109. }
  85110. declare module BABYLON {
  85111. /**
  85112. * 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.
  85113. * This is the base class of any Procedural texture and contains most of the shareable code.
  85114. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85115. */
  85116. export class ProceduralTexture extends Texture {
  85117. isCube: boolean;
  85118. /**
  85119. * Define if the texture is enabled or not (disabled texture will not render)
  85120. */
  85121. isEnabled: boolean;
  85122. /**
  85123. * Define if the texture must be cleared before rendering (default is true)
  85124. */
  85125. autoClear: boolean;
  85126. /**
  85127. * Callback called when the texture is generated
  85128. */
  85129. onGenerated: () => void;
  85130. /**
  85131. * Event raised when the texture is generated
  85132. */
  85133. onGeneratedObservable: Observable<ProceduralTexture>;
  85134. /** @hidden */
  85135. _generateMipMaps: boolean;
  85136. /** @hidden **/
  85137. _effect: Effect;
  85138. /** @hidden */
  85139. _textures: {
  85140. [key: string]: Texture;
  85141. };
  85142. /** @hidden */
  85143. protected _fallbackTexture: Nullable<Texture>;
  85144. private _size;
  85145. private _currentRefreshId;
  85146. private _frameId;
  85147. private _refreshRate;
  85148. private _vertexBuffers;
  85149. private _indexBuffer;
  85150. private _uniforms;
  85151. private _samplers;
  85152. private _fragment;
  85153. private _floats;
  85154. private _ints;
  85155. private _floatsArrays;
  85156. private _colors3;
  85157. private _colors4;
  85158. private _vectors2;
  85159. private _vectors3;
  85160. private _matrices;
  85161. private _fallbackTextureUsed;
  85162. private _engine;
  85163. private _cachedDefines;
  85164. private _contentUpdateId;
  85165. private _contentData;
  85166. /**
  85167. * Instantiates a new procedural texture.
  85168. * 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.
  85169. * This is the base class of any Procedural texture and contains most of the shareable code.
  85170. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  85171. * @param name Define the name of the texture
  85172. * @param size Define the size of the texture to create
  85173. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  85174. * @param scene Define the scene the texture belongs to
  85175. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  85176. * @param generateMipMaps Define if the texture should creates mip maps or not
  85177. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  85178. */
  85179. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  85180. /**
  85181. * The effect that is created when initializing the post process.
  85182. * @returns The created effect corresponding the the postprocess.
  85183. */
  85184. getEffect(): Effect;
  85185. /**
  85186. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  85187. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  85188. */
  85189. getContent(): Nullable<ArrayBufferView>;
  85190. private _createIndexBuffer;
  85191. /** @hidden */
  85192. _rebuild(): void;
  85193. /**
  85194. * Resets the texture in order to recreate its associated resources.
  85195. * This can be called in case of context loss
  85196. */
  85197. reset(): void;
  85198. protected _getDefines(): string;
  85199. /**
  85200. * Is the texture ready to be used ? (rendered at least once)
  85201. * @returns true if ready, otherwise, false.
  85202. */
  85203. isReady(): boolean;
  85204. /**
  85205. * Resets the refresh counter of the texture and start bak from scratch.
  85206. * Could be useful to regenerate the texture if it is setup to render only once.
  85207. */
  85208. resetRefreshCounter(): void;
  85209. /**
  85210. * Set the fragment shader to use in order to render the texture.
  85211. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  85212. */
  85213. setFragment(fragment: any): void;
  85214. /**
  85215. * Define the refresh rate of the texture or the rendering frequency.
  85216. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  85217. */
  85218. get refreshRate(): number;
  85219. set refreshRate(value: number);
  85220. /** @hidden */
  85221. _shouldRender(): boolean;
  85222. /**
  85223. * Get the size the texture is rendering at.
  85224. * @returns the size (texture is always squared)
  85225. */
  85226. getRenderSize(): number;
  85227. /**
  85228. * Resize the texture to new value.
  85229. * @param size Define the new size the texture should have
  85230. * @param generateMipMaps Define whether the new texture should create mip maps
  85231. */
  85232. resize(size: number, generateMipMaps: boolean): void;
  85233. private _checkUniform;
  85234. /**
  85235. * Set a texture in the shader program used to render.
  85236. * @param name Define the name of the uniform samplers as defined in the shader
  85237. * @param texture Define the texture to bind to this sampler
  85238. * @return the texture itself allowing "fluent" like uniform updates
  85239. */
  85240. setTexture(name: string, texture: Texture): ProceduralTexture;
  85241. /**
  85242. * Set a float in the shader.
  85243. * @param name Define the name of the uniform as defined in the shader
  85244. * @param value Define the value to give to the uniform
  85245. * @return the texture itself allowing "fluent" like uniform updates
  85246. */
  85247. setFloat(name: string, value: number): ProceduralTexture;
  85248. /**
  85249. * Set a int in the shader.
  85250. * @param name Define the name of the uniform as defined in the shader
  85251. * @param value Define the value to give to the uniform
  85252. * @return the texture itself allowing "fluent" like uniform updates
  85253. */
  85254. setInt(name: string, value: number): ProceduralTexture;
  85255. /**
  85256. * Set an array of floats in the shader.
  85257. * @param name Define the name of the uniform as defined in the shader
  85258. * @param value Define the value to give to the uniform
  85259. * @return the texture itself allowing "fluent" like uniform updates
  85260. */
  85261. setFloats(name: string, value: number[]): ProceduralTexture;
  85262. /**
  85263. * Set a vec3 in the shader from a Color3.
  85264. * @param name Define the name of the uniform as defined in the shader
  85265. * @param value Define the value to give to the uniform
  85266. * @return the texture itself allowing "fluent" like uniform updates
  85267. */
  85268. setColor3(name: string, value: Color3): ProceduralTexture;
  85269. /**
  85270. * Set a vec4 in the shader from a Color4.
  85271. * @param name Define the name of the uniform as defined in the shader
  85272. * @param value Define the value to give to the uniform
  85273. * @return the texture itself allowing "fluent" like uniform updates
  85274. */
  85275. setColor4(name: string, value: Color4): ProceduralTexture;
  85276. /**
  85277. * Set a vec2 in the shader from a Vector2.
  85278. * @param name Define the name of the uniform as defined in the shader
  85279. * @param value Define the value to give to the uniform
  85280. * @return the texture itself allowing "fluent" like uniform updates
  85281. */
  85282. setVector2(name: string, value: Vector2): ProceduralTexture;
  85283. /**
  85284. * Set a vec3 in the shader from a Vector3.
  85285. * @param name Define the name of the uniform as defined in the shader
  85286. * @param value Define the value to give to the uniform
  85287. * @return the texture itself allowing "fluent" like uniform updates
  85288. */
  85289. setVector3(name: string, value: Vector3): ProceduralTexture;
  85290. /**
  85291. * Set a mat4 in the shader from a MAtrix.
  85292. * @param name Define the name of the uniform as defined in the shader
  85293. * @param value Define the value to give to the uniform
  85294. * @return the texture itself allowing "fluent" like uniform updates
  85295. */
  85296. setMatrix(name: string, value: Matrix): ProceduralTexture;
  85297. /**
  85298. * Render the texture to its associated render target.
  85299. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  85300. */
  85301. render(useCameraPostProcess?: boolean): void;
  85302. /**
  85303. * Clone the texture.
  85304. * @returns the cloned texture
  85305. */
  85306. clone(): ProceduralTexture;
  85307. /**
  85308. * Dispose the texture and release its asoociated resources.
  85309. */
  85310. dispose(): void;
  85311. }
  85312. }
  85313. declare module BABYLON {
  85314. /**
  85315. * This represents the base class for particle system in Babylon.
  85316. * 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.
  85317. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85318. * @example https://doc.babylonjs.com/babylon101/particles
  85319. */
  85320. export class BaseParticleSystem {
  85321. /**
  85322. * Source color is added to the destination color without alpha affecting the result
  85323. */
  85324. static BLENDMODE_ONEONE: number;
  85325. /**
  85326. * Blend current color and particle color using particle’s alpha
  85327. */
  85328. static BLENDMODE_STANDARD: number;
  85329. /**
  85330. * Add current color and particle color multiplied by particle’s alpha
  85331. */
  85332. static BLENDMODE_ADD: number;
  85333. /**
  85334. * Multiply current color with particle color
  85335. */
  85336. static BLENDMODE_MULTIPLY: number;
  85337. /**
  85338. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  85339. */
  85340. static BLENDMODE_MULTIPLYADD: number;
  85341. /**
  85342. * List of animations used by the particle system.
  85343. */
  85344. animations: Animation[];
  85345. /**
  85346. * Gets or sets the unique id of the particle system
  85347. */
  85348. uniqueId: number;
  85349. /**
  85350. * The id of the Particle system.
  85351. */
  85352. id: string;
  85353. /**
  85354. * The friendly name of the Particle system.
  85355. */
  85356. name: string;
  85357. /**
  85358. * Snippet ID if the particle system was created from the snippet server
  85359. */
  85360. snippetId: string;
  85361. /**
  85362. * The rendering group used by the Particle system to chose when to render.
  85363. */
  85364. renderingGroupId: number;
  85365. /**
  85366. * The emitter represents the Mesh or position we are attaching the particle system to.
  85367. */
  85368. emitter: Nullable<AbstractMesh | Vector3>;
  85369. /**
  85370. * The maximum number of particles to emit per frame
  85371. */
  85372. emitRate: number;
  85373. /**
  85374. * If you want to launch only a few particles at once, that can be done, as well.
  85375. */
  85376. manualEmitCount: number;
  85377. /**
  85378. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  85379. */
  85380. updateSpeed: number;
  85381. /**
  85382. * The amount of time the particle system is running (depends of the overall update speed).
  85383. */
  85384. targetStopDuration: number;
  85385. /**
  85386. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  85387. */
  85388. disposeOnStop: boolean;
  85389. /**
  85390. * Minimum power of emitting particles.
  85391. */
  85392. minEmitPower: number;
  85393. /**
  85394. * Maximum power of emitting particles.
  85395. */
  85396. maxEmitPower: number;
  85397. /**
  85398. * Minimum life time of emitting particles.
  85399. */
  85400. minLifeTime: number;
  85401. /**
  85402. * Maximum life time of emitting particles.
  85403. */
  85404. maxLifeTime: number;
  85405. /**
  85406. * Minimum Size of emitting particles.
  85407. */
  85408. minSize: number;
  85409. /**
  85410. * Maximum Size of emitting particles.
  85411. */
  85412. maxSize: number;
  85413. /**
  85414. * Minimum scale of emitting particles on X axis.
  85415. */
  85416. minScaleX: number;
  85417. /**
  85418. * Maximum scale of emitting particles on X axis.
  85419. */
  85420. maxScaleX: number;
  85421. /**
  85422. * Minimum scale of emitting particles on Y axis.
  85423. */
  85424. minScaleY: number;
  85425. /**
  85426. * Maximum scale of emitting particles on Y axis.
  85427. */
  85428. maxScaleY: number;
  85429. /**
  85430. * Gets or sets the minimal initial rotation in radians.
  85431. */
  85432. minInitialRotation: number;
  85433. /**
  85434. * Gets or sets the maximal initial rotation in radians.
  85435. */
  85436. maxInitialRotation: number;
  85437. /**
  85438. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  85439. */
  85440. minAngularSpeed: number;
  85441. /**
  85442. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  85443. */
  85444. maxAngularSpeed: number;
  85445. /**
  85446. * The texture used to render each particle. (this can be a spritesheet)
  85447. */
  85448. particleTexture: Nullable<Texture>;
  85449. /**
  85450. * The layer mask we are rendering the particles through.
  85451. */
  85452. layerMask: number;
  85453. /**
  85454. * This can help using your own shader to render the particle system.
  85455. * The according effect will be created
  85456. */
  85457. customShader: any;
  85458. /**
  85459. * By default particle system starts as soon as they are created. This prevents the
  85460. * automatic start to happen and let you decide when to start emitting particles.
  85461. */
  85462. preventAutoStart: boolean;
  85463. private _noiseTexture;
  85464. /**
  85465. * Gets or sets a texture used to add random noise to particle positions
  85466. */
  85467. get noiseTexture(): Nullable<ProceduralTexture>;
  85468. set noiseTexture(value: Nullable<ProceduralTexture>);
  85469. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  85470. noiseStrength: Vector3;
  85471. /**
  85472. * Callback triggered when the particle animation is ending.
  85473. */
  85474. onAnimationEnd: Nullable<() => void>;
  85475. /**
  85476. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  85477. */
  85478. blendMode: number;
  85479. /**
  85480. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  85481. * to override the particles.
  85482. */
  85483. forceDepthWrite: boolean;
  85484. /** 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 */
  85485. preWarmCycles: number;
  85486. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  85487. preWarmStepOffset: number;
  85488. /**
  85489. * 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)
  85490. */
  85491. spriteCellChangeSpeed: number;
  85492. /**
  85493. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  85494. */
  85495. startSpriteCellID: number;
  85496. /**
  85497. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  85498. */
  85499. endSpriteCellID: number;
  85500. /**
  85501. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  85502. */
  85503. spriteCellWidth: number;
  85504. /**
  85505. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  85506. */
  85507. spriteCellHeight: number;
  85508. /**
  85509. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  85510. */
  85511. spriteRandomStartCell: boolean;
  85512. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  85513. translationPivot: Vector2;
  85514. /** @hidden */
  85515. protected _isAnimationSheetEnabled: boolean;
  85516. /**
  85517. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  85518. */
  85519. beginAnimationOnStart: boolean;
  85520. /**
  85521. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  85522. */
  85523. beginAnimationFrom: number;
  85524. /**
  85525. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  85526. */
  85527. beginAnimationTo: number;
  85528. /**
  85529. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  85530. */
  85531. beginAnimationLoop: boolean;
  85532. /**
  85533. * Gets or sets a world offset applied to all particles
  85534. */
  85535. worldOffset: Vector3;
  85536. /**
  85537. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  85538. */
  85539. get isAnimationSheetEnabled(): boolean;
  85540. set isAnimationSheetEnabled(value: boolean);
  85541. /**
  85542. * Get hosting scene
  85543. * @returns the scene
  85544. */
  85545. getScene(): Scene;
  85546. /**
  85547. * You can use gravity if you want to give an orientation to your particles.
  85548. */
  85549. gravity: Vector3;
  85550. protected _colorGradients: Nullable<Array<ColorGradient>>;
  85551. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  85552. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  85553. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  85554. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  85555. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  85556. protected _dragGradients: Nullable<Array<FactorGradient>>;
  85557. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  85558. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  85559. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  85560. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  85561. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  85562. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  85563. /**
  85564. * Defines the delay in milliseconds before starting the system (0 by default)
  85565. */
  85566. startDelay: number;
  85567. /**
  85568. * Gets the current list of drag gradients.
  85569. * You must use addDragGradient and removeDragGradient to udpate this list
  85570. * @returns the list of drag gradients
  85571. */
  85572. getDragGradients(): Nullable<Array<FactorGradient>>;
  85573. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  85574. limitVelocityDamping: number;
  85575. /**
  85576. * Gets the current list of limit velocity gradients.
  85577. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  85578. * @returns the list of limit velocity gradients
  85579. */
  85580. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  85581. /**
  85582. * Gets the current list of color gradients.
  85583. * You must use addColorGradient and removeColorGradient to udpate this list
  85584. * @returns the list of color gradients
  85585. */
  85586. getColorGradients(): Nullable<Array<ColorGradient>>;
  85587. /**
  85588. * Gets the current list of size gradients.
  85589. * You must use addSizeGradient and removeSizeGradient to udpate this list
  85590. * @returns the list of size gradients
  85591. */
  85592. getSizeGradients(): Nullable<Array<FactorGradient>>;
  85593. /**
  85594. * Gets the current list of color remap gradients.
  85595. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  85596. * @returns the list of color remap gradients
  85597. */
  85598. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  85599. /**
  85600. * Gets the current list of alpha remap gradients.
  85601. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  85602. * @returns the list of alpha remap gradients
  85603. */
  85604. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  85605. /**
  85606. * Gets the current list of life time gradients.
  85607. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  85608. * @returns the list of life time gradients
  85609. */
  85610. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  85611. /**
  85612. * Gets the current list of angular speed gradients.
  85613. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  85614. * @returns the list of angular speed gradients
  85615. */
  85616. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  85617. /**
  85618. * Gets the current list of velocity gradients.
  85619. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  85620. * @returns the list of velocity gradients
  85621. */
  85622. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  85623. /**
  85624. * Gets the current list of start size gradients.
  85625. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  85626. * @returns the list of start size gradients
  85627. */
  85628. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  85629. /**
  85630. * Gets the current list of emit rate gradients.
  85631. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  85632. * @returns the list of emit rate gradients
  85633. */
  85634. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  85635. /**
  85636. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85637. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85638. */
  85639. get direction1(): Vector3;
  85640. set direction1(value: Vector3);
  85641. /**
  85642. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  85643. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85644. */
  85645. get direction2(): Vector3;
  85646. set direction2(value: Vector3);
  85647. /**
  85648. * 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.
  85649. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85650. */
  85651. get minEmitBox(): Vector3;
  85652. set minEmitBox(value: Vector3);
  85653. /**
  85654. * 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.
  85655. * This only works when particleEmitterTyps is a BoxParticleEmitter
  85656. */
  85657. get maxEmitBox(): Vector3;
  85658. set maxEmitBox(value: Vector3);
  85659. /**
  85660. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85661. */
  85662. color1: Color4;
  85663. /**
  85664. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  85665. */
  85666. color2: Color4;
  85667. /**
  85668. * Color the particle will have at the end of its lifetime
  85669. */
  85670. colorDead: Color4;
  85671. /**
  85672. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  85673. */
  85674. textureMask: Color4;
  85675. /**
  85676. * The particle emitter type defines the emitter used by the particle system.
  85677. * It can be for example box, sphere, or cone...
  85678. */
  85679. particleEmitterType: IParticleEmitterType;
  85680. /** @hidden */
  85681. _isSubEmitter: boolean;
  85682. /**
  85683. * Gets or sets the billboard mode to use when isBillboardBased = true.
  85684. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  85685. */
  85686. billboardMode: number;
  85687. protected _isBillboardBased: boolean;
  85688. /**
  85689. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  85690. */
  85691. get isBillboardBased(): boolean;
  85692. set isBillboardBased(value: boolean);
  85693. /**
  85694. * The scene the particle system belongs to.
  85695. */
  85696. protected _scene: Scene;
  85697. /**
  85698. * Local cache of defines for image processing.
  85699. */
  85700. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  85701. /**
  85702. * Default configuration related to image processing available in the standard Material.
  85703. */
  85704. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  85705. /**
  85706. * Gets the image processing configuration used either in this material.
  85707. */
  85708. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  85709. /**
  85710. * Sets the Default image processing configuration used either in the this material.
  85711. *
  85712. * If sets to null, the scene one is in use.
  85713. */
  85714. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  85715. /**
  85716. * Attaches a new image processing configuration to the Standard Material.
  85717. * @param configuration
  85718. */
  85719. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  85720. /** @hidden */
  85721. protected _reset(): void;
  85722. /** @hidden */
  85723. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  85724. /**
  85725. * Instantiates a particle system.
  85726. * 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.
  85727. * @param name The name of the particle system
  85728. */
  85729. constructor(name: string);
  85730. /**
  85731. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  85732. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85733. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85734. * @returns the emitter
  85735. */
  85736. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  85737. /**
  85738. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  85739. * @param radius The radius of the hemisphere to emit from
  85740. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85741. * @returns the emitter
  85742. */
  85743. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  85744. /**
  85745. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  85746. * @param radius The radius of the sphere to emit from
  85747. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  85748. * @returns the emitter
  85749. */
  85750. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  85751. /**
  85752. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  85753. * @param radius The radius of the sphere to emit from
  85754. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  85755. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  85756. * @returns the emitter
  85757. */
  85758. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  85759. /**
  85760. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  85761. * @param radius The radius of the emission cylinder
  85762. * @param height The height of the emission cylinder
  85763. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  85764. * @param directionRandomizer How much to randomize the particle direction [0-1]
  85765. * @returns the emitter
  85766. */
  85767. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  85768. /**
  85769. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  85770. * @param radius The radius of the cylinder to emit from
  85771. * @param height The height of the emission cylinder
  85772. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  85773. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  85774. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  85775. * @returns the emitter
  85776. */
  85777. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  85778. /**
  85779. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  85780. * @param radius The radius of the cone to emit from
  85781. * @param angle The base angle of the cone
  85782. * @returns the emitter
  85783. */
  85784. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  85785. /**
  85786. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  85787. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  85788. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  85789. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85790. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  85791. * @returns the emitter
  85792. */
  85793. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  85794. }
  85795. }
  85796. declare module BABYLON {
  85797. /**
  85798. * Type of sub emitter
  85799. */
  85800. export enum SubEmitterType {
  85801. /**
  85802. * Attached to the particle over it's lifetime
  85803. */
  85804. ATTACHED = 0,
  85805. /**
  85806. * Created when the particle dies
  85807. */
  85808. END = 1
  85809. }
  85810. /**
  85811. * Sub emitter class used to emit particles from an existing particle
  85812. */
  85813. export class SubEmitter {
  85814. /**
  85815. * the particle system to be used by the sub emitter
  85816. */
  85817. particleSystem: ParticleSystem;
  85818. /**
  85819. * Type of the submitter (Default: END)
  85820. */
  85821. type: SubEmitterType;
  85822. /**
  85823. * 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)
  85824. * Note: This only is supported when using an emitter of type Mesh
  85825. */
  85826. inheritDirection: boolean;
  85827. /**
  85828. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  85829. */
  85830. inheritedVelocityAmount: number;
  85831. /**
  85832. * Creates a sub emitter
  85833. * @param particleSystem the particle system to be used by the sub emitter
  85834. */
  85835. constructor(
  85836. /**
  85837. * the particle system to be used by the sub emitter
  85838. */
  85839. particleSystem: ParticleSystem);
  85840. /**
  85841. * Clones the sub emitter
  85842. * @returns the cloned sub emitter
  85843. */
  85844. clone(): SubEmitter;
  85845. /**
  85846. * Serialize current object to a JSON object
  85847. * @returns the serialized object
  85848. */
  85849. serialize(): any;
  85850. /** @hidden */
  85851. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  85852. /**
  85853. * Creates a new SubEmitter from a serialized JSON version
  85854. * @param serializationObject defines the JSON object to read from
  85855. * @param scene defines the hosting scene
  85856. * @param rootUrl defines the rootUrl for data loading
  85857. * @returns a new SubEmitter
  85858. */
  85859. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  85860. /** Release associated resources */
  85861. dispose(): void;
  85862. }
  85863. }
  85864. declare module BABYLON {
  85865. /** @hidden */
  85866. export var imageProcessingDeclaration: {
  85867. name: string;
  85868. shader: string;
  85869. };
  85870. }
  85871. declare module BABYLON {
  85872. /** @hidden */
  85873. export var imageProcessingFunctions: {
  85874. name: string;
  85875. shader: string;
  85876. };
  85877. }
  85878. declare module BABYLON {
  85879. /** @hidden */
  85880. export var particlesPixelShader: {
  85881. name: string;
  85882. shader: string;
  85883. };
  85884. }
  85885. declare module BABYLON {
  85886. /** @hidden */
  85887. export var particlesVertexShader: {
  85888. name: string;
  85889. shader: string;
  85890. };
  85891. }
  85892. declare module BABYLON {
  85893. /**
  85894. * This represents a particle system in Babylon.
  85895. * 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.
  85896. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  85897. * @example https://doc.babylonjs.com/babylon101/particles
  85898. */
  85899. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  85900. /**
  85901. * Billboard mode will only apply to Y axis
  85902. */
  85903. static readonly BILLBOARDMODE_Y: number;
  85904. /**
  85905. * Billboard mode will apply to all axes
  85906. */
  85907. static readonly BILLBOARDMODE_ALL: number;
  85908. /**
  85909. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  85910. */
  85911. static readonly BILLBOARDMODE_STRETCHED: number;
  85912. /**
  85913. * This function can be defined to provide custom update for active particles.
  85914. * This function will be called instead of regular update (age, position, color, etc.).
  85915. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  85916. */
  85917. updateFunction: (particles: Particle[]) => void;
  85918. private _emitterWorldMatrix;
  85919. /**
  85920. * This function can be defined to specify initial direction for every new particle.
  85921. * It by default use the emitterType defined function
  85922. */
  85923. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85924. /**
  85925. * This function can be defined to specify initial position for every new particle.
  85926. * It by default use the emitterType defined function
  85927. */
  85928. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  85929. /**
  85930. * @hidden
  85931. */
  85932. _inheritedVelocityOffset: Vector3;
  85933. /**
  85934. * An event triggered when the system is disposed
  85935. */
  85936. onDisposeObservable: Observable<ParticleSystem>;
  85937. private _onDisposeObserver;
  85938. /**
  85939. * Sets a callback that will be triggered when the system is disposed
  85940. */
  85941. set onDispose(callback: () => void);
  85942. private _particles;
  85943. private _epsilon;
  85944. private _capacity;
  85945. private _stockParticles;
  85946. private _newPartsExcess;
  85947. private _vertexData;
  85948. private _vertexBuffer;
  85949. private _vertexBuffers;
  85950. private _spriteBuffer;
  85951. private _indexBuffer;
  85952. private _effect;
  85953. private _customEffect;
  85954. private _cachedDefines;
  85955. private _scaledColorStep;
  85956. private _colorDiff;
  85957. private _scaledDirection;
  85958. private _scaledGravity;
  85959. private _currentRenderId;
  85960. private _alive;
  85961. private _useInstancing;
  85962. private _started;
  85963. private _stopped;
  85964. private _actualFrame;
  85965. private _scaledUpdateSpeed;
  85966. private _vertexBufferSize;
  85967. /** @hidden */
  85968. _currentEmitRateGradient: Nullable<FactorGradient>;
  85969. /** @hidden */
  85970. _currentEmitRate1: number;
  85971. /** @hidden */
  85972. _currentEmitRate2: number;
  85973. /** @hidden */
  85974. _currentStartSizeGradient: Nullable<FactorGradient>;
  85975. /** @hidden */
  85976. _currentStartSize1: number;
  85977. /** @hidden */
  85978. _currentStartSize2: number;
  85979. private readonly _rawTextureWidth;
  85980. private _rampGradientsTexture;
  85981. private _useRampGradients;
  85982. /** Gets or sets a boolean indicating that ramp gradients must be used
  85983. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  85984. */
  85985. get useRampGradients(): boolean;
  85986. set useRampGradients(value: boolean);
  85987. /**
  85988. * 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.
  85989. * 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: [])
  85990. */
  85991. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  85992. private _subEmitters;
  85993. /**
  85994. * @hidden
  85995. * If the particle systems emitter should be disposed when the particle system is disposed
  85996. */
  85997. _disposeEmitterOnDispose: boolean;
  85998. /**
  85999. * The current active Sub-systems, this property is used by the root particle system only.
  86000. */
  86001. activeSubSystems: Array<ParticleSystem>;
  86002. /**
  86003. * Specifies if the particles are updated in emitter local space or world space
  86004. */
  86005. isLocal: boolean;
  86006. private _rootParticleSystem;
  86007. /**
  86008. * Gets the current list of active particles
  86009. */
  86010. get particles(): Particle[];
  86011. /**
  86012. * Gets the number of particles active at the same time.
  86013. * @returns The number of active particles.
  86014. */
  86015. getActiveCount(): number;
  86016. /**
  86017. * Returns the string "ParticleSystem"
  86018. * @returns a string containing the class name
  86019. */
  86020. getClassName(): string;
  86021. /**
  86022. * Gets a boolean indicating that the system is stopping
  86023. * @returns true if the system is currently stopping
  86024. */
  86025. isStopping(): boolean;
  86026. /**
  86027. * Instantiates a particle system.
  86028. * 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.
  86029. * @param name The name of the particle system
  86030. * @param capacity The max number of particles alive at the same time
  86031. * @param scene The scene the particle system belongs to
  86032. * @param customEffect a custom effect used to change the way particles are rendered by default
  86033. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  86034. * @param epsilon Offset used to render the particles
  86035. */
  86036. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  86037. private _addFactorGradient;
  86038. private _removeFactorGradient;
  86039. /**
  86040. * Adds a new life time gradient
  86041. * @param gradient defines the gradient to use (between 0 and 1)
  86042. * @param factor defines the life time factor to affect to the specified gradient
  86043. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86044. * @returns the current particle system
  86045. */
  86046. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86047. /**
  86048. * Remove a specific life time gradient
  86049. * @param gradient defines the gradient to remove
  86050. * @returns the current particle system
  86051. */
  86052. removeLifeTimeGradient(gradient: number): IParticleSystem;
  86053. /**
  86054. * Adds a new size gradient
  86055. * @param gradient defines the gradient to use (between 0 and 1)
  86056. * @param factor defines the size factor to affect to the specified gradient
  86057. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86058. * @returns the current particle system
  86059. */
  86060. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86061. /**
  86062. * Remove a specific size gradient
  86063. * @param gradient defines the gradient to remove
  86064. * @returns the current particle system
  86065. */
  86066. removeSizeGradient(gradient: number): IParticleSystem;
  86067. /**
  86068. * Adds a new color remap gradient
  86069. * @param gradient defines the gradient to use (between 0 and 1)
  86070. * @param min defines the color remap minimal range
  86071. * @param max defines the color remap maximal range
  86072. * @returns the current particle system
  86073. */
  86074. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86075. /**
  86076. * Remove a specific color remap gradient
  86077. * @param gradient defines the gradient to remove
  86078. * @returns the current particle system
  86079. */
  86080. removeColorRemapGradient(gradient: number): IParticleSystem;
  86081. /**
  86082. * Adds a new alpha remap gradient
  86083. * @param gradient defines the gradient to use (between 0 and 1)
  86084. * @param min defines the alpha remap minimal range
  86085. * @param max defines the alpha remap maximal range
  86086. * @returns the current particle system
  86087. */
  86088. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  86089. /**
  86090. * Remove a specific alpha remap gradient
  86091. * @param gradient defines the gradient to remove
  86092. * @returns the current particle system
  86093. */
  86094. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  86095. /**
  86096. * Adds a new angular speed gradient
  86097. * @param gradient defines the gradient to use (between 0 and 1)
  86098. * @param factor defines the angular speed to affect to the specified gradient
  86099. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86100. * @returns the current particle system
  86101. */
  86102. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86103. /**
  86104. * Remove a specific angular speed gradient
  86105. * @param gradient defines the gradient to remove
  86106. * @returns the current particle system
  86107. */
  86108. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  86109. /**
  86110. * Adds a new velocity gradient
  86111. * @param gradient defines the gradient to use (between 0 and 1)
  86112. * @param factor defines the velocity to affect to the specified gradient
  86113. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86114. * @returns the current particle system
  86115. */
  86116. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86117. /**
  86118. * Remove a specific velocity gradient
  86119. * @param gradient defines the gradient to remove
  86120. * @returns the current particle system
  86121. */
  86122. removeVelocityGradient(gradient: number): IParticleSystem;
  86123. /**
  86124. * Adds a new limit velocity gradient
  86125. * @param gradient defines the gradient to use (between 0 and 1)
  86126. * @param factor defines the limit velocity value to affect to the specified gradient
  86127. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86128. * @returns the current particle system
  86129. */
  86130. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86131. /**
  86132. * Remove a specific limit velocity gradient
  86133. * @param gradient defines the gradient to remove
  86134. * @returns the current particle system
  86135. */
  86136. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  86137. /**
  86138. * Adds a new drag gradient
  86139. * @param gradient defines the gradient to use (between 0 and 1)
  86140. * @param factor defines the drag value to affect to the specified gradient
  86141. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86142. * @returns the current particle system
  86143. */
  86144. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86145. /**
  86146. * Remove a specific drag gradient
  86147. * @param gradient defines the gradient to remove
  86148. * @returns the current particle system
  86149. */
  86150. removeDragGradient(gradient: number): IParticleSystem;
  86151. /**
  86152. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  86153. * @param gradient defines the gradient to use (between 0 and 1)
  86154. * @param factor defines the emit rate value to affect to the specified gradient
  86155. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86156. * @returns the current particle system
  86157. */
  86158. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86159. /**
  86160. * Remove a specific emit rate gradient
  86161. * @param gradient defines the gradient to remove
  86162. * @returns the current particle system
  86163. */
  86164. removeEmitRateGradient(gradient: number): IParticleSystem;
  86165. /**
  86166. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  86167. * @param gradient defines the gradient to use (between 0 and 1)
  86168. * @param factor defines the start size value to affect to the specified gradient
  86169. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  86170. * @returns the current particle system
  86171. */
  86172. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  86173. /**
  86174. * Remove a specific start size gradient
  86175. * @param gradient defines the gradient to remove
  86176. * @returns the current particle system
  86177. */
  86178. removeStartSizeGradient(gradient: number): IParticleSystem;
  86179. private _createRampGradientTexture;
  86180. /**
  86181. * Gets the current list of ramp gradients.
  86182. * You must use addRampGradient and removeRampGradient to udpate this list
  86183. * @returns the list of ramp gradients
  86184. */
  86185. getRampGradients(): Nullable<Array<Color3Gradient>>;
  86186. /** Force the system to rebuild all gradients that need to be resync */
  86187. forceRefreshGradients(): void;
  86188. private _syncRampGradientTexture;
  86189. /**
  86190. * Adds a new ramp gradient used to remap particle colors
  86191. * @param gradient defines the gradient to use (between 0 and 1)
  86192. * @param color defines the color to affect to the specified gradient
  86193. * @returns the current particle system
  86194. */
  86195. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  86196. /**
  86197. * Remove a specific ramp gradient
  86198. * @param gradient defines the gradient to remove
  86199. * @returns the current particle system
  86200. */
  86201. removeRampGradient(gradient: number): ParticleSystem;
  86202. /**
  86203. * Adds a new color gradient
  86204. * @param gradient defines the gradient to use (between 0 and 1)
  86205. * @param color1 defines the color to affect to the specified gradient
  86206. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  86207. * @returns this particle system
  86208. */
  86209. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  86210. /**
  86211. * Remove a specific color gradient
  86212. * @param gradient defines the gradient to remove
  86213. * @returns this particle system
  86214. */
  86215. removeColorGradient(gradient: number): IParticleSystem;
  86216. private _fetchR;
  86217. protected _reset(): void;
  86218. private _resetEffect;
  86219. private _createVertexBuffers;
  86220. private _createIndexBuffer;
  86221. /**
  86222. * Gets the maximum number of particles active at the same time.
  86223. * @returns The max number of active particles.
  86224. */
  86225. getCapacity(): number;
  86226. /**
  86227. * Gets whether there are still active particles in the system.
  86228. * @returns True if it is alive, otherwise false.
  86229. */
  86230. isAlive(): boolean;
  86231. /**
  86232. * Gets if the system has been started. (Note: this will still be true after stop is called)
  86233. * @returns True if it has been started, otherwise false.
  86234. */
  86235. isStarted(): boolean;
  86236. private _prepareSubEmitterInternalArray;
  86237. /**
  86238. * Starts the particle system and begins to emit
  86239. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  86240. */
  86241. start(delay?: number): void;
  86242. /**
  86243. * Stops the particle system.
  86244. * @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.
  86245. */
  86246. stop(stopSubEmitters?: boolean): void;
  86247. /**
  86248. * Remove all active particles
  86249. */
  86250. reset(): void;
  86251. /**
  86252. * @hidden (for internal use only)
  86253. */
  86254. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  86255. /**
  86256. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  86257. * Its lifetime will start back at 0.
  86258. */
  86259. recycleParticle: (particle: Particle) => void;
  86260. private _stopSubEmitters;
  86261. private _createParticle;
  86262. private _removeFromRoot;
  86263. private _emitFromParticle;
  86264. private _update;
  86265. /** @hidden */
  86266. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  86267. /** @hidden */
  86268. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  86269. /** @hidden */
  86270. private _getEffect;
  86271. /**
  86272. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  86273. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  86274. */
  86275. animate(preWarmOnly?: boolean): void;
  86276. private _appendParticleVertices;
  86277. /**
  86278. * Rebuilds the particle system.
  86279. */
  86280. rebuild(): void;
  86281. /**
  86282. * Is this system ready to be used/rendered
  86283. * @return true if the system is ready
  86284. */
  86285. isReady(): boolean;
  86286. private _render;
  86287. /**
  86288. * Renders the particle system in its current state.
  86289. * @returns the current number of particles
  86290. */
  86291. render(): number;
  86292. /**
  86293. * Disposes the particle system and free the associated resources
  86294. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  86295. */
  86296. dispose(disposeTexture?: boolean): void;
  86297. /**
  86298. * Clones the particle system.
  86299. * @param name The name of the cloned object
  86300. * @param newEmitter The new emitter to use
  86301. * @returns the cloned particle system
  86302. */
  86303. clone(name: string, newEmitter: any): ParticleSystem;
  86304. /**
  86305. * Serializes the particle system to a JSON object
  86306. * @param serializeTexture defines if the texture must be serialized as well
  86307. * @returns the JSON object
  86308. */
  86309. serialize(serializeTexture?: boolean): any;
  86310. /** @hidden */
  86311. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  86312. /** @hidden */
  86313. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  86314. /**
  86315. * Parses a JSON object to create a particle system.
  86316. * @param parsedParticleSystem The JSON object to parse
  86317. * @param scene The scene to create the particle system in
  86318. * @param rootUrl The root url to use to load external dependencies like texture
  86319. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  86320. * @returns the Parsed particle system
  86321. */
  86322. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  86323. }
  86324. }
  86325. declare module BABYLON {
  86326. /**
  86327. * A particle represents one of the element emitted by a particle system.
  86328. * This is mainly define by its coordinates, direction, velocity and age.
  86329. */
  86330. export class Particle {
  86331. /**
  86332. * The particle system the particle belongs to.
  86333. */
  86334. particleSystem: ParticleSystem;
  86335. private static _Count;
  86336. /**
  86337. * Unique ID of the particle
  86338. */
  86339. id: number;
  86340. /**
  86341. * The world position of the particle in the scene.
  86342. */
  86343. position: Vector3;
  86344. /**
  86345. * The world direction of the particle in the scene.
  86346. */
  86347. direction: Vector3;
  86348. /**
  86349. * The color of the particle.
  86350. */
  86351. color: Color4;
  86352. /**
  86353. * The color change of the particle per step.
  86354. */
  86355. colorStep: Color4;
  86356. /**
  86357. * Defines how long will the life of the particle be.
  86358. */
  86359. lifeTime: number;
  86360. /**
  86361. * The current age of the particle.
  86362. */
  86363. age: number;
  86364. /**
  86365. * The current size of the particle.
  86366. */
  86367. size: number;
  86368. /**
  86369. * The current scale of the particle.
  86370. */
  86371. scale: Vector2;
  86372. /**
  86373. * The current angle of the particle.
  86374. */
  86375. angle: number;
  86376. /**
  86377. * Defines how fast is the angle changing.
  86378. */
  86379. angularSpeed: number;
  86380. /**
  86381. * Defines the cell index used by the particle to be rendered from a sprite.
  86382. */
  86383. cellIndex: number;
  86384. /**
  86385. * The information required to support color remapping
  86386. */
  86387. remapData: Vector4;
  86388. /** @hidden */
  86389. _randomCellOffset?: number;
  86390. /** @hidden */
  86391. _initialDirection: Nullable<Vector3>;
  86392. /** @hidden */
  86393. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  86394. /** @hidden */
  86395. _initialStartSpriteCellID: number;
  86396. /** @hidden */
  86397. _initialEndSpriteCellID: number;
  86398. /** @hidden */
  86399. _currentColorGradient: Nullable<ColorGradient>;
  86400. /** @hidden */
  86401. _currentColor1: Color4;
  86402. /** @hidden */
  86403. _currentColor2: Color4;
  86404. /** @hidden */
  86405. _currentSizeGradient: Nullable<FactorGradient>;
  86406. /** @hidden */
  86407. _currentSize1: number;
  86408. /** @hidden */
  86409. _currentSize2: number;
  86410. /** @hidden */
  86411. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  86412. /** @hidden */
  86413. _currentAngularSpeed1: number;
  86414. /** @hidden */
  86415. _currentAngularSpeed2: number;
  86416. /** @hidden */
  86417. _currentVelocityGradient: Nullable<FactorGradient>;
  86418. /** @hidden */
  86419. _currentVelocity1: number;
  86420. /** @hidden */
  86421. _currentVelocity2: number;
  86422. /** @hidden */
  86423. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  86424. /** @hidden */
  86425. _currentLimitVelocity1: number;
  86426. /** @hidden */
  86427. _currentLimitVelocity2: number;
  86428. /** @hidden */
  86429. _currentDragGradient: Nullable<FactorGradient>;
  86430. /** @hidden */
  86431. _currentDrag1: number;
  86432. /** @hidden */
  86433. _currentDrag2: number;
  86434. /** @hidden */
  86435. _randomNoiseCoordinates1: Vector3;
  86436. /** @hidden */
  86437. _randomNoiseCoordinates2: Vector3;
  86438. /** @hidden */
  86439. _localPosition?: Vector3;
  86440. /**
  86441. * Creates a new instance Particle
  86442. * @param particleSystem the particle system the particle belongs to
  86443. */
  86444. constructor(
  86445. /**
  86446. * The particle system the particle belongs to.
  86447. */
  86448. particleSystem: ParticleSystem);
  86449. private updateCellInfoFromSystem;
  86450. /**
  86451. * Defines how the sprite cell index is updated for the particle
  86452. */
  86453. updateCellIndex(): void;
  86454. /** @hidden */
  86455. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  86456. /** @hidden */
  86457. _inheritParticleInfoToSubEmitters(): void;
  86458. /** @hidden */
  86459. _reset(): void;
  86460. /**
  86461. * Copy the properties of particle to another one.
  86462. * @param other the particle to copy the information to.
  86463. */
  86464. copyTo(other: Particle): void;
  86465. }
  86466. }
  86467. declare module BABYLON {
  86468. /**
  86469. * Particle emitter represents a volume emitting particles.
  86470. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  86471. */
  86472. export interface IParticleEmitterType {
  86473. /**
  86474. * Called by the particle System when the direction is computed for the created particle.
  86475. * @param worldMatrix is the world matrix of the particle system
  86476. * @param directionToUpdate is the direction vector to update with the result
  86477. * @param particle is the particle we are computed the direction for
  86478. * @param isLocal defines if the direction should be set in local space
  86479. */
  86480. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86481. /**
  86482. * Called by the particle System when the position is computed for the created particle.
  86483. * @param worldMatrix is the world matrix of the particle system
  86484. * @param positionToUpdate is the position vector to update with the result
  86485. * @param particle is the particle we are computed the position for
  86486. * @param isLocal defines if the position should be set in local space
  86487. */
  86488. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86489. /**
  86490. * Clones the current emitter and returns a copy of it
  86491. * @returns the new emitter
  86492. */
  86493. clone(): IParticleEmitterType;
  86494. /**
  86495. * Called by the GPUParticleSystem to setup the update shader
  86496. * @param effect defines the update shader
  86497. */
  86498. applyToShader(effect: Effect): void;
  86499. /**
  86500. * Returns a string to use to update the GPU particles update shader
  86501. * @returns the effect defines string
  86502. */
  86503. getEffectDefines(): string;
  86504. /**
  86505. * Returns a string representing the class name
  86506. * @returns a string containing the class name
  86507. */
  86508. getClassName(): string;
  86509. /**
  86510. * Serializes the particle system to a JSON object.
  86511. * @returns the JSON object
  86512. */
  86513. serialize(): any;
  86514. /**
  86515. * Parse properties from a JSON object
  86516. * @param serializationObject defines the JSON object
  86517. * @param scene defines the hosting scene
  86518. */
  86519. parse(serializationObject: any, scene: Scene): void;
  86520. }
  86521. }
  86522. declare module BABYLON {
  86523. /**
  86524. * Particle emitter emitting particles from the inside of a box.
  86525. * It emits the particles randomly between 2 given directions.
  86526. */
  86527. export class BoxParticleEmitter implements IParticleEmitterType {
  86528. /**
  86529. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86530. */
  86531. direction1: Vector3;
  86532. /**
  86533. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86534. */
  86535. direction2: Vector3;
  86536. /**
  86537. * 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.
  86538. */
  86539. minEmitBox: Vector3;
  86540. /**
  86541. * 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.
  86542. */
  86543. maxEmitBox: Vector3;
  86544. /**
  86545. * Creates a new instance BoxParticleEmitter
  86546. */
  86547. constructor();
  86548. /**
  86549. * Called by the particle System when the direction is computed for the created particle.
  86550. * @param worldMatrix is the world matrix of the particle system
  86551. * @param directionToUpdate is the direction vector to update with the result
  86552. * @param particle is the particle we are computed the direction for
  86553. * @param isLocal defines if the direction should be set in local space
  86554. */
  86555. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86556. /**
  86557. * Called by the particle System when the position is computed for the created particle.
  86558. * @param worldMatrix is the world matrix of the particle system
  86559. * @param positionToUpdate is the position vector to update with the result
  86560. * @param particle is the particle we are computed the position for
  86561. * @param isLocal defines if the position should be set in local space
  86562. */
  86563. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86564. /**
  86565. * Clones the current emitter and returns a copy of it
  86566. * @returns the new emitter
  86567. */
  86568. clone(): BoxParticleEmitter;
  86569. /**
  86570. * Called by the GPUParticleSystem to setup the update shader
  86571. * @param effect defines the update shader
  86572. */
  86573. applyToShader(effect: Effect): void;
  86574. /**
  86575. * Returns a string to use to update the GPU particles update shader
  86576. * @returns a string containng the defines string
  86577. */
  86578. getEffectDefines(): string;
  86579. /**
  86580. * Returns the string "BoxParticleEmitter"
  86581. * @returns a string containing the class name
  86582. */
  86583. getClassName(): string;
  86584. /**
  86585. * Serializes the particle system to a JSON object.
  86586. * @returns the JSON object
  86587. */
  86588. serialize(): any;
  86589. /**
  86590. * Parse properties from a JSON object
  86591. * @param serializationObject defines the JSON object
  86592. */
  86593. parse(serializationObject: any): void;
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * Particle emitter emitting particles from the inside of a cone.
  86599. * It emits the particles alongside the cone volume from the base to the particle.
  86600. * The emission direction might be randomized.
  86601. */
  86602. export class ConeParticleEmitter implements IParticleEmitterType {
  86603. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86604. directionRandomizer: number;
  86605. private _radius;
  86606. private _angle;
  86607. private _height;
  86608. /**
  86609. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  86610. */
  86611. radiusRange: number;
  86612. /**
  86613. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  86614. */
  86615. heightRange: number;
  86616. /**
  86617. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  86618. */
  86619. emitFromSpawnPointOnly: boolean;
  86620. /**
  86621. * Gets or sets the radius of the emission cone
  86622. */
  86623. get radius(): number;
  86624. set radius(value: number);
  86625. /**
  86626. * Gets or sets the angle of the emission cone
  86627. */
  86628. get angle(): number;
  86629. set angle(value: number);
  86630. private _buildHeight;
  86631. /**
  86632. * Creates a new instance ConeParticleEmitter
  86633. * @param radius the radius of the emission cone (1 by default)
  86634. * @param angle the cone base angle (PI by default)
  86635. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  86636. */
  86637. constructor(radius?: number, angle?: number,
  86638. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  86639. directionRandomizer?: number);
  86640. /**
  86641. * Called by the particle System when the direction is computed for the created particle.
  86642. * @param worldMatrix is the world matrix of the particle system
  86643. * @param directionToUpdate is the direction vector to update with the result
  86644. * @param particle is the particle we are computed the direction for
  86645. * @param isLocal defines if the direction should be set in local space
  86646. */
  86647. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86648. /**
  86649. * Called by the particle System when the position is computed for the created particle.
  86650. * @param worldMatrix is the world matrix of the particle system
  86651. * @param positionToUpdate is the position vector to update with the result
  86652. * @param particle is the particle we are computed the position for
  86653. * @param isLocal defines if the position should be set in local space
  86654. */
  86655. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86656. /**
  86657. * Clones the current emitter and returns a copy of it
  86658. * @returns the new emitter
  86659. */
  86660. clone(): ConeParticleEmitter;
  86661. /**
  86662. * Called by the GPUParticleSystem to setup the update shader
  86663. * @param effect defines the update shader
  86664. */
  86665. applyToShader(effect: Effect): void;
  86666. /**
  86667. * Returns a string to use to update the GPU particles update shader
  86668. * @returns a string containng the defines string
  86669. */
  86670. getEffectDefines(): string;
  86671. /**
  86672. * Returns the string "ConeParticleEmitter"
  86673. * @returns a string containing the class name
  86674. */
  86675. getClassName(): string;
  86676. /**
  86677. * Serializes the particle system to a JSON object.
  86678. * @returns the JSON object
  86679. */
  86680. serialize(): any;
  86681. /**
  86682. * Parse properties from a JSON object
  86683. * @param serializationObject defines the JSON object
  86684. */
  86685. parse(serializationObject: any): void;
  86686. }
  86687. }
  86688. declare module BABYLON {
  86689. /**
  86690. * Particle emitter emitting particles from the inside of a cylinder.
  86691. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  86692. */
  86693. export class CylinderParticleEmitter implements IParticleEmitterType {
  86694. /**
  86695. * The radius of the emission cylinder.
  86696. */
  86697. radius: number;
  86698. /**
  86699. * The height of the emission cylinder.
  86700. */
  86701. height: number;
  86702. /**
  86703. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86704. */
  86705. radiusRange: number;
  86706. /**
  86707. * How much to randomize the particle direction [0-1].
  86708. */
  86709. directionRandomizer: number;
  86710. /**
  86711. * Creates a new instance CylinderParticleEmitter
  86712. * @param radius the radius of the emission cylinder (1 by default)
  86713. * @param height the height of the emission cylinder (1 by default)
  86714. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86715. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86716. */
  86717. constructor(
  86718. /**
  86719. * The radius of the emission cylinder.
  86720. */
  86721. radius?: number,
  86722. /**
  86723. * The height of the emission cylinder.
  86724. */
  86725. height?: number,
  86726. /**
  86727. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86728. */
  86729. radiusRange?: number,
  86730. /**
  86731. * How much to randomize the particle direction [0-1].
  86732. */
  86733. directionRandomizer?: number);
  86734. /**
  86735. * Called by the particle System when the direction is computed for the created particle.
  86736. * @param worldMatrix is the world matrix of the particle system
  86737. * @param directionToUpdate is the direction vector to update with the result
  86738. * @param particle is the particle we are computed the direction for
  86739. * @param isLocal defines if the direction should be set in local space
  86740. */
  86741. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86742. /**
  86743. * Called by the particle System when the position is computed for the created particle.
  86744. * @param worldMatrix is the world matrix of the particle system
  86745. * @param positionToUpdate is the position vector to update with the result
  86746. * @param particle is the particle we are computed the position for
  86747. * @param isLocal defines if the position should be set in local space
  86748. */
  86749. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86750. /**
  86751. * Clones the current emitter and returns a copy of it
  86752. * @returns the new emitter
  86753. */
  86754. clone(): CylinderParticleEmitter;
  86755. /**
  86756. * Called by the GPUParticleSystem to setup the update shader
  86757. * @param effect defines the update shader
  86758. */
  86759. applyToShader(effect: Effect): void;
  86760. /**
  86761. * Returns a string to use to update the GPU particles update shader
  86762. * @returns a string containng the defines string
  86763. */
  86764. getEffectDefines(): string;
  86765. /**
  86766. * Returns the string "CylinderParticleEmitter"
  86767. * @returns a string containing the class name
  86768. */
  86769. getClassName(): string;
  86770. /**
  86771. * Serializes the particle system to a JSON object.
  86772. * @returns the JSON object
  86773. */
  86774. serialize(): any;
  86775. /**
  86776. * Parse properties from a JSON object
  86777. * @param serializationObject defines the JSON object
  86778. */
  86779. parse(serializationObject: any): void;
  86780. }
  86781. /**
  86782. * Particle emitter emitting particles from the inside of a cylinder.
  86783. * It emits the particles randomly between two vectors.
  86784. */
  86785. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  86786. /**
  86787. * The min limit of the emission direction.
  86788. */
  86789. direction1: Vector3;
  86790. /**
  86791. * The max limit of the emission direction.
  86792. */
  86793. direction2: Vector3;
  86794. /**
  86795. * Creates a new instance CylinderDirectedParticleEmitter
  86796. * @param radius the radius of the emission cylinder (1 by default)
  86797. * @param height the height of the emission cylinder (1 by default)
  86798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86799. * @param direction1 the min limit of the emission direction (up vector by default)
  86800. * @param direction2 the max limit of the emission direction (up vector by default)
  86801. */
  86802. constructor(radius?: number, height?: number, radiusRange?: number,
  86803. /**
  86804. * The min limit of the emission direction.
  86805. */
  86806. direction1?: Vector3,
  86807. /**
  86808. * The max limit of the emission direction.
  86809. */
  86810. direction2?: Vector3);
  86811. /**
  86812. * Called by the particle System when the direction is computed for the created particle.
  86813. * @param worldMatrix is the world matrix of the particle system
  86814. * @param directionToUpdate is the direction vector to update with the result
  86815. * @param particle is the particle we are computed the direction for
  86816. */
  86817. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  86818. /**
  86819. * Clones the current emitter and returns a copy of it
  86820. * @returns the new emitter
  86821. */
  86822. clone(): CylinderDirectedParticleEmitter;
  86823. /**
  86824. * Called by the GPUParticleSystem to setup the update shader
  86825. * @param effect defines the update shader
  86826. */
  86827. applyToShader(effect: Effect): void;
  86828. /**
  86829. * Returns a string to use to update the GPU particles update shader
  86830. * @returns a string containng the defines string
  86831. */
  86832. getEffectDefines(): string;
  86833. /**
  86834. * Returns the string "CylinderDirectedParticleEmitter"
  86835. * @returns a string containing the class name
  86836. */
  86837. getClassName(): string;
  86838. /**
  86839. * Serializes the particle system to a JSON object.
  86840. * @returns the JSON object
  86841. */
  86842. serialize(): any;
  86843. /**
  86844. * Parse properties from a JSON object
  86845. * @param serializationObject defines the JSON object
  86846. */
  86847. parse(serializationObject: any): void;
  86848. }
  86849. }
  86850. declare module BABYLON {
  86851. /**
  86852. * Particle emitter emitting particles from the inside of a hemisphere.
  86853. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  86854. */
  86855. export class HemisphericParticleEmitter implements IParticleEmitterType {
  86856. /**
  86857. * The radius of the emission hemisphere.
  86858. */
  86859. radius: number;
  86860. /**
  86861. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86862. */
  86863. radiusRange: number;
  86864. /**
  86865. * How much to randomize the particle direction [0-1].
  86866. */
  86867. directionRandomizer: number;
  86868. /**
  86869. * Creates a new instance HemisphericParticleEmitter
  86870. * @param radius the radius of the emission hemisphere (1 by default)
  86871. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  86872. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  86873. */
  86874. constructor(
  86875. /**
  86876. * The radius of the emission hemisphere.
  86877. */
  86878. radius?: number,
  86879. /**
  86880. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  86881. */
  86882. radiusRange?: number,
  86883. /**
  86884. * How much to randomize the particle direction [0-1].
  86885. */
  86886. directionRandomizer?: number);
  86887. /**
  86888. * Called by the particle System when the direction is computed for the created particle.
  86889. * @param worldMatrix is the world matrix of the particle system
  86890. * @param directionToUpdate is the direction vector to update with the result
  86891. * @param particle is the particle we are computed the direction for
  86892. * @param isLocal defines if the direction should be set in local space
  86893. */
  86894. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86895. /**
  86896. * Called by the particle System when the position is computed for the created particle.
  86897. * @param worldMatrix is the world matrix of the particle system
  86898. * @param positionToUpdate is the position vector to update with the result
  86899. * @param particle is the particle we are computed the position for
  86900. * @param isLocal defines if the position should be set in local space
  86901. */
  86902. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86903. /**
  86904. * Clones the current emitter and returns a copy of it
  86905. * @returns the new emitter
  86906. */
  86907. clone(): HemisphericParticleEmitter;
  86908. /**
  86909. * Called by the GPUParticleSystem to setup the update shader
  86910. * @param effect defines the update shader
  86911. */
  86912. applyToShader(effect: Effect): void;
  86913. /**
  86914. * Returns a string to use to update the GPU particles update shader
  86915. * @returns a string containng the defines string
  86916. */
  86917. getEffectDefines(): string;
  86918. /**
  86919. * Returns the string "HemisphericParticleEmitter"
  86920. * @returns a string containing the class name
  86921. */
  86922. getClassName(): string;
  86923. /**
  86924. * Serializes the particle system to a JSON object.
  86925. * @returns the JSON object
  86926. */
  86927. serialize(): any;
  86928. /**
  86929. * Parse properties from a JSON object
  86930. * @param serializationObject defines the JSON object
  86931. */
  86932. parse(serializationObject: any): void;
  86933. }
  86934. }
  86935. declare module BABYLON {
  86936. /**
  86937. * Particle emitter emitting particles from a point.
  86938. * It emits the particles randomly between 2 given directions.
  86939. */
  86940. export class PointParticleEmitter implements IParticleEmitterType {
  86941. /**
  86942. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86943. */
  86944. direction1: Vector3;
  86945. /**
  86946. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  86947. */
  86948. direction2: Vector3;
  86949. /**
  86950. * Creates a new instance PointParticleEmitter
  86951. */
  86952. constructor();
  86953. /**
  86954. * Called by the particle System when the direction is computed for the created particle.
  86955. * @param worldMatrix is the world matrix of the particle system
  86956. * @param directionToUpdate is the direction vector to update with the result
  86957. * @param particle is the particle we are computed the direction for
  86958. * @param isLocal defines if the direction should be set in local space
  86959. */
  86960. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86961. /**
  86962. * Called by the particle System when the position is computed for the created particle.
  86963. * @param worldMatrix is the world matrix of the particle system
  86964. * @param positionToUpdate is the position vector to update with the result
  86965. * @param particle is the particle we are computed the position for
  86966. * @param isLocal defines if the position should be set in local space
  86967. */
  86968. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  86969. /**
  86970. * Clones the current emitter and returns a copy of it
  86971. * @returns the new emitter
  86972. */
  86973. clone(): PointParticleEmitter;
  86974. /**
  86975. * Called by the GPUParticleSystem to setup the update shader
  86976. * @param effect defines the update shader
  86977. */
  86978. applyToShader(effect: Effect): void;
  86979. /**
  86980. * Returns a string to use to update the GPU particles update shader
  86981. * @returns a string containng the defines string
  86982. */
  86983. getEffectDefines(): string;
  86984. /**
  86985. * Returns the string "PointParticleEmitter"
  86986. * @returns a string containing the class name
  86987. */
  86988. getClassName(): string;
  86989. /**
  86990. * Serializes the particle system to a JSON object.
  86991. * @returns the JSON object
  86992. */
  86993. serialize(): any;
  86994. /**
  86995. * Parse properties from a JSON object
  86996. * @param serializationObject defines the JSON object
  86997. */
  86998. parse(serializationObject: any): void;
  86999. }
  87000. }
  87001. declare module BABYLON {
  87002. /**
  87003. * Particle emitter emitting particles from the inside of a sphere.
  87004. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  87005. */
  87006. export class SphereParticleEmitter implements IParticleEmitterType {
  87007. /**
  87008. * The radius of the emission sphere.
  87009. */
  87010. radius: number;
  87011. /**
  87012. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87013. */
  87014. radiusRange: number;
  87015. /**
  87016. * How much to randomize the particle direction [0-1].
  87017. */
  87018. directionRandomizer: number;
  87019. /**
  87020. * Creates a new instance SphereParticleEmitter
  87021. * @param radius the radius of the emission sphere (1 by default)
  87022. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87023. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  87024. */
  87025. constructor(
  87026. /**
  87027. * The radius of the emission sphere.
  87028. */
  87029. radius?: number,
  87030. /**
  87031. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  87032. */
  87033. radiusRange?: number,
  87034. /**
  87035. * How much to randomize the particle direction [0-1].
  87036. */
  87037. directionRandomizer?: number);
  87038. /**
  87039. * Called by the particle System when the direction is computed for the created particle.
  87040. * @param worldMatrix is the world matrix of the particle system
  87041. * @param directionToUpdate is the direction vector to update with the result
  87042. * @param particle is the particle we are computed the direction for
  87043. * @param isLocal defines if the direction should be set in local space
  87044. */
  87045. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87046. /**
  87047. * Called by the particle System when the position is computed for the created particle.
  87048. * @param worldMatrix is the world matrix of the particle system
  87049. * @param positionToUpdate is the position vector to update with the result
  87050. * @param particle is the particle we are computed the position for
  87051. * @param isLocal defines if the position should be set in local space
  87052. */
  87053. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87054. /**
  87055. * Clones the current emitter and returns a copy of it
  87056. * @returns the new emitter
  87057. */
  87058. clone(): SphereParticleEmitter;
  87059. /**
  87060. * Called by the GPUParticleSystem to setup the update shader
  87061. * @param effect defines the update shader
  87062. */
  87063. applyToShader(effect: Effect): void;
  87064. /**
  87065. * Returns a string to use to update the GPU particles update shader
  87066. * @returns a string containng the defines string
  87067. */
  87068. getEffectDefines(): string;
  87069. /**
  87070. * Returns the string "SphereParticleEmitter"
  87071. * @returns a string containing the class name
  87072. */
  87073. getClassName(): string;
  87074. /**
  87075. * Serializes the particle system to a JSON object.
  87076. * @returns the JSON object
  87077. */
  87078. serialize(): any;
  87079. /**
  87080. * Parse properties from a JSON object
  87081. * @param serializationObject defines the JSON object
  87082. */
  87083. parse(serializationObject: any): void;
  87084. }
  87085. /**
  87086. * Particle emitter emitting particles from the inside of a sphere.
  87087. * It emits the particles randomly between two vectors.
  87088. */
  87089. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  87090. /**
  87091. * The min limit of the emission direction.
  87092. */
  87093. direction1: Vector3;
  87094. /**
  87095. * The max limit of the emission direction.
  87096. */
  87097. direction2: Vector3;
  87098. /**
  87099. * Creates a new instance SphereDirectedParticleEmitter
  87100. * @param radius the radius of the emission sphere (1 by default)
  87101. * @param direction1 the min limit of the emission direction (up vector by default)
  87102. * @param direction2 the max limit of the emission direction (up vector by default)
  87103. */
  87104. constructor(radius?: number,
  87105. /**
  87106. * The min limit of the emission direction.
  87107. */
  87108. direction1?: Vector3,
  87109. /**
  87110. * The max limit of the emission direction.
  87111. */
  87112. direction2?: Vector3);
  87113. /**
  87114. * Called by the particle System when the direction is computed for the created particle.
  87115. * @param worldMatrix is the world matrix of the particle system
  87116. * @param directionToUpdate is the direction vector to update with the result
  87117. * @param particle is the particle we are computed the direction for
  87118. */
  87119. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  87120. /**
  87121. * Clones the current emitter and returns a copy of it
  87122. * @returns the new emitter
  87123. */
  87124. clone(): SphereDirectedParticleEmitter;
  87125. /**
  87126. * Called by the GPUParticleSystem to setup the update shader
  87127. * @param effect defines the update shader
  87128. */
  87129. applyToShader(effect: Effect): void;
  87130. /**
  87131. * Returns a string to use to update the GPU particles update shader
  87132. * @returns a string containng the defines string
  87133. */
  87134. getEffectDefines(): string;
  87135. /**
  87136. * Returns the string "SphereDirectedParticleEmitter"
  87137. * @returns a string containing the class name
  87138. */
  87139. getClassName(): string;
  87140. /**
  87141. * Serializes the particle system to a JSON object.
  87142. * @returns the JSON object
  87143. */
  87144. serialize(): any;
  87145. /**
  87146. * Parse properties from a JSON object
  87147. * @param serializationObject defines the JSON object
  87148. */
  87149. parse(serializationObject: any): void;
  87150. }
  87151. }
  87152. declare module BABYLON {
  87153. /**
  87154. * Particle emitter emitting particles from a custom list of positions.
  87155. */
  87156. export class CustomParticleEmitter implements IParticleEmitterType {
  87157. /**
  87158. * Gets or sets the position generator that will create the inital position of each particle.
  87159. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87160. */
  87161. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  87162. /**
  87163. * Gets or sets the destination generator that will create the final destination of each particle.
  87164. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  87165. */
  87166. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  87167. /**
  87168. * Creates a new instance CustomParticleEmitter
  87169. */
  87170. constructor();
  87171. /**
  87172. * Called by the particle System when the direction is computed for the created particle.
  87173. * @param worldMatrix is the world matrix of the particle system
  87174. * @param directionToUpdate is the direction vector to update with the result
  87175. * @param particle is the particle we are computed the direction for
  87176. * @param isLocal defines if the direction should be set in local space
  87177. */
  87178. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87179. /**
  87180. * Called by the particle System when the position is computed for the created particle.
  87181. * @param worldMatrix is the world matrix of the particle system
  87182. * @param positionToUpdate is the position vector to update with the result
  87183. * @param particle is the particle we are computed the position for
  87184. * @param isLocal defines if the position should be set in local space
  87185. */
  87186. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87187. /**
  87188. * Clones the current emitter and returns a copy of it
  87189. * @returns the new emitter
  87190. */
  87191. clone(): CustomParticleEmitter;
  87192. /**
  87193. * Called by the GPUParticleSystem to setup the update shader
  87194. * @param effect defines the update shader
  87195. */
  87196. applyToShader(effect: Effect): void;
  87197. /**
  87198. * Returns a string to use to update the GPU particles update shader
  87199. * @returns a string containng the defines string
  87200. */
  87201. getEffectDefines(): string;
  87202. /**
  87203. * Returns the string "PointParticleEmitter"
  87204. * @returns a string containing the class name
  87205. */
  87206. getClassName(): string;
  87207. /**
  87208. * Serializes the particle system to a JSON object.
  87209. * @returns the JSON object
  87210. */
  87211. serialize(): any;
  87212. /**
  87213. * Parse properties from a JSON object
  87214. * @param serializationObject defines the JSON object
  87215. */
  87216. parse(serializationObject: any): void;
  87217. }
  87218. }
  87219. declare module BABYLON {
  87220. /**
  87221. * Particle emitter emitting particles from the inside of a box.
  87222. * It emits the particles randomly between 2 given directions.
  87223. */
  87224. export class MeshParticleEmitter implements IParticleEmitterType {
  87225. private _indices;
  87226. private _positions;
  87227. private _normals;
  87228. private _storedNormal;
  87229. private _mesh;
  87230. /**
  87231. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87232. */
  87233. direction1: Vector3;
  87234. /**
  87235. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  87236. */
  87237. direction2: Vector3;
  87238. /**
  87239. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  87240. */
  87241. useMeshNormalsForDirection: boolean;
  87242. /** Defines the mesh to use as source */
  87243. get mesh(): Nullable<AbstractMesh>;
  87244. set mesh(value: Nullable<AbstractMesh>);
  87245. /**
  87246. * Creates a new instance MeshParticleEmitter
  87247. * @param mesh defines the mesh to use as source
  87248. */
  87249. constructor(mesh?: Nullable<AbstractMesh>);
  87250. /**
  87251. * Called by the particle System when the direction is computed for the created particle.
  87252. * @param worldMatrix is the world matrix of the particle system
  87253. * @param directionToUpdate is the direction vector to update with the result
  87254. * @param particle is the particle we are computed the direction for
  87255. * @param isLocal defines if the direction should be set in local space
  87256. */
  87257. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87258. /**
  87259. * Called by the particle System when the position is computed for the created particle.
  87260. * @param worldMatrix is the world matrix of the particle system
  87261. * @param positionToUpdate is the position vector to update with the result
  87262. * @param particle is the particle we are computed the position for
  87263. * @param isLocal defines if the position should be set in local space
  87264. */
  87265. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  87266. /**
  87267. * Clones the current emitter and returns a copy of it
  87268. * @returns the new emitter
  87269. */
  87270. clone(): MeshParticleEmitter;
  87271. /**
  87272. * Called by the GPUParticleSystem to setup the update shader
  87273. * @param effect defines the update shader
  87274. */
  87275. applyToShader(effect: Effect): void;
  87276. /**
  87277. * Returns a string to use to update the GPU particles update shader
  87278. * @returns a string containng the defines string
  87279. */
  87280. getEffectDefines(): string;
  87281. /**
  87282. * Returns the string "BoxParticleEmitter"
  87283. * @returns a string containing the class name
  87284. */
  87285. getClassName(): string;
  87286. /**
  87287. * Serializes the particle system to a JSON object.
  87288. * @returns the JSON object
  87289. */
  87290. serialize(): any;
  87291. /**
  87292. * Parse properties from a JSON object
  87293. * @param serializationObject defines the JSON object
  87294. * @param scene defines the hosting scene
  87295. */
  87296. parse(serializationObject: any, scene: Scene): void;
  87297. }
  87298. }
  87299. declare module BABYLON {
  87300. /**
  87301. * Interface representing a particle system in Babylon.js.
  87302. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  87303. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  87304. */
  87305. export interface IParticleSystem {
  87306. /**
  87307. * List of animations used by the particle system.
  87308. */
  87309. animations: Animation[];
  87310. /**
  87311. * The id of the Particle system.
  87312. */
  87313. id: string;
  87314. /**
  87315. * The name of the Particle system.
  87316. */
  87317. name: string;
  87318. /**
  87319. * The emitter represents the Mesh or position we are attaching the particle system to.
  87320. */
  87321. emitter: Nullable<AbstractMesh | Vector3>;
  87322. /**
  87323. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  87324. */
  87325. isBillboardBased: boolean;
  87326. /**
  87327. * The rendering group used by the Particle system to chose when to render.
  87328. */
  87329. renderingGroupId: number;
  87330. /**
  87331. * The layer mask we are rendering the particles through.
  87332. */
  87333. layerMask: number;
  87334. /**
  87335. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  87336. */
  87337. updateSpeed: number;
  87338. /**
  87339. * The amount of time the particle system is running (depends of the overall update speed).
  87340. */
  87341. targetStopDuration: number;
  87342. /**
  87343. * The texture used to render each particle. (this can be a spritesheet)
  87344. */
  87345. particleTexture: Nullable<Texture>;
  87346. /**
  87347. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  87348. */
  87349. blendMode: number;
  87350. /**
  87351. * Minimum life time of emitting particles.
  87352. */
  87353. minLifeTime: number;
  87354. /**
  87355. * Maximum life time of emitting particles.
  87356. */
  87357. maxLifeTime: number;
  87358. /**
  87359. * Minimum Size of emitting particles.
  87360. */
  87361. minSize: number;
  87362. /**
  87363. * Maximum Size of emitting particles.
  87364. */
  87365. maxSize: number;
  87366. /**
  87367. * Minimum scale of emitting particles on X axis.
  87368. */
  87369. minScaleX: number;
  87370. /**
  87371. * Maximum scale of emitting particles on X axis.
  87372. */
  87373. maxScaleX: number;
  87374. /**
  87375. * Minimum scale of emitting particles on Y axis.
  87376. */
  87377. minScaleY: number;
  87378. /**
  87379. * Maximum scale of emitting particles on Y axis.
  87380. */
  87381. maxScaleY: number;
  87382. /**
  87383. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87384. */
  87385. color1: Color4;
  87386. /**
  87387. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  87388. */
  87389. color2: Color4;
  87390. /**
  87391. * Color the particle will have at the end of its lifetime.
  87392. */
  87393. colorDead: Color4;
  87394. /**
  87395. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  87396. */
  87397. emitRate: number;
  87398. /**
  87399. * You can use gravity if you want to give an orientation to your particles.
  87400. */
  87401. gravity: Vector3;
  87402. /**
  87403. * Minimum power of emitting particles.
  87404. */
  87405. minEmitPower: number;
  87406. /**
  87407. * Maximum power of emitting particles.
  87408. */
  87409. maxEmitPower: number;
  87410. /**
  87411. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  87412. */
  87413. minAngularSpeed: number;
  87414. /**
  87415. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  87416. */
  87417. maxAngularSpeed: number;
  87418. /**
  87419. * Gets or sets the minimal initial rotation in radians.
  87420. */
  87421. minInitialRotation: number;
  87422. /**
  87423. * Gets or sets the maximal initial rotation in radians.
  87424. */
  87425. maxInitialRotation: number;
  87426. /**
  87427. * The particle emitter type defines the emitter used by the particle system.
  87428. * It can be for example box, sphere, or cone...
  87429. */
  87430. particleEmitterType: Nullable<IParticleEmitterType>;
  87431. /**
  87432. * Defines the delay in milliseconds before starting the system (0 by default)
  87433. */
  87434. startDelay: number;
  87435. /**
  87436. * 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
  87437. */
  87438. preWarmCycles: number;
  87439. /**
  87440. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  87441. */
  87442. preWarmStepOffset: number;
  87443. /**
  87444. * 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)
  87445. */
  87446. spriteCellChangeSpeed: number;
  87447. /**
  87448. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  87449. */
  87450. startSpriteCellID: number;
  87451. /**
  87452. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  87453. */
  87454. endSpriteCellID: number;
  87455. /**
  87456. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  87457. */
  87458. spriteCellWidth: number;
  87459. /**
  87460. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  87461. */
  87462. spriteCellHeight: number;
  87463. /**
  87464. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  87465. */
  87466. spriteRandomStartCell: boolean;
  87467. /**
  87468. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  87469. */
  87470. isAnimationSheetEnabled: boolean;
  87471. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  87472. translationPivot: Vector2;
  87473. /**
  87474. * Gets or sets a texture used to add random noise to particle positions
  87475. */
  87476. noiseTexture: Nullable<BaseTexture>;
  87477. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  87478. noiseStrength: Vector3;
  87479. /**
  87480. * Gets or sets the billboard mode to use when isBillboardBased = true.
  87481. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  87482. */
  87483. billboardMode: number;
  87484. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  87485. limitVelocityDamping: number;
  87486. /**
  87487. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  87488. */
  87489. beginAnimationOnStart: boolean;
  87490. /**
  87491. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  87492. */
  87493. beginAnimationFrom: number;
  87494. /**
  87495. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  87496. */
  87497. beginAnimationTo: number;
  87498. /**
  87499. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  87500. */
  87501. beginAnimationLoop: boolean;
  87502. /**
  87503. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  87504. */
  87505. disposeOnStop: boolean;
  87506. /**
  87507. * Specifies if the particles are updated in emitter local space or world space
  87508. */
  87509. isLocal: boolean;
  87510. /** Snippet ID if the particle system was created from the snippet server */
  87511. snippetId: string;
  87512. /**
  87513. * Gets the maximum number of particles active at the same time.
  87514. * @returns The max number of active particles.
  87515. */
  87516. getCapacity(): number;
  87517. /**
  87518. * Gets the number of particles active at the same time.
  87519. * @returns The number of active particles.
  87520. */
  87521. getActiveCount(): number;
  87522. /**
  87523. * Gets if the system has been started. (Note: this will still be true after stop is called)
  87524. * @returns True if it has been started, otherwise false.
  87525. */
  87526. isStarted(): boolean;
  87527. /**
  87528. * Animates the particle system for this frame.
  87529. */
  87530. animate(): void;
  87531. /**
  87532. * Renders the particle system in its current state.
  87533. * @returns the current number of particles
  87534. */
  87535. render(): number;
  87536. /**
  87537. * Dispose the particle system and frees its associated resources.
  87538. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  87539. */
  87540. dispose(disposeTexture?: boolean): void;
  87541. /**
  87542. * Clones the particle system.
  87543. * @param name The name of the cloned object
  87544. * @param newEmitter The new emitter to use
  87545. * @returns the cloned particle system
  87546. */
  87547. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  87548. /**
  87549. * Serializes the particle system to a JSON object
  87550. * @param serializeTexture defines if the texture must be serialized as well
  87551. * @returns the JSON object
  87552. */
  87553. serialize(serializeTexture: boolean): any;
  87554. /**
  87555. * Rebuild the particle system
  87556. */
  87557. rebuild(): void;
  87558. /** Force the system to rebuild all gradients that need to be resync */
  87559. forceRefreshGradients(): void;
  87560. /**
  87561. * Starts the particle system and begins to emit
  87562. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  87563. */
  87564. start(delay?: number): void;
  87565. /**
  87566. * Stops the particle system.
  87567. */
  87568. stop(): void;
  87569. /**
  87570. * Remove all active particles
  87571. */
  87572. reset(): void;
  87573. /**
  87574. * Gets a boolean indicating that the system is stopping
  87575. * @returns true if the system is currently stopping
  87576. */
  87577. isStopping(): boolean;
  87578. /**
  87579. * Is this system ready to be used/rendered
  87580. * @return true if the system is ready
  87581. */
  87582. isReady(): boolean;
  87583. /**
  87584. * Returns the string "ParticleSystem"
  87585. * @returns a string containing the class name
  87586. */
  87587. getClassName(): string;
  87588. /**
  87589. * Adds a new color gradient
  87590. * @param gradient defines the gradient to use (between 0 and 1)
  87591. * @param color1 defines the color to affect to the specified gradient
  87592. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  87593. * @returns the current particle system
  87594. */
  87595. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  87596. /**
  87597. * Remove a specific color gradient
  87598. * @param gradient defines the gradient to remove
  87599. * @returns the current particle system
  87600. */
  87601. removeColorGradient(gradient: number): IParticleSystem;
  87602. /**
  87603. * Adds a new size gradient
  87604. * @param gradient defines the gradient to use (between 0 and 1)
  87605. * @param factor defines the size factor to affect to the specified gradient
  87606. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87607. * @returns the current particle system
  87608. */
  87609. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87610. /**
  87611. * Remove a specific size gradient
  87612. * @param gradient defines the gradient to remove
  87613. * @returns the current particle system
  87614. */
  87615. removeSizeGradient(gradient: number): IParticleSystem;
  87616. /**
  87617. * Gets the current list of color gradients.
  87618. * You must use addColorGradient and removeColorGradient to udpate this list
  87619. * @returns the list of color gradients
  87620. */
  87621. getColorGradients(): Nullable<Array<ColorGradient>>;
  87622. /**
  87623. * Gets the current list of size gradients.
  87624. * You must use addSizeGradient and removeSizeGradient to udpate this list
  87625. * @returns the list of size gradients
  87626. */
  87627. getSizeGradients(): Nullable<Array<FactorGradient>>;
  87628. /**
  87629. * Gets the current list of angular speed gradients.
  87630. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  87631. * @returns the list of angular speed gradients
  87632. */
  87633. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  87634. /**
  87635. * Adds a new angular speed gradient
  87636. * @param gradient defines the gradient to use (between 0 and 1)
  87637. * @param factor defines the angular speed to affect to the specified gradient
  87638. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87639. * @returns the current particle system
  87640. */
  87641. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87642. /**
  87643. * Remove a specific angular speed gradient
  87644. * @param gradient defines the gradient to remove
  87645. * @returns the current particle system
  87646. */
  87647. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  87648. /**
  87649. * Gets the current list of velocity gradients.
  87650. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  87651. * @returns the list of velocity gradients
  87652. */
  87653. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  87654. /**
  87655. * Adds a new velocity gradient
  87656. * @param gradient defines the gradient to use (between 0 and 1)
  87657. * @param factor defines the velocity to affect to the specified gradient
  87658. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87659. * @returns the current particle system
  87660. */
  87661. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87662. /**
  87663. * Remove a specific velocity gradient
  87664. * @param gradient defines the gradient to remove
  87665. * @returns the current particle system
  87666. */
  87667. removeVelocityGradient(gradient: number): IParticleSystem;
  87668. /**
  87669. * Gets the current list of limit velocity gradients.
  87670. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  87671. * @returns the list of limit velocity gradients
  87672. */
  87673. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  87674. /**
  87675. * Adds a new limit velocity gradient
  87676. * @param gradient defines the gradient to use (between 0 and 1)
  87677. * @param factor defines the limit velocity to affect to the specified gradient
  87678. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87679. * @returns the current particle system
  87680. */
  87681. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87682. /**
  87683. * Remove a specific limit velocity gradient
  87684. * @param gradient defines the gradient to remove
  87685. * @returns the current particle system
  87686. */
  87687. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  87688. /**
  87689. * Adds a new drag gradient
  87690. * @param gradient defines the gradient to use (between 0 and 1)
  87691. * @param factor defines the drag to affect to the specified gradient
  87692. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87693. * @returns the current particle system
  87694. */
  87695. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87696. /**
  87697. * Remove a specific drag gradient
  87698. * @param gradient defines the gradient to remove
  87699. * @returns the current particle system
  87700. */
  87701. removeDragGradient(gradient: number): IParticleSystem;
  87702. /**
  87703. * Gets the current list of drag gradients.
  87704. * You must use addDragGradient and removeDragGradient to udpate this list
  87705. * @returns the list of drag gradients
  87706. */
  87707. getDragGradients(): Nullable<Array<FactorGradient>>;
  87708. /**
  87709. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  87710. * @param gradient defines the gradient to use (between 0 and 1)
  87711. * @param factor defines the emit rate to affect to the specified gradient
  87712. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87713. * @returns the current particle system
  87714. */
  87715. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87716. /**
  87717. * Remove a specific emit rate gradient
  87718. * @param gradient defines the gradient to remove
  87719. * @returns the current particle system
  87720. */
  87721. removeEmitRateGradient(gradient: number): IParticleSystem;
  87722. /**
  87723. * Gets the current list of emit rate gradients.
  87724. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  87725. * @returns the list of emit rate gradients
  87726. */
  87727. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  87728. /**
  87729. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  87730. * @param gradient defines the gradient to use (between 0 and 1)
  87731. * @param factor defines the start size to affect to the specified gradient
  87732. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87733. * @returns the current particle system
  87734. */
  87735. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87736. /**
  87737. * Remove a specific start size gradient
  87738. * @param gradient defines the gradient to remove
  87739. * @returns the current particle system
  87740. */
  87741. removeStartSizeGradient(gradient: number): IParticleSystem;
  87742. /**
  87743. * Gets the current list of start size gradients.
  87744. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  87745. * @returns the list of start size gradients
  87746. */
  87747. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  87748. /**
  87749. * Adds a new life time gradient
  87750. * @param gradient defines the gradient to use (between 0 and 1)
  87751. * @param factor defines the life time factor to affect to the specified gradient
  87752. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  87753. * @returns the current particle system
  87754. */
  87755. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  87756. /**
  87757. * Remove a specific life time gradient
  87758. * @param gradient defines the gradient to remove
  87759. * @returns the current particle system
  87760. */
  87761. removeLifeTimeGradient(gradient: number): IParticleSystem;
  87762. /**
  87763. * Gets the current list of life time gradients.
  87764. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  87765. * @returns the list of life time gradients
  87766. */
  87767. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  87768. /**
  87769. * Gets the current list of color gradients.
  87770. * You must use addColorGradient and removeColorGradient to udpate this list
  87771. * @returns the list of color gradients
  87772. */
  87773. getColorGradients(): Nullable<Array<ColorGradient>>;
  87774. /**
  87775. * Adds a new ramp gradient used to remap particle colors
  87776. * @param gradient defines the gradient to use (between 0 and 1)
  87777. * @param color defines the color to affect to the specified gradient
  87778. * @returns the current particle system
  87779. */
  87780. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  87781. /**
  87782. * Gets the current list of ramp gradients.
  87783. * You must use addRampGradient and removeRampGradient to udpate this list
  87784. * @returns the list of ramp gradients
  87785. */
  87786. getRampGradients(): Nullable<Array<Color3Gradient>>;
  87787. /** Gets or sets a boolean indicating that ramp gradients must be used
  87788. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  87789. */
  87790. useRampGradients: boolean;
  87791. /**
  87792. * Adds a new color remap gradient
  87793. * @param gradient defines the gradient to use (between 0 and 1)
  87794. * @param min defines the color remap minimal range
  87795. * @param max defines the color remap maximal range
  87796. * @returns the current particle system
  87797. */
  87798. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87799. /**
  87800. * Gets the current list of color remap gradients.
  87801. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  87802. * @returns the list of color remap gradients
  87803. */
  87804. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  87805. /**
  87806. * Adds a new alpha remap gradient
  87807. * @param gradient defines the gradient to use (between 0 and 1)
  87808. * @param min defines the alpha remap minimal range
  87809. * @param max defines the alpha remap maximal range
  87810. * @returns the current particle system
  87811. */
  87812. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  87813. /**
  87814. * Gets the current list of alpha remap gradients.
  87815. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  87816. * @returns the list of alpha remap gradients
  87817. */
  87818. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  87819. /**
  87820. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  87821. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87822. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87823. * @returns the emitter
  87824. */
  87825. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  87826. /**
  87827. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  87828. * @param radius The radius of the hemisphere to emit from
  87829. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87830. * @returns the emitter
  87831. */
  87832. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  87833. /**
  87834. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  87835. * @param radius The radius of the sphere to emit from
  87836. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  87837. * @returns the emitter
  87838. */
  87839. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  87840. /**
  87841. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  87842. * @param radius The radius of the sphere to emit from
  87843. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  87844. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  87845. * @returns the emitter
  87846. */
  87847. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87848. /**
  87849. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  87850. * @param radius The radius of the emission cylinder
  87851. * @param height The height of the emission cylinder
  87852. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  87853. * @param directionRandomizer How much to randomize the particle direction [0-1]
  87854. * @returns the emitter
  87855. */
  87856. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  87857. /**
  87858. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  87859. * @param radius The radius of the cylinder to emit from
  87860. * @param height The height of the emission cylinder
  87861. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  87862. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  87863. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  87864. * @returns the emitter
  87865. */
  87866. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  87867. /**
  87868. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  87869. * @param radius The radius of the cone to emit from
  87870. * @param angle The base angle of the cone
  87871. * @returns the emitter
  87872. */
  87873. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  87874. /**
  87875. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  87876. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  87877. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  87878. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87879. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  87880. * @returns the emitter
  87881. */
  87882. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  87883. /**
  87884. * Get hosting scene
  87885. * @returns the scene
  87886. */
  87887. getScene(): Scene;
  87888. }
  87889. }
  87890. declare module BABYLON {
  87891. /**
  87892. * 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.
  87893. * @see https://doc.babylonjs.com/how_to/transformnode
  87894. */
  87895. export class TransformNode extends Node {
  87896. /**
  87897. * Object will not rotate to face the camera
  87898. */
  87899. static BILLBOARDMODE_NONE: number;
  87900. /**
  87901. * Object will rotate to face the camera but only on the x axis
  87902. */
  87903. static BILLBOARDMODE_X: number;
  87904. /**
  87905. * Object will rotate to face the camera but only on the y axis
  87906. */
  87907. static BILLBOARDMODE_Y: number;
  87908. /**
  87909. * Object will rotate to face the camera but only on the z axis
  87910. */
  87911. static BILLBOARDMODE_Z: number;
  87912. /**
  87913. * Object will rotate to face the camera
  87914. */
  87915. static BILLBOARDMODE_ALL: number;
  87916. /**
  87917. * Object will rotate to face the camera's position instead of orientation
  87918. */
  87919. static BILLBOARDMODE_USE_POSITION: number;
  87920. private _forward;
  87921. private _forwardInverted;
  87922. private _up;
  87923. private _right;
  87924. private _rightInverted;
  87925. private _position;
  87926. private _rotation;
  87927. private _rotationQuaternion;
  87928. protected _scaling: Vector3;
  87929. protected _isDirty: boolean;
  87930. private _transformToBoneReferal;
  87931. private _isAbsoluteSynced;
  87932. private _billboardMode;
  87933. /**
  87934. * Gets or sets the billboard mode. Default is 0.
  87935. *
  87936. * | Value | Type | Description |
  87937. * | --- | --- | --- |
  87938. * | 0 | BILLBOARDMODE_NONE | |
  87939. * | 1 | BILLBOARDMODE_X | |
  87940. * | 2 | BILLBOARDMODE_Y | |
  87941. * | 4 | BILLBOARDMODE_Z | |
  87942. * | 7 | BILLBOARDMODE_ALL | |
  87943. *
  87944. */
  87945. get billboardMode(): number;
  87946. set billboardMode(value: number);
  87947. private _preserveParentRotationForBillboard;
  87948. /**
  87949. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  87950. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  87951. */
  87952. get preserveParentRotationForBillboard(): boolean;
  87953. set preserveParentRotationForBillboard(value: boolean);
  87954. /**
  87955. * 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
  87956. */
  87957. scalingDeterminant: number;
  87958. private _infiniteDistance;
  87959. /**
  87960. * Gets or sets the distance of the object to max, often used by skybox
  87961. */
  87962. get infiniteDistance(): boolean;
  87963. set infiniteDistance(value: boolean);
  87964. /**
  87965. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  87966. * By default the system will update normals to compensate
  87967. */
  87968. ignoreNonUniformScaling: boolean;
  87969. /**
  87970. * 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
  87971. */
  87972. reIntegrateRotationIntoRotationQuaternion: boolean;
  87973. /** @hidden */
  87974. _poseMatrix: Nullable<Matrix>;
  87975. /** @hidden */
  87976. _localMatrix: Matrix;
  87977. private _usePivotMatrix;
  87978. private _absolutePosition;
  87979. private _absoluteScaling;
  87980. private _absoluteRotationQuaternion;
  87981. private _pivotMatrix;
  87982. private _pivotMatrixInverse;
  87983. protected _postMultiplyPivotMatrix: boolean;
  87984. protected _isWorldMatrixFrozen: boolean;
  87985. /** @hidden */
  87986. _indexInSceneTransformNodesArray: number;
  87987. /**
  87988. * An event triggered after the world matrix is updated
  87989. */
  87990. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  87991. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  87992. /**
  87993. * Gets a string identifying the name of the class
  87994. * @returns "TransformNode" string
  87995. */
  87996. getClassName(): string;
  87997. /**
  87998. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  87999. */
  88000. get position(): Vector3;
  88001. set position(newPosition: Vector3);
  88002. /**
  88003. * 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)).
  88004. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  88005. */
  88006. get rotation(): Vector3;
  88007. set rotation(newRotation: Vector3);
  88008. /**
  88009. * 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)).
  88010. */
  88011. get scaling(): Vector3;
  88012. set scaling(newScaling: Vector3);
  88013. /**
  88014. * 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).
  88015. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  88016. */
  88017. get rotationQuaternion(): Nullable<Quaternion>;
  88018. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  88019. /**
  88020. * The forward direction of that transform in world space.
  88021. */
  88022. get forward(): Vector3;
  88023. /**
  88024. * The up direction of that transform in world space.
  88025. */
  88026. get up(): Vector3;
  88027. /**
  88028. * The right direction of that transform in world space.
  88029. */
  88030. get right(): Vector3;
  88031. /**
  88032. * Copies the parameter passed Matrix into the mesh Pose matrix.
  88033. * @param matrix the matrix to copy the pose from
  88034. * @returns this TransformNode.
  88035. */
  88036. updatePoseMatrix(matrix: Matrix): TransformNode;
  88037. /**
  88038. * Returns the mesh Pose matrix.
  88039. * @returns the pose matrix
  88040. */
  88041. getPoseMatrix(): Matrix;
  88042. /** @hidden */
  88043. _isSynchronized(): boolean;
  88044. /** @hidden */
  88045. _initCache(): void;
  88046. /**
  88047. * Flag the transform node as dirty (Forcing it to update everything)
  88048. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  88049. * @returns this transform node
  88050. */
  88051. markAsDirty(property: string): TransformNode;
  88052. /**
  88053. * Returns the current mesh absolute position.
  88054. * Returns a Vector3.
  88055. */
  88056. get absolutePosition(): Vector3;
  88057. /**
  88058. * Returns the current mesh absolute scaling.
  88059. * Returns a Vector3.
  88060. */
  88061. get absoluteScaling(): Vector3;
  88062. /**
  88063. * Returns the current mesh absolute rotation.
  88064. * Returns a Quaternion.
  88065. */
  88066. get absoluteRotationQuaternion(): Quaternion;
  88067. /**
  88068. * Sets a new matrix to apply before all other transformation
  88069. * @param matrix defines the transform matrix
  88070. * @returns the current TransformNode
  88071. */
  88072. setPreTransformMatrix(matrix: Matrix): TransformNode;
  88073. /**
  88074. * Sets a new pivot matrix to the current node
  88075. * @param matrix defines the new pivot matrix to use
  88076. * @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
  88077. * @returns the current TransformNode
  88078. */
  88079. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  88080. /**
  88081. * Returns the mesh pivot matrix.
  88082. * Default : Identity.
  88083. * @returns the matrix
  88084. */
  88085. getPivotMatrix(): Matrix;
  88086. /**
  88087. * Instantiate (when possible) or clone that node with its hierarchy
  88088. * @param newParent defines the new parent to use for the instance (or clone)
  88089. * @param options defines options to configure how copy is done
  88090. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  88091. * @returns an instance (or a clone) of the current node with its hiearchy
  88092. */
  88093. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  88094. doNotInstantiate: boolean;
  88095. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  88096. /**
  88097. * Prevents the World matrix to be computed any longer
  88098. * @param newWorldMatrix defines an optional matrix to use as world matrix
  88099. * @returns the TransformNode.
  88100. */
  88101. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  88102. /**
  88103. * Allows back the World matrix computation.
  88104. * @returns the TransformNode.
  88105. */
  88106. unfreezeWorldMatrix(): this;
  88107. /**
  88108. * True if the World matrix has been frozen.
  88109. */
  88110. get isWorldMatrixFrozen(): boolean;
  88111. /**
  88112. * Retuns the mesh absolute position in the World.
  88113. * @returns a Vector3.
  88114. */
  88115. getAbsolutePosition(): Vector3;
  88116. /**
  88117. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  88118. * @param absolutePosition the absolute position to set
  88119. * @returns the TransformNode.
  88120. */
  88121. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  88122. /**
  88123. * Sets the mesh position in its local space.
  88124. * @param vector3 the position to set in localspace
  88125. * @returns the TransformNode.
  88126. */
  88127. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  88128. /**
  88129. * Returns the mesh position in the local space from the current World matrix values.
  88130. * @returns a new Vector3.
  88131. */
  88132. getPositionExpressedInLocalSpace(): Vector3;
  88133. /**
  88134. * Translates the mesh along the passed Vector3 in its local space.
  88135. * @param vector3 the distance to translate in localspace
  88136. * @returns the TransformNode.
  88137. */
  88138. locallyTranslate(vector3: Vector3): TransformNode;
  88139. private static _lookAtVectorCache;
  88140. /**
  88141. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  88142. * @param targetPoint the position (must be in same space as current mesh) to look at
  88143. * @param yawCor optional yaw (y-axis) correction in radians
  88144. * @param pitchCor optional pitch (x-axis) correction in radians
  88145. * @param rollCor optional roll (z-axis) correction in radians
  88146. * @param space the choosen space of the target
  88147. * @returns the TransformNode.
  88148. */
  88149. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  88150. /**
  88151. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88152. * This Vector3 is expressed in the World space.
  88153. * @param localAxis axis to rotate
  88154. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  88155. */
  88156. getDirection(localAxis: Vector3): Vector3;
  88157. /**
  88158. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  88159. * localAxis is expressed in the mesh local space.
  88160. * result is computed in the Wordl space from the mesh World matrix.
  88161. * @param localAxis axis to rotate
  88162. * @param result the resulting transformnode
  88163. * @returns this TransformNode.
  88164. */
  88165. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  88166. /**
  88167. * Sets this transform node rotation to the given local axis.
  88168. * @param localAxis the axis in local space
  88169. * @param yawCor optional yaw (y-axis) correction in radians
  88170. * @param pitchCor optional pitch (x-axis) correction in radians
  88171. * @param rollCor optional roll (z-axis) correction in radians
  88172. * @returns this TransformNode
  88173. */
  88174. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  88175. /**
  88176. * Sets a new pivot point to the current node
  88177. * @param point defines the new pivot point to use
  88178. * @param space defines if the point is in world or local space (local by default)
  88179. * @returns the current TransformNode
  88180. */
  88181. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  88182. /**
  88183. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  88184. * @returns the pivot point
  88185. */
  88186. getPivotPoint(): Vector3;
  88187. /**
  88188. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  88189. * @param result the vector3 to store the result
  88190. * @returns this TransformNode.
  88191. */
  88192. getPivotPointToRef(result: Vector3): TransformNode;
  88193. /**
  88194. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  88195. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  88196. */
  88197. getAbsolutePivotPoint(): Vector3;
  88198. /**
  88199. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  88200. * @param result vector3 to store the result
  88201. * @returns this TransformNode.
  88202. */
  88203. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  88204. /**
  88205. * Defines the passed node as the parent of the current node.
  88206. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  88207. * @see https://doc.babylonjs.com/how_to/parenting
  88208. * @param node the node ot set as the parent
  88209. * @returns this TransformNode.
  88210. */
  88211. setParent(node: Nullable<Node>): TransformNode;
  88212. private _nonUniformScaling;
  88213. /**
  88214. * True if the scaling property of this object is non uniform eg. (1,2,1)
  88215. */
  88216. get nonUniformScaling(): boolean;
  88217. /** @hidden */
  88218. _updateNonUniformScalingState(value: boolean): boolean;
  88219. /**
  88220. * Attach the current TransformNode to another TransformNode associated with a bone
  88221. * @param bone Bone affecting the TransformNode
  88222. * @param affectedTransformNode TransformNode associated with the bone
  88223. * @returns this object
  88224. */
  88225. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  88226. /**
  88227. * Detach the transform node if its associated with a bone
  88228. * @returns this object
  88229. */
  88230. detachFromBone(): TransformNode;
  88231. private static _rotationAxisCache;
  88232. /**
  88233. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  88234. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  88238. * @param amount the amount to rotate in radians
  88239. * @param space Space to rotate in (Default: local)
  88240. * @returns the TransformNode.
  88241. */
  88242. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  88243. /**
  88244. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  88245. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  88246. * The passed axis is also normalized. .
  88247. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  88248. * @param point the point to rotate around
  88249. * @param axis the axis to rotate around
  88250. * @param amount the amount to rotate in radians
  88251. * @returns the TransformNode
  88252. */
  88253. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  88254. /**
  88255. * Translates the mesh along the axis vector for the passed distance in the given space.
  88256. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  88257. * @param axis the axis to translate in
  88258. * @param distance the distance to translate
  88259. * @param space Space to rotate in (Default: local)
  88260. * @returns the TransformNode.
  88261. */
  88262. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  88263. /**
  88264. * Adds a rotation step to the mesh current rotation.
  88265. * x, y, z are Euler angles expressed in radians.
  88266. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  88267. * This means this rotation is made in the mesh local space only.
  88268. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  88269. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  88270. * ```javascript
  88271. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  88272. * ```
  88273. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  88274. * 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.
  88275. * @param x Rotation to add
  88276. * @param y Rotation to add
  88277. * @param z Rotation to add
  88278. * @returns the TransformNode.
  88279. */
  88280. addRotation(x: number, y: number, z: number): TransformNode;
  88281. /**
  88282. * @hidden
  88283. */
  88284. protected _getEffectiveParent(): Nullable<Node>;
  88285. /**
  88286. * Computes the world matrix of the node
  88287. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  88288. * @returns the world matrix
  88289. */
  88290. computeWorldMatrix(force?: boolean): Matrix;
  88291. /**
  88292. * Resets this nodeTransform's local matrix to Matrix.Identity().
  88293. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  88294. */
  88295. resetLocalMatrix(independentOfChildren?: boolean): void;
  88296. protected _afterComputeWorldMatrix(): void;
  88297. /**
  88298. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  88299. * @param func callback function to add
  88300. *
  88301. * @returns the TransformNode.
  88302. */
  88303. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88304. /**
  88305. * Removes a registered callback function.
  88306. * @param func callback function to remove
  88307. * @returns the TransformNode.
  88308. */
  88309. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  88310. /**
  88311. * Gets the position of the current mesh in camera space
  88312. * @param camera defines the camera to use
  88313. * @returns a position
  88314. */
  88315. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  88316. /**
  88317. * Returns the distance from the mesh to the active camera
  88318. * @param camera defines the camera to use
  88319. * @returns the distance
  88320. */
  88321. getDistanceToCamera(camera?: Nullable<Camera>): number;
  88322. /**
  88323. * Clone the current transform node
  88324. * @param name Name of the new clone
  88325. * @param newParent New parent for the clone
  88326. * @param doNotCloneChildren Do not clone children hierarchy
  88327. * @returns the new transform node
  88328. */
  88329. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  88330. /**
  88331. * Serializes the objects information.
  88332. * @param currentSerializationObject defines the object to serialize in
  88333. * @returns the serialized object
  88334. */
  88335. serialize(currentSerializationObject?: any): any;
  88336. /**
  88337. * Returns a new TransformNode object parsed from the source provided.
  88338. * @param parsedTransformNode is the source.
  88339. * @param scene the scne the object belongs to
  88340. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  88341. * @returns a new TransformNode object parsed from the source provided.
  88342. */
  88343. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  88344. /**
  88345. * Get all child-transformNodes of this node
  88346. * @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
  88347. * @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
  88348. * @returns an array of TransformNode
  88349. */
  88350. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  88351. /**
  88352. * Releases resources associated with this transform node.
  88353. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  88354. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  88355. */
  88356. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  88357. /**
  88358. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  88359. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  88360. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  88361. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  88362. * @returns the current mesh
  88363. */
  88364. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  88365. private _syncAbsoluteScalingAndRotation;
  88366. }
  88367. }
  88368. declare module BABYLON {
  88369. /**
  88370. * Class used to override all child animations of a given target
  88371. */
  88372. export class AnimationPropertiesOverride {
  88373. /**
  88374. * Gets or sets a value indicating if animation blending must be used
  88375. */
  88376. enableBlending: boolean;
  88377. /**
  88378. * Gets or sets the blending speed to use when enableBlending is true
  88379. */
  88380. blendingSpeed: number;
  88381. /**
  88382. * Gets or sets the default loop mode to use
  88383. */
  88384. loopMode: number;
  88385. }
  88386. }
  88387. declare module BABYLON {
  88388. /**
  88389. * Class used to store bone information
  88390. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  88391. */
  88392. export class Bone extends Node {
  88393. /**
  88394. * defines the bone name
  88395. */
  88396. name: string;
  88397. private static _tmpVecs;
  88398. private static _tmpQuat;
  88399. private static _tmpMats;
  88400. /**
  88401. * Gets the list of child bones
  88402. */
  88403. children: Bone[];
  88404. /** Gets the animations associated with this bone */
  88405. animations: Animation[];
  88406. /**
  88407. * Gets or sets bone length
  88408. */
  88409. length: number;
  88410. /**
  88411. * @hidden Internal only
  88412. * Set this value to map this bone to a different index in the transform matrices
  88413. * Set this value to -1 to exclude the bone from the transform matrices
  88414. */
  88415. _index: Nullable<number>;
  88416. private _skeleton;
  88417. private _localMatrix;
  88418. private _restPose;
  88419. private _baseMatrix;
  88420. private _absoluteTransform;
  88421. private _invertedAbsoluteTransform;
  88422. private _parent;
  88423. private _scalingDeterminant;
  88424. private _worldTransform;
  88425. private _localScaling;
  88426. private _localRotation;
  88427. private _localPosition;
  88428. private _needToDecompose;
  88429. private _needToCompose;
  88430. /** @hidden */
  88431. _linkedTransformNode: Nullable<TransformNode>;
  88432. /** @hidden */
  88433. _waitingTransformNodeId: Nullable<string>;
  88434. /** @hidden */
  88435. get _matrix(): Matrix;
  88436. /** @hidden */
  88437. set _matrix(value: Matrix);
  88438. /**
  88439. * Create a new bone
  88440. * @param name defines the bone name
  88441. * @param skeleton defines the parent skeleton
  88442. * @param parentBone defines the parent (can be null if the bone is the root)
  88443. * @param localMatrix defines the local matrix
  88444. * @param restPose defines the rest pose matrix
  88445. * @param baseMatrix defines the base matrix
  88446. * @param index defines index of the bone in the hiearchy
  88447. */
  88448. constructor(
  88449. /**
  88450. * defines the bone name
  88451. */
  88452. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  88453. /**
  88454. * Gets the current object class name.
  88455. * @return the class name
  88456. */
  88457. getClassName(): string;
  88458. /**
  88459. * Gets the parent skeleton
  88460. * @returns a skeleton
  88461. */
  88462. getSkeleton(): Skeleton;
  88463. /**
  88464. * Gets parent bone
  88465. * @returns a bone or null if the bone is the root of the bone hierarchy
  88466. */
  88467. getParent(): Nullable<Bone>;
  88468. /**
  88469. * Returns an array containing the root bones
  88470. * @returns an array containing the root bones
  88471. */
  88472. getChildren(): Array<Bone>;
  88473. /**
  88474. * Gets the node index in matrix array generated for rendering
  88475. * @returns the node index
  88476. */
  88477. getIndex(): number;
  88478. /**
  88479. * Sets the parent bone
  88480. * @param parent defines the parent (can be null if the bone is the root)
  88481. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88482. */
  88483. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  88484. /**
  88485. * Gets the local matrix
  88486. * @returns a matrix
  88487. */
  88488. getLocalMatrix(): Matrix;
  88489. /**
  88490. * Gets the base matrix (initial matrix which remains unchanged)
  88491. * @returns a matrix
  88492. */
  88493. getBaseMatrix(): Matrix;
  88494. /**
  88495. * Gets the rest pose matrix
  88496. * @returns a matrix
  88497. */
  88498. getRestPose(): Matrix;
  88499. /**
  88500. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  88501. */
  88502. getWorldMatrix(): Matrix;
  88503. /**
  88504. * Sets the local matrix to rest pose matrix
  88505. */
  88506. returnToRest(): void;
  88507. /**
  88508. * Gets the inverse of the absolute transform matrix.
  88509. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  88510. * @returns a matrix
  88511. */
  88512. getInvertedAbsoluteTransform(): Matrix;
  88513. /**
  88514. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  88515. * @returns a matrix
  88516. */
  88517. getAbsoluteTransform(): Matrix;
  88518. /**
  88519. * Links with the given transform node.
  88520. * The local matrix of this bone is copied from the transform node every frame.
  88521. * @param transformNode defines the transform node to link to
  88522. */
  88523. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  88524. /**
  88525. * Gets the node used to drive the bone's transformation
  88526. * @returns a transform node or null
  88527. */
  88528. getTransformNode(): Nullable<TransformNode>;
  88529. /** Gets or sets current position (in local space) */
  88530. get position(): Vector3;
  88531. set position(newPosition: Vector3);
  88532. /** Gets or sets current rotation (in local space) */
  88533. get rotation(): Vector3;
  88534. set rotation(newRotation: Vector3);
  88535. /** Gets or sets current rotation quaternion (in local space) */
  88536. get rotationQuaternion(): Quaternion;
  88537. set rotationQuaternion(newRotation: Quaternion);
  88538. /** Gets or sets current scaling (in local space) */
  88539. get scaling(): Vector3;
  88540. set scaling(newScaling: Vector3);
  88541. /**
  88542. * Gets the animation properties override
  88543. */
  88544. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  88545. private _decompose;
  88546. private _compose;
  88547. /**
  88548. * Update the base and local matrices
  88549. * @param matrix defines the new base or local matrix
  88550. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  88551. * @param updateLocalMatrix defines if the local matrix should be updated
  88552. */
  88553. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  88554. /** @hidden */
  88555. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  88556. /**
  88557. * Flag the bone as dirty (Forcing it to update everything)
  88558. */
  88559. markAsDirty(): void;
  88560. /** @hidden */
  88561. _markAsDirtyAndCompose(): void;
  88562. private _markAsDirtyAndDecompose;
  88563. /**
  88564. * Translate the bone in local or world space
  88565. * @param vec The amount to translate the bone
  88566. * @param space The space that the translation is in
  88567. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88568. */
  88569. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88570. /**
  88571. * Set the postion of the bone in local or world space
  88572. * @param position The position to set the bone
  88573. * @param space The space that the position is in
  88574. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88575. */
  88576. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88577. /**
  88578. * Set the absolute position of the bone (world space)
  88579. * @param position The position to set the bone
  88580. * @param mesh The mesh that this bone is attached to
  88581. */
  88582. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  88583. /**
  88584. * Scale the bone on the x, y and z axes (in local space)
  88585. * @param x The amount to scale the bone on the x axis
  88586. * @param y The amount to scale the bone on the y axis
  88587. * @param z The amount to scale the bone on the z axis
  88588. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  88589. */
  88590. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  88591. /**
  88592. * Set the bone scaling in local space
  88593. * @param scale defines the scaling vector
  88594. */
  88595. setScale(scale: Vector3): void;
  88596. /**
  88597. * Gets the current scaling in local space
  88598. * @returns the current scaling vector
  88599. */
  88600. getScale(): Vector3;
  88601. /**
  88602. * Gets the current scaling in local space and stores it in a target vector
  88603. * @param result defines the target vector
  88604. */
  88605. getScaleToRef(result: Vector3): void;
  88606. /**
  88607. * Set the yaw, pitch, and roll of the bone in local or world space
  88608. * @param yaw The rotation of the bone on the y axis
  88609. * @param pitch The rotation of the bone on the x axis
  88610. * @param roll The rotation of the bone on the z axis
  88611. * @param space The space that the axes of rotation are in
  88612. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88613. */
  88614. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  88615. /**
  88616. * Add a rotation to the bone on an axis in local or world space
  88617. * @param axis The axis to rotate the bone on
  88618. * @param amount The amount to rotate the bone
  88619. * @param space The space that the axis is in
  88620. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88621. */
  88622. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  88623. /**
  88624. * Set the rotation of the bone to a particular axis angle in local or world space
  88625. * @param axis The axis to rotate the bone on
  88626. * @param angle The angle that the bone should be rotated to
  88627. * @param space The space that the axis is in
  88628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88629. */
  88630. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  88631. /**
  88632. * Set the euler rotation of the bone in local of world space
  88633. * @param rotation The euler rotation that the bone should be set to
  88634. * @param space The space that the rotation is in
  88635. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88636. */
  88637. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  88638. /**
  88639. * Set the quaternion rotation of the bone in local of world space
  88640. * @param quat The quaternion rotation that the bone should be set to
  88641. * @param space The space that the rotation is in
  88642. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88643. */
  88644. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  88645. /**
  88646. * Set the rotation matrix of the bone in local of world space
  88647. * @param rotMat The rotation matrix that the bone should be set to
  88648. * @param space The space that the rotation is in
  88649. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88650. */
  88651. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  88652. private _rotateWithMatrix;
  88653. private _getNegativeRotationToRef;
  88654. /**
  88655. * Get the position of the bone in local or world space
  88656. * @param space The space that the returned position is in
  88657. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88658. * @returns The position of the bone
  88659. */
  88660. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88661. /**
  88662. * Copy the position of the bone to a vector3 in local or world space
  88663. * @param space The space that the returned position is in
  88664. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88665. * @param result The vector3 to copy the position to
  88666. */
  88667. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  88668. /**
  88669. * Get the absolute position of the bone (world space)
  88670. * @param mesh The mesh that this bone is attached to
  88671. * @returns The absolute position of the bone
  88672. */
  88673. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  88674. /**
  88675. * Copy the absolute position of the bone (world space) to the result param
  88676. * @param mesh The mesh that this bone is attached to
  88677. * @param result The vector3 to copy the absolute position to
  88678. */
  88679. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  88680. /**
  88681. * Compute the absolute transforms of this bone and its children
  88682. */
  88683. computeAbsoluteTransforms(): void;
  88684. /**
  88685. * Get the world direction from an axis that is in the local space of the bone
  88686. * @param localAxis The local direction that is used to compute the world direction
  88687. * @param mesh The mesh that this bone is attached to
  88688. * @returns The world direction
  88689. */
  88690. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88691. /**
  88692. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  88693. * @param localAxis The local direction that is used to compute the world direction
  88694. * @param mesh The mesh that this bone is attached to
  88695. * @param result The vector3 that the world direction will be copied to
  88696. */
  88697. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88698. /**
  88699. * Get the euler rotation of the bone in local or world space
  88700. * @param space The space that the rotation should be in
  88701. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88702. * @returns The euler rotation
  88703. */
  88704. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  88705. /**
  88706. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  88707. * @param space The space that the rotation should be in
  88708. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88709. * @param result The vector3 that the rotation should be copied to
  88710. */
  88711. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88712. /**
  88713. * Get the quaternion rotation of the bone in either local or world space
  88714. * @param space The space that the rotation should be in
  88715. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88716. * @returns The quaternion rotation
  88717. */
  88718. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  88719. /**
  88720. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  88721. * @param space The space that the rotation should be in
  88722. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88723. * @param result The quaternion that the rotation should be copied to
  88724. */
  88725. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  88726. /**
  88727. * Get the rotation matrix of the bone in local or world space
  88728. * @param space The space that the rotation should be in
  88729. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88730. * @returns The rotation matrix
  88731. */
  88732. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  88733. /**
  88734. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  88735. * @param space The space that the rotation should be in
  88736. * @param mesh The mesh that this bone is attached to. This is only used in world space
  88737. * @param result The quaternion that the rotation should be copied to
  88738. */
  88739. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  88740. /**
  88741. * Get the world position of a point that is in the local space of the bone
  88742. * @param position The local position
  88743. * @param mesh The mesh that this bone is attached to
  88744. * @returns The world position
  88745. */
  88746. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88747. /**
  88748. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  88749. * @param position The local position
  88750. * @param mesh The mesh that this bone is attached to
  88751. * @param result The vector3 that the world position should be copied to
  88752. */
  88753. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88754. /**
  88755. * Get the local position of a point that is in world space
  88756. * @param position The world position
  88757. * @param mesh The mesh that this bone is attached to
  88758. * @returns The local position
  88759. */
  88760. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  88761. /**
  88762. * Get the local position of a point that is in world space and copy it to the result param
  88763. * @param position The world position
  88764. * @param mesh The mesh that this bone is attached to
  88765. * @param result The vector3 that the local position should be copied to
  88766. */
  88767. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  88768. }
  88769. }
  88770. declare module BABYLON {
  88771. /**
  88772. * Defines a runtime animation
  88773. */
  88774. export class RuntimeAnimation {
  88775. private _events;
  88776. /**
  88777. * The current frame of the runtime animation
  88778. */
  88779. private _currentFrame;
  88780. /**
  88781. * The animation used by the runtime animation
  88782. */
  88783. private _animation;
  88784. /**
  88785. * The target of the runtime animation
  88786. */
  88787. private _target;
  88788. /**
  88789. * The initiating animatable
  88790. */
  88791. private _host;
  88792. /**
  88793. * The original value of the runtime animation
  88794. */
  88795. private _originalValue;
  88796. /**
  88797. * The original blend value of the runtime animation
  88798. */
  88799. private _originalBlendValue;
  88800. /**
  88801. * The offsets cache of the runtime animation
  88802. */
  88803. private _offsetsCache;
  88804. /**
  88805. * The high limits cache of the runtime animation
  88806. */
  88807. private _highLimitsCache;
  88808. /**
  88809. * Specifies if the runtime animation has been stopped
  88810. */
  88811. private _stopped;
  88812. /**
  88813. * The blending factor of the runtime animation
  88814. */
  88815. private _blendingFactor;
  88816. /**
  88817. * The BabylonJS scene
  88818. */
  88819. private _scene;
  88820. /**
  88821. * The current value of the runtime animation
  88822. */
  88823. private _currentValue;
  88824. /** @hidden */
  88825. _animationState: _IAnimationState;
  88826. /**
  88827. * The active target of the runtime animation
  88828. */
  88829. private _activeTargets;
  88830. private _currentActiveTarget;
  88831. private _directTarget;
  88832. /**
  88833. * The target path of the runtime animation
  88834. */
  88835. private _targetPath;
  88836. /**
  88837. * The weight of the runtime animation
  88838. */
  88839. private _weight;
  88840. /**
  88841. * The ratio offset of the runtime animation
  88842. */
  88843. private _ratioOffset;
  88844. /**
  88845. * The previous delay of the runtime animation
  88846. */
  88847. private _previousDelay;
  88848. /**
  88849. * The previous ratio of the runtime animation
  88850. */
  88851. private _previousRatio;
  88852. private _enableBlending;
  88853. private _keys;
  88854. private _minFrame;
  88855. private _maxFrame;
  88856. private _minValue;
  88857. private _maxValue;
  88858. private _targetIsArray;
  88859. /**
  88860. * Gets the current frame of the runtime animation
  88861. */
  88862. get currentFrame(): number;
  88863. /**
  88864. * Gets the weight of the runtime animation
  88865. */
  88866. get weight(): number;
  88867. /**
  88868. * Gets the current value of the runtime animation
  88869. */
  88870. get currentValue(): any;
  88871. /**
  88872. * Gets the target path of the runtime animation
  88873. */
  88874. get targetPath(): string;
  88875. /**
  88876. * Gets the actual target of the runtime animation
  88877. */
  88878. get target(): any;
  88879. /**
  88880. * Gets the additive state of the runtime animation
  88881. */
  88882. get isAdditive(): boolean;
  88883. /** @hidden */
  88884. _onLoop: () => void;
  88885. /**
  88886. * Create a new RuntimeAnimation object
  88887. * @param target defines the target of the animation
  88888. * @param animation defines the source animation object
  88889. * @param scene defines the hosting scene
  88890. * @param host defines the initiating Animatable
  88891. */
  88892. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  88893. private _preparePath;
  88894. /**
  88895. * Gets the animation from the runtime animation
  88896. */
  88897. get animation(): Animation;
  88898. /**
  88899. * Resets the runtime animation to the beginning
  88900. * @param restoreOriginal defines whether to restore the target property to the original value
  88901. */
  88902. reset(restoreOriginal?: boolean): void;
  88903. /**
  88904. * Specifies if the runtime animation is stopped
  88905. * @returns Boolean specifying if the runtime animation is stopped
  88906. */
  88907. isStopped(): boolean;
  88908. /**
  88909. * Disposes of the runtime animation
  88910. */
  88911. dispose(): void;
  88912. /**
  88913. * Apply the interpolated value to the target
  88914. * @param currentValue defines the value computed by the animation
  88915. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  88916. */
  88917. setValue(currentValue: any, weight: number): void;
  88918. private _getOriginalValues;
  88919. private _setValue;
  88920. /**
  88921. * Gets the loop pmode of the runtime animation
  88922. * @returns Loop Mode
  88923. */
  88924. private _getCorrectLoopMode;
  88925. /**
  88926. * Move the current animation to a given frame
  88927. * @param frame defines the frame to move to
  88928. */
  88929. goToFrame(frame: number): void;
  88930. /**
  88931. * @hidden Internal use only
  88932. */
  88933. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  88934. /**
  88935. * Execute the current animation
  88936. * @param delay defines the delay to add to the current frame
  88937. * @param from defines the lower bound of the animation range
  88938. * @param to defines the upper bound of the animation range
  88939. * @param loop defines if the current animation must loop
  88940. * @param speedRatio defines the current speed ratio
  88941. * @param weight defines the weight of the animation (default is -1 so no weight)
  88942. * @param onLoop optional callback called when animation loops
  88943. * @returns a boolean indicating if the animation is running
  88944. */
  88945. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  88946. }
  88947. }
  88948. declare module BABYLON {
  88949. /**
  88950. * Class used to store an actual running animation
  88951. */
  88952. export class Animatable {
  88953. /** defines the target object */
  88954. target: any;
  88955. /** defines the starting frame number (default is 0) */
  88956. fromFrame: number;
  88957. /** defines the ending frame number (default is 100) */
  88958. toFrame: number;
  88959. /** defines if the animation must loop (default is false) */
  88960. loopAnimation: boolean;
  88961. /** defines a callback to call when animation ends if it is not looping */
  88962. onAnimationEnd?: (() => void) | null | undefined;
  88963. /** defines a callback to call when animation loops */
  88964. onAnimationLoop?: (() => void) | null | undefined;
  88965. /** defines whether the animation should be evaluated additively */
  88966. isAdditive: boolean;
  88967. private _localDelayOffset;
  88968. private _pausedDelay;
  88969. private _runtimeAnimations;
  88970. private _paused;
  88971. private _scene;
  88972. private _speedRatio;
  88973. private _weight;
  88974. private _syncRoot;
  88975. /**
  88976. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  88977. * This will only apply for non looping animation (default is true)
  88978. */
  88979. disposeOnEnd: boolean;
  88980. /**
  88981. * Gets a boolean indicating if the animation has started
  88982. */
  88983. animationStarted: boolean;
  88984. /**
  88985. * Observer raised when the animation ends
  88986. */
  88987. onAnimationEndObservable: Observable<Animatable>;
  88988. /**
  88989. * Observer raised when the animation loops
  88990. */
  88991. onAnimationLoopObservable: Observable<Animatable>;
  88992. /**
  88993. * Gets the root Animatable used to synchronize and normalize animations
  88994. */
  88995. get syncRoot(): Nullable<Animatable>;
  88996. /**
  88997. * Gets the current frame of the first RuntimeAnimation
  88998. * Used to synchronize Animatables
  88999. */
  89000. get masterFrame(): number;
  89001. /**
  89002. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  89003. */
  89004. get weight(): number;
  89005. set weight(value: number);
  89006. /**
  89007. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  89008. */
  89009. get speedRatio(): number;
  89010. set speedRatio(value: number);
  89011. /**
  89012. * Creates a new Animatable
  89013. * @param scene defines the hosting scene
  89014. * @param target defines the target object
  89015. * @param fromFrame defines the starting frame number (default is 0)
  89016. * @param toFrame defines the ending frame number (default is 100)
  89017. * @param loopAnimation defines if the animation must loop (default is false)
  89018. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  89019. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  89020. * @param animations defines a group of animation to add to the new Animatable
  89021. * @param onAnimationLoop defines a callback to call when animation loops
  89022. * @param isAdditive defines whether the animation should be evaluated additively
  89023. */
  89024. constructor(scene: Scene,
  89025. /** defines the target object */
  89026. target: any,
  89027. /** defines the starting frame number (default is 0) */
  89028. fromFrame?: number,
  89029. /** defines the ending frame number (default is 100) */
  89030. toFrame?: number,
  89031. /** defines if the animation must loop (default is false) */
  89032. loopAnimation?: boolean, speedRatio?: number,
  89033. /** defines a callback to call when animation ends if it is not looping */
  89034. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  89035. /** defines a callback to call when animation loops */
  89036. onAnimationLoop?: (() => void) | null | undefined,
  89037. /** defines whether the animation should be evaluated additively */
  89038. isAdditive?: boolean);
  89039. /**
  89040. * Synchronize and normalize current Animatable with a source Animatable
  89041. * This is useful when using animation weights and when animations are not of the same length
  89042. * @param root defines the root Animatable to synchronize with
  89043. * @returns the current Animatable
  89044. */
  89045. syncWith(root: Animatable): Animatable;
  89046. /**
  89047. * Gets the list of runtime animations
  89048. * @returns an array of RuntimeAnimation
  89049. */
  89050. getAnimations(): RuntimeAnimation[];
  89051. /**
  89052. * Adds more animations to the current animatable
  89053. * @param target defines the target of the animations
  89054. * @param animations defines the new animations to add
  89055. */
  89056. appendAnimations(target: any, animations: Animation[]): void;
  89057. /**
  89058. * Gets the source animation for a specific property
  89059. * @param property defines the propertyu to look for
  89060. * @returns null or the source animation for the given property
  89061. */
  89062. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  89063. /**
  89064. * Gets the runtime animation for a specific property
  89065. * @param property defines the propertyu to look for
  89066. * @returns null or the runtime animation for the given property
  89067. */
  89068. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  89069. /**
  89070. * Resets the animatable to its original state
  89071. */
  89072. reset(): void;
  89073. /**
  89074. * Allows the animatable to blend with current running animations
  89075. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89076. * @param blendingSpeed defines the blending speed to use
  89077. */
  89078. enableBlending(blendingSpeed: number): void;
  89079. /**
  89080. * Disable animation blending
  89081. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89082. */
  89083. disableBlending(): void;
  89084. /**
  89085. * Jump directly to a given frame
  89086. * @param frame defines the frame to jump to
  89087. */
  89088. goToFrame(frame: number): void;
  89089. /**
  89090. * Pause the animation
  89091. */
  89092. pause(): void;
  89093. /**
  89094. * Restart the animation
  89095. */
  89096. restart(): void;
  89097. private _raiseOnAnimationEnd;
  89098. /**
  89099. * Stop and delete the current animation
  89100. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  89101. * @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)
  89102. */
  89103. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  89104. /**
  89105. * Wait asynchronously for the animation to end
  89106. * @returns a promise which will be fullfilled when the animation ends
  89107. */
  89108. waitAsync(): Promise<Animatable>;
  89109. /** @hidden */
  89110. _animate(delay: number): boolean;
  89111. }
  89112. interface Scene {
  89113. /** @hidden */
  89114. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  89115. /** @hidden */
  89116. _processLateAnimationBindingsForMatrices(holder: {
  89117. totalWeight: number;
  89118. totalAdditiveWeight: number;
  89119. animations: RuntimeAnimation[];
  89120. additiveAnimations: RuntimeAnimation[];
  89121. originalValue: Matrix;
  89122. }): any;
  89123. /** @hidden */
  89124. _processLateAnimationBindingsForQuaternions(holder: {
  89125. totalWeight: number;
  89126. totalAdditiveWeight: number;
  89127. animations: RuntimeAnimation[];
  89128. additiveAnimations: RuntimeAnimation[];
  89129. originalValue: Quaternion;
  89130. }, refQuaternion: Quaternion): Quaternion;
  89131. /** @hidden */
  89132. _processLateAnimationBindings(): void;
  89133. /**
  89134. * Will start the animation sequence of a given target
  89135. * @param target defines the target
  89136. * @param from defines from which frame should animation start
  89137. * @param to defines until which frame should animation run.
  89138. * @param weight defines the weight to apply to the animation (1.0 by default)
  89139. * @param loop defines if the animation loops
  89140. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89141. * @param onAnimationEnd defines the function to be executed when the animation ends
  89142. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89143. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89144. * @param onAnimationLoop defines the callback to call when an animation loops
  89145. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89146. * @returns the animatable object created for this animation
  89147. */
  89148. 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;
  89149. /**
  89150. * Will start the animation sequence of a given target
  89151. * @param target defines the target
  89152. * @param from defines from which frame should animation start
  89153. * @param to defines until which frame should animation run.
  89154. * @param loop defines if the animation loops
  89155. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89156. * @param onAnimationEnd defines the function to be executed when the animation ends
  89157. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89158. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89159. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  89160. * @param onAnimationLoop defines the callback to call when an animation loops
  89161. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89162. * @returns the animatable object created for this animation
  89163. */
  89164. 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;
  89165. /**
  89166. * Will start the animation sequence of a given target and its hierarchy
  89167. * @param target defines the target
  89168. * @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.
  89169. * @param from defines from which frame should animation start
  89170. * @param to defines until which frame should animation run.
  89171. * @param loop defines if the animation loops
  89172. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  89173. * @param onAnimationEnd defines the function to be executed when the animation ends
  89174. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  89175. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  89176. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  89177. * @param onAnimationLoop defines the callback to call when an animation loops
  89178. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89179. * @returns the list of created animatables
  89180. */
  89181. 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[];
  89182. /**
  89183. * Begin a new animation on a given node
  89184. * @param target defines the target where the animation will take place
  89185. * @param animations defines the list of animations to start
  89186. * @param from defines the initial value
  89187. * @param to defines the final value
  89188. * @param loop defines if you want animation to loop (off by default)
  89189. * @param speedRatio defines the speed ratio to apply to all animations
  89190. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89191. * @param onAnimationLoop defines the callback to call when an animation loops
  89192. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89193. * @returns the list of created animatables
  89194. */
  89195. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  89196. /**
  89197. * Begin a new animation on a given node and its hierarchy
  89198. * @param target defines the root node where the animation will take place
  89199. * @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.
  89200. * @param animations defines the list of animations to start
  89201. * @param from defines the initial value
  89202. * @param to defines the final value
  89203. * @param loop defines if you want animation to loop (off by default)
  89204. * @param speedRatio defines the speed ratio to apply to all animations
  89205. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  89206. * @param onAnimationLoop defines the callback to call when an animation loops
  89207. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  89208. * @returns the list of animatables created for all nodes
  89209. */
  89210. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  89211. /**
  89212. * Gets the animatable associated with a specific target
  89213. * @param target defines the target of the animatable
  89214. * @returns the required animatable if found
  89215. */
  89216. getAnimatableByTarget(target: any): Nullable<Animatable>;
  89217. /**
  89218. * Gets all animatables associated with a given target
  89219. * @param target defines the target to look animatables for
  89220. * @returns an array of Animatables
  89221. */
  89222. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  89223. /**
  89224. * Stops and removes all animations that have been applied to the scene
  89225. */
  89226. stopAllAnimations(): void;
  89227. /**
  89228. * Gets the current delta time used by animation engine
  89229. */
  89230. deltaTime: number;
  89231. }
  89232. interface Bone {
  89233. /**
  89234. * Copy an animation range from another bone
  89235. * @param source defines the source bone
  89236. * @param rangeName defines the range name to copy
  89237. * @param frameOffset defines the frame offset
  89238. * @param rescaleAsRequired defines if rescaling must be applied if required
  89239. * @param skelDimensionsRatio defines the scaling ratio
  89240. * @returns true if operation was successful
  89241. */
  89242. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  89243. }
  89244. }
  89245. declare module BABYLON {
  89246. /**
  89247. * Class used to handle skinning animations
  89248. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  89249. */
  89250. export class Skeleton implements IAnimatable {
  89251. /** defines the skeleton name */
  89252. name: string;
  89253. /** defines the skeleton Id */
  89254. id: string;
  89255. /**
  89256. * Defines the list of child bones
  89257. */
  89258. bones: Bone[];
  89259. /**
  89260. * Defines an estimate of the dimension of the skeleton at rest
  89261. */
  89262. dimensionsAtRest: Vector3;
  89263. /**
  89264. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  89265. */
  89266. needInitialSkinMatrix: boolean;
  89267. /**
  89268. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  89269. */
  89270. overrideMesh: Nullable<AbstractMesh>;
  89271. /**
  89272. * Gets the list of animations attached to this skeleton
  89273. */
  89274. animations: Array<Animation>;
  89275. private _scene;
  89276. private _isDirty;
  89277. private _transformMatrices;
  89278. private _transformMatrixTexture;
  89279. private _meshesWithPoseMatrix;
  89280. private _animatables;
  89281. private _identity;
  89282. private _synchronizedWithMesh;
  89283. private _ranges;
  89284. private _lastAbsoluteTransformsUpdateId;
  89285. private _canUseTextureForBones;
  89286. private _uniqueId;
  89287. /** @hidden */
  89288. _numBonesWithLinkedTransformNode: number;
  89289. /** @hidden */
  89290. _hasWaitingData: Nullable<boolean>;
  89291. /**
  89292. * Specifies if the skeleton should be serialized
  89293. */
  89294. doNotSerialize: boolean;
  89295. private _useTextureToStoreBoneMatrices;
  89296. /**
  89297. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  89298. * Please note that this option is not available if the hardware does not support it
  89299. */
  89300. get useTextureToStoreBoneMatrices(): boolean;
  89301. set useTextureToStoreBoneMatrices(value: boolean);
  89302. private _animationPropertiesOverride;
  89303. /**
  89304. * Gets or sets the animation properties override
  89305. */
  89306. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  89307. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  89308. /**
  89309. * List of inspectable custom properties (used by the Inspector)
  89310. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  89311. */
  89312. inspectableCustomProperties: IInspectable[];
  89313. /**
  89314. * An observable triggered before computing the skeleton's matrices
  89315. */
  89316. onBeforeComputeObservable: Observable<Skeleton>;
  89317. /**
  89318. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  89319. */
  89320. get isUsingTextureForMatrices(): boolean;
  89321. /**
  89322. * Gets the unique ID of this skeleton
  89323. */
  89324. get uniqueId(): number;
  89325. /**
  89326. * Creates a new skeleton
  89327. * @param name defines the skeleton name
  89328. * @param id defines the skeleton Id
  89329. * @param scene defines the hosting scene
  89330. */
  89331. constructor(
  89332. /** defines the skeleton name */
  89333. name: string,
  89334. /** defines the skeleton Id */
  89335. id: string, scene: Scene);
  89336. /**
  89337. * Gets the current object class name.
  89338. * @return the class name
  89339. */
  89340. getClassName(): string;
  89341. /**
  89342. * Returns an array containing the root bones
  89343. * @returns an array containing the root bones
  89344. */
  89345. getChildren(): Array<Bone>;
  89346. /**
  89347. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  89348. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89349. * @returns a Float32Array containing matrices data
  89350. */
  89351. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  89352. /**
  89353. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  89354. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  89355. * @returns a raw texture containing the data
  89356. */
  89357. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  89358. /**
  89359. * Gets the current hosting scene
  89360. * @returns a scene object
  89361. */
  89362. getScene(): Scene;
  89363. /**
  89364. * Gets a string representing the current skeleton data
  89365. * @param fullDetails defines a boolean indicating if we want a verbose version
  89366. * @returns a string representing the current skeleton data
  89367. */
  89368. toString(fullDetails?: boolean): string;
  89369. /**
  89370. * Get bone's index searching by name
  89371. * @param name defines bone's name to search for
  89372. * @return the indice of the bone. Returns -1 if not found
  89373. */
  89374. getBoneIndexByName(name: string): number;
  89375. /**
  89376. * Creater a new animation range
  89377. * @param name defines the name of the range
  89378. * @param from defines the start key
  89379. * @param to defines the end key
  89380. */
  89381. createAnimationRange(name: string, from: number, to: number): void;
  89382. /**
  89383. * Delete a specific animation range
  89384. * @param name defines the name of the range
  89385. * @param deleteFrames defines if frames must be removed as well
  89386. */
  89387. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  89388. /**
  89389. * Gets a specific animation range
  89390. * @param name defines the name of the range to look for
  89391. * @returns the requested animation range or null if not found
  89392. */
  89393. getAnimationRange(name: string): Nullable<AnimationRange>;
  89394. /**
  89395. * Gets the list of all animation ranges defined on this skeleton
  89396. * @returns an array
  89397. */
  89398. getAnimationRanges(): Nullable<AnimationRange>[];
  89399. /**
  89400. * Copy animation range from a source skeleton.
  89401. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  89402. * @param source defines the source skeleton
  89403. * @param name defines the name of the range to copy
  89404. * @param rescaleAsRequired defines if rescaling must be applied if required
  89405. * @returns true if operation was successful
  89406. */
  89407. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  89408. /**
  89409. * Forces the skeleton to go to rest pose
  89410. */
  89411. returnToRest(): void;
  89412. private _getHighestAnimationFrame;
  89413. /**
  89414. * Begin a specific animation range
  89415. * @param name defines the name of the range to start
  89416. * @param loop defines if looping must be turned on (false by default)
  89417. * @param speedRatio defines the speed ratio to apply (1 by default)
  89418. * @param onAnimationEnd defines a callback which will be called when animation will end
  89419. * @returns a new animatable
  89420. */
  89421. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  89422. /**
  89423. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  89424. * @param skeleton defines the Skeleton containing the animation range to convert
  89425. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  89426. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  89427. * @returns the original skeleton
  89428. */
  89429. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  89430. /** @hidden */
  89431. _markAsDirty(): void;
  89432. /** @hidden */
  89433. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89434. /** @hidden */
  89435. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  89436. private _computeTransformMatrices;
  89437. /**
  89438. * Build all resources required to render a skeleton
  89439. */
  89440. prepare(): void;
  89441. /**
  89442. * Gets the list of animatables currently running for this skeleton
  89443. * @returns an array of animatables
  89444. */
  89445. getAnimatables(): IAnimatable[];
  89446. /**
  89447. * Clone the current skeleton
  89448. * @param name defines the name of the new skeleton
  89449. * @param id defines the id of the new skeleton
  89450. * @returns the new skeleton
  89451. */
  89452. clone(name: string, id?: string): Skeleton;
  89453. /**
  89454. * Enable animation blending for this skeleton
  89455. * @param blendingSpeed defines the blending speed to apply
  89456. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  89457. */
  89458. enableBlending(blendingSpeed?: number): void;
  89459. /**
  89460. * Releases all resources associated with the current skeleton
  89461. */
  89462. dispose(): void;
  89463. /**
  89464. * Serialize the skeleton in a JSON object
  89465. * @returns a JSON object
  89466. */
  89467. serialize(): any;
  89468. /**
  89469. * Creates a new skeleton from serialized data
  89470. * @param parsedSkeleton defines the serialized data
  89471. * @param scene defines the hosting scene
  89472. * @returns a new skeleton
  89473. */
  89474. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  89475. /**
  89476. * Compute all node absolute transforms
  89477. * @param forceUpdate defines if computation must be done even if cache is up to date
  89478. */
  89479. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  89480. /**
  89481. * Gets the root pose matrix
  89482. * @returns a matrix
  89483. */
  89484. getPoseMatrix(): Nullable<Matrix>;
  89485. /**
  89486. * Sorts bones per internal index
  89487. */
  89488. sortBones(): void;
  89489. private _sortBones;
  89490. }
  89491. }
  89492. declare module BABYLON {
  89493. /**
  89494. * Creates an instance based on a source mesh.
  89495. */
  89496. export class InstancedMesh extends AbstractMesh {
  89497. private _sourceMesh;
  89498. private _currentLOD;
  89499. /** @hidden */
  89500. _indexInSourceMeshInstanceArray: number;
  89501. constructor(name: string, source: Mesh);
  89502. /**
  89503. * Returns the string "InstancedMesh".
  89504. */
  89505. getClassName(): string;
  89506. /** Gets the list of lights affecting that mesh */
  89507. get lightSources(): Light[];
  89508. _resyncLightSources(): void;
  89509. _resyncLightSource(light: Light): void;
  89510. _removeLightSource(light: Light, dispose: boolean): void;
  89511. /**
  89512. * If the source mesh receives shadows
  89513. */
  89514. get receiveShadows(): boolean;
  89515. /**
  89516. * The material of the source mesh
  89517. */
  89518. get material(): Nullable<Material>;
  89519. /**
  89520. * Visibility of the source mesh
  89521. */
  89522. get visibility(): number;
  89523. /**
  89524. * Skeleton of the source mesh
  89525. */
  89526. get skeleton(): Nullable<Skeleton>;
  89527. /**
  89528. * Rendering ground id of the source mesh
  89529. */
  89530. get renderingGroupId(): number;
  89531. set renderingGroupId(value: number);
  89532. /**
  89533. * Returns the total number of vertices (integer).
  89534. */
  89535. getTotalVertices(): number;
  89536. /**
  89537. * Returns a positive integer : the total number of indices in this mesh geometry.
  89538. * @returns the numner of indices or zero if the mesh has no geometry.
  89539. */
  89540. getTotalIndices(): number;
  89541. /**
  89542. * The source mesh of the instance
  89543. */
  89544. get sourceMesh(): Mesh;
  89545. /**
  89546. * Is this node ready to be used/rendered
  89547. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  89548. * @return {boolean} is it ready
  89549. */
  89550. isReady(completeCheck?: boolean): boolean;
  89551. /**
  89552. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  89553. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  89554. * @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.
  89555. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  89556. */
  89557. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  89558. /**
  89559. * Sets the vertex data of the mesh geometry for the requested `kind`.
  89560. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  89561. * The `data` are either a numeric array either a Float32Array.
  89562. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  89563. * 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).
  89564. * Note that a new underlying VertexBuffer object is created each call.
  89565. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  89566. *
  89567. * Possible `kind` values :
  89568. * - VertexBuffer.PositionKind
  89569. * - VertexBuffer.UVKind
  89570. * - VertexBuffer.UV2Kind
  89571. * - VertexBuffer.UV3Kind
  89572. * - VertexBuffer.UV4Kind
  89573. * - VertexBuffer.UV5Kind
  89574. * - VertexBuffer.UV6Kind
  89575. * - VertexBuffer.ColorKind
  89576. * - VertexBuffer.MatricesIndicesKind
  89577. * - VertexBuffer.MatricesIndicesExtraKind
  89578. * - VertexBuffer.MatricesWeightsKind
  89579. * - VertexBuffer.MatricesWeightsExtraKind
  89580. *
  89581. * Returns the Mesh.
  89582. */
  89583. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  89584. /**
  89585. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  89586. * If the mesh has no geometry, it is simply returned as it is.
  89587. * The `data` are either a numeric array either a Float32Array.
  89588. * No new underlying VertexBuffer object is created.
  89589. * 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.
  89590. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  89591. *
  89592. * Possible `kind` values :
  89593. * - VertexBuffer.PositionKind
  89594. * - VertexBuffer.UVKind
  89595. * - VertexBuffer.UV2Kind
  89596. * - VertexBuffer.UV3Kind
  89597. * - VertexBuffer.UV4Kind
  89598. * - VertexBuffer.UV5Kind
  89599. * - VertexBuffer.UV6Kind
  89600. * - VertexBuffer.ColorKind
  89601. * - VertexBuffer.MatricesIndicesKind
  89602. * - VertexBuffer.MatricesIndicesExtraKind
  89603. * - VertexBuffer.MatricesWeightsKind
  89604. * - VertexBuffer.MatricesWeightsExtraKind
  89605. *
  89606. * Returns the Mesh.
  89607. */
  89608. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  89609. /**
  89610. * Sets the mesh indices.
  89611. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  89612. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  89613. * This method creates a new index buffer each call.
  89614. * Returns the Mesh.
  89615. */
  89616. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  89617. /**
  89618. * Boolean : True if the mesh owns the requested kind of data.
  89619. */
  89620. isVerticesDataPresent(kind: string): boolean;
  89621. /**
  89622. * Returns an array of indices (IndicesArray).
  89623. */
  89624. getIndices(): Nullable<IndicesArray>;
  89625. get _positions(): Nullable<Vector3[]>;
  89626. /**
  89627. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  89628. * This means the mesh underlying bounding box and sphere are recomputed.
  89629. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  89630. * @returns the current mesh
  89631. */
  89632. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  89633. /** @hidden */
  89634. _preActivate(): InstancedMesh;
  89635. /** @hidden */
  89636. _activate(renderId: number, intermediateRendering: boolean): boolean;
  89637. /** @hidden */
  89638. _postActivate(): void;
  89639. getWorldMatrix(): Matrix;
  89640. get isAnInstance(): boolean;
  89641. /**
  89642. * Returns the current associated LOD AbstractMesh.
  89643. */
  89644. getLOD(camera: Camera): AbstractMesh;
  89645. /** @hidden */
  89646. _preActivateForIntermediateRendering(renderId: number): Mesh;
  89647. /** @hidden */
  89648. _syncSubMeshes(): InstancedMesh;
  89649. /** @hidden */
  89650. _generatePointsArray(): boolean;
  89651. /**
  89652. * Creates a new InstancedMesh from the current mesh.
  89653. * - name (string) : the cloned mesh name
  89654. * - newParent (optional Node) : the optional Node to parent the clone to.
  89655. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  89656. *
  89657. * Returns the clone.
  89658. */
  89659. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  89660. /**
  89661. * Disposes the InstancedMesh.
  89662. * Returns nothing.
  89663. */
  89664. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  89665. }
  89666. interface Mesh {
  89667. /**
  89668. * Register a custom buffer that will be instanced
  89669. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89670. * @param kind defines the buffer kind
  89671. * @param stride defines the stride in floats
  89672. */
  89673. registerInstancedBuffer(kind: string, stride: number): void;
  89674. /** @hidden */
  89675. _userInstancedBuffersStorage: {
  89676. data: {
  89677. [key: string]: Float32Array;
  89678. };
  89679. sizes: {
  89680. [key: string]: number;
  89681. };
  89682. vertexBuffers: {
  89683. [key: string]: Nullable<VertexBuffer>;
  89684. };
  89685. strides: {
  89686. [key: string]: number;
  89687. };
  89688. };
  89689. }
  89690. interface AbstractMesh {
  89691. /**
  89692. * Object used to store instanced buffers defined by user
  89693. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  89694. */
  89695. instancedBuffers: {
  89696. [key: string]: any;
  89697. };
  89698. }
  89699. }
  89700. declare module BABYLON {
  89701. /**
  89702. * Defines the options associated with the creation of a shader material.
  89703. */
  89704. export interface IShaderMaterialOptions {
  89705. /**
  89706. * Does the material work in alpha blend mode
  89707. */
  89708. needAlphaBlending: boolean;
  89709. /**
  89710. * Does the material work in alpha test mode
  89711. */
  89712. needAlphaTesting: boolean;
  89713. /**
  89714. * The list of attribute names used in the shader
  89715. */
  89716. attributes: string[];
  89717. /**
  89718. * The list of unifrom names used in the shader
  89719. */
  89720. uniforms: string[];
  89721. /**
  89722. * The list of UBO names used in the shader
  89723. */
  89724. uniformBuffers: string[];
  89725. /**
  89726. * The list of sampler names used in the shader
  89727. */
  89728. samplers: string[];
  89729. /**
  89730. * The list of defines used in the shader
  89731. */
  89732. defines: string[];
  89733. }
  89734. /**
  89735. * 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.
  89736. *
  89737. * This returned material effects how the mesh will look based on the code in the shaders.
  89738. *
  89739. * @see http://doc.babylonjs.com/how_to/shader_material
  89740. */
  89741. export class ShaderMaterial extends Material {
  89742. private _shaderPath;
  89743. private _options;
  89744. private _textures;
  89745. private _textureArrays;
  89746. private _floats;
  89747. private _ints;
  89748. private _floatsArrays;
  89749. private _colors3;
  89750. private _colors3Arrays;
  89751. private _colors4;
  89752. private _colors4Arrays;
  89753. private _vectors2;
  89754. private _vectors3;
  89755. private _vectors4;
  89756. private _matrices;
  89757. private _matrixArrays;
  89758. private _matrices3x3;
  89759. private _matrices2x2;
  89760. private _vectors2Arrays;
  89761. private _vectors3Arrays;
  89762. private _vectors4Arrays;
  89763. private _cachedWorldViewMatrix;
  89764. private _cachedWorldViewProjectionMatrix;
  89765. private _renderId;
  89766. private _multiview;
  89767. /**
  89768. * Instantiate a new shader material.
  89769. * 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.
  89770. * This returned material effects how the mesh will look based on the code in the shaders.
  89771. * @see http://doc.babylonjs.com/how_to/shader_material
  89772. * @param name Define the name of the material in the scene
  89773. * @param scene Define the scene the material belongs to
  89774. * @param shaderPath Defines the route to the shader code in one of three ways:
  89775. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  89776. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  89777. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  89778. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  89779. * @param options Define the options used to create the shader
  89780. */
  89781. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  89782. /**
  89783. * Gets the shader path used to define the shader code
  89784. * It can be modified to trigger a new compilation
  89785. */
  89786. get shaderPath(): any;
  89787. /**
  89788. * Sets the shader path used to define the shader code
  89789. * It can be modified to trigger a new compilation
  89790. */
  89791. set shaderPath(shaderPath: any);
  89792. /**
  89793. * Gets the options used to compile the shader.
  89794. * They can be modified to trigger a new compilation
  89795. */
  89796. get options(): IShaderMaterialOptions;
  89797. /**
  89798. * Gets the current class name of the material e.g. "ShaderMaterial"
  89799. * Mainly use in serialization.
  89800. * @returns the class name
  89801. */
  89802. getClassName(): string;
  89803. /**
  89804. * Specifies if the material will require alpha blending
  89805. * @returns a boolean specifying if alpha blending is needed
  89806. */
  89807. needAlphaBlending(): boolean;
  89808. /**
  89809. * Specifies if this material should be rendered in alpha test mode
  89810. * @returns a boolean specifying if an alpha test is needed.
  89811. */
  89812. needAlphaTesting(): boolean;
  89813. private _checkUniform;
  89814. /**
  89815. * Set a texture in the shader.
  89816. * @param name Define the name of the uniform samplers as defined in the shader
  89817. * @param texture Define the texture to bind to this sampler
  89818. * @return the material itself allowing "fluent" like uniform updates
  89819. */
  89820. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  89821. /**
  89822. * Set a texture array in the shader.
  89823. * @param name Define the name of the uniform sampler array as defined in the shader
  89824. * @param textures Define the list of textures to bind to this sampler
  89825. * @return the material itself allowing "fluent" like uniform updates
  89826. */
  89827. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  89828. /**
  89829. * Set a float in the shader.
  89830. * @param name Define the name of the uniform as defined in the shader
  89831. * @param value Define the value to give to the uniform
  89832. * @return the material itself allowing "fluent" like uniform updates
  89833. */
  89834. setFloat(name: string, value: number): ShaderMaterial;
  89835. /**
  89836. * Set a int in the shader.
  89837. * @param name Define the name of the uniform as defined in the shader
  89838. * @param value Define the value to give to the uniform
  89839. * @return the material itself allowing "fluent" like uniform updates
  89840. */
  89841. setInt(name: string, value: number): ShaderMaterial;
  89842. /**
  89843. * Set an array of floats in the shader.
  89844. * @param name Define the name of the uniform as defined in the shader
  89845. * @param value Define the value to give to the uniform
  89846. * @return the material itself allowing "fluent" like uniform updates
  89847. */
  89848. setFloats(name: string, value: number[]): ShaderMaterial;
  89849. /**
  89850. * Set a vec3 in the shader from a Color3.
  89851. * @param name Define the name of the uniform as defined in the shader
  89852. * @param value Define the value to give to the uniform
  89853. * @return the material itself allowing "fluent" like uniform updates
  89854. */
  89855. setColor3(name: string, value: Color3): ShaderMaterial;
  89856. /**
  89857. * Set a vec3 array in the shader from a Color3 array.
  89858. * @param name Define the name of the uniform as defined in the shader
  89859. * @param value Define the value to give to the uniform
  89860. * @return the material itself allowing "fluent" like uniform updates
  89861. */
  89862. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  89863. /**
  89864. * Set a vec4 in the shader from a Color4.
  89865. * @param name Define the name of the uniform as defined in the shader
  89866. * @param value Define the value to give to the uniform
  89867. * @return the material itself allowing "fluent" like uniform updates
  89868. */
  89869. setColor4(name: string, value: Color4): ShaderMaterial;
  89870. /**
  89871. * Set a vec4 array in the shader from a Color4 array.
  89872. * @param name Define the name of the uniform as defined in the shader
  89873. * @param value Define the value to give to the uniform
  89874. * @return the material itself allowing "fluent" like uniform updates
  89875. */
  89876. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  89877. /**
  89878. * Set a vec2 in the shader from a Vector2.
  89879. * @param name Define the name of the uniform as defined in the shader
  89880. * @param value Define the value to give to the uniform
  89881. * @return the material itself allowing "fluent" like uniform updates
  89882. */
  89883. setVector2(name: string, value: Vector2): ShaderMaterial;
  89884. /**
  89885. * Set a vec3 in the shader from a Vector3.
  89886. * @param name Define the name of the uniform as defined in the shader
  89887. * @param value Define the value to give to the uniform
  89888. * @return the material itself allowing "fluent" like uniform updates
  89889. */
  89890. setVector3(name: string, value: Vector3): ShaderMaterial;
  89891. /**
  89892. * Set a vec4 in the shader from a Vector4.
  89893. * @param name Define the name of the uniform as defined in the shader
  89894. * @param value Define the value to give to the uniform
  89895. * @return the material itself allowing "fluent" like uniform updates
  89896. */
  89897. setVector4(name: string, value: Vector4): ShaderMaterial;
  89898. /**
  89899. * Set a mat4 in the shader from a Matrix.
  89900. * @param name Define the name of the uniform as defined in the shader
  89901. * @param value Define the value to give to the uniform
  89902. * @return the material itself allowing "fluent" like uniform updates
  89903. */
  89904. setMatrix(name: string, value: Matrix): ShaderMaterial;
  89905. /**
  89906. * Set a float32Array in the shader from a matrix array.
  89907. * @param name Define the name of the uniform as defined in the shader
  89908. * @param value Define the value to give to the uniform
  89909. * @return the material itself allowing "fluent" like uniform updates
  89910. */
  89911. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  89912. /**
  89913. * Set a mat3 in the shader from a Float32Array.
  89914. * @param name Define the name of the uniform as defined in the shader
  89915. * @param value Define the value to give to the uniform
  89916. * @return the material itself allowing "fluent" like uniform updates
  89917. */
  89918. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  89919. /**
  89920. * Set a mat2 in the shader from a Float32Array.
  89921. * @param name Define the name of the uniform as defined in the shader
  89922. * @param value Define the value to give to the uniform
  89923. * @return the material itself allowing "fluent" like uniform updates
  89924. */
  89925. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  89926. /**
  89927. * Set a vec2 array in the shader from a number array.
  89928. * @param name Define the name of the uniform as defined in the shader
  89929. * @param value Define the value to give to the uniform
  89930. * @return the material itself allowing "fluent" like uniform updates
  89931. */
  89932. setArray2(name: string, value: number[]): ShaderMaterial;
  89933. /**
  89934. * Set a vec3 array in the shader from a number array.
  89935. * @param name Define the name of the uniform as defined in the shader
  89936. * @param value Define the value to give to the uniform
  89937. * @return the material itself allowing "fluent" like uniform updates
  89938. */
  89939. setArray3(name: string, value: number[]): ShaderMaterial;
  89940. /**
  89941. * Set a vec4 array in the shader from a number array.
  89942. * @param name Define the name of the uniform as defined in the shader
  89943. * @param value Define the value to give to the uniform
  89944. * @return the material itself allowing "fluent" like uniform updates
  89945. */
  89946. setArray4(name: string, value: number[]): ShaderMaterial;
  89947. private _checkCache;
  89948. /**
  89949. * Specifies that the submesh is ready to be used
  89950. * @param mesh defines the mesh to check
  89951. * @param subMesh defines which submesh to check
  89952. * @param useInstances specifies that instances should be used
  89953. * @returns a boolean indicating that the submesh is ready or not
  89954. */
  89955. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  89956. /**
  89957. * Checks if the material is ready to render the requested mesh
  89958. * @param mesh Define the mesh to render
  89959. * @param useInstances Define whether or not the material is used with instances
  89960. * @returns true if ready, otherwise false
  89961. */
  89962. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  89963. /**
  89964. * Binds the world matrix to the material
  89965. * @param world defines the world transformation matrix
  89966. */
  89967. bindOnlyWorldMatrix(world: Matrix): void;
  89968. /**
  89969. * Binds the material to the mesh
  89970. * @param world defines the world transformation matrix
  89971. * @param mesh defines the mesh to bind the material to
  89972. */
  89973. bind(world: Matrix, mesh?: Mesh): void;
  89974. /**
  89975. * Gets the active textures from the material
  89976. * @returns an array of textures
  89977. */
  89978. getActiveTextures(): BaseTexture[];
  89979. /**
  89980. * Specifies if the material uses a texture
  89981. * @param texture defines the texture to check against the material
  89982. * @returns a boolean specifying if the material uses the texture
  89983. */
  89984. hasTexture(texture: BaseTexture): boolean;
  89985. /**
  89986. * Makes a duplicate of the material, and gives it a new name
  89987. * @param name defines the new name for the duplicated material
  89988. * @returns the cloned material
  89989. */
  89990. clone(name: string): ShaderMaterial;
  89991. /**
  89992. * Disposes the material
  89993. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  89994. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  89995. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  89996. */
  89997. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  89998. /**
  89999. * Serializes this material in a JSON representation
  90000. * @returns the serialized material object
  90001. */
  90002. serialize(): any;
  90003. /**
  90004. * Creates a shader material from parsed shader material data
  90005. * @param source defines the JSON represnetation of the material
  90006. * @param scene defines the hosting scene
  90007. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  90008. * @returns a new material
  90009. */
  90010. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  90011. }
  90012. }
  90013. declare module BABYLON {
  90014. /** @hidden */
  90015. export var colorPixelShader: {
  90016. name: string;
  90017. shader: string;
  90018. };
  90019. }
  90020. declare module BABYLON {
  90021. /** @hidden */
  90022. export var colorVertexShader: {
  90023. name: string;
  90024. shader: string;
  90025. };
  90026. }
  90027. declare module BABYLON {
  90028. /**
  90029. * Line mesh
  90030. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  90031. */
  90032. export class LinesMesh extends Mesh {
  90033. /**
  90034. * If vertex color should be applied to the mesh
  90035. */
  90036. readonly useVertexColor?: boolean | undefined;
  90037. /**
  90038. * If vertex alpha should be applied to the mesh
  90039. */
  90040. readonly useVertexAlpha?: boolean | undefined;
  90041. /**
  90042. * Color of the line (Default: White)
  90043. */
  90044. color: Color3;
  90045. /**
  90046. * Alpha of the line (Default: 1)
  90047. */
  90048. alpha: number;
  90049. /**
  90050. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90051. * This margin is expressed in world space coordinates, so its value may vary.
  90052. * Default value is 0.1
  90053. */
  90054. intersectionThreshold: number;
  90055. private _colorShader;
  90056. private color4;
  90057. /**
  90058. * Creates a new LinesMesh
  90059. * @param name defines the name
  90060. * @param scene defines the hosting scene
  90061. * @param parent defines the parent mesh if any
  90062. * @param source defines the optional source LinesMesh used to clone data from
  90063. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  90064. * When false, achieved by calling a clone(), also passing False.
  90065. * This will make creation of children, recursive.
  90066. * @param useVertexColor defines if this LinesMesh supports vertex color
  90067. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  90068. */
  90069. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  90070. /**
  90071. * If vertex color should be applied to the mesh
  90072. */
  90073. useVertexColor?: boolean | undefined,
  90074. /**
  90075. * If vertex alpha should be applied to the mesh
  90076. */
  90077. useVertexAlpha?: boolean | undefined);
  90078. private _addClipPlaneDefine;
  90079. private _removeClipPlaneDefine;
  90080. isReady(): boolean;
  90081. /**
  90082. * Returns the string "LineMesh"
  90083. */
  90084. getClassName(): string;
  90085. /**
  90086. * @hidden
  90087. */
  90088. get material(): Material;
  90089. /**
  90090. * @hidden
  90091. */
  90092. set material(value: Material);
  90093. /**
  90094. * @hidden
  90095. */
  90096. get checkCollisions(): boolean;
  90097. /** @hidden */
  90098. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  90099. /** @hidden */
  90100. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  90101. /**
  90102. * Disposes of the line mesh
  90103. * @param doNotRecurse If children should be disposed
  90104. */
  90105. dispose(doNotRecurse?: boolean): void;
  90106. /**
  90107. * Returns a new LineMesh object cloned from the current one.
  90108. */
  90109. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  90110. /**
  90111. * Creates a new InstancedLinesMesh object from the mesh model.
  90112. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  90113. * @param name defines the name of the new instance
  90114. * @returns a new InstancedLinesMesh
  90115. */
  90116. createInstance(name: string): InstancedLinesMesh;
  90117. }
  90118. /**
  90119. * Creates an instance based on a source LinesMesh
  90120. */
  90121. export class InstancedLinesMesh extends InstancedMesh {
  90122. /**
  90123. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  90124. * This margin is expressed in world space coordinates, so its value may vary.
  90125. * Initilized with the intersectionThreshold value of the source LinesMesh
  90126. */
  90127. intersectionThreshold: number;
  90128. constructor(name: string, source: LinesMesh);
  90129. /**
  90130. * Returns the string "InstancedLinesMesh".
  90131. */
  90132. getClassName(): string;
  90133. }
  90134. }
  90135. declare module BABYLON {
  90136. /** @hidden */
  90137. export var linePixelShader: {
  90138. name: string;
  90139. shader: string;
  90140. };
  90141. }
  90142. declare module BABYLON {
  90143. /** @hidden */
  90144. export var lineVertexShader: {
  90145. name: string;
  90146. shader: string;
  90147. };
  90148. }
  90149. declare module BABYLON {
  90150. interface AbstractMesh {
  90151. /**
  90152. * Gets the edgesRenderer associated with the mesh
  90153. */
  90154. edgesRenderer: Nullable<EdgesRenderer>;
  90155. }
  90156. interface LinesMesh {
  90157. /**
  90158. * Enables the edge rendering mode on the mesh.
  90159. * This mode makes the mesh edges visible
  90160. * @param epsilon defines the maximal distance between two angles to detect a face
  90161. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90162. * @returns the currentAbstractMesh
  90163. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90164. */
  90165. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  90166. }
  90167. interface InstancedLinesMesh {
  90168. /**
  90169. * Enables the edge rendering mode on the mesh.
  90170. * This mode makes the mesh edges visible
  90171. * @param epsilon defines the maximal distance between two angles to detect a face
  90172. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  90173. * @returns the current InstancedLinesMesh
  90174. * @see https://www.babylonjs-playground.com/#19O9TU#0
  90175. */
  90176. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  90177. }
  90178. /**
  90179. * Defines the minimum contract an Edges renderer should follow.
  90180. */
  90181. export interface IEdgesRenderer extends IDisposable {
  90182. /**
  90183. * Gets or sets a boolean indicating if the edgesRenderer is active
  90184. */
  90185. isEnabled: boolean;
  90186. /**
  90187. * Renders the edges of the attached mesh,
  90188. */
  90189. render(): void;
  90190. /**
  90191. * Checks wether or not the edges renderer is ready to render.
  90192. * @return true if ready, otherwise false.
  90193. */
  90194. isReady(): boolean;
  90195. }
  90196. /**
  90197. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  90198. */
  90199. export class EdgesRenderer implements IEdgesRenderer {
  90200. /**
  90201. * Define the size of the edges with an orthographic camera
  90202. */
  90203. edgesWidthScalerForOrthographic: number;
  90204. /**
  90205. * Define the size of the edges with a perspective camera
  90206. */
  90207. edgesWidthScalerForPerspective: number;
  90208. protected _source: AbstractMesh;
  90209. protected _linesPositions: number[];
  90210. protected _linesNormals: number[];
  90211. protected _linesIndices: number[];
  90212. protected _epsilon: number;
  90213. protected _indicesCount: number;
  90214. protected _lineShader: ShaderMaterial;
  90215. protected _ib: DataBuffer;
  90216. protected _buffers: {
  90217. [key: string]: Nullable<VertexBuffer>;
  90218. };
  90219. protected _checkVerticesInsteadOfIndices: boolean;
  90220. private _meshRebuildObserver;
  90221. private _meshDisposeObserver;
  90222. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  90223. isEnabled: boolean;
  90224. /**
  90225. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  90226. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  90227. * @param source Mesh used to create edges
  90228. * @param epsilon sum of angles in adjacency to check for edge
  90229. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  90230. * @param generateEdgesLines - should generate Lines or only prepare resources.
  90231. */
  90232. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  90233. protected _prepareRessources(): void;
  90234. /** @hidden */
  90235. _rebuild(): void;
  90236. /**
  90237. * Releases the required resources for the edges renderer
  90238. */
  90239. dispose(): void;
  90240. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  90241. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  90242. /**
  90243. * Checks if the pair of p0 and p1 is en edge
  90244. * @param faceIndex
  90245. * @param edge
  90246. * @param faceNormals
  90247. * @param p0
  90248. * @param p1
  90249. * @private
  90250. */
  90251. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  90252. /**
  90253. * push line into the position, normal and index buffer
  90254. * @protected
  90255. */
  90256. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  90257. /**
  90258. * Generates lines edges from adjacencjes
  90259. * @private
  90260. */
  90261. _generateEdgesLines(): void;
  90262. /**
  90263. * Checks wether or not the edges renderer is ready to render.
  90264. * @return true if ready, otherwise false.
  90265. */
  90266. isReady(): boolean;
  90267. /**
  90268. * Renders the edges of the attached mesh,
  90269. */
  90270. render(): void;
  90271. }
  90272. /**
  90273. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  90274. */
  90275. export class LineEdgesRenderer extends EdgesRenderer {
  90276. /**
  90277. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  90278. * @param source LineMesh used to generate edges
  90279. * @param epsilon not important (specified angle for edge detection)
  90280. * @param checkVerticesInsteadOfIndices not important for LineMesh
  90281. */
  90282. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  90283. /**
  90284. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  90285. */
  90286. _generateEdgesLines(): void;
  90287. }
  90288. }
  90289. declare module BABYLON {
  90290. /**
  90291. * This represents the object necessary to create a rendering group.
  90292. * This is exclusively used and created by the rendering manager.
  90293. * To modify the behavior, you use the available helpers in your scene or meshes.
  90294. * @hidden
  90295. */
  90296. export class RenderingGroup {
  90297. index: number;
  90298. private static _zeroVector;
  90299. private _scene;
  90300. private _opaqueSubMeshes;
  90301. private _transparentSubMeshes;
  90302. private _alphaTestSubMeshes;
  90303. private _depthOnlySubMeshes;
  90304. private _particleSystems;
  90305. private _spriteManagers;
  90306. private _opaqueSortCompareFn;
  90307. private _alphaTestSortCompareFn;
  90308. private _transparentSortCompareFn;
  90309. private _renderOpaque;
  90310. private _renderAlphaTest;
  90311. private _renderTransparent;
  90312. /** @hidden */
  90313. _edgesRenderers: SmartArray<IEdgesRenderer>;
  90314. onBeforeTransparentRendering: () => void;
  90315. /**
  90316. * Set the opaque sort comparison function.
  90317. * If null the sub meshes will be render in the order they were created
  90318. */
  90319. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90320. /**
  90321. * Set the alpha test sort comparison function.
  90322. * If null the sub meshes will be render in the order they were created
  90323. */
  90324. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90325. /**
  90326. * Set the transparent sort comparison function.
  90327. * If null the sub meshes will be render in the order they were created
  90328. */
  90329. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  90330. /**
  90331. * Creates a new rendering group.
  90332. * @param index The rendering group index
  90333. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  90334. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  90335. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  90336. */
  90337. 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>);
  90338. /**
  90339. * Render all the sub meshes contained in the group.
  90340. * @param customRenderFunction Used to override the default render behaviour of the group.
  90341. * @returns true if rendered some submeshes.
  90342. */
  90343. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  90344. /**
  90345. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  90346. * @param subMeshes The submeshes to render
  90347. */
  90348. private renderOpaqueSorted;
  90349. /**
  90350. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  90351. * @param subMeshes The submeshes to render
  90352. */
  90353. private renderAlphaTestSorted;
  90354. /**
  90355. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  90356. * @param subMeshes The submeshes to render
  90357. */
  90358. private renderTransparentSorted;
  90359. /**
  90360. * Renders the submeshes in a specified order.
  90361. * @param subMeshes The submeshes to sort before render
  90362. * @param sortCompareFn The comparison function use to sort
  90363. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  90364. * @param transparent Specifies to activate blending if true
  90365. */
  90366. private static renderSorted;
  90367. /**
  90368. * Renders the submeshes in the order they were dispatched (no sort applied).
  90369. * @param subMeshes The submeshes to render
  90370. */
  90371. private static renderUnsorted;
  90372. /**
  90373. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90374. * are rendered back to front if in the same alpha index.
  90375. *
  90376. * @param a The first submesh
  90377. * @param b The second submesh
  90378. * @returns The result of the comparison
  90379. */
  90380. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  90381. /**
  90382. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90383. * are rendered back to front.
  90384. *
  90385. * @param a The first submesh
  90386. * @param b The second submesh
  90387. * @returns The result of the comparison
  90388. */
  90389. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  90390. /**
  90391. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  90392. * are rendered front to back (prevent overdraw).
  90393. *
  90394. * @param a The first submesh
  90395. * @param b The second submesh
  90396. * @returns The result of the comparison
  90397. */
  90398. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  90399. /**
  90400. * Resets the different lists of submeshes to prepare a new frame.
  90401. */
  90402. prepare(): void;
  90403. dispose(): void;
  90404. /**
  90405. * Inserts the submesh in its correct queue depending on its material.
  90406. * @param subMesh The submesh to dispatch
  90407. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90408. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90409. */
  90410. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90411. dispatchSprites(spriteManager: ISpriteManager): void;
  90412. dispatchParticles(particleSystem: IParticleSystem): void;
  90413. private _renderParticles;
  90414. private _renderSprites;
  90415. }
  90416. }
  90417. declare module BABYLON {
  90418. /**
  90419. * Interface describing the different options available in the rendering manager
  90420. * regarding Auto Clear between groups.
  90421. */
  90422. export interface IRenderingManagerAutoClearSetup {
  90423. /**
  90424. * Defines whether or not autoclear is enable.
  90425. */
  90426. autoClear: boolean;
  90427. /**
  90428. * Defines whether or not to autoclear the depth buffer.
  90429. */
  90430. depth: boolean;
  90431. /**
  90432. * Defines whether or not to autoclear the stencil buffer.
  90433. */
  90434. stencil: boolean;
  90435. }
  90436. /**
  90437. * This class is used by the onRenderingGroupObservable
  90438. */
  90439. export class RenderingGroupInfo {
  90440. /**
  90441. * The Scene that being rendered
  90442. */
  90443. scene: Scene;
  90444. /**
  90445. * The camera currently used for the rendering pass
  90446. */
  90447. camera: Nullable<Camera>;
  90448. /**
  90449. * The ID of the renderingGroup being processed
  90450. */
  90451. renderingGroupId: number;
  90452. }
  90453. /**
  90454. * This is the manager responsible of all the rendering for meshes sprites and particles.
  90455. * It is enable to manage the different groups as well as the different necessary sort functions.
  90456. * This should not be used directly aside of the few static configurations
  90457. */
  90458. export class RenderingManager {
  90459. /**
  90460. * The max id used for rendering groups (not included)
  90461. */
  90462. static MAX_RENDERINGGROUPS: number;
  90463. /**
  90464. * The min id used for rendering groups (included)
  90465. */
  90466. static MIN_RENDERINGGROUPS: number;
  90467. /**
  90468. * Used to globally prevent autoclearing scenes.
  90469. */
  90470. static AUTOCLEAR: boolean;
  90471. /**
  90472. * @hidden
  90473. */
  90474. _useSceneAutoClearSetup: boolean;
  90475. private _scene;
  90476. private _renderingGroups;
  90477. private _depthStencilBufferAlreadyCleaned;
  90478. private _autoClearDepthStencil;
  90479. private _customOpaqueSortCompareFn;
  90480. private _customAlphaTestSortCompareFn;
  90481. private _customTransparentSortCompareFn;
  90482. private _renderingGroupInfo;
  90483. /**
  90484. * Instantiates a new rendering group for a particular scene
  90485. * @param scene Defines the scene the groups belongs to
  90486. */
  90487. constructor(scene: Scene);
  90488. private _clearDepthStencilBuffer;
  90489. /**
  90490. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  90491. * @hidden
  90492. */
  90493. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  90494. /**
  90495. * Resets the different information of the group to prepare a new frame
  90496. * @hidden
  90497. */
  90498. reset(): void;
  90499. /**
  90500. * Dispose and release the group and its associated resources.
  90501. * @hidden
  90502. */
  90503. dispose(): void;
  90504. /**
  90505. * Clear the info related to rendering groups preventing retention points during dispose.
  90506. */
  90507. freeRenderingGroups(): void;
  90508. private _prepareRenderingGroup;
  90509. /**
  90510. * Add a sprite manager to the rendering manager in order to render it this frame.
  90511. * @param spriteManager Define the sprite manager to render
  90512. */
  90513. dispatchSprites(spriteManager: ISpriteManager): void;
  90514. /**
  90515. * Add a particle system to the rendering manager in order to render it this frame.
  90516. * @param particleSystem Define the particle system to render
  90517. */
  90518. dispatchParticles(particleSystem: IParticleSystem): void;
  90519. /**
  90520. * Add a submesh to the manager in order to render it this frame
  90521. * @param subMesh The submesh to dispatch
  90522. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  90523. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  90524. */
  90525. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  90526. /**
  90527. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  90528. * This allowed control for front to back rendering or reversly depending of the special needs.
  90529. *
  90530. * @param renderingGroupId The rendering group id corresponding to its index
  90531. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  90532. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  90533. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  90534. */
  90535. 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;
  90536. /**
  90537. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  90538. *
  90539. * @param renderingGroupId The rendering group id corresponding to its index
  90540. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  90541. * @param depth Automatically clears depth between groups if true and autoClear is true.
  90542. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  90543. */
  90544. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  90545. /**
  90546. * Gets the current auto clear configuration for one rendering group of the rendering
  90547. * manager.
  90548. * @param index the rendering group index to get the information for
  90549. * @returns The auto clear setup for the requested rendering group
  90550. */
  90551. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  90552. }
  90553. }
  90554. declare module BABYLON {
  90555. /**
  90556. * Defines the options associated with the creation of a custom shader for a shadow generator.
  90557. */
  90558. export interface ICustomShaderOptions {
  90559. /**
  90560. * Gets or sets the custom shader name to use
  90561. */
  90562. shaderName: string;
  90563. /**
  90564. * The list of attribute names used in the shader
  90565. */
  90566. attributes?: string[];
  90567. /**
  90568. * The list of unifrom names used in the shader
  90569. */
  90570. uniforms?: string[];
  90571. /**
  90572. * The list of sampler names used in the shader
  90573. */
  90574. samplers?: string[];
  90575. /**
  90576. * The list of defines used in the shader
  90577. */
  90578. defines?: string[];
  90579. }
  90580. /**
  90581. * Interface to implement to create a shadow generator compatible with BJS.
  90582. */
  90583. export interface IShadowGenerator {
  90584. /**
  90585. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90586. * @returns The render target texture if present otherwise, null
  90587. */
  90588. getShadowMap(): Nullable<RenderTargetTexture>;
  90589. /**
  90590. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  90591. * @param subMesh The submesh we want to render in the shadow map
  90592. * @param useInstances Defines wether will draw in the map using instances
  90593. * @returns true if ready otherwise, false
  90594. */
  90595. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  90596. /**
  90597. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  90598. * @param defines Defines of the material we want to update
  90599. * @param lightIndex Index of the light in the enabled light list of the material
  90600. */
  90601. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  90602. /**
  90603. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  90604. * defined in the generator but impacting the effect).
  90605. * It implies the unifroms available on the materials are the standard BJS ones.
  90606. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  90607. * @param effect The effect we are binfing the information for
  90608. */
  90609. bindShadowLight(lightIndex: string, effect: Effect): void;
  90610. /**
  90611. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  90612. * (eq to shadow prjection matrix * light transform matrix)
  90613. * @returns The transform matrix used to create the shadow map
  90614. */
  90615. getTransformMatrix(): Matrix;
  90616. /**
  90617. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  90618. * Cube and 2D textures for instance.
  90619. */
  90620. recreateShadowMap(): void;
  90621. /**
  90622. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90623. * @param onCompiled Callback triggered at the and of the effects compilation
  90624. * @param options Sets of optional options forcing the compilation with different modes
  90625. */
  90626. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  90627. useInstances: boolean;
  90628. }>): void;
  90629. /**
  90630. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  90631. * @param options Sets of optional options forcing the compilation with different modes
  90632. * @returns A promise that resolves when the compilation completes
  90633. */
  90634. forceCompilationAsync(options?: Partial<{
  90635. useInstances: boolean;
  90636. }>): Promise<void>;
  90637. /**
  90638. * Serializes the shadow generator setup to a json object.
  90639. * @returns The serialized JSON object
  90640. */
  90641. serialize(): any;
  90642. /**
  90643. * Disposes the Shadow map and related Textures and effects.
  90644. */
  90645. dispose(): void;
  90646. }
  90647. /**
  90648. * Default implementation IShadowGenerator.
  90649. * This is the main object responsible of generating shadows in the framework.
  90650. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  90651. */
  90652. export class ShadowGenerator implements IShadowGenerator {
  90653. /**
  90654. * Name of the shadow generator class
  90655. */
  90656. static CLASSNAME: string;
  90657. /**
  90658. * Shadow generator mode None: no filtering applied.
  90659. */
  90660. static readonly FILTER_NONE: number;
  90661. /**
  90662. * Shadow generator mode ESM: Exponential Shadow Mapping.
  90663. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90664. */
  90665. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  90666. /**
  90667. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  90668. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  90669. */
  90670. static readonly FILTER_POISSONSAMPLING: number;
  90671. /**
  90672. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  90673. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90674. */
  90675. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  90676. /**
  90677. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  90678. * edge artifacts on steep falloff.
  90679. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90680. */
  90681. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  90682. /**
  90683. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  90684. * edge artifacts on steep falloff.
  90685. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  90686. */
  90687. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  90688. /**
  90689. * Shadow generator mode PCF: Percentage Closer Filtering
  90690. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90691. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  90692. */
  90693. static readonly FILTER_PCF: number;
  90694. /**
  90695. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  90696. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  90697. * Contact Hardening
  90698. */
  90699. static readonly FILTER_PCSS: number;
  90700. /**
  90701. * Reserved for PCF and PCSS
  90702. * Highest Quality.
  90703. *
  90704. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  90705. *
  90706. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  90707. */
  90708. static readonly QUALITY_HIGH: number;
  90709. /**
  90710. * Reserved for PCF and PCSS
  90711. * Good tradeoff for quality/perf cross devices
  90712. *
  90713. * Execute PCF on a 3*3 kernel.
  90714. *
  90715. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  90716. */
  90717. static readonly QUALITY_MEDIUM: number;
  90718. /**
  90719. * Reserved for PCF and PCSS
  90720. * The lowest quality but the fastest.
  90721. *
  90722. * Execute PCF on a 1*1 kernel.
  90723. *
  90724. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  90725. */
  90726. static readonly QUALITY_LOW: number;
  90727. /** Gets or sets the custom shader name to use */
  90728. customShaderOptions: ICustomShaderOptions;
  90729. /**
  90730. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  90731. */
  90732. onBeforeShadowMapRenderObservable: Observable<Effect>;
  90733. /**
  90734. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  90735. */
  90736. onAfterShadowMapRenderObservable: Observable<Effect>;
  90737. /**
  90738. * Observable triggered before a mesh is rendered in the shadow map.
  90739. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  90740. */
  90741. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  90742. /**
  90743. * Observable triggered after a mesh is rendered in the shadow map.
  90744. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  90745. */
  90746. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  90747. protected _bias: number;
  90748. /**
  90749. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  90750. */
  90751. get bias(): number;
  90752. /**
  90753. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  90754. */
  90755. set bias(bias: number);
  90756. protected _normalBias: number;
  90757. /**
  90758. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90759. */
  90760. get normalBias(): number;
  90761. /**
  90762. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  90763. */
  90764. set normalBias(normalBias: number);
  90765. protected _blurBoxOffset: number;
  90766. /**
  90767. * Gets the blur box offset: offset applied during the blur pass.
  90768. * Only useful if useKernelBlur = false
  90769. */
  90770. get blurBoxOffset(): number;
  90771. /**
  90772. * Sets the blur box offset: offset applied during the blur pass.
  90773. * Only useful if useKernelBlur = false
  90774. */
  90775. set blurBoxOffset(value: number);
  90776. protected _blurScale: number;
  90777. /**
  90778. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  90779. * 2 means half of the size.
  90780. */
  90781. get blurScale(): number;
  90782. /**
  90783. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  90784. * 2 means half of the size.
  90785. */
  90786. set blurScale(value: number);
  90787. protected _blurKernel: number;
  90788. /**
  90789. * Gets the blur kernel: kernel size of the blur pass.
  90790. * Only useful if useKernelBlur = true
  90791. */
  90792. get blurKernel(): number;
  90793. /**
  90794. * Sets the blur kernel: kernel size of the blur pass.
  90795. * Only useful if useKernelBlur = true
  90796. */
  90797. set blurKernel(value: number);
  90798. protected _useKernelBlur: boolean;
  90799. /**
  90800. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  90801. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90802. */
  90803. get useKernelBlur(): boolean;
  90804. /**
  90805. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  90806. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  90807. */
  90808. set useKernelBlur(value: boolean);
  90809. protected _depthScale: number;
  90810. /**
  90811. * Gets the depth scale used in ESM mode.
  90812. */
  90813. get depthScale(): number;
  90814. /**
  90815. * Sets the depth scale used in ESM mode.
  90816. * This can override the scale stored on the light.
  90817. */
  90818. set depthScale(value: number);
  90819. protected _validateFilter(filter: number): number;
  90820. protected _filter: number;
  90821. /**
  90822. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  90823. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90824. */
  90825. get filter(): number;
  90826. /**
  90827. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  90828. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  90829. */
  90830. set filter(value: number);
  90831. /**
  90832. * Gets if the current filter is set to Poisson Sampling.
  90833. */
  90834. get usePoissonSampling(): boolean;
  90835. /**
  90836. * Sets the current filter to Poisson Sampling.
  90837. */
  90838. set usePoissonSampling(value: boolean);
  90839. /**
  90840. * Gets if the current filter is set to ESM.
  90841. */
  90842. get useExponentialShadowMap(): boolean;
  90843. /**
  90844. * Sets the current filter is to ESM.
  90845. */
  90846. set useExponentialShadowMap(value: boolean);
  90847. /**
  90848. * Gets if the current filter is set to filtered ESM.
  90849. */
  90850. get useBlurExponentialShadowMap(): boolean;
  90851. /**
  90852. * Gets if the current filter is set to filtered ESM.
  90853. */
  90854. set useBlurExponentialShadowMap(value: boolean);
  90855. /**
  90856. * Gets if the current filter is set to "close ESM" (using the inverse of the
  90857. * exponential to prevent steep falloff artifacts).
  90858. */
  90859. get useCloseExponentialShadowMap(): boolean;
  90860. /**
  90861. * Sets the current filter to "close ESM" (using the inverse of the
  90862. * exponential to prevent steep falloff artifacts).
  90863. */
  90864. set useCloseExponentialShadowMap(value: boolean);
  90865. /**
  90866. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  90867. * exponential to prevent steep falloff artifacts).
  90868. */
  90869. get useBlurCloseExponentialShadowMap(): boolean;
  90870. /**
  90871. * Sets the current filter to filtered "close ESM" (using the inverse of the
  90872. * exponential to prevent steep falloff artifacts).
  90873. */
  90874. set useBlurCloseExponentialShadowMap(value: boolean);
  90875. /**
  90876. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  90877. */
  90878. get usePercentageCloserFiltering(): boolean;
  90879. /**
  90880. * Sets the current filter to "PCF" (percentage closer filtering).
  90881. */
  90882. set usePercentageCloserFiltering(value: boolean);
  90883. protected _filteringQuality: number;
  90884. /**
  90885. * Gets the PCF or PCSS Quality.
  90886. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90887. */
  90888. get filteringQuality(): number;
  90889. /**
  90890. * Sets the PCF or PCSS Quality.
  90891. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  90892. */
  90893. set filteringQuality(filteringQuality: number);
  90894. /**
  90895. * Gets if the current filter is set to "PCSS" (contact hardening).
  90896. */
  90897. get useContactHardeningShadow(): boolean;
  90898. /**
  90899. * Sets the current filter to "PCSS" (contact hardening).
  90900. */
  90901. set useContactHardeningShadow(value: boolean);
  90902. protected _contactHardeningLightSizeUVRatio: number;
  90903. /**
  90904. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  90913. /**
  90914. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  90915. * Using a ratio helps keeping shape stability independently of the map size.
  90916. *
  90917. * It does not account for the light projection as it was having too much
  90918. * instability during the light setup or during light position changes.
  90919. *
  90920. * Only valid if useContactHardeningShadow is true.
  90921. */
  90922. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  90923. protected _darkness: number;
  90924. /** Gets or sets the actual darkness of a shadow */
  90925. get darkness(): number;
  90926. set darkness(value: number);
  90927. /**
  90928. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  90929. * 0 means strongest and 1 would means no shadow.
  90930. * @returns the darkness.
  90931. */
  90932. getDarkness(): number;
  90933. /**
  90934. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  90935. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  90936. * @returns the shadow generator allowing fluent coding.
  90937. */
  90938. setDarkness(darkness: number): ShadowGenerator;
  90939. protected _transparencyShadow: boolean;
  90940. /** Gets or sets the ability to have transparent shadow */
  90941. get transparencyShadow(): boolean;
  90942. set transparencyShadow(value: boolean);
  90943. /**
  90944. * Sets the ability to have transparent shadow (boolean).
  90945. * @param transparent True if transparent else False
  90946. * @returns the shadow generator allowing fluent coding
  90947. */
  90948. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  90949. protected _shadowMap: Nullable<RenderTargetTexture>;
  90950. protected _shadowMap2: Nullable<RenderTargetTexture>;
  90951. /**
  90952. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  90953. * @returns The render target texture if present otherwise, null
  90954. */
  90955. getShadowMap(): Nullable<RenderTargetTexture>;
  90956. /**
  90957. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  90958. * @returns The render target texture if the shadow map is present otherwise, null
  90959. */
  90960. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  90961. /**
  90962. * Gets the class name of that object
  90963. * @returns "ShadowGenerator"
  90964. */
  90965. getClassName(): string;
  90966. /**
  90967. * Helper function to add a mesh and its descendants to the list of shadow casters.
  90968. * @param mesh Mesh to add
  90969. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  90970. * @returns the Shadow Generator itself
  90971. */
  90972. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90973. /**
  90974. * Helper function to remove a mesh and its descendants from the list of shadow casters
  90975. * @param mesh Mesh to remove
  90976. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  90977. * @returns the Shadow Generator itself
  90978. */
  90979. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  90980. /**
  90981. * Controls the extent to which the shadows fade out at the edge of the frustum
  90982. */
  90983. frustumEdgeFalloff: number;
  90984. protected _light: IShadowLight;
  90985. /**
  90986. * Returns the associated light object.
  90987. * @returns the light generating the shadow
  90988. */
  90989. getLight(): IShadowLight;
  90990. /**
  90991. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  90992. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  90993. * It might on the other hand introduce peter panning.
  90994. */
  90995. forceBackFacesOnly: boolean;
  90996. protected _scene: Scene;
  90997. protected _lightDirection: Vector3;
  90998. protected _effect: Effect;
  90999. protected _viewMatrix: Matrix;
  91000. protected _projectionMatrix: Matrix;
  91001. protected _transformMatrix: Matrix;
  91002. protected _cachedPosition: Vector3;
  91003. protected _cachedDirection: Vector3;
  91004. protected _cachedDefines: string;
  91005. protected _currentRenderID: number;
  91006. protected _boxBlurPostprocess: Nullable<PostProcess>;
  91007. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  91008. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  91009. protected _blurPostProcesses: PostProcess[];
  91010. protected _mapSize: number;
  91011. protected _currentFaceIndex: number;
  91012. protected _currentFaceIndexCache: number;
  91013. protected _textureType: number;
  91014. protected _defaultTextureMatrix: Matrix;
  91015. protected _storedUniqueId: Nullable<number>;
  91016. /** @hidden */
  91017. static _SceneComponentInitialization: (scene: Scene) => void;
  91018. /**
  91019. * Creates a ShadowGenerator object.
  91020. * A ShadowGenerator is the required tool to use the shadows.
  91021. * Each light casting shadows needs to use its own ShadowGenerator.
  91022. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  91023. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  91024. * @param light The light object generating the shadows.
  91025. * @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.
  91026. */
  91027. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  91028. protected _initializeGenerator(): void;
  91029. protected _createTargetRenderTexture(): void;
  91030. protected _initializeShadowMap(): void;
  91031. protected _initializeBlurRTTAndPostProcesses(): void;
  91032. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  91033. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  91034. protected _renderSubMeshForShadowMap(subMesh: SubMesh): void;
  91035. protected _applyFilterValues(): void;
  91036. /**
  91037. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91038. * @param onCompiled Callback triggered at the and of the effects compilation
  91039. * @param options Sets of optional options forcing the compilation with different modes
  91040. */
  91041. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  91042. useInstances: boolean;
  91043. }>): void;
  91044. /**
  91045. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  91046. * @param options Sets of optional options forcing the compilation with different modes
  91047. * @returns A promise that resolves when the compilation completes
  91048. */
  91049. forceCompilationAsync(options?: Partial<{
  91050. useInstances: boolean;
  91051. }>): Promise<void>;
  91052. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  91053. /**
  91054. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  91055. * @param subMesh The submesh we want to render in the shadow map
  91056. * @param useInstances Defines wether will draw in the map using instances
  91057. * @returns true if ready otherwise, false
  91058. */
  91059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  91060. /**
  91061. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  91062. * @param defines Defines of the material we want to update
  91063. * @param lightIndex Index of the light in the enabled light list of the material
  91064. */
  91065. prepareDefines(defines: any, lightIndex: number): void;
  91066. /**
  91067. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  91068. * defined in the generator but impacting the effect).
  91069. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  91070. * @param effect The effect we are binfing the information for
  91071. */
  91072. bindShadowLight(lightIndex: string, effect: Effect): void;
  91073. /**
  91074. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  91075. * (eq to shadow prjection matrix * light transform matrix)
  91076. * @returns The transform matrix used to create the shadow map
  91077. */
  91078. getTransformMatrix(): Matrix;
  91079. /**
  91080. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  91081. * Cube and 2D textures for instance.
  91082. */
  91083. recreateShadowMap(): void;
  91084. protected _disposeBlurPostProcesses(): void;
  91085. protected _disposeRTTandPostProcesses(): void;
  91086. /**
  91087. * Disposes the ShadowGenerator.
  91088. * Returns nothing.
  91089. */
  91090. dispose(): void;
  91091. /**
  91092. * Serializes the shadow generator setup to a json object.
  91093. * @returns The serialized JSON object
  91094. */
  91095. serialize(): any;
  91096. /**
  91097. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  91098. * @param parsedShadowGenerator The JSON object to parse
  91099. * @param scene The scene to create the shadow map for
  91100. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  91101. * @returns The parsed shadow generator
  91102. */
  91103. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  91104. }
  91105. }
  91106. declare module BABYLON {
  91107. /**
  91108. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  91109. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  91110. * 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.
  91111. */
  91112. export abstract class Light extends Node {
  91113. /**
  91114. * Falloff Default: light is falling off following the material specification:
  91115. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  91116. */
  91117. static readonly FALLOFF_DEFAULT: number;
  91118. /**
  91119. * Falloff Physical: light is falling off following the inverse squared distance law.
  91120. */
  91121. static readonly FALLOFF_PHYSICAL: number;
  91122. /**
  91123. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  91124. * to enhance interoperability with other engines.
  91125. */
  91126. static readonly FALLOFF_GLTF: number;
  91127. /**
  91128. * Falloff Standard: light is falling off like in the standard material
  91129. * to enhance interoperability with other materials.
  91130. */
  91131. static readonly FALLOFF_STANDARD: number;
  91132. /**
  91133. * If every light affecting the material is in this lightmapMode,
  91134. * material.lightmapTexture adds or multiplies
  91135. * (depends on material.useLightmapAsShadowmap)
  91136. * after every other light calculations.
  91137. */
  91138. static readonly LIGHTMAP_DEFAULT: number;
  91139. /**
  91140. * material.lightmapTexture as only diffuse lighting from this light
  91141. * adds only specular lighting from this light
  91142. * adds dynamic shadows
  91143. */
  91144. static readonly LIGHTMAP_SPECULAR: number;
  91145. /**
  91146. * material.lightmapTexture as only lighting
  91147. * no light calculation from this light
  91148. * only adds dynamic shadows from this light
  91149. */
  91150. static readonly LIGHTMAP_SHADOWSONLY: number;
  91151. /**
  91152. * Each light type uses the default quantity according to its type:
  91153. * point/spot lights use luminous intensity
  91154. * directional lights use illuminance
  91155. */
  91156. static readonly INTENSITYMODE_AUTOMATIC: number;
  91157. /**
  91158. * lumen (lm)
  91159. */
  91160. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  91161. /**
  91162. * candela (lm/sr)
  91163. */
  91164. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  91165. /**
  91166. * lux (lm/m^2)
  91167. */
  91168. static readonly INTENSITYMODE_ILLUMINANCE: number;
  91169. /**
  91170. * nit (cd/m^2)
  91171. */
  91172. static readonly INTENSITYMODE_LUMINANCE: number;
  91173. /**
  91174. * Light type const id of the point light.
  91175. */
  91176. static readonly LIGHTTYPEID_POINTLIGHT: number;
  91177. /**
  91178. * Light type const id of the directional light.
  91179. */
  91180. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  91181. /**
  91182. * Light type const id of the spot light.
  91183. */
  91184. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  91185. /**
  91186. * Light type const id of the hemispheric light.
  91187. */
  91188. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  91189. /**
  91190. * Diffuse gives the basic color to an object.
  91191. */
  91192. diffuse: Color3;
  91193. /**
  91194. * Specular produces a highlight color on an object.
  91195. * Note: This is note affecting PBR materials.
  91196. */
  91197. specular: Color3;
  91198. /**
  91199. * Defines the falloff type for this light. This lets overrriding how punctual light are
  91200. * falling off base on range or angle.
  91201. * This can be set to any values in Light.FALLOFF_x.
  91202. *
  91203. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  91204. * other types of materials.
  91205. */
  91206. falloffType: number;
  91207. /**
  91208. * Strength of the light.
  91209. * Note: By default it is define in the framework own unit.
  91210. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  91211. */
  91212. intensity: number;
  91213. private _range;
  91214. protected _inverseSquaredRange: number;
  91215. /**
  91216. * Defines how far from the source the light is impacting in scene units.
  91217. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91218. */
  91219. get range(): number;
  91220. /**
  91221. * Defines how far from the source the light is impacting in scene units.
  91222. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  91223. */
  91224. set range(value: number);
  91225. /**
  91226. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  91227. * of light.
  91228. */
  91229. private _photometricScale;
  91230. private _intensityMode;
  91231. /**
  91232. * Gets the photometric scale used to interpret the intensity.
  91233. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91234. */
  91235. get intensityMode(): number;
  91236. /**
  91237. * Sets the photometric scale used to interpret the intensity.
  91238. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  91239. */
  91240. set intensityMode(value: number);
  91241. private _radius;
  91242. /**
  91243. * Gets the light radius used by PBR Materials to simulate soft area lights.
  91244. */
  91245. get radius(): number;
  91246. /**
  91247. * sets the light radius used by PBR Materials to simulate soft area lights.
  91248. */
  91249. set radius(value: number);
  91250. private _renderPriority;
  91251. /**
  91252. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  91253. * exceeding the number allowed of the materials.
  91254. */
  91255. renderPriority: number;
  91256. private _shadowEnabled;
  91257. /**
  91258. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91259. * the current shadow generator.
  91260. */
  91261. get shadowEnabled(): boolean;
  91262. /**
  91263. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  91264. * the current shadow generator.
  91265. */
  91266. set shadowEnabled(value: boolean);
  91267. private _includedOnlyMeshes;
  91268. /**
  91269. * Gets the only meshes impacted by this light.
  91270. */
  91271. get includedOnlyMeshes(): AbstractMesh[];
  91272. /**
  91273. * Sets the only meshes impacted by this light.
  91274. */
  91275. set includedOnlyMeshes(value: AbstractMesh[]);
  91276. private _excludedMeshes;
  91277. /**
  91278. * Gets the meshes not impacted by this light.
  91279. */
  91280. get excludedMeshes(): AbstractMesh[];
  91281. /**
  91282. * Sets the meshes not impacted by this light.
  91283. */
  91284. set excludedMeshes(value: AbstractMesh[]);
  91285. private _excludeWithLayerMask;
  91286. /**
  91287. * Gets the layer id use to find what meshes are not impacted by the light.
  91288. * Inactive if 0
  91289. */
  91290. get excludeWithLayerMask(): number;
  91291. /**
  91292. * Sets the layer id use to find what meshes are not impacted by the light.
  91293. * Inactive if 0
  91294. */
  91295. set excludeWithLayerMask(value: number);
  91296. private _includeOnlyWithLayerMask;
  91297. /**
  91298. * Gets the layer id use to find what meshes are impacted by the light.
  91299. * Inactive if 0
  91300. */
  91301. get includeOnlyWithLayerMask(): number;
  91302. /**
  91303. * Sets the layer id use to find what meshes are impacted by the light.
  91304. * Inactive if 0
  91305. */
  91306. set includeOnlyWithLayerMask(value: number);
  91307. private _lightmapMode;
  91308. /**
  91309. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91310. */
  91311. get lightmapMode(): number;
  91312. /**
  91313. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  91314. */
  91315. set lightmapMode(value: number);
  91316. /**
  91317. * Shadow generator associted to the light.
  91318. * @hidden Internal use only.
  91319. */
  91320. _shadowGenerator: Nullable<IShadowGenerator>;
  91321. /**
  91322. * @hidden Internal use only.
  91323. */
  91324. _excludedMeshesIds: string[];
  91325. /**
  91326. * @hidden Internal use only.
  91327. */
  91328. _includedOnlyMeshesIds: string[];
  91329. /**
  91330. * The current light unifom buffer.
  91331. * @hidden Internal use only.
  91332. */
  91333. _uniformBuffer: UniformBuffer;
  91334. /** @hidden */
  91335. _renderId: number;
  91336. /**
  91337. * Creates a Light object in the scene.
  91338. * Documentation : https://doc.babylonjs.com/babylon101/lights
  91339. * @param name The firendly name of the light
  91340. * @param scene The scene the light belongs too
  91341. */
  91342. constructor(name: string, scene: Scene);
  91343. protected abstract _buildUniformLayout(): void;
  91344. /**
  91345. * Sets the passed Effect "effect" with the Light information.
  91346. * @param effect The effect to update
  91347. * @param lightIndex The index of the light in the effect to update
  91348. * @returns The light
  91349. */
  91350. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  91351. /**
  91352. * Sets the passed Effect "effect" with the Light textures.
  91353. * @param effect The effect to update
  91354. * @param lightIndex The index of the light in the effect to update
  91355. * @returns The light
  91356. */
  91357. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  91358. /**
  91359. * Binds the lights information from the scene to the effect for the given mesh.
  91360. * @param lightIndex Light index
  91361. * @param scene The scene where the light belongs to
  91362. * @param effect The effect we are binding the data to
  91363. * @param useSpecular Defines if specular is supported
  91364. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  91365. */
  91366. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  91367. /**
  91368. * Sets the passed Effect "effect" with the Light information.
  91369. * @param effect The effect to update
  91370. * @param lightDataUniformName The uniform used to store light data (position or direction)
  91371. * @returns The light
  91372. */
  91373. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  91374. /**
  91375. * Returns the string "Light".
  91376. * @returns the class name
  91377. */
  91378. getClassName(): string;
  91379. /** @hidden */
  91380. readonly _isLight: boolean;
  91381. /**
  91382. * Converts the light information to a readable string for debug purpose.
  91383. * @param fullDetails Supports for multiple levels of logging within scene loading
  91384. * @returns the human readable light info
  91385. */
  91386. toString(fullDetails?: boolean): string;
  91387. /** @hidden */
  91388. protected _syncParentEnabledState(): void;
  91389. /**
  91390. * Set the enabled state of this node.
  91391. * @param value - the new enabled state
  91392. */
  91393. setEnabled(value: boolean): void;
  91394. /**
  91395. * Returns the Light associated shadow generator if any.
  91396. * @return the associated shadow generator.
  91397. */
  91398. getShadowGenerator(): Nullable<IShadowGenerator>;
  91399. /**
  91400. * Returns a Vector3, the absolute light position in the World.
  91401. * @returns the world space position of the light
  91402. */
  91403. getAbsolutePosition(): Vector3;
  91404. /**
  91405. * Specifies if the light will affect the passed mesh.
  91406. * @param mesh The mesh to test against the light
  91407. * @return true the mesh is affected otherwise, false.
  91408. */
  91409. canAffectMesh(mesh: AbstractMesh): boolean;
  91410. /**
  91411. * Sort function to order lights for rendering.
  91412. * @param a First Light object to compare to second.
  91413. * @param b Second Light object to compare first.
  91414. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  91415. */
  91416. static CompareLightsPriority(a: Light, b: Light): number;
  91417. /**
  91418. * Releases resources associated with this node.
  91419. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91420. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91421. */
  91422. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  91423. /**
  91424. * Returns the light type ID (integer).
  91425. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  91426. */
  91427. getTypeID(): number;
  91428. /**
  91429. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  91430. * @returns the scaled intensity in intensity mode unit
  91431. */
  91432. getScaledIntensity(): number;
  91433. /**
  91434. * Returns a new Light object, named "name", from the current one.
  91435. * @param name The name of the cloned light
  91436. * @returns the new created light
  91437. */
  91438. clone(name: string): Nullable<Light>;
  91439. /**
  91440. * Serializes the current light into a Serialization object.
  91441. * @returns the serialized object.
  91442. */
  91443. serialize(): any;
  91444. /**
  91445. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  91446. * This new light is named "name" and added to the passed scene.
  91447. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  91448. * @param name The friendly name of the light
  91449. * @param scene The scene the new light will belong to
  91450. * @returns the constructor function
  91451. */
  91452. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  91453. /**
  91454. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  91455. * @param parsedLight The JSON representation of the light
  91456. * @param scene The scene to create the parsed light in
  91457. * @returns the created light after parsing
  91458. */
  91459. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  91460. private _hookArrayForExcluded;
  91461. private _hookArrayForIncludedOnly;
  91462. private _resyncMeshes;
  91463. /**
  91464. * Forces the meshes to update their light related information in their rendering used effects
  91465. * @hidden Internal Use Only
  91466. */
  91467. _markMeshesAsLightDirty(): void;
  91468. /**
  91469. * Recomputes the cached photometric scale if needed.
  91470. */
  91471. private _computePhotometricScale;
  91472. /**
  91473. * Returns the Photometric Scale according to the light type and intensity mode.
  91474. */
  91475. private _getPhotometricScale;
  91476. /**
  91477. * Reorder the light in the scene according to their defined priority.
  91478. * @hidden Internal Use Only
  91479. */
  91480. _reorderLightsInScene(): void;
  91481. /**
  91482. * Prepares the list of defines specific to the light type.
  91483. * @param defines the list of defines
  91484. * @param lightIndex defines the index of the light for the effect
  91485. */
  91486. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  91487. }
  91488. }
  91489. declare module BABYLON {
  91490. /**
  91491. * Interface used to define Action
  91492. */
  91493. export interface IAction {
  91494. /**
  91495. * Trigger for the action
  91496. */
  91497. trigger: number;
  91498. /** Options of the trigger */
  91499. triggerOptions: any;
  91500. /**
  91501. * Gets the trigger parameters
  91502. * @returns the trigger parameters
  91503. */
  91504. getTriggerParameter(): any;
  91505. /**
  91506. * Internal only - executes current action event
  91507. * @hidden
  91508. */
  91509. _executeCurrent(evt?: ActionEvent): void;
  91510. /**
  91511. * Serialize placeholder for child classes
  91512. * @param parent of child
  91513. * @returns the serialized object
  91514. */
  91515. serialize(parent: any): any;
  91516. /**
  91517. * Internal only
  91518. * @hidden
  91519. */
  91520. _prepare(): void;
  91521. /**
  91522. * Internal only - manager for action
  91523. * @hidden
  91524. */
  91525. _actionManager: AbstractActionManager;
  91526. /**
  91527. * Adds action to chain of actions, may be a DoNothingAction
  91528. * @param action defines the next action to execute
  91529. * @returns The action passed in
  91530. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91531. */
  91532. then(action: IAction): IAction;
  91533. }
  91534. /**
  91535. * The action to be carried out following a trigger
  91536. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  91537. */
  91538. export class Action implements IAction {
  91539. /** the trigger, with or without parameters, for the action */
  91540. triggerOptions: any;
  91541. /**
  91542. * Trigger for the action
  91543. */
  91544. trigger: number;
  91545. /**
  91546. * Internal only - manager for action
  91547. * @hidden
  91548. */
  91549. _actionManager: ActionManager;
  91550. private _nextActiveAction;
  91551. private _child;
  91552. private _condition?;
  91553. private _triggerParameter;
  91554. /**
  91555. * An event triggered prior to action being executed.
  91556. */
  91557. onBeforeExecuteObservable: Observable<Action>;
  91558. /**
  91559. * Creates a new Action
  91560. * @param triggerOptions the trigger, with or without parameters, for the action
  91561. * @param condition an optional determinant of action
  91562. */
  91563. constructor(
  91564. /** the trigger, with or without parameters, for the action */
  91565. triggerOptions: any, condition?: Condition);
  91566. /**
  91567. * Internal only
  91568. * @hidden
  91569. */
  91570. _prepare(): void;
  91571. /**
  91572. * Gets the trigger parameters
  91573. * @returns the trigger parameters
  91574. */
  91575. getTriggerParameter(): any;
  91576. /**
  91577. * Internal only - executes current action event
  91578. * @hidden
  91579. */
  91580. _executeCurrent(evt?: ActionEvent): void;
  91581. /**
  91582. * Execute placeholder for child classes
  91583. * @param evt optional action event
  91584. */
  91585. execute(evt?: ActionEvent): void;
  91586. /**
  91587. * Skips to next active action
  91588. */
  91589. skipToNextActiveAction(): void;
  91590. /**
  91591. * Adds action to chain of actions, may be a DoNothingAction
  91592. * @param action defines the next action to execute
  91593. * @returns The action passed in
  91594. * @see https://www.babylonjs-playground.com/#1T30HR#0
  91595. */
  91596. then(action: Action): Action;
  91597. /**
  91598. * Internal only
  91599. * @hidden
  91600. */
  91601. _getProperty(propertyPath: string): string;
  91602. /**
  91603. * Internal only
  91604. * @hidden
  91605. */
  91606. _getEffectiveTarget(target: any, propertyPath: string): any;
  91607. /**
  91608. * Serialize placeholder for child classes
  91609. * @param parent of child
  91610. * @returns the serialized object
  91611. */
  91612. serialize(parent: any): any;
  91613. /**
  91614. * Internal only called by serialize
  91615. * @hidden
  91616. */
  91617. protected _serialize(serializedAction: any, parent?: any): any;
  91618. /**
  91619. * Internal only
  91620. * @hidden
  91621. */
  91622. static _SerializeValueAsString: (value: any) => string;
  91623. /**
  91624. * Internal only
  91625. * @hidden
  91626. */
  91627. static _GetTargetProperty: (target: Node | Scene) => {
  91628. name: string;
  91629. targetType: string;
  91630. value: string;
  91631. };
  91632. }
  91633. }
  91634. declare module BABYLON {
  91635. /**
  91636. * A Condition applied to an Action
  91637. */
  91638. export class Condition {
  91639. /**
  91640. * Internal only - manager for action
  91641. * @hidden
  91642. */
  91643. _actionManager: ActionManager;
  91644. /**
  91645. * Internal only
  91646. * @hidden
  91647. */
  91648. _evaluationId: number;
  91649. /**
  91650. * Internal only
  91651. * @hidden
  91652. */
  91653. _currentResult: boolean;
  91654. /**
  91655. * Creates a new Condition
  91656. * @param actionManager the manager of the action the condition is applied to
  91657. */
  91658. constructor(actionManager: ActionManager);
  91659. /**
  91660. * Check if the current condition is valid
  91661. * @returns a boolean
  91662. */
  91663. isValid(): boolean;
  91664. /**
  91665. * Internal only
  91666. * @hidden
  91667. */
  91668. _getProperty(propertyPath: string): string;
  91669. /**
  91670. * Internal only
  91671. * @hidden
  91672. */
  91673. _getEffectiveTarget(target: any, propertyPath: string): any;
  91674. /**
  91675. * Serialize placeholder for child classes
  91676. * @returns the serialized object
  91677. */
  91678. serialize(): any;
  91679. /**
  91680. * Internal only
  91681. * @hidden
  91682. */
  91683. protected _serialize(serializedCondition: any): any;
  91684. }
  91685. /**
  91686. * Defines specific conditional operators as extensions of Condition
  91687. */
  91688. export class ValueCondition extends Condition {
  91689. /** path to specify the property of the target the conditional operator uses */
  91690. propertyPath: string;
  91691. /** the value compared by the conditional operator against the current value of the property */
  91692. value: any;
  91693. /** the conditional operator, default ValueCondition.IsEqual */
  91694. operator: number;
  91695. /**
  91696. * Internal only
  91697. * @hidden
  91698. */
  91699. private static _IsEqual;
  91700. /**
  91701. * Internal only
  91702. * @hidden
  91703. */
  91704. private static _IsDifferent;
  91705. /**
  91706. * Internal only
  91707. * @hidden
  91708. */
  91709. private static _IsGreater;
  91710. /**
  91711. * Internal only
  91712. * @hidden
  91713. */
  91714. private static _IsLesser;
  91715. /**
  91716. * returns the number for IsEqual
  91717. */
  91718. static get IsEqual(): number;
  91719. /**
  91720. * Returns the number for IsDifferent
  91721. */
  91722. static get IsDifferent(): number;
  91723. /**
  91724. * Returns the number for IsGreater
  91725. */
  91726. static get IsGreater(): number;
  91727. /**
  91728. * Returns the number for IsLesser
  91729. */
  91730. static get IsLesser(): number;
  91731. /**
  91732. * Internal only The action manager for the condition
  91733. * @hidden
  91734. */
  91735. _actionManager: ActionManager;
  91736. /**
  91737. * Internal only
  91738. * @hidden
  91739. */
  91740. private _target;
  91741. /**
  91742. * Internal only
  91743. * @hidden
  91744. */
  91745. private _effectiveTarget;
  91746. /**
  91747. * Internal only
  91748. * @hidden
  91749. */
  91750. private _property;
  91751. /**
  91752. * Creates a new ValueCondition
  91753. * @param actionManager manager for the action the condition applies to
  91754. * @param target for the action
  91755. * @param propertyPath path to specify the property of the target the conditional operator uses
  91756. * @param value the value compared by the conditional operator against the current value of the property
  91757. * @param operator the conditional operator, default ValueCondition.IsEqual
  91758. */
  91759. constructor(actionManager: ActionManager, target: any,
  91760. /** path to specify the property of the target the conditional operator uses */
  91761. propertyPath: string,
  91762. /** the value compared by the conditional operator against the current value of the property */
  91763. value: any,
  91764. /** the conditional operator, default ValueCondition.IsEqual */
  91765. operator?: number);
  91766. /**
  91767. * Compares the given value with the property value for the specified conditional operator
  91768. * @returns the result of the comparison
  91769. */
  91770. isValid(): boolean;
  91771. /**
  91772. * Serialize the ValueCondition into a JSON compatible object
  91773. * @returns serialization object
  91774. */
  91775. serialize(): any;
  91776. /**
  91777. * Gets the name of the conditional operator for the ValueCondition
  91778. * @param operator the conditional operator
  91779. * @returns the name
  91780. */
  91781. static GetOperatorName(operator: number): string;
  91782. }
  91783. /**
  91784. * Defines a predicate condition as an extension of Condition
  91785. */
  91786. export class PredicateCondition extends Condition {
  91787. /** defines the predicate function used to validate the condition */
  91788. predicate: () => boolean;
  91789. /**
  91790. * Internal only - manager for action
  91791. * @hidden
  91792. */
  91793. _actionManager: ActionManager;
  91794. /**
  91795. * Creates a new PredicateCondition
  91796. * @param actionManager manager for the action the condition applies to
  91797. * @param predicate defines the predicate function used to validate the condition
  91798. */
  91799. constructor(actionManager: ActionManager,
  91800. /** defines the predicate function used to validate the condition */
  91801. predicate: () => boolean);
  91802. /**
  91803. * @returns the validity of the predicate condition
  91804. */
  91805. isValid(): boolean;
  91806. }
  91807. /**
  91808. * Defines a state condition as an extension of Condition
  91809. */
  91810. export class StateCondition extends Condition {
  91811. /** Value to compare with target state */
  91812. value: string;
  91813. /**
  91814. * Internal only - manager for action
  91815. * @hidden
  91816. */
  91817. _actionManager: ActionManager;
  91818. /**
  91819. * Internal only
  91820. * @hidden
  91821. */
  91822. private _target;
  91823. /**
  91824. * Creates a new StateCondition
  91825. * @param actionManager manager for the action the condition applies to
  91826. * @param target of the condition
  91827. * @param value to compare with target state
  91828. */
  91829. constructor(actionManager: ActionManager, target: any,
  91830. /** Value to compare with target state */
  91831. value: string);
  91832. /**
  91833. * Gets a boolean indicating if the current condition is met
  91834. * @returns the validity of the state
  91835. */
  91836. isValid(): boolean;
  91837. /**
  91838. * Serialize the StateCondition into a JSON compatible object
  91839. * @returns serialization object
  91840. */
  91841. serialize(): any;
  91842. }
  91843. }
  91844. declare module BABYLON {
  91845. /**
  91846. * This defines an action responsible to toggle a boolean once triggered.
  91847. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91848. */
  91849. export class SwitchBooleanAction extends Action {
  91850. /**
  91851. * The path to the boolean property in the target object
  91852. */
  91853. propertyPath: string;
  91854. private _target;
  91855. private _effectiveTarget;
  91856. private _property;
  91857. /**
  91858. * Instantiate the action
  91859. * @param triggerOptions defines the trigger options
  91860. * @param target defines the object containing the boolean
  91861. * @param propertyPath defines the path to the boolean property in the target object
  91862. * @param condition defines the trigger related conditions
  91863. */
  91864. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  91865. /** @hidden */
  91866. _prepare(): void;
  91867. /**
  91868. * Execute the action toggle the boolean value.
  91869. */
  91870. execute(): void;
  91871. /**
  91872. * Serializes the actions and its related information.
  91873. * @param parent defines the object to serialize in
  91874. * @returns the serialized object
  91875. */
  91876. serialize(parent: any): any;
  91877. }
  91878. /**
  91879. * This defines an action responsible to set a the state field of the target
  91880. * to a desired value once triggered.
  91881. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91882. */
  91883. export class SetStateAction extends Action {
  91884. /**
  91885. * The value to store in the state field.
  91886. */
  91887. value: string;
  91888. private _target;
  91889. /**
  91890. * Instantiate the action
  91891. * @param triggerOptions defines the trigger options
  91892. * @param target defines the object containing the state property
  91893. * @param value defines the value to store in the state field
  91894. * @param condition defines the trigger related conditions
  91895. */
  91896. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  91897. /**
  91898. * Execute the action and store the value on the target state property.
  91899. */
  91900. execute(): void;
  91901. /**
  91902. * Serializes the actions and its related information.
  91903. * @param parent defines the object to serialize in
  91904. * @returns the serialized object
  91905. */
  91906. serialize(parent: any): any;
  91907. }
  91908. /**
  91909. * This defines an action responsible to set a property of the target
  91910. * to a desired value once triggered.
  91911. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91912. */
  91913. export class SetValueAction extends Action {
  91914. /**
  91915. * The path of the property to set in the target.
  91916. */
  91917. propertyPath: string;
  91918. /**
  91919. * The value to set in the property
  91920. */
  91921. value: any;
  91922. private _target;
  91923. private _effectiveTarget;
  91924. private _property;
  91925. /**
  91926. * Instantiate the action
  91927. * @param triggerOptions defines the trigger options
  91928. * @param target defines the object containing the property
  91929. * @param propertyPath defines the path of the property to set in the target
  91930. * @param value defines the value to set in the property
  91931. * @param condition defines the trigger related conditions
  91932. */
  91933. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91934. /** @hidden */
  91935. _prepare(): void;
  91936. /**
  91937. * Execute the action and set the targetted property to the desired value.
  91938. */
  91939. execute(): void;
  91940. /**
  91941. * Serializes the actions and its related information.
  91942. * @param parent defines the object to serialize in
  91943. * @returns the serialized object
  91944. */
  91945. serialize(parent: any): any;
  91946. }
  91947. /**
  91948. * This defines an action responsible to increment the target value
  91949. * to a desired value once triggered.
  91950. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91951. */
  91952. export class IncrementValueAction extends Action {
  91953. /**
  91954. * The path of the property to increment in the target.
  91955. */
  91956. propertyPath: string;
  91957. /**
  91958. * The value we should increment the property by.
  91959. */
  91960. value: any;
  91961. private _target;
  91962. private _effectiveTarget;
  91963. private _property;
  91964. /**
  91965. * Instantiate the action
  91966. * @param triggerOptions defines the trigger options
  91967. * @param target defines the object containing the property
  91968. * @param propertyPath defines the path of the property to increment in the target
  91969. * @param value defines the value value we should increment the property by
  91970. * @param condition defines the trigger related conditions
  91971. */
  91972. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  91973. /** @hidden */
  91974. _prepare(): void;
  91975. /**
  91976. * Execute the action and increment the target of the value amount.
  91977. */
  91978. execute(): void;
  91979. /**
  91980. * Serializes the actions and its related information.
  91981. * @param parent defines the object to serialize in
  91982. * @returns the serialized object
  91983. */
  91984. serialize(parent: any): any;
  91985. }
  91986. /**
  91987. * This defines an action responsible to start an animation once triggered.
  91988. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91989. */
  91990. export class PlayAnimationAction extends Action {
  91991. /**
  91992. * Where the animation should start (animation frame)
  91993. */
  91994. from: number;
  91995. /**
  91996. * Where the animation should stop (animation frame)
  91997. */
  91998. to: number;
  91999. /**
  92000. * Define if the animation should loop or stop after the first play.
  92001. */
  92002. loop?: boolean;
  92003. private _target;
  92004. /**
  92005. * Instantiate the action
  92006. * @param triggerOptions defines the trigger options
  92007. * @param target defines the target animation or animation name
  92008. * @param from defines from where the animation should start (animation frame)
  92009. * @param end defines where the animation should stop (animation frame)
  92010. * @param loop defines if the animation should loop or stop after the first play
  92011. * @param condition defines the trigger related conditions
  92012. */
  92013. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  92014. /** @hidden */
  92015. _prepare(): void;
  92016. /**
  92017. * Execute the action and play the animation.
  92018. */
  92019. execute(): void;
  92020. /**
  92021. * Serializes the actions and its related information.
  92022. * @param parent defines the object to serialize in
  92023. * @returns the serialized object
  92024. */
  92025. serialize(parent: any): any;
  92026. }
  92027. /**
  92028. * This defines an action responsible to stop an animation once triggered.
  92029. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92030. */
  92031. export class StopAnimationAction extends Action {
  92032. private _target;
  92033. /**
  92034. * Instantiate the action
  92035. * @param triggerOptions defines the trigger options
  92036. * @param target defines the target animation or animation name
  92037. * @param condition defines the trigger related conditions
  92038. */
  92039. constructor(triggerOptions: any, target: any, condition?: Condition);
  92040. /** @hidden */
  92041. _prepare(): void;
  92042. /**
  92043. * Execute the action and stop the animation.
  92044. */
  92045. execute(): void;
  92046. /**
  92047. * Serializes the actions and its related information.
  92048. * @param parent defines the object to serialize in
  92049. * @returns the serialized object
  92050. */
  92051. serialize(parent: any): any;
  92052. }
  92053. /**
  92054. * This defines an action responsible that does nothing once triggered.
  92055. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92056. */
  92057. export class DoNothingAction extends Action {
  92058. /**
  92059. * Instantiate the action
  92060. * @param triggerOptions defines the trigger options
  92061. * @param condition defines the trigger related conditions
  92062. */
  92063. constructor(triggerOptions?: any, condition?: Condition);
  92064. /**
  92065. * Execute the action and do nothing.
  92066. */
  92067. execute(): void;
  92068. /**
  92069. * Serializes the actions and its related information.
  92070. * @param parent defines the object to serialize in
  92071. * @returns the serialized object
  92072. */
  92073. serialize(parent: any): any;
  92074. }
  92075. /**
  92076. * This defines an action responsible to trigger several actions once triggered.
  92077. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92078. */
  92079. export class CombineAction extends Action {
  92080. /**
  92081. * The list of aggregated animations to run.
  92082. */
  92083. children: Action[];
  92084. /**
  92085. * Instantiate the action
  92086. * @param triggerOptions defines the trigger options
  92087. * @param children defines the list of aggregated animations to run
  92088. * @param condition defines the trigger related conditions
  92089. */
  92090. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  92091. /** @hidden */
  92092. _prepare(): void;
  92093. /**
  92094. * Execute the action and executes all the aggregated actions.
  92095. */
  92096. execute(evt: ActionEvent): void;
  92097. /**
  92098. * Serializes the actions and its related information.
  92099. * @param parent defines the object to serialize in
  92100. * @returns the serialized object
  92101. */
  92102. serialize(parent: any): any;
  92103. }
  92104. /**
  92105. * This defines an action responsible to run code (external event) once triggered.
  92106. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92107. */
  92108. export class ExecuteCodeAction extends Action {
  92109. /**
  92110. * The callback function to run.
  92111. */
  92112. func: (evt: ActionEvent) => void;
  92113. /**
  92114. * Instantiate the action
  92115. * @param triggerOptions defines the trigger options
  92116. * @param func defines the callback function to run
  92117. * @param condition defines the trigger related conditions
  92118. */
  92119. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  92120. /**
  92121. * Execute the action and run the attached code.
  92122. */
  92123. execute(evt: ActionEvent): void;
  92124. }
  92125. /**
  92126. * This defines an action responsible to set the parent property of the target once triggered.
  92127. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92128. */
  92129. export class SetParentAction extends Action {
  92130. private _parent;
  92131. private _target;
  92132. /**
  92133. * Instantiate the action
  92134. * @param triggerOptions defines the trigger options
  92135. * @param target defines the target containing the parent property
  92136. * @param parent defines from where the animation should start (animation frame)
  92137. * @param condition defines the trigger related conditions
  92138. */
  92139. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  92140. /** @hidden */
  92141. _prepare(): void;
  92142. /**
  92143. * Execute the action and set the parent property.
  92144. */
  92145. execute(): void;
  92146. /**
  92147. * Serializes the actions and its related information.
  92148. * @param parent defines the object to serialize in
  92149. * @returns the serialized object
  92150. */
  92151. serialize(parent: any): any;
  92152. }
  92153. }
  92154. declare module BABYLON {
  92155. /**
  92156. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  92157. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  92158. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  92159. */
  92160. export class ActionManager extends AbstractActionManager {
  92161. /**
  92162. * Nothing
  92163. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92164. */
  92165. static readonly NothingTrigger: number;
  92166. /**
  92167. * On pick
  92168. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92169. */
  92170. static readonly OnPickTrigger: number;
  92171. /**
  92172. * On left pick
  92173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92174. */
  92175. static readonly OnLeftPickTrigger: number;
  92176. /**
  92177. * On right pick
  92178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92179. */
  92180. static readonly OnRightPickTrigger: number;
  92181. /**
  92182. * On center pick
  92183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92184. */
  92185. static readonly OnCenterPickTrigger: number;
  92186. /**
  92187. * On pick down
  92188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92189. */
  92190. static readonly OnPickDownTrigger: number;
  92191. /**
  92192. * On double pick
  92193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92194. */
  92195. static readonly OnDoublePickTrigger: number;
  92196. /**
  92197. * On pick up
  92198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92199. */
  92200. static readonly OnPickUpTrigger: number;
  92201. /**
  92202. * On pick out.
  92203. * This trigger will only be raised if you also declared a OnPickDown
  92204. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92205. */
  92206. static readonly OnPickOutTrigger: number;
  92207. /**
  92208. * On long press
  92209. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92210. */
  92211. static readonly OnLongPressTrigger: number;
  92212. /**
  92213. * On pointer over
  92214. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92215. */
  92216. static readonly OnPointerOverTrigger: number;
  92217. /**
  92218. * On pointer out
  92219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92220. */
  92221. static readonly OnPointerOutTrigger: number;
  92222. /**
  92223. * On every frame
  92224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92225. */
  92226. static readonly OnEveryFrameTrigger: number;
  92227. /**
  92228. * On intersection enter
  92229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92230. */
  92231. static readonly OnIntersectionEnterTrigger: number;
  92232. /**
  92233. * On intersection exit
  92234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92235. */
  92236. static readonly OnIntersectionExitTrigger: number;
  92237. /**
  92238. * On key down
  92239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92240. */
  92241. static readonly OnKeyDownTrigger: number;
  92242. /**
  92243. * On key up
  92244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  92245. */
  92246. static readonly OnKeyUpTrigger: number;
  92247. private _scene;
  92248. /**
  92249. * Creates a new action manager
  92250. * @param scene defines the hosting scene
  92251. */
  92252. constructor(scene: Scene);
  92253. /**
  92254. * Releases all associated resources
  92255. */
  92256. dispose(): void;
  92257. /**
  92258. * Gets hosting scene
  92259. * @returns the hosting scene
  92260. */
  92261. getScene(): Scene;
  92262. /**
  92263. * Does this action manager handles actions of any of the given triggers
  92264. * @param triggers defines the triggers to be tested
  92265. * @return a boolean indicating whether one (or more) of the triggers is handled
  92266. */
  92267. hasSpecificTriggers(triggers: number[]): boolean;
  92268. /**
  92269. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  92270. * speed.
  92271. * @param triggerA defines the trigger to be tested
  92272. * @param triggerB defines the trigger to be tested
  92273. * @return a boolean indicating whether one (or more) of the triggers is handled
  92274. */
  92275. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  92276. /**
  92277. * Does this action manager handles actions of a given trigger
  92278. * @param trigger defines the trigger to be tested
  92279. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  92280. * @return whether the trigger is handled
  92281. */
  92282. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  92283. /**
  92284. * Does this action manager has pointer triggers
  92285. */
  92286. get hasPointerTriggers(): boolean;
  92287. /**
  92288. * Does this action manager has pick triggers
  92289. */
  92290. get hasPickTriggers(): boolean;
  92291. /**
  92292. * Registers an action to this action manager
  92293. * @param action defines the action to be registered
  92294. * @return the action amended (prepared) after registration
  92295. */
  92296. registerAction(action: IAction): Nullable<IAction>;
  92297. /**
  92298. * Unregisters an action to this action manager
  92299. * @param action defines the action to be unregistered
  92300. * @return a boolean indicating whether the action has been unregistered
  92301. */
  92302. unregisterAction(action: IAction): Boolean;
  92303. /**
  92304. * Process a specific trigger
  92305. * @param trigger defines the trigger to process
  92306. * @param evt defines the event details to be processed
  92307. */
  92308. processTrigger(trigger: number, evt?: IActionEvent): void;
  92309. /** @hidden */
  92310. _getEffectiveTarget(target: any, propertyPath: string): any;
  92311. /** @hidden */
  92312. _getProperty(propertyPath: string): string;
  92313. /**
  92314. * Serialize this manager to a JSON object
  92315. * @param name defines the property name to store this manager
  92316. * @returns a JSON representation of this manager
  92317. */
  92318. serialize(name: string): any;
  92319. /**
  92320. * Creates a new ActionManager from a JSON data
  92321. * @param parsedActions defines the JSON data to read from
  92322. * @param object defines the hosting mesh
  92323. * @param scene defines the hosting scene
  92324. */
  92325. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  92326. /**
  92327. * Get a trigger name by index
  92328. * @param trigger defines the trigger index
  92329. * @returns a trigger name
  92330. */
  92331. static GetTriggerName(trigger: number): string;
  92332. }
  92333. }
  92334. declare module BABYLON {
  92335. /**
  92336. * Class used to represent a sprite
  92337. * @see http://doc.babylonjs.com/babylon101/sprites
  92338. */
  92339. export class Sprite {
  92340. /** defines the name */
  92341. name: string;
  92342. /** Gets or sets the current world position */
  92343. position: Vector3;
  92344. /** Gets or sets the main color */
  92345. color: Color4;
  92346. /** Gets or sets the width */
  92347. width: number;
  92348. /** Gets or sets the height */
  92349. height: number;
  92350. /** Gets or sets rotation angle */
  92351. angle: number;
  92352. /** Gets or sets the cell index in the sprite sheet */
  92353. cellIndex: number;
  92354. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  92355. cellRef: string;
  92356. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  92357. invertU: number;
  92358. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  92359. invertV: number;
  92360. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  92361. disposeWhenFinishedAnimating: boolean;
  92362. /** Gets the list of attached animations */
  92363. animations: Animation[];
  92364. /** Gets or sets a boolean indicating if the sprite can be picked */
  92365. isPickable: boolean;
  92366. /**
  92367. * Gets or sets the associated action manager
  92368. */
  92369. actionManager: Nullable<ActionManager>;
  92370. private _animationStarted;
  92371. private _loopAnimation;
  92372. private _fromIndex;
  92373. private _toIndex;
  92374. private _delay;
  92375. private _direction;
  92376. private _manager;
  92377. private _time;
  92378. private _onAnimationEnd;
  92379. /**
  92380. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  92381. */
  92382. isVisible: boolean;
  92383. /**
  92384. * Gets or sets the sprite size
  92385. */
  92386. get size(): number;
  92387. set size(value: number);
  92388. /**
  92389. * Creates a new Sprite
  92390. * @param name defines the name
  92391. * @param manager defines the manager
  92392. */
  92393. constructor(
  92394. /** defines the name */
  92395. name: string, manager: ISpriteManager);
  92396. /**
  92397. * Starts an animation
  92398. * @param from defines the initial key
  92399. * @param to defines the end key
  92400. * @param loop defines if the animation must loop
  92401. * @param delay defines the start delay (in ms)
  92402. * @param onAnimationEnd defines a callback to call when animation ends
  92403. */
  92404. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  92405. /** Stops current animation (if any) */
  92406. stopAnimation(): void;
  92407. /** @hidden */
  92408. _animate(deltaTime: number): void;
  92409. /** Release associated resources */
  92410. dispose(): void;
  92411. }
  92412. }
  92413. declare module BABYLON {
  92414. /**
  92415. * Information about the result of picking within a scene
  92416. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  92417. */
  92418. export class PickingInfo {
  92419. /** @hidden */
  92420. _pickingUnavailable: boolean;
  92421. /**
  92422. * If the pick collided with an object
  92423. */
  92424. hit: boolean;
  92425. /**
  92426. * Distance away where the pick collided
  92427. */
  92428. distance: number;
  92429. /**
  92430. * The location of pick collision
  92431. */
  92432. pickedPoint: Nullable<Vector3>;
  92433. /**
  92434. * The mesh corresponding the the pick collision
  92435. */
  92436. pickedMesh: Nullable<AbstractMesh>;
  92437. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  92438. bu: number;
  92439. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  92440. bv: number;
  92441. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  92442. faceId: number;
  92443. /** Id of the the submesh that was picked */
  92444. subMeshId: number;
  92445. /** If a sprite was picked, this will be the sprite the pick collided with */
  92446. pickedSprite: Nullable<Sprite>;
  92447. /**
  92448. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  92449. */
  92450. originMesh: Nullable<AbstractMesh>;
  92451. /**
  92452. * The ray that was used to perform the picking.
  92453. */
  92454. ray: Nullable<Ray>;
  92455. /**
  92456. * Gets the normal correspodning to the face the pick collided with
  92457. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  92458. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  92459. * @returns The normal correspodning to the face the pick collided with
  92460. */
  92461. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  92462. /**
  92463. * Gets the texture coordinates of where the pick occured
  92464. * @returns the vector containing the coordnates of the texture
  92465. */
  92466. getTextureCoordinates(): Nullable<Vector2>;
  92467. }
  92468. }
  92469. declare module BABYLON {
  92470. /**
  92471. * Gather the list of pointer event types as constants.
  92472. */
  92473. export class PointerEventTypes {
  92474. /**
  92475. * 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.
  92476. */
  92477. static readonly POINTERDOWN: number;
  92478. /**
  92479. * The pointerup event is fired when a pointer is no longer active.
  92480. */
  92481. static readonly POINTERUP: number;
  92482. /**
  92483. * The pointermove event is fired when a pointer changes coordinates.
  92484. */
  92485. static readonly POINTERMOVE: number;
  92486. /**
  92487. * The pointerwheel event is fired when a mouse wheel has been rotated.
  92488. */
  92489. static readonly POINTERWHEEL: number;
  92490. /**
  92491. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  92492. */
  92493. static readonly POINTERPICK: number;
  92494. /**
  92495. * The pointertap event is fired when a the object has been touched and released without drag.
  92496. */
  92497. static readonly POINTERTAP: number;
  92498. /**
  92499. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  92500. */
  92501. static readonly POINTERDOUBLETAP: number;
  92502. }
  92503. /**
  92504. * Base class of pointer info types.
  92505. */
  92506. export class PointerInfoBase {
  92507. /**
  92508. * Defines the type of event (PointerEventTypes)
  92509. */
  92510. type: number;
  92511. /**
  92512. * Defines the related dom event
  92513. */
  92514. event: PointerEvent | MouseWheelEvent;
  92515. /**
  92516. * Instantiates the base class of pointers info.
  92517. * @param type Defines the type of event (PointerEventTypes)
  92518. * @param event Defines the related dom event
  92519. */
  92520. constructor(
  92521. /**
  92522. * Defines the type of event (PointerEventTypes)
  92523. */
  92524. type: number,
  92525. /**
  92526. * Defines the related dom event
  92527. */
  92528. event: PointerEvent | MouseWheelEvent);
  92529. }
  92530. /**
  92531. * This class is used to store pointer related info for the onPrePointerObservable event.
  92532. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  92533. */
  92534. export class PointerInfoPre extends PointerInfoBase {
  92535. /**
  92536. * Ray from a pointer if availible (eg. 6dof controller)
  92537. */
  92538. ray: Nullable<Ray>;
  92539. /**
  92540. * Defines the local position of the pointer on the canvas.
  92541. */
  92542. localPosition: Vector2;
  92543. /**
  92544. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  92545. */
  92546. skipOnPointerObservable: boolean;
  92547. /**
  92548. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  92549. * @param type Defines the type of event (PointerEventTypes)
  92550. * @param event Defines the related dom event
  92551. * @param localX Defines the local x coordinates of the pointer when the event occured
  92552. * @param localY Defines the local y coordinates of the pointer when the event occured
  92553. */
  92554. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  92555. }
  92556. /**
  92557. * This type contains all the data related to a pointer event in Babylon.js.
  92558. * 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.
  92559. */
  92560. export class PointerInfo extends PointerInfoBase {
  92561. /**
  92562. * Defines the picking info associated to the info (if any)\
  92563. */
  92564. pickInfo: Nullable<PickingInfo>;
  92565. /**
  92566. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  92567. * @param type Defines the type of event (PointerEventTypes)
  92568. * @param event Defines the related dom event
  92569. * @param pickInfo Defines the picking info associated to the info (if any)\
  92570. */
  92571. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  92572. /**
  92573. * Defines the picking info associated to the info (if any)\
  92574. */
  92575. pickInfo: Nullable<PickingInfo>);
  92576. }
  92577. /**
  92578. * Data relating to a touch event on the screen.
  92579. */
  92580. export interface PointerTouch {
  92581. /**
  92582. * X coordinate of touch.
  92583. */
  92584. x: number;
  92585. /**
  92586. * Y coordinate of touch.
  92587. */
  92588. y: number;
  92589. /**
  92590. * Id of touch. Unique for each finger.
  92591. */
  92592. pointerId: number;
  92593. /**
  92594. * Event type passed from DOM.
  92595. */
  92596. type: any;
  92597. }
  92598. }
  92599. declare module BABYLON {
  92600. /**
  92601. * Manage the mouse inputs to control the movement of a free camera.
  92602. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92603. */
  92604. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  92605. /**
  92606. * Define if touch is enabled in the mouse input
  92607. */
  92608. touchEnabled: boolean;
  92609. /**
  92610. * Defines the camera the input is attached to.
  92611. */
  92612. camera: FreeCamera;
  92613. /**
  92614. * Defines the buttons associated with the input to handle camera move.
  92615. */
  92616. buttons: number[];
  92617. /**
  92618. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  92619. */
  92620. angularSensibility: number;
  92621. private _pointerInput;
  92622. private _onMouseMove;
  92623. private _observer;
  92624. private previousPosition;
  92625. /**
  92626. * Observable for when a pointer move event occurs containing the move offset
  92627. */
  92628. onPointerMovedObservable: Observable<{
  92629. offsetX: number;
  92630. offsetY: number;
  92631. }>;
  92632. /**
  92633. * @hidden
  92634. * If the camera should be rotated automatically based on pointer movement
  92635. */
  92636. _allowCameraRotation: boolean;
  92637. /**
  92638. * Manage the mouse inputs to control the movement of a free camera.
  92639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92640. * @param touchEnabled Defines if touch is enabled or not
  92641. */
  92642. constructor(
  92643. /**
  92644. * Define if touch is enabled in the mouse input
  92645. */
  92646. touchEnabled?: boolean);
  92647. /**
  92648. * Attach the input controls to a specific dom element to get the input from.
  92649. * @param element Defines the element the controls should be listened from
  92650. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92651. */
  92652. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92653. /**
  92654. * Called on JS contextmenu event.
  92655. * Override this method to provide functionality.
  92656. */
  92657. protected onContextMenu(evt: PointerEvent): void;
  92658. /**
  92659. * Detach the current controls from the specified dom element.
  92660. * @param element Defines the element to stop listening the inputs from
  92661. */
  92662. detachControl(element: Nullable<HTMLElement>): void;
  92663. /**
  92664. * Gets the class name of the current intput.
  92665. * @returns the class name
  92666. */
  92667. getClassName(): string;
  92668. /**
  92669. * Get the friendly name associated with the input class.
  92670. * @returns the input friendly name
  92671. */
  92672. getSimpleName(): string;
  92673. }
  92674. }
  92675. declare module BABYLON {
  92676. /**
  92677. * Manage the touch inputs to control the movement of a free camera.
  92678. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92679. */
  92680. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  92681. /**
  92682. * Defines the camera the input is attached to.
  92683. */
  92684. camera: FreeCamera;
  92685. /**
  92686. * Defines the touch sensibility for rotation.
  92687. * The higher the faster.
  92688. */
  92689. touchAngularSensibility: number;
  92690. /**
  92691. * Defines the touch sensibility for move.
  92692. * The higher the faster.
  92693. */
  92694. touchMoveSensibility: number;
  92695. private _offsetX;
  92696. private _offsetY;
  92697. private _pointerPressed;
  92698. private _pointerInput;
  92699. private _observer;
  92700. private _onLostFocus;
  92701. /**
  92702. * Attach the input controls to a specific dom element to get the input from.
  92703. * @param element Defines the element the controls should be listened from
  92704. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92705. */
  92706. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92707. /**
  92708. * Detach the current controls from the specified dom element.
  92709. * @param element Defines the element to stop listening the inputs from
  92710. */
  92711. detachControl(element: Nullable<HTMLElement>): void;
  92712. /**
  92713. * Update the current camera state depending on the inputs that have been used this frame.
  92714. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  92715. */
  92716. checkInputs(): void;
  92717. /**
  92718. * Gets the class name of the current intput.
  92719. * @returns the class name
  92720. */
  92721. getClassName(): string;
  92722. /**
  92723. * Get the friendly name associated with the input class.
  92724. * @returns the input friendly name
  92725. */
  92726. getSimpleName(): string;
  92727. }
  92728. }
  92729. declare module BABYLON {
  92730. /**
  92731. * Default Inputs manager for the FreeCamera.
  92732. * It groups all the default supported inputs for ease of use.
  92733. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  92734. */
  92735. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  92736. /**
  92737. * @hidden
  92738. */
  92739. _mouseInput: Nullable<FreeCameraMouseInput>;
  92740. /**
  92741. * Instantiates a new FreeCameraInputsManager.
  92742. * @param camera Defines the camera the inputs belong to
  92743. */
  92744. constructor(camera: FreeCamera);
  92745. /**
  92746. * Add keyboard input support to the input manager.
  92747. * @returns the current input manager
  92748. */
  92749. addKeyboard(): FreeCameraInputsManager;
  92750. /**
  92751. * Add mouse input support to the input manager.
  92752. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  92753. * @returns the current input manager
  92754. */
  92755. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  92756. /**
  92757. * Removes the mouse input support from the manager
  92758. * @returns the current input manager
  92759. */
  92760. removeMouse(): FreeCameraInputsManager;
  92761. /**
  92762. * Add touch input support to the input manager.
  92763. * @returns the current input manager
  92764. */
  92765. addTouch(): FreeCameraInputsManager;
  92766. /**
  92767. * Remove all attached input methods from a camera
  92768. */
  92769. clear(): void;
  92770. }
  92771. }
  92772. declare module BABYLON {
  92773. /**
  92774. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92775. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  92776. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92777. */
  92778. export class FreeCamera extends TargetCamera {
  92779. /**
  92780. * Define the collision ellipsoid of the camera.
  92781. * This is helpful to simulate a camera body like the player body around the camera
  92782. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  92783. */
  92784. ellipsoid: Vector3;
  92785. /**
  92786. * Define an offset for the position of the ellipsoid around the camera.
  92787. * This can be helpful to determine the center of the body near the gravity center of the body
  92788. * instead of its head.
  92789. */
  92790. ellipsoidOffset: Vector3;
  92791. /**
  92792. * Enable or disable collisions of the camera with the rest of the scene objects.
  92793. */
  92794. checkCollisions: boolean;
  92795. /**
  92796. * Enable or disable gravity on the camera.
  92797. */
  92798. applyGravity: boolean;
  92799. /**
  92800. * Define the input manager associated to the camera.
  92801. */
  92802. inputs: FreeCameraInputsManager;
  92803. /**
  92804. * Gets the input sensibility for a mouse input. (default is 2000.0)
  92805. * Higher values reduce sensitivity.
  92806. */
  92807. get angularSensibility(): number;
  92808. /**
  92809. * Sets the input sensibility for a mouse input. (default is 2000.0)
  92810. * Higher values reduce sensitivity.
  92811. */
  92812. set angularSensibility(value: number);
  92813. /**
  92814. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  92815. */
  92816. get keysUp(): number[];
  92817. set keysUp(value: number[]);
  92818. /**
  92819. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  92820. */
  92821. get keysUpward(): number[];
  92822. set keysUpward(value: number[]);
  92823. /**
  92824. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  92825. */
  92826. get keysDown(): number[];
  92827. set keysDown(value: number[]);
  92828. /**
  92829. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  92830. */
  92831. get keysDownward(): number[];
  92832. set keysDownward(value: number[]);
  92833. /**
  92834. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  92835. */
  92836. get keysLeft(): number[];
  92837. set keysLeft(value: number[]);
  92838. /**
  92839. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  92840. */
  92841. get keysRight(): number[];
  92842. set keysRight(value: number[]);
  92843. /**
  92844. * Event raised when the camera collide with a mesh in the scene.
  92845. */
  92846. onCollide: (collidedMesh: AbstractMesh) => void;
  92847. private _collider;
  92848. private _needMoveForGravity;
  92849. private _oldPosition;
  92850. private _diffPosition;
  92851. private _newPosition;
  92852. /** @hidden */
  92853. _localDirection: Vector3;
  92854. /** @hidden */
  92855. _transformedDirection: Vector3;
  92856. /**
  92857. * Instantiates a Free Camera.
  92858. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  92859. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  92860. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  92861. * @param name Define the name of the camera in the scene
  92862. * @param position Define the start position of the camera in the scene
  92863. * @param scene Define the scene the camera belongs to
  92864. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  92865. */
  92866. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  92867. /**
  92868. * Attached controls to the current camera.
  92869. * @param element Defines the element the controls should be listened from
  92870. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  92871. */
  92872. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  92873. /**
  92874. * Detach the current controls from the camera.
  92875. * The camera will stop reacting to inputs.
  92876. * @param element Defines the element to stop listening the inputs from
  92877. */
  92878. detachControl(element: HTMLElement): void;
  92879. private _collisionMask;
  92880. /**
  92881. * Define a collision mask to limit the list of object the camera can collide with
  92882. */
  92883. get collisionMask(): number;
  92884. set collisionMask(mask: number);
  92885. /** @hidden */
  92886. _collideWithWorld(displacement: Vector3): void;
  92887. private _onCollisionPositionChange;
  92888. /** @hidden */
  92889. _checkInputs(): void;
  92890. /** @hidden */
  92891. _decideIfNeedsToMove(): boolean;
  92892. /** @hidden */
  92893. _updatePosition(): void;
  92894. /**
  92895. * Destroy the camera and release the current resources hold by it.
  92896. */
  92897. dispose(): void;
  92898. /**
  92899. * Gets the current object class name.
  92900. * @return the class name
  92901. */
  92902. getClassName(): string;
  92903. }
  92904. }
  92905. declare module BABYLON {
  92906. /**
  92907. * Represents a gamepad control stick position
  92908. */
  92909. export class StickValues {
  92910. /**
  92911. * The x component of the control stick
  92912. */
  92913. x: number;
  92914. /**
  92915. * The y component of the control stick
  92916. */
  92917. y: number;
  92918. /**
  92919. * Initializes the gamepad x and y control stick values
  92920. * @param x The x component of the gamepad control stick value
  92921. * @param y The y component of the gamepad control stick value
  92922. */
  92923. constructor(
  92924. /**
  92925. * The x component of the control stick
  92926. */
  92927. x: number,
  92928. /**
  92929. * The y component of the control stick
  92930. */
  92931. y: number);
  92932. }
  92933. /**
  92934. * An interface which manages callbacks for gamepad button changes
  92935. */
  92936. export interface GamepadButtonChanges {
  92937. /**
  92938. * Called when a gamepad has been changed
  92939. */
  92940. changed: boolean;
  92941. /**
  92942. * Called when a gamepad press event has been triggered
  92943. */
  92944. pressChanged: boolean;
  92945. /**
  92946. * Called when a touch event has been triggered
  92947. */
  92948. touchChanged: boolean;
  92949. /**
  92950. * Called when a value has changed
  92951. */
  92952. valueChanged: boolean;
  92953. }
  92954. /**
  92955. * Represents a gamepad
  92956. */
  92957. export class Gamepad {
  92958. /**
  92959. * The id of the gamepad
  92960. */
  92961. id: string;
  92962. /**
  92963. * The index of the gamepad
  92964. */
  92965. index: number;
  92966. /**
  92967. * The browser gamepad
  92968. */
  92969. browserGamepad: any;
  92970. /**
  92971. * Specifies what type of gamepad this represents
  92972. */
  92973. type: number;
  92974. private _leftStick;
  92975. private _rightStick;
  92976. /** @hidden */
  92977. _isConnected: boolean;
  92978. private _leftStickAxisX;
  92979. private _leftStickAxisY;
  92980. private _rightStickAxisX;
  92981. private _rightStickAxisY;
  92982. /**
  92983. * Triggered when the left control stick has been changed
  92984. */
  92985. private _onleftstickchanged;
  92986. /**
  92987. * Triggered when the right control stick has been changed
  92988. */
  92989. private _onrightstickchanged;
  92990. /**
  92991. * Represents a gamepad controller
  92992. */
  92993. static GAMEPAD: number;
  92994. /**
  92995. * Represents a generic controller
  92996. */
  92997. static GENERIC: number;
  92998. /**
  92999. * Represents an XBox controller
  93000. */
  93001. static XBOX: number;
  93002. /**
  93003. * Represents a pose-enabled controller
  93004. */
  93005. static POSE_ENABLED: number;
  93006. /**
  93007. * Represents an Dual Shock controller
  93008. */
  93009. static DUALSHOCK: number;
  93010. /**
  93011. * Specifies whether the left control stick should be Y-inverted
  93012. */
  93013. protected _invertLeftStickY: boolean;
  93014. /**
  93015. * Specifies if the gamepad has been connected
  93016. */
  93017. get isConnected(): boolean;
  93018. /**
  93019. * Initializes the gamepad
  93020. * @param id The id of the gamepad
  93021. * @param index The index of the gamepad
  93022. * @param browserGamepad The browser gamepad
  93023. * @param leftStickX The x component of the left joystick
  93024. * @param leftStickY The y component of the left joystick
  93025. * @param rightStickX The x component of the right joystick
  93026. * @param rightStickY The y component of the right joystick
  93027. */
  93028. constructor(
  93029. /**
  93030. * The id of the gamepad
  93031. */
  93032. id: string,
  93033. /**
  93034. * The index of the gamepad
  93035. */
  93036. index: number,
  93037. /**
  93038. * The browser gamepad
  93039. */
  93040. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  93041. /**
  93042. * Callback triggered when the left joystick has changed
  93043. * @param callback
  93044. */
  93045. onleftstickchanged(callback: (values: StickValues) => void): void;
  93046. /**
  93047. * Callback triggered when the right joystick has changed
  93048. * @param callback
  93049. */
  93050. onrightstickchanged(callback: (values: StickValues) => void): void;
  93051. /**
  93052. * Gets the left joystick
  93053. */
  93054. get leftStick(): StickValues;
  93055. /**
  93056. * Sets the left joystick values
  93057. */
  93058. set leftStick(newValues: StickValues);
  93059. /**
  93060. * Gets the right joystick
  93061. */
  93062. get rightStick(): StickValues;
  93063. /**
  93064. * Sets the right joystick value
  93065. */
  93066. set rightStick(newValues: StickValues);
  93067. /**
  93068. * Updates the gamepad joystick positions
  93069. */
  93070. update(): void;
  93071. /**
  93072. * Disposes the gamepad
  93073. */
  93074. dispose(): void;
  93075. }
  93076. /**
  93077. * Represents a generic gamepad
  93078. */
  93079. export class GenericPad extends Gamepad {
  93080. private _buttons;
  93081. private _onbuttondown;
  93082. private _onbuttonup;
  93083. /**
  93084. * Observable triggered when a button has been pressed
  93085. */
  93086. onButtonDownObservable: Observable<number>;
  93087. /**
  93088. * Observable triggered when a button has been released
  93089. */
  93090. onButtonUpObservable: Observable<number>;
  93091. /**
  93092. * Callback triggered when a button has been pressed
  93093. * @param callback Called when a button has been pressed
  93094. */
  93095. onbuttondown(callback: (buttonPressed: number) => void): void;
  93096. /**
  93097. * Callback triggered when a button has been released
  93098. * @param callback Called when a button has been released
  93099. */
  93100. onbuttonup(callback: (buttonReleased: number) => void): void;
  93101. /**
  93102. * Initializes the generic gamepad
  93103. * @param id The id of the generic gamepad
  93104. * @param index The index of the generic gamepad
  93105. * @param browserGamepad The browser gamepad
  93106. */
  93107. constructor(id: string, index: number, browserGamepad: any);
  93108. private _setButtonValue;
  93109. /**
  93110. * Updates the generic gamepad
  93111. */
  93112. update(): void;
  93113. /**
  93114. * Disposes the generic gamepad
  93115. */
  93116. dispose(): void;
  93117. }
  93118. }
  93119. declare module BABYLON {
  93120. /**
  93121. * Defines the types of pose enabled controllers that are supported
  93122. */
  93123. export enum PoseEnabledControllerType {
  93124. /**
  93125. * HTC Vive
  93126. */
  93127. VIVE = 0,
  93128. /**
  93129. * Oculus Rift
  93130. */
  93131. OCULUS = 1,
  93132. /**
  93133. * Windows mixed reality
  93134. */
  93135. WINDOWS = 2,
  93136. /**
  93137. * Samsung gear VR
  93138. */
  93139. GEAR_VR = 3,
  93140. /**
  93141. * Google Daydream
  93142. */
  93143. DAYDREAM = 4,
  93144. /**
  93145. * Generic
  93146. */
  93147. GENERIC = 5
  93148. }
  93149. /**
  93150. * Defines the MutableGamepadButton interface for the state of a gamepad button
  93151. */
  93152. export interface MutableGamepadButton {
  93153. /**
  93154. * Value of the button/trigger
  93155. */
  93156. value: number;
  93157. /**
  93158. * If the button/trigger is currently touched
  93159. */
  93160. touched: boolean;
  93161. /**
  93162. * If the button/trigger is currently pressed
  93163. */
  93164. pressed: boolean;
  93165. }
  93166. /**
  93167. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  93168. * @hidden
  93169. */
  93170. export interface ExtendedGamepadButton extends GamepadButton {
  93171. /**
  93172. * If the button/trigger is currently pressed
  93173. */
  93174. readonly pressed: boolean;
  93175. /**
  93176. * If the button/trigger is currently touched
  93177. */
  93178. readonly touched: boolean;
  93179. /**
  93180. * Value of the button/trigger
  93181. */
  93182. readonly value: number;
  93183. }
  93184. /** @hidden */
  93185. export interface _GamePadFactory {
  93186. /**
  93187. * Returns whether or not the current gamepad can be created for this type of controller.
  93188. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93189. * @returns true if it can be created, otherwise false
  93190. */
  93191. canCreate(gamepadInfo: any): boolean;
  93192. /**
  93193. * Creates a new instance of the Gamepad.
  93194. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  93195. * @returns the new gamepad instance
  93196. */
  93197. create(gamepadInfo: any): Gamepad;
  93198. }
  93199. /**
  93200. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93201. */
  93202. export class PoseEnabledControllerHelper {
  93203. /** @hidden */
  93204. static _ControllerFactories: _GamePadFactory[];
  93205. /** @hidden */
  93206. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  93207. /**
  93208. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  93209. * @param vrGamepad the gamepad to initialized
  93210. * @returns a vr controller of the type the gamepad identified as
  93211. */
  93212. static InitiateController(vrGamepad: any): Gamepad;
  93213. }
  93214. /**
  93215. * Defines the PoseEnabledController object that contains state of a vr capable controller
  93216. */
  93217. export class PoseEnabledController extends Gamepad implements PoseControlled {
  93218. /**
  93219. * If the controller is used in a webXR session
  93220. */
  93221. isXR: boolean;
  93222. private _deviceRoomPosition;
  93223. private _deviceRoomRotationQuaternion;
  93224. /**
  93225. * The device position in babylon space
  93226. */
  93227. devicePosition: Vector3;
  93228. /**
  93229. * The device rotation in babylon space
  93230. */
  93231. deviceRotationQuaternion: Quaternion;
  93232. /**
  93233. * The scale factor of the device in babylon space
  93234. */
  93235. deviceScaleFactor: number;
  93236. /**
  93237. * (Likely devicePosition should be used instead) The device position in its room space
  93238. */
  93239. position: Vector3;
  93240. /**
  93241. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  93242. */
  93243. rotationQuaternion: Quaternion;
  93244. /**
  93245. * The type of controller (Eg. Windows mixed reality)
  93246. */
  93247. controllerType: PoseEnabledControllerType;
  93248. protected _calculatedPosition: Vector3;
  93249. private _calculatedRotation;
  93250. /**
  93251. * The raw pose from the device
  93252. */
  93253. rawPose: DevicePose;
  93254. private _trackPosition;
  93255. private _maxRotationDistFromHeadset;
  93256. private _draggedRoomRotation;
  93257. /**
  93258. * @hidden
  93259. */
  93260. _disableTrackPosition(fixedPosition: Vector3): void;
  93261. /**
  93262. * Internal, the mesh attached to the controller
  93263. * @hidden
  93264. */
  93265. _mesh: Nullable<AbstractMesh>;
  93266. private _poseControlledCamera;
  93267. private _leftHandSystemQuaternion;
  93268. /**
  93269. * Internal, matrix used to convert room space to babylon space
  93270. * @hidden
  93271. */
  93272. _deviceToWorld: Matrix;
  93273. /**
  93274. * Node to be used when casting a ray from the controller
  93275. * @hidden
  93276. */
  93277. _pointingPoseNode: Nullable<TransformNode>;
  93278. /**
  93279. * Name of the child mesh that can be used to cast a ray from the controller
  93280. */
  93281. static readonly POINTING_POSE: string;
  93282. /**
  93283. * Creates a new PoseEnabledController from a gamepad
  93284. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  93285. */
  93286. constructor(browserGamepad: any);
  93287. private _workingMatrix;
  93288. /**
  93289. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  93290. */
  93291. update(): void;
  93292. /**
  93293. * Updates only the pose device and mesh without doing any button event checking
  93294. */
  93295. protected _updatePoseAndMesh(): void;
  93296. /**
  93297. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  93298. * @param poseData raw pose fromthe device
  93299. */
  93300. updateFromDevice(poseData: DevicePose): void;
  93301. /**
  93302. * @hidden
  93303. */
  93304. _meshAttachedObservable: Observable<AbstractMesh>;
  93305. /**
  93306. * Attaches a mesh to the controller
  93307. * @param mesh the mesh to be attached
  93308. */
  93309. attachToMesh(mesh: AbstractMesh): void;
  93310. /**
  93311. * Attaches the controllers mesh to a camera
  93312. * @param camera the camera the mesh should be attached to
  93313. */
  93314. attachToPoseControlledCamera(camera: TargetCamera): void;
  93315. /**
  93316. * Disposes of the controller
  93317. */
  93318. dispose(): void;
  93319. /**
  93320. * The mesh that is attached to the controller
  93321. */
  93322. get mesh(): Nullable<AbstractMesh>;
  93323. /**
  93324. * Gets the ray of the controller in the direction the controller is pointing
  93325. * @param length the length the resulting ray should be
  93326. * @returns a ray in the direction the controller is pointing
  93327. */
  93328. getForwardRay(length?: number): Ray;
  93329. }
  93330. }
  93331. declare module BABYLON {
  93332. /**
  93333. * Defines the WebVRController object that represents controllers tracked in 3D space
  93334. */
  93335. export abstract class WebVRController extends PoseEnabledController {
  93336. /**
  93337. * Internal, the default controller model for the controller
  93338. */
  93339. protected _defaultModel: Nullable<AbstractMesh>;
  93340. /**
  93341. * Fired when the trigger state has changed
  93342. */
  93343. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  93344. /**
  93345. * Fired when the main button state has changed
  93346. */
  93347. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93348. /**
  93349. * Fired when the secondary button state has changed
  93350. */
  93351. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  93352. /**
  93353. * Fired when the pad state has changed
  93354. */
  93355. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  93356. /**
  93357. * Fired when controllers stick values have changed
  93358. */
  93359. onPadValuesChangedObservable: Observable<StickValues>;
  93360. /**
  93361. * Array of button availible on the controller
  93362. */
  93363. protected _buttons: Array<MutableGamepadButton>;
  93364. private _onButtonStateChange;
  93365. /**
  93366. * Fired when a controller button's state has changed
  93367. * @param callback the callback containing the button that was modified
  93368. */
  93369. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  93370. /**
  93371. * X and Y axis corresponding to the controllers joystick
  93372. */
  93373. pad: StickValues;
  93374. /**
  93375. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  93376. */
  93377. hand: string;
  93378. /**
  93379. * The default controller model for the controller
  93380. */
  93381. get defaultModel(): Nullable<AbstractMesh>;
  93382. /**
  93383. * Creates a new WebVRController from a gamepad
  93384. * @param vrGamepad the gamepad that the WebVRController should be created from
  93385. */
  93386. constructor(vrGamepad: any);
  93387. /**
  93388. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  93389. */
  93390. update(): void;
  93391. /**
  93392. * Function to be called when a button is modified
  93393. */
  93394. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  93395. /**
  93396. * Loads a mesh and attaches it to the controller
  93397. * @param scene the scene the mesh should be added to
  93398. * @param meshLoaded callback for when the mesh has been loaded
  93399. */
  93400. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  93401. private _setButtonValue;
  93402. private _changes;
  93403. private _checkChanges;
  93404. /**
  93405. * Disposes of th webVRCOntroller
  93406. */
  93407. dispose(): void;
  93408. }
  93409. }
  93410. declare module BABYLON {
  93411. /**
  93412. * The HemisphericLight simulates the ambient environment light,
  93413. * so the passed direction is the light reflection direction, not the incoming direction.
  93414. */
  93415. export class HemisphericLight extends Light {
  93416. /**
  93417. * The groundColor is the light in the opposite direction to the one specified during creation.
  93418. * 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.
  93419. */
  93420. groundColor: Color3;
  93421. /**
  93422. * The light reflection direction, not the incoming direction.
  93423. */
  93424. direction: Vector3;
  93425. /**
  93426. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  93427. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  93428. * The HemisphericLight can't cast shadows.
  93429. * Documentation : https://doc.babylonjs.com/babylon101/lights
  93430. * @param name The friendly name of the light
  93431. * @param direction The direction of the light reflection
  93432. * @param scene The scene the light belongs to
  93433. */
  93434. constructor(name: string, direction: Vector3, scene: Scene);
  93435. protected _buildUniformLayout(): void;
  93436. /**
  93437. * Returns the string "HemisphericLight".
  93438. * @return The class name
  93439. */
  93440. getClassName(): string;
  93441. /**
  93442. * Sets the HemisphericLight direction towards the passed target (Vector3).
  93443. * Returns the updated direction.
  93444. * @param target The target the direction should point to
  93445. * @return The computed direction
  93446. */
  93447. setDirectionToTarget(target: Vector3): Vector3;
  93448. /**
  93449. * Returns the shadow generator associated to the light.
  93450. * @returns Always null for hemispheric lights because it does not support shadows.
  93451. */
  93452. getShadowGenerator(): Nullable<IShadowGenerator>;
  93453. /**
  93454. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  93455. * @param effect The effect to update
  93456. * @param lightIndex The index of the light in the effect to update
  93457. * @returns The hemispheric light
  93458. */
  93459. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  93460. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  93461. /**
  93462. * Computes the world matrix of the node
  93463. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  93464. * @param useWasUpdatedFlag defines a reserved property
  93465. * @returns the world matrix
  93466. */
  93467. computeWorldMatrix(): Matrix;
  93468. /**
  93469. * Returns the integer 3.
  93470. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  93471. */
  93472. getTypeID(): number;
  93473. /**
  93474. * Prepares the list of defines specific to the light type.
  93475. * @param defines the list of defines
  93476. * @param lightIndex defines the index of the light for the effect
  93477. */
  93478. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  93479. }
  93480. }
  93481. declare module BABYLON {
  93482. /** @hidden */
  93483. export var vrMultiviewToSingleviewPixelShader: {
  93484. name: string;
  93485. shader: string;
  93486. };
  93487. }
  93488. declare module BABYLON {
  93489. /**
  93490. * Renders to multiple views with a single draw call
  93491. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  93492. */
  93493. export class MultiviewRenderTarget extends RenderTargetTexture {
  93494. /**
  93495. * Creates a multiview render target
  93496. * @param scene scene used with the render target
  93497. * @param size the size of the render target (used for each view)
  93498. */
  93499. constructor(scene: Scene, size?: number | {
  93500. width: number;
  93501. height: number;
  93502. } | {
  93503. ratio: number;
  93504. });
  93505. /**
  93506. * @hidden
  93507. * @param faceIndex the face index, if its a cube texture
  93508. */
  93509. _bindFrameBuffer(faceIndex?: number): void;
  93510. /**
  93511. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  93512. * @returns the view count
  93513. */
  93514. getViewCount(): number;
  93515. }
  93516. }
  93517. declare module BABYLON {
  93518. /**
  93519. * Represents a camera frustum
  93520. */
  93521. export class Frustum {
  93522. /**
  93523. * Gets the planes representing the frustum
  93524. * @param transform matrix to be applied to the returned planes
  93525. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  93526. */
  93527. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  93528. /**
  93529. * Gets the near frustum plane transformed by the transform matrix
  93530. * @param transform transformation matrix to be applied to the resulting frustum plane
  93531. * @param frustumPlane the resuling frustum plane
  93532. */
  93533. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93534. /**
  93535. * Gets the far frustum plane transformed by the transform matrix
  93536. * @param transform transformation matrix to be applied to the resulting frustum plane
  93537. * @param frustumPlane the resuling frustum plane
  93538. */
  93539. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93540. /**
  93541. * Gets the left frustum plane transformed by the transform matrix
  93542. * @param transform transformation matrix to be applied to the resulting frustum plane
  93543. * @param frustumPlane the resuling frustum plane
  93544. */
  93545. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93546. /**
  93547. * Gets the right frustum plane transformed by the transform matrix
  93548. * @param transform transformation matrix to be applied to the resulting frustum plane
  93549. * @param frustumPlane the resuling frustum plane
  93550. */
  93551. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93552. /**
  93553. * Gets the top frustum plane transformed by the transform matrix
  93554. * @param transform transformation matrix to be applied to the resulting frustum plane
  93555. * @param frustumPlane the resuling frustum plane
  93556. */
  93557. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93558. /**
  93559. * Gets the bottom frustum plane transformed by the transform matrix
  93560. * @param transform transformation matrix to be applied to the resulting frustum plane
  93561. * @param frustumPlane the resuling frustum plane
  93562. */
  93563. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  93564. /**
  93565. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  93566. * @param transform transformation matrix to be applied to the resulting frustum planes
  93567. * @param frustumPlanes the resuling frustum planes
  93568. */
  93569. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  93570. }
  93571. }
  93572. declare module BABYLON {
  93573. interface Engine {
  93574. /**
  93575. * Creates a new multiview render target
  93576. * @param width defines the width of the texture
  93577. * @param height defines the height of the texture
  93578. * @returns the created multiview texture
  93579. */
  93580. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  93581. /**
  93582. * Binds a multiview framebuffer to be drawn to
  93583. * @param multiviewTexture texture to bind
  93584. */
  93585. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  93586. }
  93587. interface Camera {
  93588. /**
  93589. * @hidden
  93590. * 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)
  93591. */
  93592. _useMultiviewToSingleView: boolean;
  93593. /**
  93594. * @hidden
  93595. * 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)
  93596. */
  93597. _multiviewTexture: Nullable<RenderTargetTexture>;
  93598. /**
  93599. * @hidden
  93600. * ensures the multiview texture of the camera exists and has the specified width/height
  93601. * @param width height to set on the multiview texture
  93602. * @param height width to set on the multiview texture
  93603. */
  93604. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  93605. }
  93606. interface Scene {
  93607. /** @hidden */
  93608. _transformMatrixR: Matrix;
  93609. /** @hidden */
  93610. _multiviewSceneUbo: Nullable<UniformBuffer>;
  93611. /** @hidden */
  93612. _createMultiviewUbo(): void;
  93613. /** @hidden */
  93614. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  93615. /** @hidden */
  93616. _renderMultiviewToSingleView(camera: Camera): void;
  93617. }
  93618. }
  93619. declare module BABYLON {
  93620. /**
  93621. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  93622. * This will not be used for webXR as it supports displaying texture arrays directly
  93623. */
  93624. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  93625. /**
  93626. * Initializes a VRMultiviewToSingleview
  93627. * @param name name of the post process
  93628. * @param camera camera to be applied to
  93629. * @param scaleFactor scaling factor to the size of the output texture
  93630. */
  93631. constructor(name: string, camera: Camera, scaleFactor: number);
  93632. }
  93633. }
  93634. declare module BABYLON {
  93635. /**
  93636. * Interface used to define additional presentation attributes
  93637. */
  93638. export interface IVRPresentationAttributes {
  93639. /**
  93640. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  93641. */
  93642. highRefreshRate: boolean;
  93643. /**
  93644. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  93645. */
  93646. foveationLevel: number;
  93647. }
  93648. interface Engine {
  93649. /** @hidden */
  93650. _vrDisplay: any;
  93651. /** @hidden */
  93652. _vrSupported: boolean;
  93653. /** @hidden */
  93654. _oldSize: Size;
  93655. /** @hidden */
  93656. _oldHardwareScaleFactor: number;
  93657. /** @hidden */
  93658. _vrExclusivePointerMode: boolean;
  93659. /** @hidden */
  93660. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  93661. /** @hidden */
  93662. _onVRDisplayPointerRestricted: () => void;
  93663. /** @hidden */
  93664. _onVRDisplayPointerUnrestricted: () => void;
  93665. /** @hidden */
  93666. _onVrDisplayConnect: Nullable<(display: any) => void>;
  93667. /** @hidden */
  93668. _onVrDisplayDisconnect: Nullable<() => void>;
  93669. /** @hidden */
  93670. _onVrDisplayPresentChange: Nullable<() => void>;
  93671. /**
  93672. * Observable signaled when VR display mode changes
  93673. */
  93674. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  93675. /**
  93676. * Observable signaled when VR request present is complete
  93677. */
  93678. onVRRequestPresentComplete: Observable<boolean>;
  93679. /**
  93680. * Observable signaled when VR request present starts
  93681. */
  93682. onVRRequestPresentStart: Observable<Engine>;
  93683. /**
  93684. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  93685. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  93686. */
  93687. isInVRExclusivePointerMode: boolean;
  93688. /**
  93689. * Gets a boolean indicating if a webVR device was detected
  93690. * @returns true if a webVR device was detected
  93691. */
  93692. isVRDevicePresent(): boolean;
  93693. /**
  93694. * Gets the current webVR device
  93695. * @returns the current webVR device (or null)
  93696. */
  93697. getVRDevice(): any;
  93698. /**
  93699. * Initializes a webVR display and starts listening to display change events
  93700. * The onVRDisplayChangedObservable will be notified upon these changes
  93701. * @returns A promise containing a VRDisplay and if vr is supported
  93702. */
  93703. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  93704. /** @hidden */
  93705. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  93706. /**
  93707. * Gets or sets the presentation attributes used to configure VR rendering
  93708. */
  93709. vrPresentationAttributes?: IVRPresentationAttributes;
  93710. /**
  93711. * Call this function to switch to webVR mode
  93712. * Will do nothing if webVR is not supported or if there is no webVR device
  93713. * @param options the webvr options provided to the camera. mainly used for multiview
  93714. * @see http://doc.babylonjs.com/how_to/webvr_camera
  93715. */
  93716. enableVR(options: WebVROptions): void;
  93717. /** @hidden */
  93718. _onVRFullScreenTriggered(): void;
  93719. }
  93720. }
  93721. declare module BABYLON {
  93722. /**
  93723. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  93724. * IMPORTANT!! The data is right-hand data.
  93725. * @export
  93726. * @interface DevicePose
  93727. */
  93728. export interface DevicePose {
  93729. /**
  93730. * The position of the device, values in array are [x,y,z].
  93731. */
  93732. readonly position: Nullable<Float32Array>;
  93733. /**
  93734. * The linearVelocity of the device, values in array are [x,y,z].
  93735. */
  93736. readonly linearVelocity: Nullable<Float32Array>;
  93737. /**
  93738. * The linearAcceleration of the device, values in array are [x,y,z].
  93739. */
  93740. readonly linearAcceleration: Nullable<Float32Array>;
  93741. /**
  93742. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  93743. */
  93744. readonly orientation: Nullable<Float32Array>;
  93745. /**
  93746. * The angularVelocity of the device, values in array are [x,y,z].
  93747. */
  93748. readonly angularVelocity: Nullable<Float32Array>;
  93749. /**
  93750. * The angularAcceleration of the device, values in array are [x,y,z].
  93751. */
  93752. readonly angularAcceleration: Nullable<Float32Array>;
  93753. }
  93754. /**
  93755. * Interface representing a pose controlled object in Babylon.
  93756. * A pose controlled object has both regular pose values as well as pose values
  93757. * from an external device such as a VR head mounted display
  93758. */
  93759. export interface PoseControlled {
  93760. /**
  93761. * The position of the object in babylon space.
  93762. */
  93763. position: Vector3;
  93764. /**
  93765. * The rotation quaternion of the object in babylon space.
  93766. */
  93767. rotationQuaternion: Quaternion;
  93768. /**
  93769. * The position of the device in babylon space.
  93770. */
  93771. devicePosition?: Vector3;
  93772. /**
  93773. * The rotation quaternion of the device in babylon space.
  93774. */
  93775. deviceRotationQuaternion: Quaternion;
  93776. /**
  93777. * The raw pose coming from the device.
  93778. */
  93779. rawPose: Nullable<DevicePose>;
  93780. /**
  93781. * The scale of the device to be used when translating from device space to babylon space.
  93782. */
  93783. deviceScaleFactor: number;
  93784. /**
  93785. * Updates the poseControlled values based on the input device pose.
  93786. * @param poseData the pose data to update the object with
  93787. */
  93788. updateFromDevice(poseData: DevicePose): void;
  93789. }
  93790. /**
  93791. * Set of options to customize the webVRCamera
  93792. */
  93793. export interface WebVROptions {
  93794. /**
  93795. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  93796. */
  93797. trackPosition?: boolean;
  93798. /**
  93799. * Sets the scale of the vrDevice in babylon space. (default: 1)
  93800. */
  93801. positionScale?: number;
  93802. /**
  93803. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  93804. */
  93805. displayName?: string;
  93806. /**
  93807. * Should the native controller meshes be initialized. (default: true)
  93808. */
  93809. controllerMeshes?: boolean;
  93810. /**
  93811. * Creating a default HemiLight only on controllers. (default: true)
  93812. */
  93813. defaultLightingOnControllers?: boolean;
  93814. /**
  93815. * If you don't want to use the default VR button of the helper. (default: false)
  93816. */
  93817. useCustomVRButton?: boolean;
  93818. /**
  93819. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  93820. */
  93821. customVRButton?: HTMLButtonElement;
  93822. /**
  93823. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  93824. */
  93825. rayLength?: number;
  93826. /**
  93827. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  93828. */
  93829. defaultHeight?: number;
  93830. /**
  93831. * If multiview should be used if availible (default: false)
  93832. */
  93833. useMultiview?: boolean;
  93834. }
  93835. /**
  93836. * This represents a WebVR camera.
  93837. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  93838. * @example http://doc.babylonjs.com/how_to/webvr_camera
  93839. */
  93840. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  93841. private webVROptions;
  93842. /**
  93843. * @hidden
  93844. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  93845. */
  93846. _vrDevice: any;
  93847. /**
  93848. * The rawPose of the vrDevice.
  93849. */
  93850. rawPose: Nullable<DevicePose>;
  93851. private _onVREnabled;
  93852. private _specsVersion;
  93853. private _attached;
  93854. private _frameData;
  93855. protected _descendants: Array<Node>;
  93856. private _deviceRoomPosition;
  93857. /** @hidden */
  93858. _deviceRoomRotationQuaternion: Quaternion;
  93859. private _standingMatrix;
  93860. /**
  93861. * Represents device position in babylon space.
  93862. */
  93863. devicePosition: Vector3;
  93864. /**
  93865. * Represents device rotation in babylon space.
  93866. */
  93867. deviceRotationQuaternion: Quaternion;
  93868. /**
  93869. * The scale of the device to be used when translating from device space to babylon space.
  93870. */
  93871. deviceScaleFactor: number;
  93872. private _deviceToWorld;
  93873. private _worldToDevice;
  93874. /**
  93875. * References to the webVR controllers for the vrDevice.
  93876. */
  93877. controllers: Array<WebVRController>;
  93878. /**
  93879. * Emits an event when a controller is attached.
  93880. */
  93881. onControllersAttachedObservable: Observable<WebVRController[]>;
  93882. /**
  93883. * Emits an event when a controller's mesh has been loaded;
  93884. */
  93885. onControllerMeshLoadedObservable: Observable<WebVRController>;
  93886. /**
  93887. * Emits an event when the HMD's pose has been updated.
  93888. */
  93889. onPoseUpdatedFromDeviceObservable: Observable<any>;
  93890. private _poseSet;
  93891. /**
  93892. * If the rig cameras be used as parent instead of this camera.
  93893. */
  93894. rigParenting: boolean;
  93895. private _lightOnControllers;
  93896. private _defaultHeight?;
  93897. /**
  93898. * Instantiates a WebVRFreeCamera.
  93899. * @param name The name of the WebVRFreeCamera
  93900. * @param position The starting anchor position for the camera
  93901. * @param scene The scene the camera belongs to
  93902. * @param webVROptions a set of customizable options for the webVRCamera
  93903. */
  93904. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  93905. /**
  93906. * Gets the device distance from the ground in meters.
  93907. * @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.
  93908. */
  93909. deviceDistanceToRoomGround(): number;
  93910. /**
  93911. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93912. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  93913. */
  93914. useStandingMatrix(callback?: (bool: boolean) => void): void;
  93915. /**
  93916. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  93917. * @returns A promise with a boolean set to if the standing matrix is supported.
  93918. */
  93919. useStandingMatrixAsync(): Promise<boolean>;
  93920. /**
  93921. * Disposes the camera
  93922. */
  93923. dispose(): void;
  93924. /**
  93925. * Gets a vrController by name.
  93926. * @param name The name of the controller to retreive
  93927. * @returns the controller matching the name specified or null if not found
  93928. */
  93929. getControllerByName(name: string): Nullable<WebVRController>;
  93930. private _leftController;
  93931. /**
  93932. * The controller corresponding to the users left hand.
  93933. */
  93934. get leftController(): Nullable<WebVRController>;
  93935. private _rightController;
  93936. /**
  93937. * The controller corresponding to the users right hand.
  93938. */
  93939. get rightController(): Nullable<WebVRController>;
  93940. /**
  93941. * Casts a ray forward from the vrCamera's gaze.
  93942. * @param length Length of the ray (default: 100)
  93943. * @returns the ray corresponding to the gaze
  93944. */
  93945. getForwardRay(length?: number): Ray;
  93946. /**
  93947. * @hidden
  93948. * Updates the camera based on device's frame data
  93949. */
  93950. _checkInputs(): void;
  93951. /**
  93952. * Updates the poseControlled values based on the input device pose.
  93953. * @param poseData Pose coming from the device
  93954. */
  93955. updateFromDevice(poseData: DevicePose): void;
  93956. private _htmlElementAttached;
  93957. private _detachIfAttached;
  93958. /**
  93959. * WebVR's attach control will start broadcasting frames to the device.
  93960. * Note that in certain browsers (chrome for example) this function must be called
  93961. * within a user-interaction callback. Example:
  93962. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  93963. *
  93964. * @param element html element to attach the vrDevice to
  93965. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  93966. */
  93967. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  93968. /**
  93969. * Detaches the camera from the html element and disables VR
  93970. *
  93971. * @param element html element to detach from
  93972. */
  93973. detachControl(element: HTMLElement): void;
  93974. /**
  93975. * @returns the name of this class
  93976. */
  93977. getClassName(): string;
  93978. /**
  93979. * Calls resetPose on the vrDisplay
  93980. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  93981. */
  93982. resetToCurrentRotation(): void;
  93983. /**
  93984. * @hidden
  93985. * Updates the rig cameras (left and right eye)
  93986. */
  93987. _updateRigCameras(): void;
  93988. private _workingVector;
  93989. private _oneVector;
  93990. private _workingMatrix;
  93991. private updateCacheCalled;
  93992. private _correctPositionIfNotTrackPosition;
  93993. /**
  93994. * @hidden
  93995. * Updates the cached values of the camera
  93996. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  93997. */
  93998. _updateCache(ignoreParentClass?: boolean): void;
  93999. /**
  94000. * @hidden
  94001. * Get current device position in babylon world
  94002. */
  94003. _computeDevicePosition(): void;
  94004. /**
  94005. * Updates the current device position and rotation in the babylon world
  94006. */
  94007. update(): void;
  94008. /**
  94009. * @hidden
  94010. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  94011. * @returns an identity matrix
  94012. */
  94013. _getViewMatrix(): Matrix;
  94014. private _tmpMatrix;
  94015. /**
  94016. * This function is called by the two RIG cameras.
  94017. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  94018. * @hidden
  94019. */
  94020. _getWebVRViewMatrix(): Matrix;
  94021. /** @hidden */
  94022. _getWebVRProjectionMatrix(): Matrix;
  94023. private _onGamepadConnectedObserver;
  94024. private _onGamepadDisconnectedObserver;
  94025. private _updateCacheWhenTrackingDisabledObserver;
  94026. /**
  94027. * Initializes the controllers and their meshes
  94028. */
  94029. initControllers(): void;
  94030. }
  94031. }
  94032. declare module BABYLON {
  94033. /**
  94034. * Size options for a post process
  94035. */
  94036. export type PostProcessOptions = {
  94037. width: number;
  94038. height: number;
  94039. };
  94040. /**
  94041. * PostProcess can be used to apply a shader to a texture after it has been rendered
  94042. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94043. */
  94044. export class PostProcess {
  94045. /** Name of the PostProcess. */
  94046. name: string;
  94047. /**
  94048. * Gets or sets the unique id of the post process
  94049. */
  94050. uniqueId: number;
  94051. /**
  94052. * Width of the texture to apply the post process on
  94053. */
  94054. width: number;
  94055. /**
  94056. * Height of the texture to apply the post process on
  94057. */
  94058. height: number;
  94059. /**
  94060. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  94061. * @hidden
  94062. */
  94063. _outputTexture: Nullable<InternalTexture>;
  94064. /**
  94065. * Sampling mode used by the shader
  94066. * See https://doc.babylonjs.com/classes/3.1/texture
  94067. */
  94068. renderTargetSamplingMode: number;
  94069. /**
  94070. * Clear color to use when screen clearing
  94071. */
  94072. clearColor: Color4;
  94073. /**
  94074. * If the buffer needs to be cleared before applying the post process. (default: true)
  94075. * Should be set to false if shader will overwrite all previous pixels.
  94076. */
  94077. autoClear: boolean;
  94078. /**
  94079. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  94080. */
  94081. alphaMode: number;
  94082. /**
  94083. * Sets the setAlphaBlendConstants of the babylon engine
  94084. */
  94085. alphaConstants: Color4;
  94086. /**
  94087. * Animations to be used for the post processing
  94088. */
  94089. animations: Animation[];
  94090. /**
  94091. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  94092. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  94093. */
  94094. enablePixelPerfectMode: boolean;
  94095. /**
  94096. * Force the postprocess to be applied without taking in account viewport
  94097. */
  94098. forceFullscreenViewport: boolean;
  94099. /**
  94100. * List of inspectable custom properties (used by the Inspector)
  94101. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94102. */
  94103. inspectableCustomProperties: IInspectable[];
  94104. /**
  94105. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  94106. *
  94107. * | Value | Type | Description |
  94108. * | ----- | ----------------------------------- | ----------- |
  94109. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  94110. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  94111. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  94112. *
  94113. */
  94114. scaleMode: number;
  94115. /**
  94116. * Force textures to be a power of two (default: false)
  94117. */
  94118. alwaysForcePOT: boolean;
  94119. private _samples;
  94120. /**
  94121. * Number of sample textures (default: 1)
  94122. */
  94123. get samples(): number;
  94124. set samples(n: number);
  94125. /**
  94126. * Modify the scale of the post process to be the same as the viewport (default: false)
  94127. */
  94128. adaptScaleToCurrentViewport: boolean;
  94129. private _camera;
  94130. private _scene;
  94131. private _engine;
  94132. private _options;
  94133. private _reusable;
  94134. private _textureType;
  94135. private _textureFormat;
  94136. /**
  94137. * Smart array of input and output textures for the post process.
  94138. * @hidden
  94139. */
  94140. _textures: SmartArray<InternalTexture>;
  94141. /**
  94142. * The index in _textures that corresponds to the output texture.
  94143. * @hidden
  94144. */
  94145. _currentRenderTextureInd: number;
  94146. private _effect;
  94147. private _samplers;
  94148. private _fragmentUrl;
  94149. private _vertexUrl;
  94150. private _parameters;
  94151. private _scaleRatio;
  94152. protected _indexParameters: any;
  94153. private _shareOutputWithPostProcess;
  94154. private _texelSize;
  94155. private _forcedOutputTexture;
  94156. /**
  94157. * Returns the fragment url or shader name used in the post process.
  94158. * @returns the fragment url or name in the shader store.
  94159. */
  94160. getEffectName(): string;
  94161. /**
  94162. * An event triggered when the postprocess is activated.
  94163. */
  94164. onActivateObservable: Observable<Camera>;
  94165. private _onActivateObserver;
  94166. /**
  94167. * A function that is added to the onActivateObservable
  94168. */
  94169. set onActivate(callback: Nullable<(camera: Camera) => void>);
  94170. /**
  94171. * An event triggered when the postprocess changes its size.
  94172. */
  94173. onSizeChangedObservable: Observable<PostProcess>;
  94174. private _onSizeChangedObserver;
  94175. /**
  94176. * A function that is added to the onSizeChangedObservable
  94177. */
  94178. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  94179. /**
  94180. * An event triggered when the postprocess applies its effect.
  94181. */
  94182. onApplyObservable: Observable<Effect>;
  94183. private _onApplyObserver;
  94184. /**
  94185. * A function that is added to the onApplyObservable
  94186. */
  94187. set onApply(callback: (effect: Effect) => void);
  94188. /**
  94189. * An event triggered before rendering the postprocess
  94190. */
  94191. onBeforeRenderObservable: Observable<Effect>;
  94192. private _onBeforeRenderObserver;
  94193. /**
  94194. * A function that is added to the onBeforeRenderObservable
  94195. */
  94196. set onBeforeRender(callback: (effect: Effect) => void);
  94197. /**
  94198. * An event triggered after rendering the postprocess
  94199. */
  94200. onAfterRenderObservable: Observable<Effect>;
  94201. private _onAfterRenderObserver;
  94202. /**
  94203. * A function that is added to the onAfterRenderObservable
  94204. */
  94205. set onAfterRender(callback: (efect: Effect) => void);
  94206. /**
  94207. * 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
  94208. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  94209. */
  94210. get inputTexture(): InternalTexture;
  94211. set inputTexture(value: InternalTexture);
  94212. /**
  94213. * Gets the camera which post process is applied to.
  94214. * @returns The camera the post process is applied to.
  94215. */
  94216. getCamera(): Camera;
  94217. /**
  94218. * Gets the texel size of the postprocess.
  94219. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  94220. */
  94221. get texelSize(): Vector2;
  94222. /**
  94223. * Creates a new instance PostProcess
  94224. * @param name The name of the PostProcess.
  94225. * @param fragmentUrl The url of the fragment shader to be used.
  94226. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  94227. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  94228. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94229. * @param camera The camera to apply the render pass to.
  94230. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94231. * @param engine The engine which the post process will be applied. (default: current engine)
  94232. * @param reusable If the post process can be reused on the same frame. (default: false)
  94233. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  94234. * @param textureType Type of textures used when performing the post process. (default: 0)
  94235. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  94236. * @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
  94237. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  94238. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  94239. */
  94240. constructor(
  94241. /** Name of the PostProcess. */
  94242. 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);
  94243. /**
  94244. * Gets a string idenfifying the name of the class
  94245. * @returns "PostProcess" string
  94246. */
  94247. getClassName(): string;
  94248. /**
  94249. * Gets the engine which this post process belongs to.
  94250. * @returns The engine the post process was enabled with.
  94251. */
  94252. getEngine(): Engine;
  94253. /**
  94254. * The effect that is created when initializing the post process.
  94255. * @returns The created effect corresponding the the postprocess.
  94256. */
  94257. getEffect(): Effect;
  94258. /**
  94259. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  94260. * @param postProcess The post process to share the output with.
  94261. * @returns This post process.
  94262. */
  94263. shareOutputWith(postProcess: PostProcess): PostProcess;
  94264. /**
  94265. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  94266. * This should be called if the post process that shares output with this post process is disabled/disposed.
  94267. */
  94268. useOwnOutput(): void;
  94269. /**
  94270. * Updates the effect with the current post process compile time values and recompiles the shader.
  94271. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94272. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94273. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94274. * @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
  94275. * @param onCompiled Called when the shader has been compiled.
  94276. * @param onError Called if there is an error when compiling a shader.
  94277. */
  94278. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94279. /**
  94280. * The post process is reusable if it can be used multiple times within one frame.
  94281. * @returns If the post process is reusable
  94282. */
  94283. isReusable(): boolean;
  94284. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  94285. markTextureDirty(): void;
  94286. /**
  94287. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  94288. * 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.
  94289. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  94290. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  94291. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  94292. * @returns The target texture that was bound to be written to.
  94293. */
  94294. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  94295. /**
  94296. * If the post process is supported.
  94297. */
  94298. get isSupported(): boolean;
  94299. /**
  94300. * The aspect ratio of the output texture.
  94301. */
  94302. get aspectRatio(): number;
  94303. /**
  94304. * Get a value indicating if the post-process is ready to be used
  94305. * @returns true if the post-process is ready (shader is compiled)
  94306. */
  94307. isReady(): boolean;
  94308. /**
  94309. * Binds all textures and uniforms to the shader, this will be run on every pass.
  94310. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  94311. */
  94312. apply(): Nullable<Effect>;
  94313. private _disposeTextures;
  94314. /**
  94315. * Disposes the post process.
  94316. * @param camera The camera to dispose the post process on.
  94317. */
  94318. dispose(camera?: Camera): void;
  94319. }
  94320. }
  94321. declare module BABYLON {
  94322. /** @hidden */
  94323. export var kernelBlurVaryingDeclaration: {
  94324. name: string;
  94325. shader: string;
  94326. };
  94327. }
  94328. declare module BABYLON {
  94329. /** @hidden */
  94330. export var kernelBlurFragment: {
  94331. name: string;
  94332. shader: string;
  94333. };
  94334. }
  94335. declare module BABYLON {
  94336. /** @hidden */
  94337. export var kernelBlurFragment2: {
  94338. name: string;
  94339. shader: string;
  94340. };
  94341. }
  94342. declare module BABYLON {
  94343. /** @hidden */
  94344. export var kernelBlurPixelShader: {
  94345. name: string;
  94346. shader: string;
  94347. };
  94348. }
  94349. declare module BABYLON {
  94350. /** @hidden */
  94351. export var kernelBlurVertex: {
  94352. name: string;
  94353. shader: string;
  94354. };
  94355. }
  94356. declare module BABYLON {
  94357. /** @hidden */
  94358. export var kernelBlurVertexShader: {
  94359. name: string;
  94360. shader: string;
  94361. };
  94362. }
  94363. declare module BABYLON {
  94364. /**
  94365. * The Blur Post Process which blurs an image based on a kernel and direction.
  94366. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  94367. */
  94368. export class BlurPostProcess extends PostProcess {
  94369. /** The direction in which to blur the image. */
  94370. direction: Vector2;
  94371. private blockCompilation;
  94372. protected _kernel: number;
  94373. protected _idealKernel: number;
  94374. protected _packedFloat: boolean;
  94375. private _staticDefines;
  94376. /**
  94377. * Sets the length in pixels of the blur sample region
  94378. */
  94379. set kernel(v: number);
  94380. /**
  94381. * Gets the length in pixels of the blur sample region
  94382. */
  94383. get kernel(): number;
  94384. /**
  94385. * Sets wether or not the blur needs to unpack/repack floats
  94386. */
  94387. set packedFloat(v: boolean);
  94388. /**
  94389. * Gets wether or not the blur is unpacking/repacking floats
  94390. */
  94391. get packedFloat(): boolean;
  94392. /**
  94393. * Creates a new instance BlurPostProcess
  94394. * @param name The name of the effect.
  94395. * @param direction The direction in which to blur the image.
  94396. * @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.
  94397. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  94398. * @param camera The camera to apply the render pass to.
  94399. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  94400. * @param engine The engine which the post process will be applied. (default: current engine)
  94401. * @param reusable If the post process can be reused on the same frame. (default: false)
  94402. * @param textureType Type of textures used when performing the post process. (default: 0)
  94403. * @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)
  94404. */
  94405. constructor(name: string,
  94406. /** The direction in which to blur the image. */
  94407. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  94408. /**
  94409. * Updates the effect with the current post process compile time values and recompiles the shader.
  94410. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  94411. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  94412. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  94413. * @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
  94414. * @param onCompiled Called when the shader has been compiled.
  94415. * @param onError Called if there is an error when compiling a shader.
  94416. */
  94417. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94418. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  94419. /**
  94420. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  94421. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  94422. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  94423. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  94424. * The gaps between physical kernels are compensated for in the weighting of the samples
  94425. * @param idealKernel Ideal blur kernel.
  94426. * @return Nearest best kernel.
  94427. */
  94428. protected _nearestBestKernel(idealKernel: number): number;
  94429. /**
  94430. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  94431. * @param x The point on the Gaussian distribution to sample.
  94432. * @return the value of the Gaussian function at x.
  94433. */
  94434. protected _gaussianWeight(x: number): number;
  94435. /**
  94436. * Generates a string that can be used as a floating point number in GLSL.
  94437. * @param x Value to print.
  94438. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  94439. * @return GLSL float string.
  94440. */
  94441. protected _glslFloat(x: number, decimalFigures?: number): string;
  94442. }
  94443. }
  94444. declare module BABYLON {
  94445. /**
  94446. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94447. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94448. * You can then easily use it as a reflectionTexture on a flat surface.
  94449. * In case the surface is not a plane, please consider relying on reflection probes.
  94450. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94451. */
  94452. export class MirrorTexture extends RenderTargetTexture {
  94453. private scene;
  94454. /**
  94455. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  94456. * 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.
  94457. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94458. */
  94459. mirrorPlane: Plane;
  94460. /**
  94461. * Define the blur ratio used to blur the reflection if needed.
  94462. */
  94463. set blurRatio(value: number);
  94464. get blurRatio(): number;
  94465. /**
  94466. * Define the adaptive blur kernel used to blur the reflection if needed.
  94467. * This will autocompute the closest best match for the `blurKernel`
  94468. */
  94469. set adaptiveBlurKernel(value: number);
  94470. /**
  94471. * Define the blur kernel used to blur the reflection if needed.
  94472. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94473. */
  94474. set blurKernel(value: number);
  94475. /**
  94476. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  94477. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94478. */
  94479. set blurKernelX(value: number);
  94480. get blurKernelX(): number;
  94481. /**
  94482. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  94483. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  94484. */
  94485. set blurKernelY(value: number);
  94486. get blurKernelY(): number;
  94487. private _autoComputeBlurKernel;
  94488. protected _onRatioRescale(): void;
  94489. private _updateGammaSpace;
  94490. private _imageProcessingConfigChangeObserver;
  94491. private _transformMatrix;
  94492. private _mirrorMatrix;
  94493. private _savedViewMatrix;
  94494. private _blurX;
  94495. private _blurY;
  94496. private _adaptiveBlurKernel;
  94497. private _blurKernelX;
  94498. private _blurKernelY;
  94499. private _blurRatio;
  94500. /**
  94501. * Instantiates a Mirror Texture.
  94502. * Mirror texture can be used to simulate the view from a mirror in a scene.
  94503. * It will dynamically be rendered every frame to adapt to the camera point of view.
  94504. * You can then easily use it as a reflectionTexture on a flat surface.
  94505. * In case the surface is not a plane, please consider relying on reflection probes.
  94506. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  94507. * @param name
  94508. * @param size
  94509. * @param scene
  94510. * @param generateMipMaps
  94511. * @param type
  94512. * @param samplingMode
  94513. * @param generateDepthBuffer
  94514. */
  94515. constructor(name: string, size: number | {
  94516. width: number;
  94517. height: number;
  94518. } | {
  94519. ratio: number;
  94520. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  94521. private _preparePostProcesses;
  94522. /**
  94523. * Clone the mirror texture.
  94524. * @returns the cloned texture
  94525. */
  94526. clone(): MirrorTexture;
  94527. /**
  94528. * Serialize the texture to a JSON representation you could use in Parse later on
  94529. * @returns the serialized JSON representation
  94530. */
  94531. serialize(): any;
  94532. /**
  94533. * Dispose the texture and release its associated resources.
  94534. */
  94535. dispose(): void;
  94536. }
  94537. }
  94538. declare module BABYLON {
  94539. /**
  94540. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94541. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94542. */
  94543. export class Texture extends BaseTexture {
  94544. /**
  94545. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  94546. */
  94547. static SerializeBuffers: boolean;
  94548. /** @hidden */
  94549. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  94550. /** @hidden */
  94551. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  94552. /** @hidden */
  94553. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  94554. /** nearest is mag = nearest and min = nearest and mip = linear */
  94555. static readonly NEAREST_SAMPLINGMODE: number;
  94556. /** nearest is mag = nearest and min = nearest and mip = linear */
  94557. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  94558. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94559. static readonly BILINEAR_SAMPLINGMODE: number;
  94560. /** Bilinear is mag = linear and min = linear and mip = nearest */
  94561. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  94562. /** Trilinear is mag = linear and min = linear and mip = linear */
  94563. static readonly TRILINEAR_SAMPLINGMODE: number;
  94564. /** Trilinear is mag = linear and min = linear and mip = linear */
  94565. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  94566. /** mag = nearest and min = nearest and mip = nearest */
  94567. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  94568. /** mag = nearest and min = linear and mip = nearest */
  94569. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  94570. /** mag = nearest and min = linear and mip = linear */
  94571. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  94572. /** mag = nearest and min = linear and mip = none */
  94573. static readonly NEAREST_LINEAR: number;
  94574. /** mag = nearest and min = nearest and mip = none */
  94575. static readonly NEAREST_NEAREST: number;
  94576. /** mag = linear and min = nearest and mip = nearest */
  94577. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  94578. /** mag = linear and min = nearest and mip = linear */
  94579. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  94580. /** mag = linear and min = linear and mip = none */
  94581. static readonly LINEAR_LINEAR: number;
  94582. /** mag = linear and min = nearest and mip = none */
  94583. static readonly LINEAR_NEAREST: number;
  94584. /** Explicit coordinates mode */
  94585. static readonly EXPLICIT_MODE: number;
  94586. /** Spherical coordinates mode */
  94587. static readonly SPHERICAL_MODE: number;
  94588. /** Planar coordinates mode */
  94589. static readonly PLANAR_MODE: number;
  94590. /** Cubic coordinates mode */
  94591. static readonly CUBIC_MODE: number;
  94592. /** Projection coordinates mode */
  94593. static readonly PROJECTION_MODE: number;
  94594. /** Inverse Cubic coordinates mode */
  94595. static readonly SKYBOX_MODE: number;
  94596. /** Inverse Cubic coordinates mode */
  94597. static readonly INVCUBIC_MODE: number;
  94598. /** Equirectangular coordinates mode */
  94599. static readonly EQUIRECTANGULAR_MODE: number;
  94600. /** Equirectangular Fixed coordinates mode */
  94601. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  94602. /** Equirectangular Fixed Mirrored coordinates mode */
  94603. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  94604. /** Texture is not repeating outside of 0..1 UVs */
  94605. static readonly CLAMP_ADDRESSMODE: number;
  94606. /** Texture is repeating outside of 0..1 UVs */
  94607. static readonly WRAP_ADDRESSMODE: number;
  94608. /** Texture is repeating and mirrored */
  94609. static readonly MIRROR_ADDRESSMODE: number;
  94610. /**
  94611. * 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
  94612. */
  94613. static UseSerializedUrlIfAny: boolean;
  94614. /**
  94615. * Define the url of the texture.
  94616. */
  94617. url: Nullable<string>;
  94618. /**
  94619. * Define an offset on the texture to offset the u coordinates of the UVs
  94620. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94621. */
  94622. uOffset: number;
  94623. /**
  94624. * Define an offset on the texture to offset the v coordinates of the UVs
  94625. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  94626. */
  94627. vOffset: number;
  94628. /**
  94629. * Define an offset on the texture to scale the u coordinates of the UVs
  94630. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94631. */
  94632. uScale: number;
  94633. /**
  94634. * Define an offset on the texture to scale the v coordinates of the UVs
  94635. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  94636. */
  94637. vScale: number;
  94638. /**
  94639. * Define an offset on the texture to rotate around the u coordinates of the UVs
  94640. * @see http://doc.babylonjs.com/how_to/more_materials
  94641. */
  94642. uAng: number;
  94643. /**
  94644. * Define an offset on the texture to rotate around the v coordinates of the UVs
  94645. * @see http://doc.babylonjs.com/how_to/more_materials
  94646. */
  94647. vAng: number;
  94648. /**
  94649. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  94650. * @see http://doc.babylonjs.com/how_to/more_materials
  94651. */
  94652. wAng: number;
  94653. /**
  94654. * Defines the center of rotation (U)
  94655. */
  94656. uRotationCenter: number;
  94657. /**
  94658. * Defines the center of rotation (V)
  94659. */
  94660. vRotationCenter: number;
  94661. /**
  94662. * Defines the center of rotation (W)
  94663. */
  94664. wRotationCenter: number;
  94665. /**
  94666. * Are mip maps generated for this texture or not.
  94667. */
  94668. get noMipmap(): boolean;
  94669. /**
  94670. * List of inspectable custom properties (used by the Inspector)
  94671. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  94672. */
  94673. inspectableCustomProperties: Nullable<IInspectable[]>;
  94674. private _noMipmap;
  94675. /** @hidden */
  94676. _invertY: boolean;
  94677. private _rowGenerationMatrix;
  94678. private _cachedTextureMatrix;
  94679. private _projectionModeMatrix;
  94680. private _t0;
  94681. private _t1;
  94682. private _t2;
  94683. private _cachedUOffset;
  94684. private _cachedVOffset;
  94685. private _cachedUScale;
  94686. private _cachedVScale;
  94687. private _cachedUAng;
  94688. private _cachedVAng;
  94689. private _cachedWAng;
  94690. private _cachedProjectionMatrixId;
  94691. private _cachedCoordinatesMode;
  94692. /** @hidden */
  94693. protected _initialSamplingMode: number;
  94694. /** @hidden */
  94695. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  94696. private _deleteBuffer;
  94697. protected _format: Nullable<number>;
  94698. private _delayedOnLoad;
  94699. private _delayedOnError;
  94700. private _mimeType?;
  94701. /**
  94702. * Observable triggered once the texture has been loaded.
  94703. */
  94704. onLoadObservable: Observable<Texture>;
  94705. protected _isBlocking: boolean;
  94706. /**
  94707. * Is the texture preventing material to render while loading.
  94708. * If false, a default texture will be used instead of the loading one during the preparation step.
  94709. */
  94710. set isBlocking(value: boolean);
  94711. get isBlocking(): boolean;
  94712. /**
  94713. * Get the current sampling mode associated with the texture.
  94714. */
  94715. get samplingMode(): number;
  94716. /**
  94717. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  94718. */
  94719. get invertY(): boolean;
  94720. /**
  94721. * Instantiates a new texture.
  94722. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  94723. * @see http://doc.babylonjs.com/babylon101/materials#texture
  94724. * @param url defines the url of the picture to load as a texture
  94725. * @param scene defines the scene or engine the texture will belong to
  94726. * @param noMipmap defines if the texture will require mip maps or not
  94727. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  94728. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94729. * @param onLoad defines a callback triggered when the texture has been loaded
  94730. * @param onError defines a callback triggered when an error occurred during the loading session
  94731. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  94732. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  94733. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94734. * @param mimeType defines an optional mime type information
  94735. */
  94736. 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);
  94737. /**
  94738. * Update the url (and optional buffer) of this texture if url was null during construction.
  94739. * @param url the url of the texture
  94740. * @param buffer the buffer of the texture (defaults to null)
  94741. * @param onLoad callback called when the texture is loaded (defaults to null)
  94742. */
  94743. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  94744. /**
  94745. * Finish the loading sequence of a texture flagged as delayed load.
  94746. * @hidden
  94747. */
  94748. delayLoad(): void;
  94749. private _prepareRowForTextureGeneration;
  94750. /**
  94751. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  94752. * @returns the transform matrix of the texture.
  94753. */
  94754. getTextureMatrix(uBase?: number): Matrix;
  94755. /**
  94756. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  94757. * @returns The reflection texture transform
  94758. */
  94759. getReflectionTextureMatrix(): Matrix;
  94760. /**
  94761. * Clones the texture.
  94762. * @returns the cloned texture
  94763. */
  94764. clone(): Texture;
  94765. /**
  94766. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  94767. * @returns The JSON representation of the texture
  94768. */
  94769. serialize(): any;
  94770. /**
  94771. * Get the current class name of the texture useful for serialization or dynamic coding.
  94772. * @returns "Texture"
  94773. */
  94774. getClassName(): string;
  94775. /**
  94776. * Dispose the texture and release its associated resources.
  94777. */
  94778. dispose(): void;
  94779. /**
  94780. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  94781. * @param parsedTexture Define the JSON representation of the texture
  94782. * @param scene Define the scene the parsed texture should be instantiated in
  94783. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  94784. * @returns The parsed texture if successful
  94785. */
  94786. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  94787. /**
  94788. * Creates a texture from its base 64 representation.
  94789. * @param data Define the base64 payload without the data: prefix
  94790. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94791. * @param scene Define the scene the texture should belong to
  94792. * @param noMipmap Forces the texture to not create mip map information if true
  94793. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94794. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94795. * @param onLoad define a callback triggered when the texture has been loaded
  94796. * @param onError define a callback triggered when an error occurred during the loading session
  94797. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94798. * @returns the created texture
  94799. */
  94800. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  94801. /**
  94802. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  94803. * @param data Define the base64 payload without the data: prefix
  94804. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  94805. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  94806. * @param scene Define the scene the texture should belong to
  94807. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  94808. * @param noMipmap Forces the texture to not create mip map information if true
  94809. * @param invertY define if the texture needs to be inverted on the y axis during loading
  94810. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  94811. * @param onLoad define a callback triggered when the texture has been loaded
  94812. * @param onError define a callback triggered when an error occurred during the loading session
  94813. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  94814. * @returns the created texture
  94815. */
  94816. 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;
  94817. }
  94818. }
  94819. declare module BABYLON {
  94820. /**
  94821. * PostProcessManager is used to manage one or more post processes or post process pipelines
  94822. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  94823. */
  94824. export class PostProcessManager {
  94825. private _scene;
  94826. private _indexBuffer;
  94827. private _vertexBuffers;
  94828. /**
  94829. * Creates a new instance PostProcess
  94830. * @param scene The scene that the post process is associated with.
  94831. */
  94832. constructor(scene: Scene);
  94833. private _prepareBuffers;
  94834. private _buildIndexBuffer;
  94835. /**
  94836. * Rebuilds the vertex buffers of the manager.
  94837. * @hidden
  94838. */
  94839. _rebuild(): void;
  94840. /**
  94841. * Prepares a frame to be run through a post process.
  94842. * @param sourceTexture The input texture to the post procesess. (default: null)
  94843. * @param postProcesses An array of post processes to be run. (default: null)
  94844. * @returns True if the post processes were able to be run.
  94845. * @hidden
  94846. */
  94847. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  94848. /**
  94849. * Manually render a set of post processes to a texture.
  94850. * @param postProcesses An array of post processes to be run.
  94851. * @param targetTexture The target texture to render to.
  94852. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  94853. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  94854. * @param lodLevel defines which lod of the texture to render to
  94855. */
  94856. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  94857. /**
  94858. * Finalize the result of the output of the postprocesses.
  94859. * @param doNotPresent If true the result will not be displayed to the screen.
  94860. * @param targetTexture The target texture to render to.
  94861. * @param faceIndex The index of the face to bind the target texture to.
  94862. * @param postProcesses The array of post processes to render.
  94863. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  94864. * @hidden
  94865. */
  94866. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  94867. /**
  94868. * Disposes of the post process manager.
  94869. */
  94870. dispose(): void;
  94871. }
  94872. }
  94873. declare module BABYLON {
  94874. /**
  94875. * This Helps creating a texture that will be created from a camera in your scene.
  94876. * It is basically a dynamic texture that could be used to create special effects for instance.
  94877. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  94878. */
  94879. export class RenderTargetTexture extends Texture {
  94880. isCube: boolean;
  94881. /**
  94882. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  94883. */
  94884. static readonly REFRESHRATE_RENDER_ONCE: number;
  94885. /**
  94886. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  94887. */
  94888. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  94889. /**
  94890. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  94891. * the central point of your effect and can save a lot of performances.
  94892. */
  94893. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  94894. /**
  94895. * Use this predicate to dynamically define the list of mesh you want to render.
  94896. * If set, the renderList property will be overwritten.
  94897. */
  94898. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  94899. private _renderList;
  94900. /**
  94901. * Use this list to define the list of mesh you want to render.
  94902. */
  94903. get renderList(): Nullable<Array<AbstractMesh>>;
  94904. set renderList(value: Nullable<Array<AbstractMesh>>);
  94905. /**
  94906. * Use this function to overload the renderList array at rendering time.
  94907. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  94908. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  94909. * the cube (if the RTT is a cube, else layerOrFace=0).
  94910. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  94911. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  94912. * hold dummy elements!
  94913. */
  94914. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  94915. private _hookArray;
  94916. /**
  94917. * Define if particles should be rendered in your texture.
  94918. */
  94919. renderParticles: boolean;
  94920. /**
  94921. * Define if sprites should be rendered in your texture.
  94922. */
  94923. renderSprites: boolean;
  94924. /**
  94925. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  94926. */
  94927. coordinatesMode: number;
  94928. /**
  94929. * Define the camera used to render the texture.
  94930. */
  94931. activeCamera: Nullable<Camera>;
  94932. /**
  94933. * Override the mesh isReady function with your own one.
  94934. */
  94935. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  94936. /**
  94937. * Override the render function of the texture with your own one.
  94938. */
  94939. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  94940. /**
  94941. * Define if camera post processes should be use while rendering the texture.
  94942. */
  94943. useCameraPostProcesses: boolean;
  94944. /**
  94945. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  94946. */
  94947. ignoreCameraViewport: boolean;
  94948. private _postProcessManager;
  94949. private _postProcesses;
  94950. private _resizeObserver;
  94951. /**
  94952. * An event triggered when the texture is unbind.
  94953. */
  94954. onBeforeBindObservable: Observable<RenderTargetTexture>;
  94955. /**
  94956. * An event triggered when the texture is unbind.
  94957. */
  94958. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  94959. private _onAfterUnbindObserver;
  94960. /**
  94961. * Set a after unbind callback in the texture.
  94962. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  94963. */
  94964. set onAfterUnbind(callback: () => void);
  94965. /**
  94966. * An event triggered before rendering the texture
  94967. */
  94968. onBeforeRenderObservable: Observable<number>;
  94969. private _onBeforeRenderObserver;
  94970. /**
  94971. * Set a before render callback in the texture.
  94972. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  94973. */
  94974. set onBeforeRender(callback: (faceIndex: number) => void);
  94975. /**
  94976. * An event triggered after rendering the texture
  94977. */
  94978. onAfterRenderObservable: Observable<number>;
  94979. private _onAfterRenderObserver;
  94980. /**
  94981. * Set a after render callback in the texture.
  94982. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  94983. */
  94984. set onAfterRender(callback: (faceIndex: number) => void);
  94985. /**
  94986. * An event triggered after the texture clear
  94987. */
  94988. onClearObservable: Observable<Engine>;
  94989. private _onClearObserver;
  94990. /**
  94991. * Set a clear callback in the texture.
  94992. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  94993. */
  94994. set onClear(callback: (Engine: Engine) => void);
  94995. /**
  94996. * An event triggered when the texture is resized.
  94997. */
  94998. onResizeObservable: Observable<RenderTargetTexture>;
  94999. /**
  95000. * Define the clear color of the Render Target if it should be different from the scene.
  95001. */
  95002. clearColor: Color4;
  95003. protected _size: number | {
  95004. width: number;
  95005. height: number;
  95006. layers?: number;
  95007. };
  95008. protected _initialSizeParameter: number | {
  95009. width: number;
  95010. height: number;
  95011. } | {
  95012. ratio: number;
  95013. };
  95014. protected _sizeRatio: Nullable<number>;
  95015. /** @hidden */
  95016. _generateMipMaps: boolean;
  95017. protected _renderingManager: RenderingManager;
  95018. /** @hidden */
  95019. _waitingRenderList: string[];
  95020. protected _doNotChangeAspectRatio: boolean;
  95021. protected _currentRefreshId: number;
  95022. protected _refreshRate: number;
  95023. protected _textureMatrix: Matrix;
  95024. protected _samples: number;
  95025. protected _renderTargetOptions: RenderTargetCreationOptions;
  95026. /**
  95027. * Gets render target creation options that were used.
  95028. */
  95029. get renderTargetOptions(): RenderTargetCreationOptions;
  95030. protected _engine: Engine;
  95031. protected _onRatioRescale(): void;
  95032. /**
  95033. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  95034. * It must define where the camera used to render the texture is set
  95035. */
  95036. boundingBoxPosition: Vector3;
  95037. private _boundingBoxSize;
  95038. /**
  95039. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  95040. * When defined, the cubemap will switch to local mode
  95041. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  95042. * @example https://www.babylonjs-playground.com/#RNASML
  95043. */
  95044. set boundingBoxSize(value: Vector3);
  95045. get boundingBoxSize(): Vector3;
  95046. /**
  95047. * In case the RTT has been created with a depth texture, get the associated
  95048. * depth texture.
  95049. * Otherwise, return null.
  95050. */
  95051. get depthStencilTexture(): Nullable<InternalTexture>;
  95052. /**
  95053. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  95054. * or used a shadow, depth texture...
  95055. * @param name The friendly name of the texture
  95056. * @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)
  95057. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  95058. * @param generateMipMaps True if mip maps need to be generated after render.
  95059. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  95060. * @param type The type of the buffer in the RTT (int, half float, float...)
  95061. * @param isCube True if a cube texture needs to be created
  95062. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  95063. * @param generateDepthBuffer True to generate a depth buffer
  95064. * @param generateStencilBuffer True to generate a stencil buffer
  95065. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  95066. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  95067. * @param delayAllocation if the texture allocation should be delayed (default: false)
  95068. */
  95069. constructor(name: string, size: number | {
  95070. width: number;
  95071. height: number;
  95072. layers?: number;
  95073. } | {
  95074. ratio: number;
  95075. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  95076. /**
  95077. * Creates a depth stencil texture.
  95078. * This is only available in WebGL 2 or with the depth texture extension available.
  95079. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  95080. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  95081. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  95082. */
  95083. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  95084. private _processSizeParameter;
  95085. /**
  95086. * Define the number of samples to use in case of MSAA.
  95087. * It defaults to one meaning no MSAA has been enabled.
  95088. */
  95089. get samples(): number;
  95090. set samples(value: number);
  95091. /**
  95092. * Resets the refresh counter of the texture and start bak from scratch.
  95093. * Could be useful to regenerate the texture if it is setup to render only once.
  95094. */
  95095. resetRefreshCounter(): void;
  95096. /**
  95097. * Define the refresh rate of the texture or the rendering frequency.
  95098. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  95099. */
  95100. get refreshRate(): number;
  95101. set refreshRate(value: number);
  95102. /**
  95103. * Adds a post process to the render target rendering passes.
  95104. * @param postProcess define the post process to add
  95105. */
  95106. addPostProcess(postProcess: PostProcess): void;
  95107. /**
  95108. * Clear all the post processes attached to the render target
  95109. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  95110. */
  95111. clearPostProcesses(dispose?: boolean): void;
  95112. /**
  95113. * Remove one of the post process from the list of attached post processes to the texture
  95114. * @param postProcess define the post process to remove from the list
  95115. */
  95116. removePostProcess(postProcess: PostProcess): void;
  95117. /** @hidden */
  95118. _shouldRender(): boolean;
  95119. /**
  95120. * Gets the actual render size of the texture.
  95121. * @returns the width of the render size
  95122. */
  95123. getRenderSize(): number;
  95124. /**
  95125. * Gets the actual render width of the texture.
  95126. * @returns the width of the render size
  95127. */
  95128. getRenderWidth(): number;
  95129. /**
  95130. * Gets the actual render height of the texture.
  95131. * @returns the height of the render size
  95132. */
  95133. getRenderHeight(): number;
  95134. /**
  95135. * Gets the actual number of layers of the texture.
  95136. * @returns the number of layers
  95137. */
  95138. getRenderLayers(): number;
  95139. /**
  95140. * Get if the texture can be rescaled or not.
  95141. */
  95142. get canRescale(): boolean;
  95143. /**
  95144. * Resize the texture using a ratio.
  95145. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  95146. */
  95147. scale(ratio: number): void;
  95148. /**
  95149. * Get the texture reflection matrix used to rotate/transform the reflection.
  95150. * @returns the reflection matrix
  95151. */
  95152. getReflectionTextureMatrix(): Matrix;
  95153. /**
  95154. * Resize the texture to a new desired size.
  95155. * Be carrefull as it will recreate all the data in the new texture.
  95156. * @param size Define the new size. It can be:
  95157. * - a number for squared texture,
  95158. * - an object containing { width: number, height: number }
  95159. * - or an object containing a ratio { ratio: number }
  95160. */
  95161. resize(size: number | {
  95162. width: number;
  95163. height: number;
  95164. } | {
  95165. ratio: number;
  95166. }): void;
  95167. private _defaultRenderListPrepared;
  95168. /**
  95169. * Renders all the objects from the render list into the texture.
  95170. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  95171. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  95172. */
  95173. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  95174. private _bestReflectionRenderTargetDimension;
  95175. private _prepareRenderingManager;
  95176. /**
  95177. * @hidden
  95178. * @param faceIndex face index to bind to if this is a cubetexture
  95179. * @param layer defines the index of the texture to bind in the array
  95180. */
  95181. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  95182. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  95183. private renderToTarget;
  95184. /**
  95185. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  95186. * This allowed control for front to back rendering or reversly depending of the special needs.
  95187. *
  95188. * @param renderingGroupId The rendering group id corresponding to its index
  95189. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  95190. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  95191. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  95192. */
  95193. 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;
  95194. /**
  95195. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  95196. *
  95197. * @param renderingGroupId The rendering group id corresponding to its index
  95198. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  95199. */
  95200. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  95201. /**
  95202. * Clones the texture.
  95203. * @returns the cloned texture
  95204. */
  95205. clone(): RenderTargetTexture;
  95206. /**
  95207. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  95208. * @returns The JSON representation of the texture
  95209. */
  95210. serialize(): any;
  95211. /**
  95212. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  95213. */
  95214. disposeFramebufferObjects(): void;
  95215. /**
  95216. * Dispose the texture and release its associated resources.
  95217. */
  95218. dispose(): void;
  95219. /** @hidden */
  95220. _rebuild(): void;
  95221. /**
  95222. * Clear the info related to rendering groups preventing retention point in material dispose.
  95223. */
  95224. freeRenderingGroups(): void;
  95225. /**
  95226. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  95227. * @returns the view count
  95228. */
  95229. getViewCount(): number;
  95230. }
  95231. }
  95232. declare module BABYLON {
  95233. /**
  95234. * Options for compiling materials.
  95235. */
  95236. export interface IMaterialCompilationOptions {
  95237. /**
  95238. * Defines whether clip planes are enabled.
  95239. */
  95240. clipPlane: boolean;
  95241. /**
  95242. * Defines whether instances are enabled.
  95243. */
  95244. useInstances: boolean;
  95245. }
  95246. /**
  95247. * Base class for the main features of a material in Babylon.js
  95248. */
  95249. export class Material implements IAnimatable {
  95250. /**
  95251. * Returns the triangle fill mode
  95252. */
  95253. static readonly TriangleFillMode: number;
  95254. /**
  95255. * Returns the wireframe mode
  95256. */
  95257. static readonly WireFrameFillMode: number;
  95258. /**
  95259. * Returns the point fill mode
  95260. */
  95261. static readonly PointFillMode: number;
  95262. /**
  95263. * Returns the point list draw mode
  95264. */
  95265. static readonly PointListDrawMode: number;
  95266. /**
  95267. * Returns the line list draw mode
  95268. */
  95269. static readonly LineListDrawMode: number;
  95270. /**
  95271. * Returns the line loop draw mode
  95272. */
  95273. static readonly LineLoopDrawMode: number;
  95274. /**
  95275. * Returns the line strip draw mode
  95276. */
  95277. static readonly LineStripDrawMode: number;
  95278. /**
  95279. * Returns the triangle strip draw mode
  95280. */
  95281. static readonly TriangleStripDrawMode: number;
  95282. /**
  95283. * Returns the triangle fan draw mode
  95284. */
  95285. static readonly TriangleFanDrawMode: number;
  95286. /**
  95287. * Stores the clock-wise side orientation
  95288. */
  95289. static readonly ClockWiseSideOrientation: number;
  95290. /**
  95291. * Stores the counter clock-wise side orientation
  95292. */
  95293. static readonly CounterClockWiseSideOrientation: number;
  95294. /**
  95295. * The dirty texture flag value
  95296. */
  95297. static readonly TextureDirtyFlag: number;
  95298. /**
  95299. * The dirty light flag value
  95300. */
  95301. static readonly LightDirtyFlag: number;
  95302. /**
  95303. * The dirty fresnel flag value
  95304. */
  95305. static readonly FresnelDirtyFlag: number;
  95306. /**
  95307. * The dirty attribute flag value
  95308. */
  95309. static readonly AttributesDirtyFlag: number;
  95310. /**
  95311. * The dirty misc flag value
  95312. */
  95313. static readonly MiscDirtyFlag: number;
  95314. /**
  95315. * The all dirty flag value
  95316. */
  95317. static readonly AllDirtyFlag: number;
  95318. /**
  95319. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  95320. */
  95321. static readonly MATERIAL_OPAQUE: number;
  95322. /**
  95323. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  95324. */
  95325. static readonly MATERIAL_ALPHATEST: number;
  95326. /**
  95327. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95328. */
  95329. static readonly MATERIAL_ALPHABLEND: number;
  95330. /**
  95331. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  95332. * They are also discarded below the alpha cutoff threshold to improve performances.
  95333. */
  95334. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  95335. /**
  95336. * The ID of the material
  95337. */
  95338. id: string;
  95339. /**
  95340. * Gets or sets the unique id of the material
  95341. */
  95342. uniqueId: number;
  95343. /**
  95344. * The name of the material
  95345. */
  95346. name: string;
  95347. /**
  95348. * Gets or sets user defined metadata
  95349. */
  95350. metadata: any;
  95351. /**
  95352. * For internal use only. Please do not use.
  95353. */
  95354. reservedDataStore: any;
  95355. /**
  95356. * Specifies if the ready state should be checked on each call
  95357. */
  95358. checkReadyOnEveryCall: boolean;
  95359. /**
  95360. * Specifies if the ready state should be checked once
  95361. */
  95362. checkReadyOnlyOnce: boolean;
  95363. /**
  95364. * The state of the material
  95365. */
  95366. state: string;
  95367. /**
  95368. * The alpha value of the material
  95369. */
  95370. protected _alpha: number;
  95371. /**
  95372. * List of inspectable custom properties (used by the Inspector)
  95373. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  95374. */
  95375. inspectableCustomProperties: IInspectable[];
  95376. /**
  95377. * Sets the alpha value of the material
  95378. */
  95379. set alpha(value: number);
  95380. /**
  95381. * Gets the alpha value of the material
  95382. */
  95383. get alpha(): number;
  95384. /**
  95385. * Specifies if back face culling is enabled
  95386. */
  95387. protected _backFaceCulling: boolean;
  95388. /**
  95389. * Sets the back-face culling state
  95390. */
  95391. set backFaceCulling(value: boolean);
  95392. /**
  95393. * Gets the back-face culling state
  95394. */
  95395. get backFaceCulling(): boolean;
  95396. /**
  95397. * Stores the value for side orientation
  95398. */
  95399. sideOrientation: number;
  95400. /**
  95401. * Callback triggered when the material is compiled
  95402. */
  95403. onCompiled: Nullable<(effect: Effect) => void>;
  95404. /**
  95405. * Callback triggered when an error occurs
  95406. */
  95407. onError: Nullable<(effect: Effect, errors: string) => void>;
  95408. /**
  95409. * Callback triggered to get the render target textures
  95410. */
  95411. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  95412. /**
  95413. * Gets a boolean indicating that current material needs to register RTT
  95414. */
  95415. get hasRenderTargetTextures(): boolean;
  95416. /**
  95417. * Specifies if the material should be serialized
  95418. */
  95419. doNotSerialize: boolean;
  95420. /**
  95421. * @hidden
  95422. */
  95423. _storeEffectOnSubMeshes: boolean;
  95424. /**
  95425. * Stores the animations for the material
  95426. */
  95427. animations: Nullable<Array<Animation>>;
  95428. /**
  95429. * An event triggered when the material is disposed
  95430. */
  95431. onDisposeObservable: Observable<Material>;
  95432. /**
  95433. * An observer which watches for dispose events
  95434. */
  95435. private _onDisposeObserver;
  95436. private _onUnBindObservable;
  95437. /**
  95438. * Called during a dispose event
  95439. */
  95440. set onDispose(callback: () => void);
  95441. private _onBindObservable;
  95442. /**
  95443. * An event triggered when the material is bound
  95444. */
  95445. get onBindObservable(): Observable<AbstractMesh>;
  95446. /**
  95447. * An observer which watches for bind events
  95448. */
  95449. private _onBindObserver;
  95450. /**
  95451. * Called during a bind event
  95452. */
  95453. set onBind(callback: (Mesh: AbstractMesh) => void);
  95454. /**
  95455. * An event triggered when the material is unbound
  95456. */
  95457. get onUnBindObservable(): Observable<Material>;
  95458. /**
  95459. * Stores the value of the alpha mode
  95460. */
  95461. private _alphaMode;
  95462. /**
  95463. * Sets the value of the alpha mode.
  95464. *
  95465. * | Value | Type | Description |
  95466. * | --- | --- | --- |
  95467. * | 0 | ALPHA_DISABLE | |
  95468. * | 1 | ALPHA_ADD | |
  95469. * | 2 | ALPHA_COMBINE | |
  95470. * | 3 | ALPHA_SUBTRACT | |
  95471. * | 4 | ALPHA_MULTIPLY | |
  95472. * | 5 | ALPHA_MAXIMIZED | |
  95473. * | 6 | ALPHA_ONEONE | |
  95474. * | 7 | ALPHA_PREMULTIPLIED | |
  95475. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  95476. * | 9 | ALPHA_INTERPOLATE | |
  95477. * | 10 | ALPHA_SCREENMODE | |
  95478. *
  95479. */
  95480. set alphaMode(value: number);
  95481. /**
  95482. * Gets the value of the alpha mode
  95483. */
  95484. get alphaMode(): number;
  95485. /**
  95486. * Stores the state of the need depth pre-pass value
  95487. */
  95488. private _needDepthPrePass;
  95489. /**
  95490. * Sets the need depth pre-pass value
  95491. */
  95492. set needDepthPrePass(value: boolean);
  95493. /**
  95494. * Gets the depth pre-pass value
  95495. */
  95496. get needDepthPrePass(): boolean;
  95497. /**
  95498. * Specifies if depth writing should be disabled
  95499. */
  95500. disableDepthWrite: boolean;
  95501. /**
  95502. * Specifies if depth writing should be forced
  95503. */
  95504. forceDepthWrite: boolean;
  95505. /**
  95506. * Specifies the depth function that should be used. 0 means the default engine function
  95507. */
  95508. depthFunction: number;
  95509. /**
  95510. * Specifies if there should be a separate pass for culling
  95511. */
  95512. separateCullingPass: boolean;
  95513. /**
  95514. * Stores the state specifing if fog should be enabled
  95515. */
  95516. private _fogEnabled;
  95517. /**
  95518. * Sets the state for enabling fog
  95519. */
  95520. set fogEnabled(value: boolean);
  95521. /**
  95522. * Gets the value of the fog enabled state
  95523. */
  95524. get fogEnabled(): boolean;
  95525. /**
  95526. * Stores the size of points
  95527. */
  95528. pointSize: number;
  95529. /**
  95530. * Stores the z offset value
  95531. */
  95532. zOffset: number;
  95533. /**
  95534. * Gets a value specifying if wireframe mode is enabled
  95535. */
  95536. get wireframe(): boolean;
  95537. /**
  95538. * Sets the state of wireframe mode
  95539. */
  95540. set wireframe(value: boolean);
  95541. /**
  95542. * Gets the value specifying if point clouds are enabled
  95543. */
  95544. get pointsCloud(): boolean;
  95545. /**
  95546. * Sets the state of point cloud mode
  95547. */
  95548. set pointsCloud(value: boolean);
  95549. /**
  95550. * Gets the material fill mode
  95551. */
  95552. get fillMode(): number;
  95553. /**
  95554. * Sets the material fill mode
  95555. */
  95556. set fillMode(value: number);
  95557. /**
  95558. * @hidden
  95559. * Stores the effects for the material
  95560. */
  95561. _effect: Nullable<Effect>;
  95562. /**
  95563. * Specifies if uniform buffers should be used
  95564. */
  95565. private _useUBO;
  95566. /**
  95567. * Stores a reference to the scene
  95568. */
  95569. private _scene;
  95570. /**
  95571. * Stores the fill mode state
  95572. */
  95573. private _fillMode;
  95574. /**
  95575. * Specifies if the depth write state should be cached
  95576. */
  95577. private _cachedDepthWriteState;
  95578. /**
  95579. * Specifies if the depth function state should be cached
  95580. */
  95581. private _cachedDepthFunctionState;
  95582. /**
  95583. * Stores the uniform buffer
  95584. */
  95585. protected _uniformBuffer: UniformBuffer;
  95586. /** @hidden */
  95587. _indexInSceneMaterialArray: number;
  95588. /** @hidden */
  95589. meshMap: Nullable<{
  95590. [id: string]: AbstractMesh | undefined;
  95591. }>;
  95592. /**
  95593. * Creates a material instance
  95594. * @param name defines the name of the material
  95595. * @param scene defines the scene to reference
  95596. * @param doNotAdd specifies if the material should be added to the scene
  95597. */
  95598. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  95599. /**
  95600. * Returns a string representation of the current material
  95601. * @param fullDetails defines a boolean indicating which levels of logging is desired
  95602. * @returns a string with material information
  95603. */
  95604. toString(fullDetails?: boolean): string;
  95605. /**
  95606. * Gets the class name of the material
  95607. * @returns a string with the class name of the material
  95608. */
  95609. getClassName(): string;
  95610. /**
  95611. * Specifies if updates for the material been locked
  95612. */
  95613. get isFrozen(): boolean;
  95614. /**
  95615. * Locks updates for the material
  95616. */
  95617. freeze(): void;
  95618. /**
  95619. * Unlocks updates for the material
  95620. */
  95621. unfreeze(): void;
  95622. /**
  95623. * Specifies if the material is ready to be used
  95624. * @param mesh defines the mesh to check
  95625. * @param useInstances specifies if instances should be used
  95626. * @returns a boolean indicating if the material is ready to be used
  95627. */
  95628. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  95629. /**
  95630. * Specifies that the submesh is ready to be used
  95631. * @param mesh defines the mesh to check
  95632. * @param subMesh defines which submesh to check
  95633. * @param useInstances specifies that instances should be used
  95634. * @returns a boolean indicating that the submesh is ready or not
  95635. */
  95636. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95637. /**
  95638. * Returns the material effect
  95639. * @returns the effect associated with the material
  95640. */
  95641. getEffect(): Nullable<Effect>;
  95642. /**
  95643. * Returns the current scene
  95644. * @returns a Scene
  95645. */
  95646. getScene(): Scene;
  95647. /**
  95648. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  95649. */
  95650. protected _forceAlphaTest: boolean;
  95651. /**
  95652. * The transparency mode of the material.
  95653. */
  95654. protected _transparencyMode: Nullable<number>;
  95655. /**
  95656. * Gets the current transparency mode.
  95657. */
  95658. get transparencyMode(): Nullable<number>;
  95659. /**
  95660. * Sets the transparency mode of the material.
  95661. *
  95662. * | Value | Type | Description |
  95663. * | ----- | ----------------------------------- | ----------- |
  95664. * | 0 | OPAQUE | |
  95665. * | 1 | ALPHATEST | |
  95666. * | 2 | ALPHABLEND | |
  95667. * | 3 | ALPHATESTANDBLEND | |
  95668. *
  95669. */
  95670. set transparencyMode(value: Nullable<number>);
  95671. /**
  95672. * Returns true if alpha blending should be disabled.
  95673. */
  95674. protected get _disableAlphaBlending(): boolean;
  95675. /**
  95676. * Specifies whether or not this material should be rendered in alpha blend mode.
  95677. * @returns a boolean specifying if alpha blending is needed
  95678. */
  95679. needAlphaBlending(): boolean;
  95680. /**
  95681. * Specifies if the mesh will require alpha blending
  95682. * @param mesh defines the mesh to check
  95683. * @returns a boolean specifying if alpha blending is needed for the mesh
  95684. */
  95685. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  95686. /**
  95687. * Specifies whether or not this material should be rendered in alpha test mode.
  95688. * @returns a boolean specifying if an alpha test is needed.
  95689. */
  95690. needAlphaTesting(): boolean;
  95691. /**
  95692. * Specifies if material alpha testing should be turned on for the mesh
  95693. * @param mesh defines the mesh to check
  95694. */
  95695. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  95696. /**
  95697. * Gets the texture used for the alpha test
  95698. * @returns the texture to use for alpha testing
  95699. */
  95700. getAlphaTestTexture(): Nullable<BaseTexture>;
  95701. /**
  95702. * Marks the material to indicate that it needs to be re-calculated
  95703. */
  95704. markDirty(): void;
  95705. /** @hidden */
  95706. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  95707. /**
  95708. * Binds the material to the mesh
  95709. * @param world defines the world transformation matrix
  95710. * @param mesh defines the mesh to bind the material to
  95711. */
  95712. bind(world: Matrix, mesh?: Mesh): void;
  95713. /**
  95714. * Binds the submesh to the material
  95715. * @param world defines the world transformation matrix
  95716. * @param mesh defines the mesh containing the submesh
  95717. * @param subMesh defines the submesh to bind the material to
  95718. */
  95719. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  95720. /**
  95721. * Binds the world matrix to the material
  95722. * @param world defines the world transformation matrix
  95723. */
  95724. bindOnlyWorldMatrix(world: Matrix): void;
  95725. /**
  95726. * Binds the scene's uniform buffer to the effect.
  95727. * @param effect defines the effect to bind to the scene uniform buffer
  95728. * @param sceneUbo defines the uniform buffer storing scene data
  95729. */
  95730. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  95731. /**
  95732. * Binds the view matrix to the effect
  95733. * @param effect defines the effect to bind the view matrix to
  95734. */
  95735. bindView(effect: Effect): void;
  95736. /**
  95737. * Binds the view projection matrix to the effect
  95738. * @param effect defines the effect to bind the view projection matrix to
  95739. */
  95740. bindViewProjection(effect: Effect): void;
  95741. /**
  95742. * Processes to execute after binding the material to a mesh
  95743. * @param mesh defines the rendered mesh
  95744. */
  95745. protected _afterBind(mesh?: Mesh): void;
  95746. /**
  95747. * Unbinds the material from the mesh
  95748. */
  95749. unbind(): void;
  95750. /**
  95751. * Gets the active textures from the material
  95752. * @returns an array of textures
  95753. */
  95754. getActiveTextures(): BaseTexture[];
  95755. /**
  95756. * Specifies if the material uses a texture
  95757. * @param texture defines the texture to check against the material
  95758. * @returns a boolean specifying if the material uses the texture
  95759. */
  95760. hasTexture(texture: BaseTexture): boolean;
  95761. /**
  95762. * Makes a duplicate of the material, and gives it a new name
  95763. * @param name defines the new name for the duplicated material
  95764. * @returns the cloned material
  95765. */
  95766. clone(name: string): Nullable<Material>;
  95767. /**
  95768. * Gets the meshes bound to the material
  95769. * @returns an array of meshes bound to the material
  95770. */
  95771. getBindedMeshes(): AbstractMesh[];
  95772. /**
  95773. * Force shader compilation
  95774. * @param mesh defines the mesh associated with this material
  95775. * @param onCompiled defines a function to execute once the material is compiled
  95776. * @param options defines the options to configure the compilation
  95777. * @param onError defines a function to execute if the material fails compiling
  95778. */
  95779. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  95780. /**
  95781. * Force shader compilation
  95782. * @param mesh defines the mesh that will use this material
  95783. * @param options defines additional options for compiling the shaders
  95784. * @returns a promise that resolves when the compilation completes
  95785. */
  95786. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  95787. private static readonly _AllDirtyCallBack;
  95788. private static readonly _ImageProcessingDirtyCallBack;
  95789. private static readonly _TextureDirtyCallBack;
  95790. private static readonly _FresnelDirtyCallBack;
  95791. private static readonly _MiscDirtyCallBack;
  95792. private static readonly _LightsDirtyCallBack;
  95793. private static readonly _AttributeDirtyCallBack;
  95794. private static _FresnelAndMiscDirtyCallBack;
  95795. private static _TextureAndMiscDirtyCallBack;
  95796. private static readonly _DirtyCallbackArray;
  95797. private static readonly _RunDirtyCallBacks;
  95798. /**
  95799. * Marks a define in the material to indicate that it needs to be re-computed
  95800. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  95801. */
  95802. markAsDirty(flag: number): void;
  95803. /**
  95804. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  95805. * @param func defines a function which checks material defines against the submeshes
  95806. */
  95807. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  95808. /**
  95809. * Indicates that we need to re-calculated for all submeshes
  95810. */
  95811. protected _markAllSubMeshesAsAllDirty(): void;
  95812. /**
  95813. * Indicates that image processing needs to be re-calculated for all submeshes
  95814. */
  95815. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  95816. /**
  95817. * Indicates that textures need to be re-calculated for all submeshes
  95818. */
  95819. protected _markAllSubMeshesAsTexturesDirty(): void;
  95820. /**
  95821. * Indicates that fresnel needs to be re-calculated for all submeshes
  95822. */
  95823. protected _markAllSubMeshesAsFresnelDirty(): void;
  95824. /**
  95825. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  95826. */
  95827. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  95828. /**
  95829. * Indicates that lights need to be re-calculated for all submeshes
  95830. */
  95831. protected _markAllSubMeshesAsLightsDirty(): void;
  95832. /**
  95833. * Indicates that attributes need to be re-calculated for all submeshes
  95834. */
  95835. protected _markAllSubMeshesAsAttributesDirty(): void;
  95836. /**
  95837. * Indicates that misc needs to be re-calculated for all submeshes
  95838. */
  95839. protected _markAllSubMeshesAsMiscDirty(): void;
  95840. /**
  95841. * Indicates that textures and misc need to be re-calculated for all submeshes
  95842. */
  95843. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  95844. /**
  95845. * Disposes the material
  95846. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  95847. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  95848. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  95849. */
  95850. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  95851. /** @hidden */
  95852. private releaseVertexArrayObject;
  95853. /**
  95854. * Serializes this material
  95855. * @returns the serialized material object
  95856. */
  95857. serialize(): any;
  95858. /**
  95859. * Creates a material from parsed material data
  95860. * @param parsedMaterial defines parsed material data
  95861. * @param scene defines the hosting scene
  95862. * @param rootUrl defines the root URL to use to load textures
  95863. * @returns a new material
  95864. */
  95865. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  95866. }
  95867. }
  95868. declare module BABYLON {
  95869. /**
  95870. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95871. * separate meshes. This can be use to improve performances.
  95872. * @see http://doc.babylonjs.com/how_to/multi_materials
  95873. */
  95874. export class MultiMaterial extends Material {
  95875. private _subMaterials;
  95876. /**
  95877. * Gets or Sets the list of Materials used within the multi material.
  95878. * They need to be ordered according to the submeshes order in the associated mesh
  95879. */
  95880. get subMaterials(): Nullable<Material>[];
  95881. set subMaterials(value: Nullable<Material>[]);
  95882. /**
  95883. * Function used to align with Node.getChildren()
  95884. * @returns the list of Materials used within the multi material
  95885. */
  95886. getChildren(): Nullable<Material>[];
  95887. /**
  95888. * Instantiates a new Multi Material
  95889. * A multi-material is used to apply different materials to different parts of the same object without the need of
  95890. * separate meshes. This can be use to improve performances.
  95891. * @see http://doc.babylonjs.com/how_to/multi_materials
  95892. * @param name Define the name in the scene
  95893. * @param scene Define the scene the material belongs to
  95894. */
  95895. constructor(name: string, scene: Scene);
  95896. private _hookArray;
  95897. /**
  95898. * Get one of the submaterial by its index in the submaterials array
  95899. * @param index The index to look the sub material at
  95900. * @returns The Material if the index has been defined
  95901. */
  95902. getSubMaterial(index: number): Nullable<Material>;
  95903. /**
  95904. * Get the list of active textures for the whole sub materials list.
  95905. * @returns All the textures that will be used during the rendering
  95906. */
  95907. getActiveTextures(): BaseTexture[];
  95908. /**
  95909. * Gets the current class name of the material e.g. "MultiMaterial"
  95910. * Mainly use in serialization.
  95911. * @returns the class name
  95912. */
  95913. getClassName(): string;
  95914. /**
  95915. * Checks if the material is ready to render the requested sub mesh
  95916. * @param mesh Define the mesh the submesh belongs to
  95917. * @param subMesh Define the sub mesh to look readyness for
  95918. * @param useInstances Define whether or not the material is used with instances
  95919. * @returns true if ready, otherwise false
  95920. */
  95921. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  95922. /**
  95923. * Clones the current material and its related sub materials
  95924. * @param name Define the name of the newly cloned material
  95925. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  95926. * @returns the cloned material
  95927. */
  95928. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  95929. /**
  95930. * Serializes the materials into a JSON representation.
  95931. * @returns the JSON representation
  95932. */
  95933. serialize(): any;
  95934. /**
  95935. * Dispose the material and release its associated resources
  95936. * @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)
  95937. * @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)
  95938. * @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)
  95939. */
  95940. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  95941. /**
  95942. * Creates a MultiMaterial from parsed MultiMaterial data.
  95943. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  95944. * @param scene defines the hosting scene
  95945. * @returns a new MultiMaterial
  95946. */
  95947. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  95948. }
  95949. }
  95950. declare module BABYLON {
  95951. /**
  95952. * Base class for submeshes
  95953. */
  95954. export class BaseSubMesh {
  95955. /** @hidden */
  95956. _materialDefines: Nullable<MaterialDefines>;
  95957. /** @hidden */
  95958. _materialEffect: Nullable<Effect>;
  95959. /**
  95960. * Gets material defines used by the effect associated to the sub mesh
  95961. */
  95962. get materialDefines(): Nullable<MaterialDefines>;
  95963. /**
  95964. * Sets material defines used by the effect associated to the sub mesh
  95965. */
  95966. set materialDefines(defines: Nullable<MaterialDefines>);
  95967. /**
  95968. * Gets associated effect
  95969. */
  95970. get effect(): Nullable<Effect>;
  95971. /**
  95972. * Sets associated effect (effect used to render this submesh)
  95973. * @param effect defines the effect to associate with
  95974. * @param defines defines the set of defines used to compile this effect
  95975. */
  95976. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  95977. }
  95978. /**
  95979. * Defines a subdivision inside a mesh
  95980. */
  95981. export class SubMesh extends BaseSubMesh implements ICullable {
  95982. /** the material index to use */
  95983. materialIndex: number;
  95984. /** vertex index start */
  95985. verticesStart: number;
  95986. /** vertices count */
  95987. verticesCount: number;
  95988. /** index start */
  95989. indexStart: number;
  95990. /** indices count */
  95991. indexCount: number;
  95992. /** @hidden */
  95993. _linesIndexCount: number;
  95994. private _mesh;
  95995. private _renderingMesh;
  95996. private _boundingInfo;
  95997. private _linesIndexBuffer;
  95998. /** @hidden */
  95999. _lastColliderWorldVertices: Nullable<Vector3[]>;
  96000. /** @hidden */
  96001. _trianglePlanes: Plane[];
  96002. /** @hidden */
  96003. _lastColliderTransformMatrix: Nullable<Matrix>;
  96004. /** @hidden */
  96005. _renderId: number;
  96006. /** @hidden */
  96007. _alphaIndex: number;
  96008. /** @hidden */
  96009. _distanceToCamera: number;
  96010. /** @hidden */
  96011. _id: number;
  96012. private _currentMaterial;
  96013. /**
  96014. * Add a new submesh to a mesh
  96015. * @param materialIndex defines the material index to use
  96016. * @param verticesStart defines vertex index start
  96017. * @param verticesCount defines vertices count
  96018. * @param indexStart defines index start
  96019. * @param indexCount defines indices count
  96020. * @param mesh defines the parent mesh
  96021. * @param renderingMesh defines an optional rendering mesh
  96022. * @param createBoundingBox defines if bounding box should be created for this submesh
  96023. * @returns the new submesh
  96024. */
  96025. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  96026. /**
  96027. * Creates a new submesh
  96028. * @param materialIndex defines the material index to use
  96029. * @param verticesStart defines vertex index start
  96030. * @param verticesCount defines vertices count
  96031. * @param indexStart defines index start
  96032. * @param indexCount defines indices count
  96033. * @param mesh defines the parent mesh
  96034. * @param renderingMesh defines an optional rendering mesh
  96035. * @param createBoundingBox defines if bounding box should be created for this submesh
  96036. */
  96037. constructor(
  96038. /** the material index to use */
  96039. materialIndex: number,
  96040. /** vertex index start */
  96041. verticesStart: number,
  96042. /** vertices count */
  96043. verticesCount: number,
  96044. /** index start */
  96045. indexStart: number,
  96046. /** indices count */
  96047. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  96048. /**
  96049. * Returns true if this submesh covers the entire parent mesh
  96050. * @ignorenaming
  96051. */
  96052. get IsGlobal(): boolean;
  96053. /**
  96054. * Returns the submesh BoudingInfo object
  96055. * @returns current bounding info (or mesh's one if the submesh is global)
  96056. */
  96057. getBoundingInfo(): BoundingInfo;
  96058. /**
  96059. * Sets the submesh BoundingInfo
  96060. * @param boundingInfo defines the new bounding info to use
  96061. * @returns the SubMesh
  96062. */
  96063. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  96064. /**
  96065. * Returns the mesh of the current submesh
  96066. * @return the parent mesh
  96067. */
  96068. getMesh(): AbstractMesh;
  96069. /**
  96070. * Returns the rendering mesh of the submesh
  96071. * @returns the rendering mesh (could be different from parent mesh)
  96072. */
  96073. getRenderingMesh(): Mesh;
  96074. /**
  96075. * Returns the submesh material
  96076. * @returns null or the current material
  96077. */
  96078. getMaterial(): Nullable<Material>;
  96079. /**
  96080. * Sets a new updated BoundingInfo object to the submesh
  96081. * @param data defines an optional position array to use to determine the bounding info
  96082. * @returns the SubMesh
  96083. */
  96084. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  96085. /** @hidden */
  96086. _checkCollision(collider: Collider): boolean;
  96087. /**
  96088. * Updates the submesh BoundingInfo
  96089. * @param world defines the world matrix to use to update the bounding info
  96090. * @returns the submesh
  96091. */
  96092. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  96093. /**
  96094. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  96095. * @param frustumPlanes defines the frustum planes
  96096. * @returns true if the submesh is intersecting with the frustum
  96097. */
  96098. isInFrustum(frustumPlanes: Plane[]): boolean;
  96099. /**
  96100. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  96101. * @param frustumPlanes defines the frustum planes
  96102. * @returns true if the submesh is inside the frustum
  96103. */
  96104. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  96105. /**
  96106. * Renders the submesh
  96107. * @param enableAlphaMode defines if alpha needs to be used
  96108. * @returns the submesh
  96109. */
  96110. render(enableAlphaMode: boolean): SubMesh;
  96111. /**
  96112. * @hidden
  96113. */
  96114. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  96115. /**
  96116. * Checks if the submesh intersects with a ray
  96117. * @param ray defines the ray to test
  96118. * @returns true is the passed ray intersects the submesh bounding box
  96119. */
  96120. canIntersects(ray: Ray): boolean;
  96121. /**
  96122. * Intersects current submesh with a ray
  96123. * @param ray defines the ray to test
  96124. * @param positions defines mesh's positions array
  96125. * @param indices defines mesh's indices array
  96126. * @param fastCheck defines if only bounding info should be used
  96127. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  96128. * @returns intersection info or null if no intersection
  96129. */
  96130. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  96131. /** @hidden */
  96132. private _intersectLines;
  96133. /** @hidden */
  96134. private _intersectUnIndexedLines;
  96135. /** @hidden */
  96136. private _intersectTriangles;
  96137. /** @hidden */
  96138. private _intersectUnIndexedTriangles;
  96139. /** @hidden */
  96140. _rebuild(): void;
  96141. /**
  96142. * Creates a new submesh from the passed mesh
  96143. * @param newMesh defines the new hosting mesh
  96144. * @param newRenderingMesh defines an optional rendering mesh
  96145. * @returns the new submesh
  96146. */
  96147. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  96148. /**
  96149. * Release associated resources
  96150. */
  96151. dispose(): void;
  96152. /**
  96153. * Gets the class name
  96154. * @returns the string "SubMesh".
  96155. */
  96156. getClassName(): string;
  96157. /**
  96158. * Creates a new submesh from indices data
  96159. * @param materialIndex the index of the main mesh material
  96160. * @param startIndex the index where to start the copy in the mesh indices array
  96161. * @param indexCount the number of indices to copy then from the startIndex
  96162. * @param mesh the main mesh to create the submesh from
  96163. * @param renderingMesh the optional rendering mesh
  96164. * @returns a new submesh
  96165. */
  96166. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  96167. }
  96168. }
  96169. declare module BABYLON {
  96170. /**
  96171. * Class used to represent data loading progression
  96172. */
  96173. export class SceneLoaderFlags {
  96174. private static _ForceFullSceneLoadingForIncremental;
  96175. private static _ShowLoadingScreen;
  96176. private static _CleanBoneMatrixWeights;
  96177. private static _loggingLevel;
  96178. /**
  96179. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  96180. */
  96181. static get ForceFullSceneLoadingForIncremental(): boolean;
  96182. static set ForceFullSceneLoadingForIncremental(value: boolean);
  96183. /**
  96184. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  96185. */
  96186. static get ShowLoadingScreen(): boolean;
  96187. static set ShowLoadingScreen(value: boolean);
  96188. /**
  96189. * Defines the current logging level (while loading the scene)
  96190. * @ignorenaming
  96191. */
  96192. static get loggingLevel(): number;
  96193. static set loggingLevel(value: number);
  96194. /**
  96195. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  96196. */
  96197. static get CleanBoneMatrixWeights(): boolean;
  96198. static set CleanBoneMatrixWeights(value: boolean);
  96199. }
  96200. }
  96201. declare module BABYLON {
  96202. /**
  96203. * Class used to store geometry data (vertex buffers + index buffer)
  96204. */
  96205. export class Geometry implements IGetSetVerticesData {
  96206. /**
  96207. * Gets or sets the ID of the geometry
  96208. */
  96209. id: string;
  96210. /**
  96211. * Gets or sets the unique ID of the geometry
  96212. */
  96213. uniqueId: number;
  96214. /**
  96215. * Gets the delay loading state of the geometry (none by default which means not delayed)
  96216. */
  96217. delayLoadState: number;
  96218. /**
  96219. * Gets the file containing the data to load when running in delay load state
  96220. */
  96221. delayLoadingFile: Nullable<string>;
  96222. /**
  96223. * Callback called when the geometry is updated
  96224. */
  96225. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  96226. private _scene;
  96227. private _engine;
  96228. private _meshes;
  96229. private _totalVertices;
  96230. /** @hidden */
  96231. _indices: IndicesArray;
  96232. /** @hidden */
  96233. _vertexBuffers: {
  96234. [key: string]: VertexBuffer;
  96235. };
  96236. private _isDisposed;
  96237. private _extend;
  96238. private _boundingBias;
  96239. /** @hidden */
  96240. _delayInfo: Array<string>;
  96241. private _indexBuffer;
  96242. private _indexBufferIsUpdatable;
  96243. /** @hidden */
  96244. _boundingInfo: Nullable<BoundingInfo>;
  96245. /** @hidden */
  96246. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  96247. /** @hidden */
  96248. _softwareSkinningFrameId: number;
  96249. private _vertexArrayObjects;
  96250. private _updatable;
  96251. /** @hidden */
  96252. _positions: Nullable<Vector3[]>;
  96253. /**
  96254. * 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
  96255. */
  96256. get boundingBias(): Vector2;
  96257. /**
  96258. * 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
  96259. */
  96260. set boundingBias(value: Vector2);
  96261. /**
  96262. * Static function used to attach a new empty geometry to a mesh
  96263. * @param mesh defines the mesh to attach the geometry to
  96264. * @returns the new Geometry
  96265. */
  96266. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  96267. /** Get the list of meshes using this geometry */
  96268. get meshes(): Mesh[];
  96269. /**
  96270. * Creates a new geometry
  96271. * @param id defines the unique ID
  96272. * @param scene defines the hosting scene
  96273. * @param vertexData defines the VertexData used to get geometry data
  96274. * @param updatable defines if geometry must be updatable (false by default)
  96275. * @param mesh defines the mesh that will be associated with the geometry
  96276. */
  96277. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  96278. /**
  96279. * Gets the current extend of the geometry
  96280. */
  96281. get extend(): {
  96282. minimum: Vector3;
  96283. maximum: Vector3;
  96284. };
  96285. /**
  96286. * Gets the hosting scene
  96287. * @returns the hosting Scene
  96288. */
  96289. getScene(): Scene;
  96290. /**
  96291. * Gets the hosting engine
  96292. * @returns the hosting Engine
  96293. */
  96294. getEngine(): Engine;
  96295. /**
  96296. * Defines if the geometry is ready to use
  96297. * @returns true if the geometry is ready to be used
  96298. */
  96299. isReady(): boolean;
  96300. /**
  96301. * Gets a value indicating that the geometry should not be serialized
  96302. */
  96303. get doNotSerialize(): boolean;
  96304. /** @hidden */
  96305. _rebuild(): void;
  96306. /**
  96307. * Affects all geometry data in one call
  96308. * @param vertexData defines the geometry data
  96309. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  96310. */
  96311. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  96312. /**
  96313. * Set specific vertex data
  96314. * @param kind defines the data kind (Position, normal, etc...)
  96315. * @param data defines the vertex data to use
  96316. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96317. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96318. */
  96319. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  96320. /**
  96321. * Removes a specific vertex data
  96322. * @param kind defines the data kind (Position, normal, etc...)
  96323. */
  96324. removeVerticesData(kind: string): void;
  96325. /**
  96326. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  96327. * @param buffer defines the vertex buffer to use
  96328. * @param totalVertices defines the total number of vertices for position kind (could be null)
  96329. */
  96330. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  96331. /**
  96332. * Update a specific vertex buffer
  96333. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  96334. * It will do nothing if the buffer is not updatable
  96335. * @param kind defines the data kind (Position, normal, etc...)
  96336. * @param data defines the data to use
  96337. * @param offset defines the offset in the target buffer where to store the data
  96338. * @param useBytes set to true if the offset is in bytes
  96339. */
  96340. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  96341. /**
  96342. * Update a specific vertex buffer
  96343. * This function will create a new buffer if the current one is not updatable
  96344. * @param kind defines the data kind (Position, normal, etc...)
  96345. * @param data defines the data to use
  96346. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  96347. */
  96348. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  96349. private _updateBoundingInfo;
  96350. /** @hidden */
  96351. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  96352. /**
  96353. * Gets total number of vertices
  96354. * @returns the total number of vertices
  96355. */
  96356. getTotalVertices(): number;
  96357. /**
  96358. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96359. * @param kind defines the data kind (Position, normal, etc...)
  96360. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96361. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96362. * @returns a float array containing vertex data
  96363. */
  96364. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96365. /**
  96366. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  96367. * @param kind defines the data kind (Position, normal, etc...)
  96368. * @returns true if the vertex buffer with the specified kind is updatable
  96369. */
  96370. isVertexBufferUpdatable(kind: string): boolean;
  96371. /**
  96372. * Gets a specific vertex buffer
  96373. * @param kind defines the data kind (Position, normal, etc...)
  96374. * @returns a VertexBuffer
  96375. */
  96376. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  96377. /**
  96378. * Returns all vertex buffers
  96379. * @return an object holding all vertex buffers indexed by kind
  96380. */
  96381. getVertexBuffers(): Nullable<{
  96382. [key: string]: VertexBuffer;
  96383. }>;
  96384. /**
  96385. * Gets a boolean indicating if specific vertex buffer is present
  96386. * @param kind defines the data kind (Position, normal, etc...)
  96387. * @returns true if data is present
  96388. */
  96389. isVerticesDataPresent(kind: string): boolean;
  96390. /**
  96391. * Gets a list of all attached data kinds (Position, normal, etc...)
  96392. * @returns a list of string containing all kinds
  96393. */
  96394. getVerticesDataKinds(): string[];
  96395. /**
  96396. * Update index buffer
  96397. * @param indices defines the indices to store in the index buffer
  96398. * @param offset defines the offset in the target buffer where to store the data
  96399. * @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)
  96400. */
  96401. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  96402. /**
  96403. * Creates a new index buffer
  96404. * @param indices defines the indices to store in the index buffer
  96405. * @param totalVertices defines the total number of vertices (could be null)
  96406. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96407. */
  96408. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  96409. /**
  96410. * Return the total number of indices
  96411. * @returns the total number of indices
  96412. */
  96413. getTotalIndices(): number;
  96414. /**
  96415. * Gets the index buffer array
  96416. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96417. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96418. * @returns the index buffer array
  96419. */
  96420. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96421. /**
  96422. * Gets the index buffer
  96423. * @return the index buffer
  96424. */
  96425. getIndexBuffer(): Nullable<DataBuffer>;
  96426. /** @hidden */
  96427. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  96428. /**
  96429. * Release the associated resources for a specific mesh
  96430. * @param mesh defines the source mesh
  96431. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  96432. */
  96433. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  96434. /**
  96435. * Apply current geometry to a given mesh
  96436. * @param mesh defines the mesh to apply geometry to
  96437. */
  96438. applyToMesh(mesh: Mesh): void;
  96439. private _updateExtend;
  96440. private _applyToMesh;
  96441. private notifyUpdate;
  96442. /**
  96443. * Load the geometry if it was flagged as delay loaded
  96444. * @param scene defines the hosting scene
  96445. * @param onLoaded defines a callback called when the geometry is loaded
  96446. */
  96447. load(scene: Scene, onLoaded?: () => void): void;
  96448. private _queueLoad;
  96449. /**
  96450. * Invert the geometry to move from a right handed system to a left handed one.
  96451. */
  96452. toLeftHanded(): void;
  96453. /** @hidden */
  96454. _resetPointsArrayCache(): void;
  96455. /** @hidden */
  96456. _generatePointsArray(): boolean;
  96457. /**
  96458. * Gets a value indicating if the geometry is disposed
  96459. * @returns true if the geometry was disposed
  96460. */
  96461. isDisposed(): boolean;
  96462. private _disposeVertexArrayObjects;
  96463. /**
  96464. * Free all associated resources
  96465. */
  96466. dispose(): void;
  96467. /**
  96468. * Clone the current geometry into a new geometry
  96469. * @param id defines the unique ID of the new geometry
  96470. * @returns a new geometry object
  96471. */
  96472. copy(id: string): Geometry;
  96473. /**
  96474. * Serialize the current geometry info (and not the vertices data) into a JSON object
  96475. * @return a JSON representation of the current geometry data (without the vertices data)
  96476. */
  96477. serialize(): any;
  96478. private toNumberArray;
  96479. /**
  96480. * Serialize all vertices data into a JSON oject
  96481. * @returns a JSON representation of the current geometry data
  96482. */
  96483. serializeVerticeData(): any;
  96484. /**
  96485. * Extracts a clone of a mesh geometry
  96486. * @param mesh defines the source mesh
  96487. * @param id defines the unique ID of the new geometry object
  96488. * @returns the new geometry object
  96489. */
  96490. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  96491. /**
  96492. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  96493. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  96494. * Be aware Math.random() could cause collisions, but:
  96495. * "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"
  96496. * @returns a string containing a new GUID
  96497. */
  96498. static RandomId(): string;
  96499. /** @hidden */
  96500. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  96501. private static _CleanMatricesWeights;
  96502. /**
  96503. * Create a new geometry from persisted data (Using .babylon file format)
  96504. * @param parsedVertexData defines the persisted data
  96505. * @param scene defines the hosting scene
  96506. * @param rootUrl defines the root url to use to load assets (like delayed data)
  96507. * @returns the new geometry object
  96508. */
  96509. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  96510. }
  96511. }
  96512. declare module BABYLON {
  96513. /**
  96514. * Define an interface for all classes that will get and set the data on vertices
  96515. */
  96516. export interface IGetSetVerticesData {
  96517. /**
  96518. * Gets a boolean indicating if specific vertex data is present
  96519. * @param kind defines the vertex data kind to use
  96520. * @returns true is data kind is present
  96521. */
  96522. isVerticesDataPresent(kind: string): boolean;
  96523. /**
  96524. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  96525. * @param kind defines the data kind (Position, normal, etc...)
  96526. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  96527. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96528. * @returns a float array containing vertex data
  96529. */
  96530. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  96531. /**
  96532. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96533. * @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.
  96534. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  96535. * @returns the indices array or an empty array if the mesh has no geometry
  96536. */
  96537. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  96538. /**
  96539. * Set specific vertex data
  96540. * @param kind defines the data kind (Position, normal, etc...)
  96541. * @param data defines the vertex data to use
  96542. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  96543. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  96544. */
  96545. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  96546. /**
  96547. * Update a specific associated vertex buffer
  96548. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  96549. * - VertexBuffer.PositionKind
  96550. * - VertexBuffer.UVKind
  96551. * - VertexBuffer.UV2Kind
  96552. * - VertexBuffer.UV3Kind
  96553. * - VertexBuffer.UV4Kind
  96554. * - VertexBuffer.UV5Kind
  96555. * - VertexBuffer.UV6Kind
  96556. * - VertexBuffer.ColorKind
  96557. * - VertexBuffer.MatricesIndicesKind
  96558. * - VertexBuffer.MatricesIndicesExtraKind
  96559. * - VertexBuffer.MatricesWeightsKind
  96560. * - VertexBuffer.MatricesWeightsExtraKind
  96561. * @param data defines the data source
  96562. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  96563. * @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)
  96564. */
  96565. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  96566. /**
  96567. * Creates a new index buffer
  96568. * @param indices defines the indices to store in the index buffer
  96569. * @param totalVertices defines the total number of vertices (could be null)
  96570. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  96571. */
  96572. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  96573. }
  96574. /**
  96575. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  96576. */
  96577. export class VertexData {
  96578. /**
  96579. * Mesh side orientation : usually the external or front surface
  96580. */
  96581. static readonly FRONTSIDE: number;
  96582. /**
  96583. * Mesh side orientation : usually the internal or back surface
  96584. */
  96585. static readonly BACKSIDE: number;
  96586. /**
  96587. * Mesh side orientation : both internal and external or front and back surfaces
  96588. */
  96589. static readonly DOUBLESIDE: number;
  96590. /**
  96591. * Mesh side orientation : by default, `FRONTSIDE`
  96592. */
  96593. static readonly DEFAULTSIDE: number;
  96594. /**
  96595. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  96596. */
  96597. positions: Nullable<FloatArray>;
  96598. /**
  96599. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  96600. */
  96601. normals: Nullable<FloatArray>;
  96602. /**
  96603. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  96604. */
  96605. tangents: Nullable<FloatArray>;
  96606. /**
  96607. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96608. */
  96609. uvs: Nullable<FloatArray>;
  96610. /**
  96611. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96612. */
  96613. uvs2: Nullable<FloatArray>;
  96614. /**
  96615. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96616. */
  96617. uvs3: Nullable<FloatArray>;
  96618. /**
  96619. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96620. */
  96621. uvs4: Nullable<FloatArray>;
  96622. /**
  96623. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96624. */
  96625. uvs5: Nullable<FloatArray>;
  96626. /**
  96627. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  96628. */
  96629. uvs6: Nullable<FloatArray>;
  96630. /**
  96631. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  96632. */
  96633. colors: Nullable<FloatArray>;
  96634. /**
  96635. * 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).
  96636. */
  96637. matricesIndices: Nullable<FloatArray>;
  96638. /**
  96639. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  96640. */
  96641. matricesWeights: Nullable<FloatArray>;
  96642. /**
  96643. * An array extending the number of possible indices
  96644. */
  96645. matricesIndicesExtra: Nullable<FloatArray>;
  96646. /**
  96647. * An array extending the number of possible weights when the number of indices is extended
  96648. */
  96649. matricesWeightsExtra: Nullable<FloatArray>;
  96650. /**
  96651. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  96652. */
  96653. indices: Nullable<IndicesArray>;
  96654. /**
  96655. * Uses the passed data array to set the set the values for the specified kind of data
  96656. * @param data a linear array of floating numbers
  96657. * @param kind the type of data that is being set, eg positions, colors etc
  96658. */
  96659. set(data: FloatArray, kind: string): void;
  96660. /**
  96661. * Associates the vertexData to the passed Mesh.
  96662. * Sets it as updatable or not (default `false`)
  96663. * @param mesh the mesh the vertexData is applied to
  96664. * @param updatable when used and having the value true allows new data to update the vertexData
  96665. * @returns the VertexData
  96666. */
  96667. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  96668. /**
  96669. * Associates the vertexData to the passed Geometry.
  96670. * Sets it as updatable or not (default `false`)
  96671. * @param geometry the geometry the vertexData is applied to
  96672. * @param updatable when used and having the value true allows new data to update the vertexData
  96673. * @returns VertexData
  96674. */
  96675. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  96676. /**
  96677. * Updates the associated mesh
  96678. * @param mesh the mesh to be updated
  96679. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96680. * @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
  96681. * @returns VertexData
  96682. */
  96683. updateMesh(mesh: Mesh): VertexData;
  96684. /**
  96685. * Updates the associated geometry
  96686. * @param geometry the geometry to be updated
  96687. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  96688. * @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
  96689. * @returns VertexData.
  96690. */
  96691. updateGeometry(geometry: Geometry): VertexData;
  96692. private _applyTo;
  96693. private _update;
  96694. /**
  96695. * Transforms each position and each normal of the vertexData according to the passed Matrix
  96696. * @param matrix the transforming matrix
  96697. * @returns the VertexData
  96698. */
  96699. transform(matrix: Matrix): VertexData;
  96700. /**
  96701. * Merges the passed VertexData into the current one
  96702. * @param other the VertexData to be merged into the current one
  96703. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  96704. * @returns the modified VertexData
  96705. */
  96706. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  96707. private _mergeElement;
  96708. private _validate;
  96709. /**
  96710. * Serializes the VertexData
  96711. * @returns a serialized object
  96712. */
  96713. serialize(): any;
  96714. /**
  96715. * Extracts the vertexData from a mesh
  96716. * @param mesh the mesh from which to extract the VertexData
  96717. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  96718. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96719. * @returns the object VertexData associated to the passed mesh
  96720. */
  96721. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96722. /**
  96723. * Extracts the vertexData from the geometry
  96724. * @param geometry the geometry from which to extract the VertexData
  96725. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  96726. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  96727. * @returns the object VertexData associated to the passed mesh
  96728. */
  96729. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  96730. private static _ExtractFrom;
  96731. /**
  96732. * Creates the VertexData for a Ribbon
  96733. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  96734. * * pathArray array of paths, each of which an array of successive Vector3
  96735. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  96736. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  96737. * * 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
  96738. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96739. * * 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)
  96740. * * 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)
  96741. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  96742. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  96743. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  96744. * @returns the VertexData of the ribbon
  96745. */
  96746. static CreateRibbon(options: {
  96747. pathArray: Vector3[][];
  96748. closeArray?: boolean;
  96749. closePath?: boolean;
  96750. offset?: number;
  96751. sideOrientation?: number;
  96752. frontUVs?: Vector4;
  96753. backUVs?: Vector4;
  96754. invertUV?: boolean;
  96755. uvs?: Vector2[];
  96756. colors?: Color4[];
  96757. }): VertexData;
  96758. /**
  96759. * Creates the VertexData for a box
  96760. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96761. * * size sets the width, height and depth of the box to the value of size, optional default 1
  96762. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  96763. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  96764. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  96765. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96766. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96767. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96768. * * 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)
  96769. * * 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)
  96770. * @returns the VertexData of the box
  96771. */
  96772. static CreateBox(options: {
  96773. size?: number;
  96774. width?: number;
  96775. height?: number;
  96776. depth?: number;
  96777. faceUV?: Vector4[];
  96778. faceColors?: Color4[];
  96779. sideOrientation?: number;
  96780. frontUVs?: Vector4;
  96781. backUVs?: Vector4;
  96782. }): VertexData;
  96783. /**
  96784. * Creates the VertexData for a tiled box
  96785. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96786. * * faceTiles sets the pattern, tile size and number of tiles for a face
  96787. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  96788. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  96789. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96790. * @returns the VertexData of the box
  96791. */
  96792. static CreateTiledBox(options: {
  96793. pattern?: number;
  96794. width?: number;
  96795. height?: number;
  96796. depth?: number;
  96797. tileSize?: number;
  96798. tileWidth?: number;
  96799. tileHeight?: number;
  96800. alignHorizontal?: number;
  96801. alignVertical?: number;
  96802. faceUV?: Vector4[];
  96803. faceColors?: Color4[];
  96804. sideOrientation?: number;
  96805. }): VertexData;
  96806. /**
  96807. * Creates the VertexData for a tiled plane
  96808. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96809. * * pattern a limited pattern arrangement depending on the number
  96810. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  96811. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  96812. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  96813. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96814. * * 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)
  96815. * * 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)
  96816. * @returns the VertexData of the tiled plane
  96817. */
  96818. static CreateTiledPlane(options: {
  96819. pattern?: number;
  96820. tileSize?: number;
  96821. tileWidth?: number;
  96822. tileHeight?: number;
  96823. size?: number;
  96824. width?: number;
  96825. height?: number;
  96826. alignHorizontal?: number;
  96827. alignVertical?: number;
  96828. sideOrientation?: number;
  96829. frontUVs?: Vector4;
  96830. backUVs?: Vector4;
  96831. }): VertexData;
  96832. /**
  96833. * Creates the VertexData for an ellipsoid, defaults to a sphere
  96834. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96835. * * segments sets the number of horizontal strips optional, default 32
  96836. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  96837. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  96838. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  96839. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  96840. * * 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
  96841. * * 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
  96842. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96843. * * 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)
  96844. * * 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)
  96845. * @returns the VertexData of the ellipsoid
  96846. */
  96847. static CreateSphere(options: {
  96848. segments?: number;
  96849. diameter?: number;
  96850. diameterX?: number;
  96851. diameterY?: number;
  96852. diameterZ?: number;
  96853. arc?: number;
  96854. slice?: number;
  96855. sideOrientation?: number;
  96856. frontUVs?: Vector4;
  96857. backUVs?: Vector4;
  96858. }): VertexData;
  96859. /**
  96860. * Creates the VertexData for a cylinder, cone or prism
  96861. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96862. * * height sets the height (y direction) of the cylinder, optional, default 2
  96863. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  96864. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  96865. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  96866. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96867. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  96868. * * 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
  96869. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  96870. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  96871. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  96872. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  96873. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96874. * * 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)
  96875. * * 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)
  96876. * @returns the VertexData of the cylinder, cone or prism
  96877. */
  96878. static CreateCylinder(options: {
  96879. height?: number;
  96880. diameterTop?: number;
  96881. diameterBottom?: number;
  96882. diameter?: number;
  96883. tessellation?: number;
  96884. subdivisions?: number;
  96885. arc?: number;
  96886. faceColors?: Color4[];
  96887. faceUV?: Vector4[];
  96888. hasRings?: boolean;
  96889. enclose?: boolean;
  96890. sideOrientation?: number;
  96891. frontUVs?: Vector4;
  96892. backUVs?: Vector4;
  96893. }): VertexData;
  96894. /**
  96895. * Creates the VertexData for a torus
  96896. * @param options an object used to set the following optional parameters for the box, required but can be empty
  96897. * * diameter the diameter of the torus, optional default 1
  96898. * * thickness the diameter of the tube forming the torus, optional default 0.5
  96899. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  96900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  96901. * * 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)
  96902. * * 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)
  96903. * @returns the VertexData of the torus
  96904. */
  96905. static CreateTorus(options: {
  96906. diameter?: number;
  96907. thickness?: number;
  96908. tessellation?: number;
  96909. sideOrientation?: number;
  96910. frontUVs?: Vector4;
  96911. backUVs?: Vector4;
  96912. }): VertexData;
  96913. /**
  96914. * Creates the VertexData of the LineSystem
  96915. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  96916. * - lines an array of lines, each line being an array of successive Vector3
  96917. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  96918. * @returns the VertexData of the LineSystem
  96919. */
  96920. static CreateLineSystem(options: {
  96921. lines: Vector3[][];
  96922. colors?: Nullable<Color4[][]>;
  96923. }): VertexData;
  96924. /**
  96925. * Create the VertexData for a DashedLines
  96926. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  96927. * - points an array successive Vector3
  96928. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  96929. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  96930. * - dashNb the intended total number of dashes, optional, default 200
  96931. * @returns the VertexData for the DashedLines
  96932. */
  96933. static CreateDashedLines(options: {
  96934. points: Vector3[];
  96935. dashSize?: number;
  96936. gapSize?: number;
  96937. dashNb?: number;
  96938. }): VertexData;
  96939. /**
  96940. * Creates the VertexData for a Ground
  96941. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96942. * - width the width (x direction) of the ground, optional, default 1
  96943. * - height the height (z direction) of the ground, optional, default 1
  96944. * - subdivisions the number of subdivisions per side, optional, default 1
  96945. * @returns the VertexData of the Ground
  96946. */
  96947. static CreateGround(options: {
  96948. width?: number;
  96949. height?: number;
  96950. subdivisions?: number;
  96951. subdivisionsX?: number;
  96952. subdivisionsY?: number;
  96953. }): VertexData;
  96954. /**
  96955. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  96956. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  96957. * * xmin the ground minimum X coordinate, optional, default -1
  96958. * * zmin the ground minimum Z coordinate, optional, default -1
  96959. * * xmax the ground maximum X coordinate, optional, default 1
  96960. * * zmax the ground maximum Z coordinate, optional, default 1
  96961. * * 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}
  96962. * * 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}
  96963. * @returns the VertexData of the TiledGround
  96964. */
  96965. static CreateTiledGround(options: {
  96966. xmin: number;
  96967. zmin: number;
  96968. xmax: number;
  96969. zmax: number;
  96970. subdivisions?: {
  96971. w: number;
  96972. h: number;
  96973. };
  96974. precision?: {
  96975. w: number;
  96976. h: number;
  96977. };
  96978. }): VertexData;
  96979. /**
  96980. * Creates the VertexData of the Ground designed from a heightmap
  96981. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  96982. * * width the width (x direction) of the ground
  96983. * * height the height (z direction) of the ground
  96984. * * subdivisions the number of subdivisions per side
  96985. * * minHeight the minimum altitude on the ground, optional, default 0
  96986. * * maxHeight the maximum altitude on the ground, optional default 1
  96987. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  96988. * * buffer the array holding the image color data
  96989. * * bufferWidth the width of image
  96990. * * bufferHeight the height of image
  96991. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  96992. * @returns the VertexData of the Ground designed from a heightmap
  96993. */
  96994. static CreateGroundFromHeightMap(options: {
  96995. width: number;
  96996. height: number;
  96997. subdivisions: number;
  96998. minHeight: number;
  96999. maxHeight: number;
  97000. colorFilter: Color3;
  97001. buffer: Uint8Array;
  97002. bufferWidth: number;
  97003. bufferHeight: number;
  97004. alphaFilter: number;
  97005. }): VertexData;
  97006. /**
  97007. * Creates the VertexData for a Plane
  97008. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  97009. * * size sets the width and height of the plane to the value of size, optional default 1
  97010. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  97011. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  97012. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97013. * * 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)
  97014. * * 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)
  97015. * @returns the VertexData of the box
  97016. */
  97017. static CreatePlane(options: {
  97018. size?: number;
  97019. width?: number;
  97020. height?: number;
  97021. sideOrientation?: number;
  97022. frontUVs?: Vector4;
  97023. backUVs?: Vector4;
  97024. }): VertexData;
  97025. /**
  97026. * Creates the VertexData of the Disc or regular Polygon
  97027. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  97028. * * radius the radius of the disc, optional default 0.5
  97029. * * tessellation the number of polygon sides, optional, default 64
  97030. * * 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
  97031. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97032. * * 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)
  97033. * * 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)
  97034. * @returns the VertexData of the box
  97035. */
  97036. static CreateDisc(options: {
  97037. radius?: number;
  97038. tessellation?: number;
  97039. arc?: number;
  97040. sideOrientation?: number;
  97041. frontUVs?: Vector4;
  97042. backUVs?: Vector4;
  97043. }): VertexData;
  97044. /**
  97045. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  97046. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  97047. * @param polygon a mesh built from polygonTriangulation.build()
  97048. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97049. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97050. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97051. * @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)
  97052. * @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)
  97053. * @returns the VertexData of the Polygon
  97054. */
  97055. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  97056. /**
  97057. * Creates the VertexData of the IcoSphere
  97058. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  97059. * * radius the radius of the IcoSphere, optional default 1
  97060. * * radiusX allows stretching in the x direction, optional, default radius
  97061. * * radiusY allows stretching in the y direction, optional, default radius
  97062. * * radiusZ allows stretching in the z direction, optional, default radius
  97063. * * flat when true creates a flat shaded mesh, optional, default true
  97064. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97065. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97066. * * 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)
  97067. * * 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)
  97068. * @returns the VertexData of the IcoSphere
  97069. */
  97070. static CreateIcoSphere(options: {
  97071. radius?: number;
  97072. radiusX?: number;
  97073. radiusY?: number;
  97074. radiusZ?: number;
  97075. flat?: boolean;
  97076. subdivisions?: number;
  97077. sideOrientation?: number;
  97078. frontUVs?: Vector4;
  97079. backUVs?: Vector4;
  97080. }): VertexData;
  97081. /**
  97082. * Creates the VertexData for a Polyhedron
  97083. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  97084. * * type provided types are:
  97085. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  97086. * * 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)
  97087. * * size the size of the IcoSphere, optional default 1
  97088. * * sizeX allows stretching in the x direction, optional, default size
  97089. * * sizeY allows stretching in the y direction, optional, default size
  97090. * * sizeZ allows stretching in the z direction, optional, default size
  97091. * * 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
  97092. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  97093. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  97094. * * flat when true creates a flat shaded mesh, optional, default true
  97095. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  97096. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97097. * * 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)
  97098. * * 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)
  97099. * @returns the VertexData of the Polyhedron
  97100. */
  97101. static CreatePolyhedron(options: {
  97102. type?: number;
  97103. size?: number;
  97104. sizeX?: number;
  97105. sizeY?: number;
  97106. sizeZ?: number;
  97107. custom?: any;
  97108. faceUV?: Vector4[];
  97109. faceColors?: Color4[];
  97110. flat?: boolean;
  97111. sideOrientation?: number;
  97112. frontUVs?: Vector4;
  97113. backUVs?: Vector4;
  97114. }): VertexData;
  97115. /**
  97116. * Creates the VertexData for a TorusKnot
  97117. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  97118. * * radius the radius of the torus knot, optional, default 2
  97119. * * tube the thickness of the tube, optional, default 0.5
  97120. * * radialSegments the number of sides on each tube segments, optional, default 32
  97121. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  97122. * * p the number of windings around the z axis, optional, default 2
  97123. * * q the number of windings around the x axis, optional, default 3
  97124. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  97125. * * 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)
  97126. * * 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)
  97127. * @returns the VertexData of the Torus Knot
  97128. */
  97129. static CreateTorusKnot(options: {
  97130. radius?: number;
  97131. tube?: number;
  97132. radialSegments?: number;
  97133. tubularSegments?: number;
  97134. p?: number;
  97135. q?: number;
  97136. sideOrientation?: number;
  97137. frontUVs?: Vector4;
  97138. backUVs?: Vector4;
  97139. }): VertexData;
  97140. /**
  97141. * Compute normals for given positions and indices
  97142. * @param positions an array of vertex positions, [...., x, y, z, ......]
  97143. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  97144. * @param normals an array of vertex normals, [...., x, y, z, ......]
  97145. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  97146. * * facetNormals : optional array of facet normals (vector3)
  97147. * * facetPositions : optional array of facet positions (vector3)
  97148. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  97149. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  97150. * * bInfo : optional bounding info, required for facetPartitioning computation
  97151. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  97152. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  97153. * * useRightHandedSystem: optional boolean to for right handed system computation
  97154. * * depthSort : optional boolean to enable the facet depth sort computation
  97155. * * distanceTo : optional Vector3 to compute the facet depth from this location
  97156. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  97157. */
  97158. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  97159. facetNormals?: any;
  97160. facetPositions?: any;
  97161. facetPartitioning?: any;
  97162. ratio?: number;
  97163. bInfo?: any;
  97164. bbSize?: Vector3;
  97165. subDiv?: any;
  97166. useRightHandedSystem?: boolean;
  97167. depthSort?: boolean;
  97168. distanceTo?: Vector3;
  97169. depthSortedFacets?: any;
  97170. }): void;
  97171. /** @hidden */
  97172. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  97173. /**
  97174. * Applies VertexData created from the imported parameters to the geometry
  97175. * @param parsedVertexData the parsed data from an imported file
  97176. * @param geometry the geometry to apply the VertexData to
  97177. */
  97178. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  97179. }
  97180. }
  97181. declare module BABYLON {
  97182. /**
  97183. * Defines a target to use with MorphTargetManager
  97184. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97185. */
  97186. export class MorphTarget implements IAnimatable {
  97187. /** defines the name of the target */
  97188. name: string;
  97189. /**
  97190. * Gets or sets the list of animations
  97191. */
  97192. animations: Animation[];
  97193. private _scene;
  97194. private _positions;
  97195. private _normals;
  97196. private _tangents;
  97197. private _uvs;
  97198. private _influence;
  97199. private _uniqueId;
  97200. /**
  97201. * Observable raised when the influence changes
  97202. */
  97203. onInfluenceChanged: Observable<boolean>;
  97204. /** @hidden */
  97205. _onDataLayoutChanged: Observable<void>;
  97206. /**
  97207. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  97208. */
  97209. get influence(): number;
  97210. set influence(influence: number);
  97211. /**
  97212. * Gets or sets the id of the morph Target
  97213. */
  97214. id: string;
  97215. private _animationPropertiesOverride;
  97216. /**
  97217. * Gets or sets the animation properties override
  97218. */
  97219. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  97220. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  97221. /**
  97222. * Creates a new MorphTarget
  97223. * @param name defines the name of the target
  97224. * @param influence defines the influence to use
  97225. * @param scene defines the scene the morphtarget belongs to
  97226. */
  97227. constructor(
  97228. /** defines the name of the target */
  97229. name: string, influence?: number, scene?: Nullable<Scene>);
  97230. /**
  97231. * Gets the unique ID of this manager
  97232. */
  97233. get uniqueId(): number;
  97234. /**
  97235. * Gets a boolean defining if the target contains position data
  97236. */
  97237. get hasPositions(): boolean;
  97238. /**
  97239. * Gets a boolean defining if the target contains normal data
  97240. */
  97241. get hasNormals(): boolean;
  97242. /**
  97243. * Gets a boolean defining if the target contains tangent data
  97244. */
  97245. get hasTangents(): boolean;
  97246. /**
  97247. * Gets a boolean defining if the target contains texture coordinates data
  97248. */
  97249. get hasUVs(): boolean;
  97250. /**
  97251. * Affects position data to this target
  97252. * @param data defines the position data to use
  97253. */
  97254. setPositions(data: Nullable<FloatArray>): void;
  97255. /**
  97256. * Gets the position data stored in this target
  97257. * @returns a FloatArray containing the position data (or null if not present)
  97258. */
  97259. getPositions(): Nullable<FloatArray>;
  97260. /**
  97261. * Affects normal data to this target
  97262. * @param data defines the normal data to use
  97263. */
  97264. setNormals(data: Nullable<FloatArray>): void;
  97265. /**
  97266. * Gets the normal data stored in this target
  97267. * @returns a FloatArray containing the normal data (or null if not present)
  97268. */
  97269. getNormals(): Nullable<FloatArray>;
  97270. /**
  97271. * Affects tangent data to this target
  97272. * @param data defines the tangent data to use
  97273. */
  97274. setTangents(data: Nullable<FloatArray>): void;
  97275. /**
  97276. * Gets the tangent data stored in this target
  97277. * @returns a FloatArray containing the tangent data (or null if not present)
  97278. */
  97279. getTangents(): Nullable<FloatArray>;
  97280. /**
  97281. * Affects texture coordinates data to this target
  97282. * @param data defines the texture coordinates data to use
  97283. */
  97284. setUVs(data: Nullable<FloatArray>): void;
  97285. /**
  97286. * Gets the texture coordinates data stored in this target
  97287. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  97288. */
  97289. getUVs(): Nullable<FloatArray>;
  97290. /**
  97291. * Clone the current target
  97292. * @returns a new MorphTarget
  97293. */
  97294. clone(): MorphTarget;
  97295. /**
  97296. * Serializes the current target into a Serialization object
  97297. * @returns the serialized object
  97298. */
  97299. serialize(): any;
  97300. /**
  97301. * Returns the string "MorphTarget"
  97302. * @returns "MorphTarget"
  97303. */
  97304. getClassName(): string;
  97305. /**
  97306. * Creates a new target from serialized data
  97307. * @param serializationObject defines the serialized data to use
  97308. * @returns a new MorphTarget
  97309. */
  97310. static Parse(serializationObject: any): MorphTarget;
  97311. /**
  97312. * Creates a MorphTarget from mesh data
  97313. * @param mesh defines the source mesh
  97314. * @param name defines the name to use for the new target
  97315. * @param influence defines the influence to attach to the target
  97316. * @returns a new MorphTarget
  97317. */
  97318. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  97319. }
  97320. }
  97321. declare module BABYLON {
  97322. /**
  97323. * This class is used to deform meshes using morphing between different targets
  97324. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  97325. */
  97326. export class MorphTargetManager {
  97327. private _targets;
  97328. private _targetInfluenceChangedObservers;
  97329. private _targetDataLayoutChangedObservers;
  97330. private _activeTargets;
  97331. private _scene;
  97332. private _influences;
  97333. private _supportsNormals;
  97334. private _supportsTangents;
  97335. private _supportsUVs;
  97336. private _vertexCount;
  97337. private _uniqueId;
  97338. private _tempInfluences;
  97339. /**
  97340. * Gets or sets a boolean indicating if normals must be morphed
  97341. */
  97342. enableNormalMorphing: boolean;
  97343. /**
  97344. * Gets or sets a boolean indicating if tangents must be morphed
  97345. */
  97346. enableTangentMorphing: boolean;
  97347. /**
  97348. * Gets or sets a boolean indicating if UV must be morphed
  97349. */
  97350. enableUVMorphing: boolean;
  97351. /**
  97352. * Creates a new MorphTargetManager
  97353. * @param scene defines the current scene
  97354. */
  97355. constructor(scene?: Nullable<Scene>);
  97356. /**
  97357. * Gets the unique ID of this manager
  97358. */
  97359. get uniqueId(): number;
  97360. /**
  97361. * Gets the number of vertices handled by this manager
  97362. */
  97363. get vertexCount(): number;
  97364. /**
  97365. * Gets a boolean indicating if this manager supports morphing of normals
  97366. */
  97367. get supportsNormals(): boolean;
  97368. /**
  97369. * Gets a boolean indicating if this manager supports morphing of tangents
  97370. */
  97371. get supportsTangents(): boolean;
  97372. /**
  97373. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  97374. */
  97375. get supportsUVs(): boolean;
  97376. /**
  97377. * Gets the number of targets stored in this manager
  97378. */
  97379. get numTargets(): number;
  97380. /**
  97381. * Gets the number of influencers (ie. the number of targets with influences > 0)
  97382. */
  97383. get numInfluencers(): number;
  97384. /**
  97385. * Gets the list of influences (one per target)
  97386. */
  97387. get influences(): Float32Array;
  97388. /**
  97389. * Gets the active target at specified index. An active target is a target with an influence > 0
  97390. * @param index defines the index to check
  97391. * @returns the requested target
  97392. */
  97393. getActiveTarget(index: number): MorphTarget;
  97394. /**
  97395. * Gets the target at specified index
  97396. * @param index defines the index to check
  97397. * @returns the requested target
  97398. */
  97399. getTarget(index: number): MorphTarget;
  97400. /**
  97401. * Add a new target to this manager
  97402. * @param target defines the target to add
  97403. */
  97404. addTarget(target: MorphTarget): void;
  97405. /**
  97406. * Removes a target from the manager
  97407. * @param target defines the target to remove
  97408. */
  97409. removeTarget(target: MorphTarget): void;
  97410. /**
  97411. * Clone the current manager
  97412. * @returns a new MorphTargetManager
  97413. */
  97414. clone(): MorphTargetManager;
  97415. /**
  97416. * Serializes the current manager into a Serialization object
  97417. * @returns the serialized object
  97418. */
  97419. serialize(): any;
  97420. private _syncActiveTargets;
  97421. /**
  97422. * Syncrhonize the targets with all the meshes using this morph target manager
  97423. */
  97424. synchronize(): void;
  97425. /**
  97426. * Creates a new MorphTargetManager from serialized data
  97427. * @param serializationObject defines the serialized data
  97428. * @param scene defines the hosting scene
  97429. * @returns the new MorphTargetManager
  97430. */
  97431. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  97432. }
  97433. }
  97434. declare module BABYLON {
  97435. /**
  97436. * Class used to represent a specific level of detail of a mesh
  97437. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  97438. */
  97439. export class MeshLODLevel {
  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. * Creates a new LOD level
  97446. * @param distance defines the distance where this level should star being displayed
  97447. * @param mesh defines the mesh to use to render this level
  97448. */
  97449. constructor(
  97450. /** Defines the distance where this level should start being displayed */
  97451. distance: number,
  97452. /** Defines the mesh to use to render this level */
  97453. mesh: Nullable<Mesh>);
  97454. }
  97455. }
  97456. declare module BABYLON {
  97457. /**
  97458. * Mesh representing the gorund
  97459. */
  97460. export class GroundMesh extends Mesh {
  97461. /** If octree should be generated */
  97462. generateOctree: boolean;
  97463. private _heightQuads;
  97464. /** @hidden */
  97465. _subdivisionsX: number;
  97466. /** @hidden */
  97467. _subdivisionsY: number;
  97468. /** @hidden */
  97469. _width: number;
  97470. /** @hidden */
  97471. _height: number;
  97472. /** @hidden */
  97473. _minX: number;
  97474. /** @hidden */
  97475. _maxX: number;
  97476. /** @hidden */
  97477. _minZ: number;
  97478. /** @hidden */
  97479. _maxZ: number;
  97480. constructor(name: string, scene: Scene);
  97481. /**
  97482. * "GroundMesh"
  97483. * @returns "GroundMesh"
  97484. */
  97485. getClassName(): string;
  97486. /**
  97487. * The minimum of x and y subdivisions
  97488. */
  97489. get subdivisions(): number;
  97490. /**
  97491. * X subdivisions
  97492. */
  97493. get subdivisionsX(): number;
  97494. /**
  97495. * Y subdivisions
  97496. */
  97497. get subdivisionsY(): number;
  97498. /**
  97499. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  97500. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  97501. * @param chunksCount the number of subdivisions for x and y
  97502. * @param octreeBlocksSize (Default: 32)
  97503. */
  97504. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  97505. /**
  97506. * Returns a height (y) value in the Worl system :
  97507. * the ground altitude at the coordinates (x, z) expressed in the World system.
  97508. * @param x x coordinate
  97509. * @param z z coordinate
  97510. * @returns the ground y position if (x, z) are outside the ground surface.
  97511. */
  97512. getHeightAtCoordinates(x: number, z: number): number;
  97513. /**
  97514. * Returns a normalized vector (Vector3) orthogonal to the ground
  97515. * at the ground coordinates (x, z) expressed in the World system.
  97516. * @param x x coordinate
  97517. * @param z z coordinate
  97518. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  97519. */
  97520. getNormalAtCoordinates(x: number, z: number): Vector3;
  97521. /**
  97522. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  97523. * at the ground coordinates (x, z) expressed in the World system.
  97524. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  97525. * @param x x coordinate
  97526. * @param z z coordinate
  97527. * @param ref vector to store the result
  97528. * @returns the GroundMesh.
  97529. */
  97530. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  97531. /**
  97532. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  97533. * if the ground has been updated.
  97534. * This can be used in the render loop.
  97535. * @returns the GroundMesh.
  97536. */
  97537. updateCoordinateHeights(): GroundMesh;
  97538. private _getFacetAt;
  97539. private _initHeightQuads;
  97540. private _computeHeightQuads;
  97541. /**
  97542. * Serializes this ground mesh
  97543. * @param serializationObject object to write serialization to
  97544. */
  97545. serialize(serializationObject: any): void;
  97546. /**
  97547. * Parses a serialized ground mesh
  97548. * @param parsedMesh the serialized mesh
  97549. * @param scene the scene to create the ground mesh in
  97550. * @returns the created ground mesh
  97551. */
  97552. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  97553. }
  97554. }
  97555. declare module BABYLON {
  97556. /**
  97557. * Interface for Physics-Joint data
  97558. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97559. */
  97560. export interface PhysicsJointData {
  97561. /**
  97562. * The main pivot of the joint
  97563. */
  97564. mainPivot?: Vector3;
  97565. /**
  97566. * The connected pivot of the joint
  97567. */
  97568. connectedPivot?: Vector3;
  97569. /**
  97570. * The main axis of the joint
  97571. */
  97572. mainAxis?: Vector3;
  97573. /**
  97574. * The connected axis of the joint
  97575. */
  97576. connectedAxis?: Vector3;
  97577. /**
  97578. * The collision of the joint
  97579. */
  97580. collision?: boolean;
  97581. /**
  97582. * Native Oimo/Cannon/Energy data
  97583. */
  97584. nativeParams?: any;
  97585. }
  97586. /**
  97587. * This is a holder class for the physics joint created by the physics plugin
  97588. * It holds a set of functions to control the underlying joint
  97589. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97590. */
  97591. export class PhysicsJoint {
  97592. /**
  97593. * The type of the physics joint
  97594. */
  97595. type: number;
  97596. /**
  97597. * The data for the physics joint
  97598. */
  97599. jointData: PhysicsJointData;
  97600. private _physicsJoint;
  97601. protected _physicsPlugin: IPhysicsEnginePlugin;
  97602. /**
  97603. * Initializes the physics joint
  97604. * @param type The type of the physics joint
  97605. * @param jointData The data for the physics joint
  97606. */
  97607. constructor(
  97608. /**
  97609. * The type of the physics joint
  97610. */
  97611. type: number,
  97612. /**
  97613. * The data for the physics joint
  97614. */
  97615. jointData: PhysicsJointData);
  97616. /**
  97617. * Gets the physics joint
  97618. */
  97619. get physicsJoint(): any;
  97620. /**
  97621. * Sets the physics joint
  97622. */
  97623. set physicsJoint(newJoint: any);
  97624. /**
  97625. * Sets the physics plugin
  97626. */
  97627. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  97628. /**
  97629. * Execute a function that is physics-plugin specific.
  97630. * @param {Function} func the function that will be executed.
  97631. * It accepts two parameters: the physics world and the physics joint
  97632. */
  97633. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  97634. /**
  97635. * Distance-Joint type
  97636. */
  97637. static DistanceJoint: number;
  97638. /**
  97639. * Hinge-Joint type
  97640. */
  97641. static HingeJoint: number;
  97642. /**
  97643. * Ball-and-Socket joint type
  97644. */
  97645. static BallAndSocketJoint: number;
  97646. /**
  97647. * Wheel-Joint type
  97648. */
  97649. static WheelJoint: number;
  97650. /**
  97651. * Slider-Joint type
  97652. */
  97653. static SliderJoint: number;
  97654. /**
  97655. * Prismatic-Joint type
  97656. */
  97657. static PrismaticJoint: number;
  97658. /**
  97659. * Universal-Joint type
  97660. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  97661. */
  97662. static UniversalJoint: number;
  97663. /**
  97664. * Hinge-Joint 2 type
  97665. */
  97666. static Hinge2Joint: number;
  97667. /**
  97668. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  97669. */
  97670. static PointToPointJoint: number;
  97671. /**
  97672. * Spring-Joint type
  97673. */
  97674. static SpringJoint: number;
  97675. /**
  97676. * Lock-Joint type
  97677. */
  97678. static LockJoint: number;
  97679. }
  97680. /**
  97681. * A class representing a physics distance joint
  97682. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97683. */
  97684. export class DistanceJoint extends PhysicsJoint {
  97685. /**
  97686. *
  97687. * @param jointData The data for the Distance-Joint
  97688. */
  97689. constructor(jointData: DistanceJointData);
  97690. /**
  97691. * Update the predefined distance.
  97692. * @param maxDistance The maximum preferred distance
  97693. * @param minDistance The minimum preferred distance
  97694. */
  97695. updateDistance(maxDistance: number, minDistance?: number): void;
  97696. }
  97697. /**
  97698. * Represents a Motor-Enabled Joint
  97699. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97700. */
  97701. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  97702. /**
  97703. * Initializes the Motor-Enabled Joint
  97704. * @param type The type of the joint
  97705. * @param jointData The physica joint data for the joint
  97706. */
  97707. constructor(type: number, jointData: PhysicsJointData);
  97708. /**
  97709. * Set the motor values.
  97710. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97711. * @param force the force to apply
  97712. * @param maxForce max force for this motor.
  97713. */
  97714. setMotor(force?: number, maxForce?: number): void;
  97715. /**
  97716. * Set the motor's limits.
  97717. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97718. * @param upperLimit The upper limit of the motor
  97719. * @param lowerLimit The lower limit of the motor
  97720. */
  97721. setLimit(upperLimit: number, lowerLimit?: number): void;
  97722. }
  97723. /**
  97724. * This class represents a single physics Hinge-Joint
  97725. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97726. */
  97727. export class HingeJoint extends MotorEnabledJoint {
  97728. /**
  97729. * Initializes the Hinge-Joint
  97730. * @param jointData The joint data for the Hinge-Joint
  97731. */
  97732. constructor(jointData: PhysicsJointData);
  97733. /**
  97734. * Set the motor values.
  97735. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97736. * @param {number} force the force to apply
  97737. * @param {number} maxForce max force for this motor.
  97738. */
  97739. setMotor(force?: number, maxForce?: number): void;
  97740. /**
  97741. * Set the motor's limits.
  97742. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97743. * @param upperLimit The upper limit of the motor
  97744. * @param lowerLimit The lower limit of the motor
  97745. */
  97746. setLimit(upperLimit: number, lowerLimit?: number): void;
  97747. }
  97748. /**
  97749. * This class represents a dual hinge physics joint (same as wheel joint)
  97750. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97751. */
  97752. export class Hinge2Joint extends MotorEnabledJoint {
  97753. /**
  97754. * Initializes the Hinge2-Joint
  97755. * @param jointData The joint data for the Hinge2-Joint
  97756. */
  97757. constructor(jointData: PhysicsJointData);
  97758. /**
  97759. * Set the motor values.
  97760. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97761. * @param {number} targetSpeed the speed the motor is to reach
  97762. * @param {number} maxForce max force for this motor.
  97763. * @param {motorIndex} the motor's index, 0 or 1.
  97764. */
  97765. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  97766. /**
  97767. * Set the motor limits.
  97768. * Attention, this function is plugin specific. Engines won't react 100% the same.
  97769. * @param {number} upperLimit the upper limit
  97770. * @param {number} lowerLimit lower limit
  97771. * @param {motorIndex} the motor's index, 0 or 1.
  97772. */
  97773. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97774. }
  97775. /**
  97776. * Interface for a motor enabled joint
  97777. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97778. */
  97779. export interface IMotorEnabledJoint {
  97780. /**
  97781. * Physics joint
  97782. */
  97783. physicsJoint: any;
  97784. /**
  97785. * Sets the motor of the motor-enabled joint
  97786. * @param force The force of the motor
  97787. * @param maxForce The maximum force of the motor
  97788. * @param motorIndex The index of the motor
  97789. */
  97790. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  97791. /**
  97792. * Sets the limit of the motor
  97793. * @param upperLimit The upper limit of the motor
  97794. * @param lowerLimit The lower limit of the motor
  97795. * @param motorIndex The index of the motor
  97796. */
  97797. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97798. }
  97799. /**
  97800. * Joint data for a Distance-Joint
  97801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97802. */
  97803. export interface DistanceJointData extends PhysicsJointData {
  97804. /**
  97805. * Max distance the 2 joint objects can be apart
  97806. */
  97807. maxDistance: number;
  97808. }
  97809. /**
  97810. * Joint data from a spring joint
  97811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97812. */
  97813. export interface SpringJointData extends PhysicsJointData {
  97814. /**
  97815. * Length of the spring
  97816. */
  97817. length: number;
  97818. /**
  97819. * Stiffness of the spring
  97820. */
  97821. stiffness: number;
  97822. /**
  97823. * Damping of the spring
  97824. */
  97825. damping: number;
  97826. /** this callback will be called when applying the force to the impostors. */
  97827. forceApplicationCallback: () => void;
  97828. }
  97829. }
  97830. declare module BABYLON {
  97831. /**
  97832. * Holds the data for the raycast result
  97833. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  97834. */
  97835. export class PhysicsRaycastResult {
  97836. private _hasHit;
  97837. private _hitDistance;
  97838. private _hitNormalWorld;
  97839. private _hitPointWorld;
  97840. private _rayFromWorld;
  97841. private _rayToWorld;
  97842. /**
  97843. * Gets if there was a hit
  97844. */
  97845. get hasHit(): boolean;
  97846. /**
  97847. * Gets the distance from the hit
  97848. */
  97849. get hitDistance(): number;
  97850. /**
  97851. * Gets the hit normal/direction in the world
  97852. */
  97853. get hitNormalWorld(): Vector3;
  97854. /**
  97855. * Gets the hit point in the world
  97856. */
  97857. get hitPointWorld(): Vector3;
  97858. /**
  97859. * Gets the ray "start point" of the ray in the world
  97860. */
  97861. get rayFromWorld(): Vector3;
  97862. /**
  97863. * Gets the ray "end point" of the ray in the world
  97864. */
  97865. get rayToWorld(): Vector3;
  97866. /**
  97867. * Sets the hit data (normal & point in world space)
  97868. * @param hitNormalWorld defines the normal in world space
  97869. * @param hitPointWorld defines the point in world space
  97870. */
  97871. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  97872. /**
  97873. * Sets the distance from the start point to the hit point
  97874. * @param distance
  97875. */
  97876. setHitDistance(distance: number): void;
  97877. /**
  97878. * Calculates the distance manually
  97879. */
  97880. calculateHitDistance(): void;
  97881. /**
  97882. * Resets all the values to default
  97883. * @param from The from point on world space
  97884. * @param to The to point on world space
  97885. */
  97886. reset(from?: Vector3, to?: Vector3): void;
  97887. }
  97888. /**
  97889. * Interface for the size containing width and height
  97890. */
  97891. interface IXYZ {
  97892. /**
  97893. * X
  97894. */
  97895. x: number;
  97896. /**
  97897. * Y
  97898. */
  97899. y: number;
  97900. /**
  97901. * Z
  97902. */
  97903. z: number;
  97904. }
  97905. }
  97906. declare module BABYLON {
  97907. /**
  97908. * Interface used to describe a physics joint
  97909. */
  97910. export interface PhysicsImpostorJoint {
  97911. /** Defines the main impostor to which the joint is linked */
  97912. mainImpostor: PhysicsImpostor;
  97913. /** Defines the impostor that is connected to the main impostor using this joint */
  97914. connectedImpostor: PhysicsImpostor;
  97915. /** Defines the joint itself */
  97916. joint: PhysicsJoint;
  97917. }
  97918. /** @hidden */
  97919. export interface IPhysicsEnginePlugin {
  97920. world: any;
  97921. name: string;
  97922. setGravity(gravity: Vector3): void;
  97923. setTimeStep(timeStep: number): void;
  97924. getTimeStep(): number;
  97925. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  97926. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97927. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  97928. generatePhysicsBody(impostor: PhysicsImpostor): void;
  97929. removePhysicsBody(impostor: PhysicsImpostor): void;
  97930. generateJoint(joint: PhysicsImpostorJoint): void;
  97931. removeJoint(joint: PhysicsImpostorJoint): void;
  97932. isSupported(): boolean;
  97933. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  97934. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  97935. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97936. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  97937. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97938. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  97939. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  97940. getBodyMass(impostor: PhysicsImpostor): number;
  97941. getBodyFriction(impostor: PhysicsImpostor): number;
  97942. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  97943. getBodyRestitution(impostor: PhysicsImpostor): number;
  97944. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  97945. getBodyPressure?(impostor: PhysicsImpostor): number;
  97946. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  97947. getBodyStiffness?(impostor: PhysicsImpostor): number;
  97948. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  97949. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  97950. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  97951. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  97952. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  97953. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97954. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  97955. sleepBody(impostor: PhysicsImpostor): void;
  97956. wakeUpBody(impostor: PhysicsImpostor): void;
  97957. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  97958. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  97959. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  97960. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  97961. getRadius(impostor: PhysicsImpostor): number;
  97962. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  97963. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  97964. dispose(): void;
  97965. }
  97966. /**
  97967. * Interface used to define a physics engine
  97968. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  97969. */
  97970. export interface IPhysicsEngine {
  97971. /**
  97972. * Gets the gravity vector used by the simulation
  97973. */
  97974. gravity: Vector3;
  97975. /**
  97976. * Sets the gravity vector used by the simulation
  97977. * @param gravity defines the gravity vector to use
  97978. */
  97979. setGravity(gravity: Vector3): void;
  97980. /**
  97981. * Set the time step of the physics engine.
  97982. * Default is 1/60.
  97983. * To slow it down, enter 1/600 for example.
  97984. * To speed it up, 1/30
  97985. * @param newTimeStep the new timestep to apply to this world.
  97986. */
  97987. setTimeStep(newTimeStep: number): void;
  97988. /**
  97989. * Get the time step of the physics engine.
  97990. * @returns the current time step
  97991. */
  97992. getTimeStep(): number;
  97993. /**
  97994. * Set the sub time step of the physics engine.
  97995. * Default is 0 meaning there is no sub steps
  97996. * To increase physics resolution precision, set a small value (like 1 ms)
  97997. * @param subTimeStep defines the new sub timestep used for physics resolution.
  97998. */
  97999. setSubTimeStep(subTimeStep: number): void;
  98000. /**
  98001. * Get the sub time step of the physics engine.
  98002. * @returns the current sub time step
  98003. */
  98004. getSubTimeStep(): number;
  98005. /**
  98006. * Release all resources
  98007. */
  98008. dispose(): void;
  98009. /**
  98010. * Gets the name of the current physics plugin
  98011. * @returns the name of the plugin
  98012. */
  98013. getPhysicsPluginName(): string;
  98014. /**
  98015. * Adding a new impostor for the impostor tracking.
  98016. * This will be done by the impostor itself.
  98017. * @param impostor the impostor to add
  98018. */
  98019. addImpostor(impostor: PhysicsImpostor): void;
  98020. /**
  98021. * Remove an impostor from the engine.
  98022. * This impostor and its mesh will not longer be updated by the physics engine.
  98023. * @param impostor the impostor to remove
  98024. */
  98025. removeImpostor(impostor: PhysicsImpostor): void;
  98026. /**
  98027. * Add a joint to the physics engine
  98028. * @param mainImpostor defines the main impostor to which the joint is added.
  98029. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  98030. * @param joint defines the joint that will connect both impostors.
  98031. */
  98032. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98033. /**
  98034. * Removes a joint from the simulation
  98035. * @param mainImpostor defines the impostor used with the joint
  98036. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  98037. * @param joint defines the joint to remove
  98038. */
  98039. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  98040. /**
  98041. * Gets the current plugin used to run the simulation
  98042. * @returns current plugin
  98043. */
  98044. getPhysicsPlugin(): IPhysicsEnginePlugin;
  98045. /**
  98046. * Gets the list of physic impostors
  98047. * @returns an array of PhysicsImpostor
  98048. */
  98049. getImpostors(): Array<PhysicsImpostor>;
  98050. /**
  98051. * Gets the impostor for a physics enabled object
  98052. * @param object defines the object impersonated by the impostor
  98053. * @returns the PhysicsImpostor or null if not found
  98054. */
  98055. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98056. /**
  98057. * Gets the impostor for a physics body object
  98058. * @param body defines physics body used by the impostor
  98059. * @returns the PhysicsImpostor or null if not found
  98060. */
  98061. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  98062. /**
  98063. * Does a raycast in the physics world
  98064. * @param from when should the ray start?
  98065. * @param to when should the ray end?
  98066. * @returns PhysicsRaycastResult
  98067. */
  98068. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  98069. /**
  98070. * Called by the scene. No need to call it.
  98071. * @param delta defines the timespam between frames
  98072. */
  98073. _step(delta: number): void;
  98074. }
  98075. }
  98076. declare module BABYLON {
  98077. /**
  98078. * The interface for the physics imposter parameters
  98079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98080. */
  98081. export interface PhysicsImpostorParameters {
  98082. /**
  98083. * The mass of the physics imposter
  98084. */
  98085. mass: number;
  98086. /**
  98087. * The friction of the physics imposter
  98088. */
  98089. friction?: number;
  98090. /**
  98091. * The coefficient of restitution of the physics imposter
  98092. */
  98093. restitution?: number;
  98094. /**
  98095. * The native options of the physics imposter
  98096. */
  98097. nativeOptions?: any;
  98098. /**
  98099. * Specifies if the parent should be ignored
  98100. */
  98101. ignoreParent?: boolean;
  98102. /**
  98103. * Specifies if bi-directional transformations should be disabled
  98104. */
  98105. disableBidirectionalTransformation?: boolean;
  98106. /**
  98107. * The pressure inside the physics imposter, soft object only
  98108. */
  98109. pressure?: number;
  98110. /**
  98111. * The stiffness the physics imposter, soft object only
  98112. */
  98113. stiffness?: number;
  98114. /**
  98115. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  98116. */
  98117. velocityIterations?: number;
  98118. /**
  98119. * The number of iterations used in maintaining consistent vertex positions, soft object only
  98120. */
  98121. positionIterations?: number;
  98122. /**
  98123. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  98124. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  98125. * Add to fix multiple points
  98126. */
  98127. fixedPoints?: number;
  98128. /**
  98129. * The collision margin around a soft object
  98130. */
  98131. margin?: number;
  98132. /**
  98133. * The collision margin around a soft object
  98134. */
  98135. damping?: number;
  98136. /**
  98137. * The path for a rope based on an extrusion
  98138. */
  98139. path?: any;
  98140. /**
  98141. * The shape of an extrusion used for a rope based on an extrusion
  98142. */
  98143. shape?: any;
  98144. }
  98145. /**
  98146. * Interface for a physics-enabled object
  98147. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98148. */
  98149. export interface IPhysicsEnabledObject {
  98150. /**
  98151. * The position of the physics-enabled object
  98152. */
  98153. position: Vector3;
  98154. /**
  98155. * The rotation of the physics-enabled object
  98156. */
  98157. rotationQuaternion: Nullable<Quaternion>;
  98158. /**
  98159. * The scale of the physics-enabled object
  98160. */
  98161. scaling: Vector3;
  98162. /**
  98163. * The rotation of the physics-enabled object
  98164. */
  98165. rotation?: Vector3;
  98166. /**
  98167. * The parent of the physics-enabled object
  98168. */
  98169. parent?: any;
  98170. /**
  98171. * The bounding info of the physics-enabled object
  98172. * @returns The bounding info of the physics-enabled object
  98173. */
  98174. getBoundingInfo(): BoundingInfo;
  98175. /**
  98176. * Computes the world matrix
  98177. * @param force Specifies if the world matrix should be computed by force
  98178. * @returns A world matrix
  98179. */
  98180. computeWorldMatrix(force: boolean): Matrix;
  98181. /**
  98182. * Gets the world matrix
  98183. * @returns A world matrix
  98184. */
  98185. getWorldMatrix?(): Matrix;
  98186. /**
  98187. * Gets the child meshes
  98188. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  98189. * @returns An array of abstract meshes
  98190. */
  98191. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  98192. /**
  98193. * Gets the vertex data
  98194. * @param kind The type of vertex data
  98195. * @returns A nullable array of numbers, or a float32 array
  98196. */
  98197. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  98198. /**
  98199. * Gets the indices from the mesh
  98200. * @returns A nullable array of index arrays
  98201. */
  98202. getIndices?(): Nullable<IndicesArray>;
  98203. /**
  98204. * Gets the scene from the mesh
  98205. * @returns the indices array or null
  98206. */
  98207. getScene?(): Scene;
  98208. /**
  98209. * Gets the absolute position from the mesh
  98210. * @returns the absolute position
  98211. */
  98212. getAbsolutePosition(): Vector3;
  98213. /**
  98214. * Gets the absolute pivot point from the mesh
  98215. * @returns the absolute pivot point
  98216. */
  98217. getAbsolutePivotPoint(): Vector3;
  98218. /**
  98219. * Rotates the mesh
  98220. * @param axis The axis of rotation
  98221. * @param amount The amount of rotation
  98222. * @param space The space of the rotation
  98223. * @returns The rotation transform node
  98224. */
  98225. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  98226. /**
  98227. * Translates the mesh
  98228. * @param axis The axis of translation
  98229. * @param distance The distance of translation
  98230. * @param space The space of the translation
  98231. * @returns The transform node
  98232. */
  98233. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  98234. /**
  98235. * Sets the absolute position of the mesh
  98236. * @param absolutePosition The absolute position of the mesh
  98237. * @returns The transform node
  98238. */
  98239. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  98240. /**
  98241. * Gets the class name of the mesh
  98242. * @returns The class name
  98243. */
  98244. getClassName(): string;
  98245. }
  98246. /**
  98247. * Represents a physics imposter
  98248. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  98249. */
  98250. export class PhysicsImpostor {
  98251. /**
  98252. * The physics-enabled object used as the physics imposter
  98253. */
  98254. object: IPhysicsEnabledObject;
  98255. /**
  98256. * The type of the physics imposter
  98257. */
  98258. type: number;
  98259. private _options;
  98260. private _scene?;
  98261. /**
  98262. * The default object size of the imposter
  98263. */
  98264. static DEFAULT_OBJECT_SIZE: Vector3;
  98265. /**
  98266. * The identity quaternion of the imposter
  98267. */
  98268. static IDENTITY_QUATERNION: Quaternion;
  98269. /** @hidden */
  98270. _pluginData: any;
  98271. private _physicsEngine;
  98272. private _physicsBody;
  98273. private _bodyUpdateRequired;
  98274. private _onBeforePhysicsStepCallbacks;
  98275. private _onAfterPhysicsStepCallbacks;
  98276. /** @hidden */
  98277. _onPhysicsCollideCallbacks: Array<{
  98278. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  98279. otherImpostors: Array<PhysicsImpostor>;
  98280. }>;
  98281. private _deltaPosition;
  98282. private _deltaRotation;
  98283. private _deltaRotationConjugated;
  98284. /** @hidden */
  98285. _isFromLine: boolean;
  98286. private _parent;
  98287. private _isDisposed;
  98288. private static _tmpVecs;
  98289. private static _tmpQuat;
  98290. /**
  98291. * Specifies if the physics imposter is disposed
  98292. */
  98293. get isDisposed(): boolean;
  98294. /**
  98295. * Gets the mass of the physics imposter
  98296. */
  98297. get mass(): number;
  98298. set mass(value: number);
  98299. /**
  98300. * Gets the coefficient of friction
  98301. */
  98302. get friction(): number;
  98303. /**
  98304. * Sets the coefficient of friction
  98305. */
  98306. set friction(value: number);
  98307. /**
  98308. * Gets the coefficient of restitution
  98309. */
  98310. get restitution(): number;
  98311. /**
  98312. * Sets the coefficient of restitution
  98313. */
  98314. set restitution(value: number);
  98315. /**
  98316. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  98317. */
  98318. get pressure(): number;
  98319. /**
  98320. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  98321. */
  98322. set pressure(value: number);
  98323. /**
  98324. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98325. */
  98326. get stiffness(): number;
  98327. /**
  98328. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  98329. */
  98330. set stiffness(value: number);
  98331. /**
  98332. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98333. */
  98334. get velocityIterations(): number;
  98335. /**
  98336. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  98337. */
  98338. set velocityIterations(value: number);
  98339. /**
  98340. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98341. */
  98342. get positionIterations(): number;
  98343. /**
  98344. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  98345. */
  98346. set positionIterations(value: number);
  98347. /**
  98348. * The unique id of the physics imposter
  98349. * set by the physics engine when adding this impostor to the array
  98350. */
  98351. uniqueId: number;
  98352. /**
  98353. * @hidden
  98354. */
  98355. soft: boolean;
  98356. /**
  98357. * @hidden
  98358. */
  98359. segments: number;
  98360. private _joints;
  98361. /**
  98362. * Initializes the physics imposter
  98363. * @param object The physics-enabled object used as the physics imposter
  98364. * @param type The type of the physics imposter
  98365. * @param _options The options for the physics imposter
  98366. * @param _scene The Babylon scene
  98367. */
  98368. constructor(
  98369. /**
  98370. * The physics-enabled object used as the physics imposter
  98371. */
  98372. object: IPhysicsEnabledObject,
  98373. /**
  98374. * The type of the physics imposter
  98375. */
  98376. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  98377. /**
  98378. * This function will completly initialize this impostor.
  98379. * It will create a new body - but only if this mesh has no parent.
  98380. * If it has, this impostor will not be used other than to define the impostor
  98381. * of the child mesh.
  98382. * @hidden
  98383. */
  98384. _init(): void;
  98385. private _getPhysicsParent;
  98386. /**
  98387. * Should a new body be generated.
  98388. * @returns boolean specifying if body initialization is required
  98389. */
  98390. isBodyInitRequired(): boolean;
  98391. /**
  98392. * Sets the updated scaling
  98393. * @param updated Specifies if the scaling is updated
  98394. */
  98395. setScalingUpdated(): void;
  98396. /**
  98397. * Force a regeneration of this or the parent's impostor's body.
  98398. * Use under cautious - This will remove all joints already implemented.
  98399. */
  98400. forceUpdate(): void;
  98401. /**
  98402. * Gets the body that holds this impostor. Either its own, or its parent.
  98403. */
  98404. get physicsBody(): any;
  98405. /**
  98406. * Get the parent of the physics imposter
  98407. * @returns Physics imposter or null
  98408. */
  98409. get parent(): Nullable<PhysicsImpostor>;
  98410. /**
  98411. * Sets the parent of the physics imposter
  98412. */
  98413. set parent(value: Nullable<PhysicsImpostor>);
  98414. /**
  98415. * Set the physics body. Used mainly by the physics engine/plugin
  98416. */
  98417. set physicsBody(physicsBody: any);
  98418. /**
  98419. * Resets the update flags
  98420. */
  98421. resetUpdateFlags(): void;
  98422. /**
  98423. * Gets the object extend size
  98424. * @returns the object extend size
  98425. */
  98426. getObjectExtendSize(): Vector3;
  98427. /**
  98428. * Gets the object center
  98429. * @returns The object center
  98430. */
  98431. getObjectCenter(): Vector3;
  98432. /**
  98433. * Get a specific parameter from the options parameters
  98434. * @param paramName The object parameter name
  98435. * @returns The object parameter
  98436. */
  98437. getParam(paramName: string): any;
  98438. /**
  98439. * Sets a specific parameter in the options given to the physics plugin
  98440. * @param paramName The parameter name
  98441. * @param value The value of the parameter
  98442. */
  98443. setParam(paramName: string, value: number): void;
  98444. /**
  98445. * Specifically change the body's mass option. Won't recreate the physics body object
  98446. * @param mass The mass of the physics imposter
  98447. */
  98448. setMass(mass: number): void;
  98449. /**
  98450. * Gets the linear velocity
  98451. * @returns linear velocity or null
  98452. */
  98453. getLinearVelocity(): Nullable<Vector3>;
  98454. /**
  98455. * Sets the linear velocity
  98456. * @param velocity linear velocity or null
  98457. */
  98458. setLinearVelocity(velocity: Nullable<Vector3>): void;
  98459. /**
  98460. * Gets the angular velocity
  98461. * @returns angular velocity or null
  98462. */
  98463. getAngularVelocity(): Nullable<Vector3>;
  98464. /**
  98465. * Sets the angular velocity
  98466. * @param velocity The velocity or null
  98467. */
  98468. setAngularVelocity(velocity: Nullable<Vector3>): void;
  98469. /**
  98470. * Execute a function with the physics plugin native code
  98471. * Provide a function the will have two variables - the world object and the physics body object
  98472. * @param func The function to execute with the physics plugin native code
  98473. */
  98474. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  98475. /**
  98476. * Register a function that will be executed before the physics world is stepping forward
  98477. * @param func The function to execute before the physics world is stepped forward
  98478. */
  98479. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98480. /**
  98481. * Unregister a function that will be executed before the physics world is stepping forward
  98482. * @param func The function to execute before the physics world is stepped forward
  98483. */
  98484. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98485. /**
  98486. * Register a function that will be executed after the physics step
  98487. * @param func The function to execute after physics step
  98488. */
  98489. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98490. /**
  98491. * Unregisters a function that will be executed after the physics step
  98492. * @param func The function to execute after physics step
  98493. */
  98494. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  98495. /**
  98496. * register a function that will be executed when this impostor collides against a different body
  98497. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  98498. * @param func Callback that is executed on collision
  98499. */
  98500. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  98501. /**
  98502. * Unregisters the physics imposter on contact
  98503. * @param collideAgainst The physics object to collide against
  98504. * @param func Callback to execute on collision
  98505. */
  98506. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  98507. private _tmpQuat;
  98508. private _tmpQuat2;
  98509. /**
  98510. * Get the parent rotation
  98511. * @returns The parent rotation
  98512. */
  98513. getParentsRotation(): Quaternion;
  98514. /**
  98515. * this function is executed by the physics engine.
  98516. */
  98517. beforeStep: () => void;
  98518. /**
  98519. * this function is executed by the physics engine
  98520. */
  98521. afterStep: () => void;
  98522. /**
  98523. * Legacy collision detection event support
  98524. */
  98525. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  98526. /**
  98527. * event and body object due to cannon's event-based architecture.
  98528. */
  98529. onCollide: (e: {
  98530. body: any;
  98531. }) => void;
  98532. /**
  98533. * Apply a force
  98534. * @param force The force to apply
  98535. * @param contactPoint The contact point for the force
  98536. * @returns The physics imposter
  98537. */
  98538. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98539. /**
  98540. * Apply an impulse
  98541. * @param force The impulse force
  98542. * @param contactPoint The contact point for the impulse force
  98543. * @returns The physics imposter
  98544. */
  98545. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  98546. /**
  98547. * A help function to create a joint
  98548. * @param otherImpostor A physics imposter used to create a joint
  98549. * @param jointType The type of joint
  98550. * @param jointData The data for the joint
  98551. * @returns The physics imposter
  98552. */
  98553. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  98554. /**
  98555. * Add a joint to this impostor with a different impostor
  98556. * @param otherImpostor A physics imposter used to add a joint
  98557. * @param joint The joint to add
  98558. * @returns The physics imposter
  98559. */
  98560. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  98561. /**
  98562. * Add an anchor to a cloth impostor
  98563. * @param otherImpostor rigid impostor to anchor to
  98564. * @param width ratio across width from 0 to 1
  98565. * @param height ratio up height from 0 to 1
  98566. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  98567. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  98568. * @returns impostor the soft imposter
  98569. */
  98570. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98571. /**
  98572. * Add a hook to a rope impostor
  98573. * @param otherImpostor rigid impostor to anchor to
  98574. * @param length ratio across rope from 0 to 1
  98575. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  98576. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  98577. * @returns impostor the rope imposter
  98578. */
  98579. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  98580. /**
  98581. * Will keep this body still, in a sleep mode.
  98582. * @returns the physics imposter
  98583. */
  98584. sleep(): PhysicsImpostor;
  98585. /**
  98586. * Wake the body up.
  98587. * @returns The physics imposter
  98588. */
  98589. wakeUp(): PhysicsImpostor;
  98590. /**
  98591. * Clones the physics imposter
  98592. * @param newObject The physics imposter clones to this physics-enabled object
  98593. * @returns A nullable physics imposter
  98594. */
  98595. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  98596. /**
  98597. * Disposes the physics imposter
  98598. */
  98599. dispose(): void;
  98600. /**
  98601. * Sets the delta position
  98602. * @param position The delta position amount
  98603. */
  98604. setDeltaPosition(position: Vector3): void;
  98605. /**
  98606. * Sets the delta rotation
  98607. * @param rotation The delta rotation amount
  98608. */
  98609. setDeltaRotation(rotation: Quaternion): void;
  98610. /**
  98611. * Gets the box size of the physics imposter and stores the result in the input parameter
  98612. * @param result Stores the box size
  98613. * @returns The physics imposter
  98614. */
  98615. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  98616. /**
  98617. * Gets the radius of the physics imposter
  98618. * @returns Radius of the physics imposter
  98619. */
  98620. getRadius(): number;
  98621. /**
  98622. * Sync a bone with this impostor
  98623. * @param bone The bone to sync to the impostor.
  98624. * @param boneMesh The mesh that the bone is influencing.
  98625. * @param jointPivot The pivot of the joint / bone in local space.
  98626. * @param distToJoint Optional distance from the impostor to the joint.
  98627. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98628. */
  98629. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  98630. /**
  98631. * Sync impostor to a bone
  98632. * @param bone The bone that the impostor will be synced to.
  98633. * @param boneMesh The mesh that the bone is influencing.
  98634. * @param jointPivot The pivot of the joint / bone in local space.
  98635. * @param distToJoint Optional distance from the impostor to the joint.
  98636. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  98637. * @param boneAxis Optional vector3 axis the bone is aligned with
  98638. */
  98639. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  98640. /**
  98641. * No-Imposter type
  98642. */
  98643. static NoImpostor: number;
  98644. /**
  98645. * Sphere-Imposter type
  98646. */
  98647. static SphereImpostor: number;
  98648. /**
  98649. * Box-Imposter type
  98650. */
  98651. static BoxImpostor: number;
  98652. /**
  98653. * Plane-Imposter type
  98654. */
  98655. static PlaneImpostor: number;
  98656. /**
  98657. * Mesh-imposter type
  98658. */
  98659. static MeshImpostor: number;
  98660. /**
  98661. * Capsule-Impostor type (Ammo.js plugin only)
  98662. */
  98663. static CapsuleImpostor: number;
  98664. /**
  98665. * Cylinder-Imposter type
  98666. */
  98667. static CylinderImpostor: number;
  98668. /**
  98669. * Particle-Imposter type
  98670. */
  98671. static ParticleImpostor: number;
  98672. /**
  98673. * Heightmap-Imposter type
  98674. */
  98675. static HeightmapImpostor: number;
  98676. /**
  98677. * ConvexHull-Impostor type (Ammo.js plugin only)
  98678. */
  98679. static ConvexHullImpostor: number;
  98680. /**
  98681. * Custom-Imposter type (Ammo.js plugin only)
  98682. */
  98683. static CustomImpostor: number;
  98684. /**
  98685. * Rope-Imposter type
  98686. */
  98687. static RopeImpostor: number;
  98688. /**
  98689. * Cloth-Imposter type
  98690. */
  98691. static ClothImpostor: number;
  98692. /**
  98693. * Softbody-Imposter type
  98694. */
  98695. static SoftbodyImpostor: number;
  98696. }
  98697. }
  98698. declare module BABYLON {
  98699. /**
  98700. * @hidden
  98701. **/
  98702. export class _CreationDataStorage {
  98703. closePath?: boolean;
  98704. closeArray?: boolean;
  98705. idx: number[];
  98706. dashSize: number;
  98707. gapSize: number;
  98708. path3D: Path3D;
  98709. pathArray: Vector3[][];
  98710. arc: number;
  98711. radius: number;
  98712. cap: number;
  98713. tessellation: number;
  98714. }
  98715. /**
  98716. * @hidden
  98717. **/
  98718. class _InstanceDataStorage {
  98719. visibleInstances: any;
  98720. batchCache: _InstancesBatch;
  98721. instancesBufferSize: number;
  98722. instancesBuffer: Nullable<Buffer>;
  98723. instancesData: Float32Array;
  98724. overridenInstanceCount: number;
  98725. isFrozen: boolean;
  98726. previousBatch: Nullable<_InstancesBatch>;
  98727. hardwareInstancedRendering: boolean;
  98728. sideOrientation: number;
  98729. manualUpdate: boolean;
  98730. }
  98731. /**
  98732. * @hidden
  98733. **/
  98734. export class _InstancesBatch {
  98735. mustReturn: boolean;
  98736. visibleInstances: Nullable<InstancedMesh[]>[];
  98737. renderSelf: boolean[];
  98738. hardwareInstancedRendering: boolean[];
  98739. }
  98740. /**
  98741. * Class used to represent renderable models
  98742. */
  98743. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  98744. /**
  98745. * Mesh side orientation : usually the external or front surface
  98746. */
  98747. static readonly FRONTSIDE: number;
  98748. /**
  98749. * Mesh side orientation : usually the internal or back surface
  98750. */
  98751. static readonly BACKSIDE: number;
  98752. /**
  98753. * Mesh side orientation : both internal and external or front and back surfaces
  98754. */
  98755. static readonly DOUBLESIDE: number;
  98756. /**
  98757. * Mesh side orientation : by default, `FRONTSIDE`
  98758. */
  98759. static readonly DEFAULTSIDE: number;
  98760. /**
  98761. * Mesh cap setting : no cap
  98762. */
  98763. static readonly NO_CAP: number;
  98764. /**
  98765. * Mesh cap setting : one cap at the beginning of the mesh
  98766. */
  98767. static readonly CAP_START: number;
  98768. /**
  98769. * Mesh cap setting : one cap at the end of the mesh
  98770. */
  98771. static readonly CAP_END: number;
  98772. /**
  98773. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  98774. */
  98775. static readonly CAP_ALL: number;
  98776. /**
  98777. * Mesh pattern setting : no flip or rotate
  98778. */
  98779. static readonly NO_FLIP: number;
  98780. /**
  98781. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  98782. */
  98783. static readonly FLIP_TILE: number;
  98784. /**
  98785. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  98786. */
  98787. static readonly ROTATE_TILE: number;
  98788. /**
  98789. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  98790. */
  98791. static readonly FLIP_ROW: number;
  98792. /**
  98793. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  98794. */
  98795. static readonly ROTATE_ROW: number;
  98796. /**
  98797. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  98798. */
  98799. static readonly FLIP_N_ROTATE_TILE: number;
  98800. /**
  98801. * Mesh pattern setting : rotate pattern and rotate
  98802. */
  98803. static readonly FLIP_N_ROTATE_ROW: number;
  98804. /**
  98805. * Mesh tile positioning : part tiles same on left/right or top/bottom
  98806. */
  98807. static readonly CENTER: number;
  98808. /**
  98809. * Mesh tile positioning : part tiles on left
  98810. */
  98811. static readonly LEFT: number;
  98812. /**
  98813. * Mesh tile positioning : part tiles on right
  98814. */
  98815. static readonly RIGHT: number;
  98816. /**
  98817. * Mesh tile positioning : part tiles on top
  98818. */
  98819. static readonly TOP: number;
  98820. /**
  98821. * Mesh tile positioning : part tiles on bottom
  98822. */
  98823. static readonly BOTTOM: number;
  98824. /**
  98825. * Gets the default side orientation.
  98826. * @param orientation the orientation to value to attempt to get
  98827. * @returns the default orientation
  98828. * @hidden
  98829. */
  98830. static _GetDefaultSideOrientation(orientation?: number): number;
  98831. private _internalMeshDataInfo;
  98832. /**
  98833. * An event triggered before rendering the mesh
  98834. */
  98835. get onBeforeRenderObservable(): Observable<Mesh>;
  98836. /**
  98837. * An event triggered before binding the mesh
  98838. */
  98839. get onBeforeBindObservable(): Observable<Mesh>;
  98840. /**
  98841. * An event triggered after rendering the mesh
  98842. */
  98843. get onAfterRenderObservable(): Observable<Mesh>;
  98844. /**
  98845. * An event triggered before drawing the mesh
  98846. */
  98847. get onBeforeDrawObservable(): Observable<Mesh>;
  98848. private _onBeforeDrawObserver;
  98849. /**
  98850. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  98851. */
  98852. set onBeforeDraw(callback: () => void);
  98853. get hasInstances(): boolean;
  98854. /**
  98855. * Gets the delay loading state of the mesh (when delay loading is turned on)
  98856. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  98857. */
  98858. delayLoadState: number;
  98859. /**
  98860. * Gets the list of instances created from this mesh
  98861. * it is not supposed to be modified manually.
  98862. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  98863. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  98864. */
  98865. instances: InstancedMesh[];
  98866. /**
  98867. * Gets the file containing delay loading data for this mesh
  98868. */
  98869. delayLoadingFile: string;
  98870. /** @hidden */
  98871. _binaryInfo: any;
  98872. /**
  98873. * User defined function used to change how LOD level selection is done
  98874. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  98875. */
  98876. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  98877. /**
  98878. * Gets or sets the morph target manager
  98879. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  98880. */
  98881. get morphTargetManager(): Nullable<MorphTargetManager>;
  98882. set morphTargetManager(value: Nullable<MorphTargetManager>);
  98883. /** @hidden */
  98884. _creationDataStorage: Nullable<_CreationDataStorage>;
  98885. /** @hidden */
  98886. _geometry: Nullable<Geometry>;
  98887. /** @hidden */
  98888. _delayInfo: Array<string>;
  98889. /** @hidden */
  98890. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  98891. /** @hidden */
  98892. _instanceDataStorage: _InstanceDataStorage;
  98893. private _effectiveMaterial;
  98894. /** @hidden */
  98895. _shouldGenerateFlatShading: boolean;
  98896. /** @hidden */
  98897. _originalBuilderSideOrientation: number;
  98898. /**
  98899. * Use this property to change the original side orientation defined at construction time
  98900. */
  98901. overrideMaterialSideOrientation: Nullable<number>;
  98902. /**
  98903. * Gets the source mesh (the one used to clone this one from)
  98904. */
  98905. get source(): Nullable<Mesh>;
  98906. /**
  98907. * Gets or sets a boolean indicating that this mesh does not use index buffer
  98908. */
  98909. get isUnIndexed(): boolean;
  98910. set isUnIndexed(value: boolean);
  98911. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  98912. get worldMatrixInstancedBuffer(): Float32Array;
  98913. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  98914. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  98915. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  98916. /**
  98917. * @constructor
  98918. * @param name The value used by scene.getMeshByName() to do a lookup.
  98919. * @param scene The scene to add this mesh to.
  98920. * @param parent The parent of this mesh, if it has one
  98921. * @param source An optional Mesh from which geometry is shared, cloned.
  98922. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  98923. * When false, achieved by calling a clone(), also passing False.
  98924. * This will make creation of children, recursive.
  98925. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  98926. */
  98927. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  98928. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  98929. doNotInstantiate: boolean;
  98930. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  98931. /**
  98932. * Gets the class name
  98933. * @returns the string "Mesh".
  98934. */
  98935. getClassName(): string;
  98936. /** @hidden */
  98937. get _isMesh(): boolean;
  98938. /**
  98939. * Returns a description of this mesh
  98940. * @param fullDetails define if full details about this mesh must be used
  98941. * @returns a descriptive string representing this mesh
  98942. */
  98943. toString(fullDetails?: boolean): string;
  98944. /** @hidden */
  98945. _unBindEffect(): void;
  98946. /**
  98947. * Gets a boolean indicating if this mesh has LOD
  98948. */
  98949. get hasLODLevels(): boolean;
  98950. /**
  98951. * Gets the list of MeshLODLevel associated with the current mesh
  98952. * @returns an array of MeshLODLevel
  98953. */
  98954. getLODLevels(): MeshLODLevel[];
  98955. private _sortLODLevels;
  98956. /**
  98957. * Add a mesh as LOD level triggered at the given distance.
  98958. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98959. * @param distance The distance from the center of the object to show this level
  98960. * @param mesh The mesh to be added as LOD level (can be null)
  98961. * @return This mesh (for chaining)
  98962. */
  98963. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  98964. /**
  98965. * Returns the LOD level mesh at the passed distance or null if not found.
  98966. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98967. * @param distance The distance from the center of the object to show this level
  98968. * @returns a Mesh or `null`
  98969. */
  98970. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  98971. /**
  98972. * Remove a mesh from the LOD array
  98973. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98974. * @param mesh defines the mesh to be removed
  98975. * @return This mesh (for chaining)
  98976. */
  98977. removeLODLevel(mesh: Mesh): Mesh;
  98978. /**
  98979. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  98980. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  98981. * @param camera defines the camera to use to compute distance
  98982. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  98983. * @return This mesh (for chaining)
  98984. */
  98985. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  98986. /**
  98987. * Gets the mesh internal Geometry object
  98988. */
  98989. get geometry(): Nullable<Geometry>;
  98990. /**
  98991. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  98992. * @returns the total number of vertices
  98993. */
  98994. getTotalVertices(): number;
  98995. /**
  98996. * Returns the content of an associated vertex buffer
  98997. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  98998. * - VertexBuffer.PositionKind
  98999. * - VertexBuffer.UVKind
  99000. * - VertexBuffer.UV2Kind
  99001. * - VertexBuffer.UV3Kind
  99002. * - VertexBuffer.UV4Kind
  99003. * - VertexBuffer.UV5Kind
  99004. * - VertexBuffer.UV6Kind
  99005. * - VertexBuffer.ColorKind
  99006. * - VertexBuffer.MatricesIndicesKind
  99007. * - VertexBuffer.MatricesIndicesExtraKind
  99008. * - VertexBuffer.MatricesWeightsKind
  99009. * - VertexBuffer.MatricesWeightsExtraKind
  99010. * @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
  99011. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  99012. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  99013. */
  99014. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  99015. /**
  99016. * Returns the mesh VertexBuffer object from the requested `kind`
  99017. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99018. * - VertexBuffer.PositionKind
  99019. * - VertexBuffer.NormalKind
  99020. * - VertexBuffer.UVKind
  99021. * - VertexBuffer.UV2Kind
  99022. * - VertexBuffer.UV3Kind
  99023. * - VertexBuffer.UV4Kind
  99024. * - VertexBuffer.UV5Kind
  99025. * - VertexBuffer.UV6Kind
  99026. * - VertexBuffer.ColorKind
  99027. * - VertexBuffer.MatricesIndicesKind
  99028. * - VertexBuffer.MatricesIndicesExtraKind
  99029. * - VertexBuffer.MatricesWeightsKind
  99030. * - VertexBuffer.MatricesWeightsExtraKind
  99031. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  99032. */
  99033. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  99034. /**
  99035. * Tests if a specific vertex buffer is associated with this mesh
  99036. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99037. * - VertexBuffer.PositionKind
  99038. * - VertexBuffer.NormalKind
  99039. * - VertexBuffer.UVKind
  99040. * - VertexBuffer.UV2Kind
  99041. * - VertexBuffer.UV3Kind
  99042. * - VertexBuffer.UV4Kind
  99043. * - VertexBuffer.UV5Kind
  99044. * - VertexBuffer.UV6Kind
  99045. * - VertexBuffer.ColorKind
  99046. * - VertexBuffer.MatricesIndicesKind
  99047. * - VertexBuffer.MatricesIndicesExtraKind
  99048. * - VertexBuffer.MatricesWeightsKind
  99049. * - VertexBuffer.MatricesWeightsExtraKind
  99050. * @returns a boolean
  99051. */
  99052. isVerticesDataPresent(kind: string): boolean;
  99053. /**
  99054. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  99055. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  99056. * - VertexBuffer.PositionKind
  99057. * - VertexBuffer.UVKind
  99058. * - VertexBuffer.UV2Kind
  99059. * - VertexBuffer.UV3Kind
  99060. * - VertexBuffer.UV4Kind
  99061. * - VertexBuffer.UV5Kind
  99062. * - VertexBuffer.UV6Kind
  99063. * - VertexBuffer.ColorKind
  99064. * - VertexBuffer.MatricesIndicesKind
  99065. * - VertexBuffer.MatricesIndicesExtraKind
  99066. * - VertexBuffer.MatricesWeightsKind
  99067. * - VertexBuffer.MatricesWeightsExtraKind
  99068. * @returns a boolean
  99069. */
  99070. isVertexBufferUpdatable(kind: string): boolean;
  99071. /**
  99072. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  99073. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  99074. * - VertexBuffer.PositionKind
  99075. * - VertexBuffer.NormalKind
  99076. * - VertexBuffer.UVKind
  99077. * - VertexBuffer.UV2Kind
  99078. * - VertexBuffer.UV3Kind
  99079. * - VertexBuffer.UV4Kind
  99080. * - VertexBuffer.UV5Kind
  99081. * - VertexBuffer.UV6Kind
  99082. * - VertexBuffer.ColorKind
  99083. * - VertexBuffer.MatricesIndicesKind
  99084. * - VertexBuffer.MatricesIndicesExtraKind
  99085. * - VertexBuffer.MatricesWeightsKind
  99086. * - VertexBuffer.MatricesWeightsExtraKind
  99087. * @returns an array of strings
  99088. */
  99089. getVerticesDataKinds(): string[];
  99090. /**
  99091. * Returns a positive integer : the total number of indices in this mesh geometry.
  99092. * @returns the numner of indices or zero if the mesh has no geometry.
  99093. */
  99094. getTotalIndices(): number;
  99095. /**
  99096. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  99097. * @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.
  99098. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  99099. * @returns the indices array or an empty array if the mesh has no geometry
  99100. */
  99101. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  99102. get isBlocked(): boolean;
  99103. /**
  99104. * Determine if the current mesh is ready to be rendered
  99105. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  99106. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  99107. * @returns true if all associated assets are ready (material, textures, shaders)
  99108. */
  99109. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  99110. /**
  99111. * 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.
  99112. */
  99113. get areNormalsFrozen(): boolean;
  99114. /**
  99115. * 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.
  99116. * @returns the current mesh
  99117. */
  99118. freezeNormals(): Mesh;
  99119. /**
  99120. * 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
  99121. * @returns the current mesh
  99122. */
  99123. unfreezeNormals(): Mesh;
  99124. /**
  99125. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  99126. */
  99127. set overridenInstanceCount(count: number);
  99128. /** @hidden */
  99129. _preActivate(): Mesh;
  99130. /** @hidden */
  99131. _preActivateForIntermediateRendering(renderId: number): Mesh;
  99132. /** @hidden */
  99133. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  99134. /**
  99135. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  99136. * This means the mesh underlying bounding box and sphere are recomputed.
  99137. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  99138. * @returns the current mesh
  99139. */
  99140. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  99141. /** @hidden */
  99142. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  99143. /**
  99144. * This function will subdivide the mesh into multiple submeshes
  99145. * @param count defines the expected number of submeshes
  99146. */
  99147. subdivide(count: number): void;
  99148. /**
  99149. * Copy a FloatArray into a specific associated vertex buffer
  99150. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99151. * - VertexBuffer.PositionKind
  99152. * - VertexBuffer.UVKind
  99153. * - VertexBuffer.UV2Kind
  99154. * - VertexBuffer.UV3Kind
  99155. * - VertexBuffer.UV4Kind
  99156. * - VertexBuffer.UV5Kind
  99157. * - VertexBuffer.UV6Kind
  99158. * - VertexBuffer.ColorKind
  99159. * - VertexBuffer.MatricesIndicesKind
  99160. * - VertexBuffer.MatricesIndicesExtraKind
  99161. * - VertexBuffer.MatricesWeightsKind
  99162. * - VertexBuffer.MatricesWeightsExtraKind
  99163. * @param data defines the data source
  99164. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99165. * @param stride defines the data stride size (can be null)
  99166. * @returns the current mesh
  99167. */
  99168. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  99169. /**
  99170. * Delete a vertex buffer associated with this mesh
  99171. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  99172. * - VertexBuffer.PositionKind
  99173. * - VertexBuffer.UVKind
  99174. * - VertexBuffer.UV2Kind
  99175. * - VertexBuffer.UV3Kind
  99176. * - VertexBuffer.UV4Kind
  99177. * - VertexBuffer.UV5Kind
  99178. * - VertexBuffer.UV6Kind
  99179. * - VertexBuffer.ColorKind
  99180. * - VertexBuffer.MatricesIndicesKind
  99181. * - VertexBuffer.MatricesIndicesExtraKind
  99182. * - VertexBuffer.MatricesWeightsKind
  99183. * - VertexBuffer.MatricesWeightsExtraKind
  99184. */
  99185. removeVerticesData(kind: string): void;
  99186. /**
  99187. * Flags an associated vertex buffer as updatable
  99188. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  99189. * - VertexBuffer.PositionKind
  99190. * - VertexBuffer.UVKind
  99191. * - VertexBuffer.UV2Kind
  99192. * - VertexBuffer.UV3Kind
  99193. * - VertexBuffer.UV4Kind
  99194. * - VertexBuffer.UV5Kind
  99195. * - VertexBuffer.UV6Kind
  99196. * - VertexBuffer.ColorKind
  99197. * - VertexBuffer.MatricesIndicesKind
  99198. * - VertexBuffer.MatricesIndicesExtraKind
  99199. * - VertexBuffer.MatricesWeightsKind
  99200. * - VertexBuffer.MatricesWeightsExtraKind
  99201. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  99202. */
  99203. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  99204. /**
  99205. * Sets the mesh global Vertex Buffer
  99206. * @param buffer defines the buffer to use
  99207. * @returns the current mesh
  99208. */
  99209. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  99210. /**
  99211. * Update a specific associated vertex buffer
  99212. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  99213. * - VertexBuffer.PositionKind
  99214. * - VertexBuffer.UVKind
  99215. * - VertexBuffer.UV2Kind
  99216. * - VertexBuffer.UV3Kind
  99217. * - VertexBuffer.UV4Kind
  99218. * - VertexBuffer.UV5Kind
  99219. * - VertexBuffer.UV6Kind
  99220. * - VertexBuffer.ColorKind
  99221. * - VertexBuffer.MatricesIndicesKind
  99222. * - VertexBuffer.MatricesIndicesExtraKind
  99223. * - VertexBuffer.MatricesWeightsKind
  99224. * - VertexBuffer.MatricesWeightsExtraKind
  99225. * @param data defines the data source
  99226. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  99227. * @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)
  99228. * @returns the current mesh
  99229. */
  99230. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  99231. /**
  99232. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  99233. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  99234. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  99235. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  99236. * @returns the current mesh
  99237. */
  99238. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  99239. /**
  99240. * Creates a un-shared specific occurence of the geometry for the mesh.
  99241. * @returns the current mesh
  99242. */
  99243. makeGeometryUnique(): Mesh;
  99244. /**
  99245. * Set the index buffer of this mesh
  99246. * @param indices defines the source data
  99247. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  99248. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  99249. * @returns the current mesh
  99250. */
  99251. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  99252. /**
  99253. * Update the current index buffer
  99254. * @param indices defines the source data
  99255. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  99256. * @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)
  99257. * @returns the current mesh
  99258. */
  99259. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  99260. /**
  99261. * Invert the geometry to move from a right handed system to a left handed one.
  99262. * @returns the current mesh
  99263. */
  99264. toLeftHanded(): Mesh;
  99265. /** @hidden */
  99266. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  99267. /** @hidden */
  99268. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  99269. /**
  99270. * Registers for this mesh a javascript function called just before the rendering process
  99271. * @param func defines the function to call before rendering this mesh
  99272. * @returns the current mesh
  99273. */
  99274. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99275. /**
  99276. * Disposes a previously registered javascript function called before the rendering
  99277. * @param func defines the function to remove
  99278. * @returns the current mesh
  99279. */
  99280. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  99281. /**
  99282. * Registers for this mesh a javascript function called just after the rendering is complete
  99283. * @param func defines the function to call after rendering this mesh
  99284. * @returns the current mesh
  99285. */
  99286. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99287. /**
  99288. * Disposes a previously registered javascript function called after the rendering.
  99289. * @param func defines the function to remove
  99290. * @returns the current mesh
  99291. */
  99292. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  99293. /** @hidden */
  99294. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  99295. /** @hidden */
  99296. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  99297. /** @hidden */
  99298. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  99299. /** @hidden */
  99300. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  99301. /** @hidden */
  99302. _rebuild(): void;
  99303. /** @hidden */
  99304. _freeze(): void;
  99305. /** @hidden */
  99306. _unFreeze(): void;
  99307. /**
  99308. * 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
  99309. * @param subMesh defines the subMesh to render
  99310. * @param enableAlphaMode defines if alpha mode can be changed
  99311. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  99312. * @returns the current mesh
  99313. */
  99314. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  99315. private _onBeforeDraw;
  99316. /**
  99317. * Renormalize the mesh and patch it up if there are no weights
  99318. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  99319. * However in the case of zero weights then we set just a single influence to 1.
  99320. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  99321. */
  99322. cleanMatrixWeights(): void;
  99323. private normalizeSkinFourWeights;
  99324. private normalizeSkinWeightsAndExtra;
  99325. /**
  99326. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  99327. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  99328. * the user know there was an issue with importing the mesh
  99329. * @returns a validation object with skinned, valid and report string
  99330. */
  99331. validateSkinning(): {
  99332. skinned: boolean;
  99333. valid: boolean;
  99334. report: string;
  99335. };
  99336. /** @hidden */
  99337. _checkDelayState(): Mesh;
  99338. private _queueLoad;
  99339. /**
  99340. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  99341. * A mesh is in the frustum if its bounding box intersects the frustum
  99342. * @param frustumPlanes defines the frustum to test
  99343. * @returns true if the mesh is in the frustum planes
  99344. */
  99345. isInFrustum(frustumPlanes: Plane[]): boolean;
  99346. /**
  99347. * Sets the mesh material by the material or multiMaterial `id` property
  99348. * @param id is a string identifying the material or the multiMaterial
  99349. * @returns the current mesh
  99350. */
  99351. setMaterialByID(id: string): Mesh;
  99352. /**
  99353. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  99354. * @returns an array of IAnimatable
  99355. */
  99356. getAnimatables(): IAnimatable[];
  99357. /**
  99358. * Modifies the mesh geometry according to the passed transformation matrix.
  99359. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  99360. * The mesh normals are modified using the same transformation.
  99361. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99362. * @param transform defines the transform matrix to use
  99363. * @see http://doc.babylonjs.com/resources/baking_transformations
  99364. * @returns the current mesh
  99365. */
  99366. bakeTransformIntoVertices(transform: Matrix): Mesh;
  99367. /**
  99368. * Modifies the mesh geometry according to its own current World Matrix.
  99369. * The mesh World Matrix is then reset.
  99370. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  99371. * Note that, under the hood, this method sets a new VertexBuffer each call.
  99372. * @see http://doc.babylonjs.com/resources/baking_transformations
  99373. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  99374. * @returns the current mesh
  99375. */
  99376. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  99377. /** @hidden */
  99378. get _positions(): Nullable<Vector3[]>;
  99379. /** @hidden */
  99380. _resetPointsArrayCache(): Mesh;
  99381. /** @hidden */
  99382. _generatePointsArray(): boolean;
  99383. /**
  99384. * Returns a new Mesh object generated from the current mesh properties.
  99385. * This method must not get confused with createInstance()
  99386. * @param name is a string, the name given to the new mesh
  99387. * @param newParent can be any Node object (default `null`)
  99388. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  99389. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  99390. * @returns a new mesh
  99391. */
  99392. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  99393. /**
  99394. * Releases resources associated with this mesh.
  99395. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  99396. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  99397. */
  99398. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  99399. /** @hidden */
  99400. _disposeInstanceSpecificData(): void;
  99401. /**
  99402. * Modifies the mesh geometry according to a displacement map.
  99403. * 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.
  99404. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99405. * @param url is a string, the URL from the image file is to be downloaded.
  99406. * @param minHeight is the lower limit of the displacement.
  99407. * @param maxHeight is the upper limit of the displacement.
  99408. * @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.
  99409. * @param uvOffset is an optional vector2 used to offset UV.
  99410. * @param uvScale is an optional vector2 used to scale UV.
  99411. * @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.
  99412. * @returns the Mesh.
  99413. */
  99414. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99415. /**
  99416. * Modifies the mesh geometry according to a displacementMap buffer.
  99417. * 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.
  99418. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  99419. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  99420. * @param heightMapWidth is the width of the buffer image.
  99421. * @param heightMapHeight is the height of the buffer image.
  99422. * @param minHeight is the lower limit of the displacement.
  99423. * @param maxHeight is the upper limit of the displacement.
  99424. * @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.
  99425. * @param uvOffset is an optional vector2 used to offset UV.
  99426. * @param uvScale is an optional vector2 used to scale UV.
  99427. * @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.
  99428. * @returns the Mesh.
  99429. */
  99430. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  99431. /**
  99432. * Modify the mesh to get a flat shading rendering.
  99433. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  99434. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  99435. * @returns current mesh
  99436. */
  99437. convertToFlatShadedMesh(): Mesh;
  99438. /**
  99439. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  99440. * In other words, more vertices, no more indices and a single bigger VBO.
  99441. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  99442. * @returns current mesh
  99443. */
  99444. convertToUnIndexedMesh(): Mesh;
  99445. /**
  99446. * Inverses facet orientations.
  99447. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99448. * @param flipNormals will also inverts the normals
  99449. * @returns current mesh
  99450. */
  99451. flipFaces(flipNormals?: boolean): Mesh;
  99452. /**
  99453. * Increase the number of facets and hence vertices in a mesh
  99454. * Vertex normals are interpolated from existing vertex normals
  99455. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99456. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  99457. */
  99458. increaseVertices(numberPerEdge: number): void;
  99459. /**
  99460. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  99461. * This will undo any application of covertToFlatShadedMesh
  99462. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  99463. */
  99464. forceSharedVertices(): void;
  99465. /** @hidden */
  99466. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  99467. /** @hidden */
  99468. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  99469. /**
  99470. * Creates a new InstancedMesh object from the mesh model.
  99471. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  99472. * @param name defines the name of the new instance
  99473. * @returns a new InstancedMesh
  99474. */
  99475. createInstance(name: string): InstancedMesh;
  99476. /**
  99477. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  99478. * After this call, all the mesh instances have the same submeshes than the current mesh.
  99479. * @returns the current mesh
  99480. */
  99481. synchronizeInstances(): Mesh;
  99482. /**
  99483. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  99484. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  99485. * This should be used together with the simplification to avoid disappearing triangles.
  99486. * @param successCallback an optional success callback to be called after the optimization finished.
  99487. * @returns the current mesh
  99488. */
  99489. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  99490. /**
  99491. * Serialize current mesh
  99492. * @param serializationObject defines the object which will receive the serialization data
  99493. */
  99494. serialize(serializationObject: any): void;
  99495. /** @hidden */
  99496. _syncGeometryWithMorphTargetManager(): void;
  99497. /** @hidden */
  99498. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  99499. /**
  99500. * Returns a new Mesh object parsed from the source provided.
  99501. * @param parsedMesh is the source
  99502. * @param scene defines the hosting scene
  99503. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  99504. * @returns a new Mesh
  99505. */
  99506. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  99507. /**
  99508. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  99509. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99510. * @param name defines the name of the mesh to create
  99511. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  99512. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  99513. * @param closePath creates a seam between the first and the last points of each path of the path array
  99514. * @param offset is taken in account only if the `pathArray` is containing a single path
  99515. * @param scene defines the hosting scene
  99516. * @param updatable defines if the mesh must be flagged as updatable
  99517. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99518. * @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)
  99519. * @returns a new Mesh
  99520. */
  99521. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99522. /**
  99523. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  99524. * @param name defines the name of the mesh to create
  99525. * @param radius sets the radius size (float) of the polygon (default 0.5)
  99526. * @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
  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 CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99533. /**
  99534. * Creates a box 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 size sets the size (float) of each box side (default 1)
  99537. * @param scene defines the hosting scene
  99538. * @param updatable defines if the mesh must be flagged as updatable
  99539. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99540. * @returns a new Mesh
  99541. */
  99542. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  99543. /**
  99544. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  99545. * @param name defines the name of the mesh to create
  99546. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99547. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99548. * @param scene defines the hosting scene
  99549. * @param updatable defines if the mesh must be flagged as updatable
  99550. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99551. * @returns a new Mesh
  99552. */
  99553. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99554. /**
  99555. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  99556. * @param name defines the name of the mesh to create
  99557. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  99558. * @param diameter sets the diameter size (float) of the sphere (default 1)
  99559. * @param scene defines the hosting scene
  99560. * @returns a new Mesh
  99561. */
  99562. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  99563. /**
  99564. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  99565. * @param name defines the name of the mesh to create
  99566. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  99567. * @param diameterTop set the top cap diameter (floats, default 1)
  99568. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  99569. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  99570. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  99571. * @param scene defines the hosting scene
  99572. * @param updatable defines if the mesh must be flagged as updatable
  99573. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99574. * @returns a new Mesh
  99575. */
  99576. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  99577. /**
  99578. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  99579. * @param name defines the name of the mesh to create
  99580. * @param diameter sets the diameter size (float) of the torus (default 1)
  99581. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  99582. * @param tessellation sets the number of torus sides (postive integer, default 16)
  99583. * @param scene defines the hosting scene
  99584. * @param updatable defines if the mesh must be flagged as updatable
  99585. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99586. * @returns a new Mesh
  99587. */
  99588. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99589. /**
  99590. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  99591. * @param name defines the name of the mesh to create
  99592. * @param radius sets the global radius size (float) of the torus knot (default 2)
  99593. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  99594. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  99595. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  99596. * @param p the number of windings on X axis (positive integers, default 2)
  99597. * @param q the number of windings on Y axis (positive integers, default 3)
  99598. * @param scene defines the hosting scene
  99599. * @param updatable defines if the mesh must be flagged as updatable
  99600. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99601. * @returns a new Mesh
  99602. */
  99603. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99604. /**
  99605. * Creates a 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 scene defines the hosting scene
  99609. * @param updatable defines if the mesh must be flagged as updatable
  99610. * @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).
  99611. * @returns a new Mesh
  99612. */
  99613. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  99614. /**
  99615. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  99616. * @param name defines the name of the mesh to create
  99617. * @param points is an array successive Vector3
  99618. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  99619. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  99620. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  99621. * @param scene defines the hosting scene
  99622. * @param updatable defines if the mesh must be flagged as updatable
  99623. * @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)
  99624. * @returns a new Mesh
  99625. */
  99626. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  99627. /**
  99628. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  99629. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  99630. * 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.
  99631. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99632. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  99633. * Remember you can only change the shape positions, not their number when updating a polygon.
  99634. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  99635. * @param name defines the name of the mesh to create
  99636. * @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
  99637. * @param scene defines the hosting scene
  99638. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99639. * @param updatable defines if the mesh must be flagged as updatable
  99640. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99641. * @param earcutInjection can be used to inject your own earcut reference
  99642. * @returns a new Mesh
  99643. */
  99644. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99645. /**
  99646. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  99647. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  99648. * @param name defines the name of the mesh to create
  99649. * @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
  99650. * @param depth defines the height of extrusion
  99651. * @param scene defines the hosting scene
  99652. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  99653. * @param updatable defines if the mesh must be flagged as updatable
  99654. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99655. * @param earcutInjection can be used to inject your own earcut reference
  99656. * @returns a new Mesh
  99657. */
  99658. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  99659. /**
  99660. * Creates an extruded shape mesh.
  99661. * 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
  99662. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99663. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99664. * @param name defines the name of the mesh to create
  99665. * @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
  99666. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99667. * @param scale is the value to scale the shape
  99668. * @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
  99669. * @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
  99670. * @param scene defines the hosting scene
  99671. * @param updatable defines if the mesh must be flagged as updatable
  99672. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99673. * @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)
  99674. * @returns a new Mesh
  99675. */
  99676. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99677. /**
  99678. * Creates an custom extruded shape mesh.
  99679. * The custom extrusion is a parametric shape.
  99680. * It has no predefined shape. Its final shape will depend on the input parameters.
  99681. * Please consider using the same method from the MeshBuilder class instead
  99682. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  99683. * @param name defines the name of the mesh to create
  99684. * @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
  99685. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  99686. * @param scaleFunction is a custom Javascript function called on each path point
  99687. * @param rotationFunction is a custom Javascript function called on each path point
  99688. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  99689. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  99690. * @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
  99691. * @param scene defines the hosting scene
  99692. * @param updatable defines if the mesh must be flagged as updatable
  99693. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99694. * @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)
  99695. * @returns a new Mesh
  99696. */
  99697. 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;
  99698. /**
  99699. * Creates lathe mesh.
  99700. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  99701. * Please consider using the same method from the MeshBuilder class instead
  99702. * @param name defines the name of the mesh to create
  99703. * @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
  99704. * @param radius is the radius value of the lathe
  99705. * @param tessellation is the side number of the lathe.
  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 CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99712. /**
  99713. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  99714. * @param name defines the name of the mesh to create
  99715. * @param size sets the size (float) of both sides of the plane at once (default 1)
  99716. * @param scene defines the hosting scene
  99717. * @param updatable defines if the mesh must be flagged as updatable
  99718. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99719. * @returns a new Mesh
  99720. */
  99721. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  99722. /**
  99723. * Creates a ground mesh.
  99724. * Please consider using the same method from the MeshBuilder class instead
  99725. * @param name defines the name of the mesh to create
  99726. * @param width set the width of the ground
  99727. * @param height set the height of the ground
  99728. * @param subdivisions sets the number of subdivisions per side
  99729. * @param scene defines the hosting scene
  99730. * @param updatable defines if the mesh must be flagged as updatable
  99731. * @returns a new Mesh
  99732. */
  99733. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  99734. /**
  99735. * Creates a tiled ground mesh.
  99736. * Please consider using the same method from the MeshBuilder class instead
  99737. * @param name defines the name of the mesh to create
  99738. * @param xmin set the ground minimum X coordinate
  99739. * @param zmin set the ground minimum Y coordinate
  99740. * @param xmax set the ground maximum X coordinate
  99741. * @param zmax set the ground maximum Z coordinate
  99742. * @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
  99743. * @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
  99744. * @param scene defines the hosting scene
  99745. * @param updatable defines if the mesh must be flagged as updatable
  99746. * @returns a new Mesh
  99747. */
  99748. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  99749. w: number;
  99750. h: number;
  99751. }, precision: {
  99752. w: number;
  99753. h: number;
  99754. }, scene: Scene, updatable?: boolean): Mesh;
  99755. /**
  99756. * Creates a ground mesh from a height map.
  99757. * Please consider using the same method from the MeshBuilder class instead
  99758. * @see http://doc.babylonjs.com/babylon101/height_map
  99759. * @param name defines the name of the mesh to create
  99760. * @param url sets the URL of the height map image resource
  99761. * @param width set the ground width size
  99762. * @param height set the ground height size
  99763. * @param subdivisions sets the number of subdivision per side
  99764. * @param minHeight is the minimum altitude on the ground
  99765. * @param maxHeight is the maximum altitude on the ground
  99766. * @param scene defines the hosting scene
  99767. * @param updatable defines if the mesh must be flagged as updatable
  99768. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  99769. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  99770. * @returns a new Mesh
  99771. */
  99772. 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;
  99773. /**
  99774. * Creates a tube mesh.
  99775. * The tube is a parametric shape.
  99776. * It has no predefined shape. Its final shape will depend on the input parameters.
  99777. * Please consider using the same method from the MeshBuilder class instead
  99778. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  99779. * @param name defines the name of the mesh to create
  99780. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  99781. * @param radius sets the tube radius size
  99782. * @param tessellation is the number of sides on the tubular surface
  99783. * @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
  99784. * @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
  99785. * @param scene defines the hosting scene
  99786. * @param updatable defines if the mesh must be flagged as updatable
  99787. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  99788. * @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)
  99789. * @returns a new Mesh
  99790. */
  99791. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  99792. (i: number, distance: number): number;
  99793. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  99794. /**
  99795. * Creates a polyhedron mesh.
  99796. * Please consider using the same method from the MeshBuilder class instead.
  99797. * * 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
  99798. * * The parameter `size` (positive float, default 1) sets the polygon size
  99799. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  99800. * * 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`
  99801. * * 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
  99802. * * 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)`)
  99803. * * 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
  99804. * * 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
  99805. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99806. * * If you create a double-sided mesh, you can choose what parts of 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
  99807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99808. * @param name defines the name of the mesh to create
  99809. * @param options defines the options used to create the mesh
  99810. * @param scene defines the hosting scene
  99811. * @returns a new Mesh
  99812. */
  99813. static CreatePolyhedron(name: string, options: {
  99814. type?: number;
  99815. size?: number;
  99816. sizeX?: number;
  99817. sizeY?: number;
  99818. sizeZ?: number;
  99819. custom?: any;
  99820. faceUV?: Vector4[];
  99821. faceColors?: Color4[];
  99822. updatable?: boolean;
  99823. sideOrientation?: number;
  99824. }, scene: Scene): Mesh;
  99825. /**
  99826. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  99827. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  99828. * * 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`)
  99829. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  99830. * * 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
  99831. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  99832. * * If you create a double-sided mesh, you can choose what parts of 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
  99833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  99834. * @param name defines the name of the mesh
  99835. * @param options defines the options used to create the mesh
  99836. * @param scene defines the hosting scene
  99837. * @returns a new Mesh
  99838. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  99839. */
  99840. static CreateIcoSphere(name: string, options: {
  99841. radius?: number;
  99842. flat?: boolean;
  99843. subdivisions?: number;
  99844. sideOrientation?: number;
  99845. updatable?: boolean;
  99846. }, scene: Scene): Mesh;
  99847. /**
  99848. * Creates a decal mesh.
  99849. * Please consider using the same method from the MeshBuilder class instead.
  99850. * A decal is a mesh usually applied as a model onto the surface of another mesh
  99851. * @param name defines the name of the mesh
  99852. * @param sourceMesh defines the mesh receiving the decal
  99853. * @param position sets the position of the decal in world coordinates
  99854. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  99855. * @param size sets the decal scaling
  99856. * @param angle sets the angle to rotate the decal
  99857. * @returns a new Mesh
  99858. */
  99859. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  99860. /**
  99861. * Prepare internal position array for software CPU skinning
  99862. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  99863. */
  99864. setPositionsForCPUSkinning(): Float32Array;
  99865. /**
  99866. * Prepare internal normal array for software CPU skinning
  99867. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  99868. */
  99869. setNormalsForCPUSkinning(): Float32Array;
  99870. /**
  99871. * Updates the vertex buffer by applying transformation from the bones
  99872. * @param skeleton defines the skeleton to apply to current mesh
  99873. * @returns the current mesh
  99874. */
  99875. applySkeleton(skeleton: Skeleton): Mesh;
  99876. /**
  99877. * 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
  99878. * @param meshes defines the list of meshes to scan
  99879. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  99880. */
  99881. static MinMax(meshes: AbstractMesh[]): {
  99882. min: Vector3;
  99883. max: Vector3;
  99884. };
  99885. /**
  99886. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  99887. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  99888. * @returns a vector3
  99889. */
  99890. static Center(meshesOrMinMaxVector: {
  99891. min: Vector3;
  99892. max: Vector3;
  99893. } | AbstractMesh[]): Vector3;
  99894. /**
  99895. * Merge the array of meshes into a single mesh for performance reasons.
  99896. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  99897. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  99898. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  99899. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  99900. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  99901. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  99902. * @returns a new mesh
  99903. */
  99904. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  99905. /** @hidden */
  99906. addInstance(instance: InstancedMesh): void;
  99907. /** @hidden */
  99908. removeInstance(instance: InstancedMesh): void;
  99909. }
  99910. }
  99911. declare module BABYLON {
  99912. /**
  99913. * This is the base class of all the camera used in the application.
  99914. * @see http://doc.babylonjs.com/features/cameras
  99915. */
  99916. export class Camera extends Node {
  99917. /** @hidden */
  99918. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  99919. /**
  99920. * This is the default projection mode used by the cameras.
  99921. * It helps recreating a feeling of perspective and better appreciate depth.
  99922. * This is the best way to simulate real life cameras.
  99923. */
  99924. static readonly PERSPECTIVE_CAMERA: number;
  99925. /**
  99926. * This helps creating camera with an orthographic mode.
  99927. * 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.
  99928. */
  99929. static readonly ORTHOGRAPHIC_CAMERA: number;
  99930. /**
  99931. * This is the default FOV mode for perspective cameras.
  99932. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  99933. */
  99934. static readonly FOVMODE_VERTICAL_FIXED: number;
  99935. /**
  99936. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  99937. */
  99938. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  99939. /**
  99940. * This specifies ther is no need for a camera rig.
  99941. * Basically only one eye is rendered corresponding to the camera.
  99942. */
  99943. static readonly RIG_MODE_NONE: number;
  99944. /**
  99945. * Simulates a camera Rig with one blue eye and one red eye.
  99946. * This can be use with 3d blue and red glasses.
  99947. */
  99948. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  99949. /**
  99950. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  99951. */
  99952. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  99953. /**
  99954. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  99955. */
  99956. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  99957. /**
  99958. * Defines that both eyes of the camera will be rendered over under each other.
  99959. */
  99960. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  99961. /**
  99962. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  99963. */
  99964. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  99965. /**
  99966. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  99967. */
  99968. static readonly RIG_MODE_VR: number;
  99969. /**
  99970. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  99971. */
  99972. static readonly RIG_MODE_WEBVR: number;
  99973. /**
  99974. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  99975. */
  99976. static readonly RIG_MODE_CUSTOM: number;
  99977. /**
  99978. * Defines if by default attaching controls should prevent the default javascript event to continue.
  99979. */
  99980. static ForceAttachControlToAlwaysPreventDefault: boolean;
  99981. /**
  99982. * Define the input manager associated with the camera.
  99983. */
  99984. inputs: CameraInputsManager<Camera>;
  99985. /** @hidden */
  99986. _position: Vector3;
  99987. /**
  99988. * Define the current local position of the camera in the scene
  99989. */
  99990. get position(): Vector3;
  99991. set position(newPosition: Vector3);
  99992. /**
  99993. * The vector the camera should consider as up.
  99994. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  99995. */
  99996. upVector: Vector3;
  99997. /**
  99998. * Define the current limit on the left side for an orthographic camera
  99999. * In scene unit
  100000. */
  100001. orthoLeft: Nullable<number>;
  100002. /**
  100003. * Define the current limit on the right side for an orthographic camera
  100004. * In scene unit
  100005. */
  100006. orthoRight: Nullable<number>;
  100007. /**
  100008. * Define the current limit on the bottom side for an orthographic camera
  100009. * In scene unit
  100010. */
  100011. orthoBottom: Nullable<number>;
  100012. /**
  100013. * Define the current limit on the top side for an orthographic camera
  100014. * In scene unit
  100015. */
  100016. orthoTop: Nullable<number>;
  100017. /**
  100018. * Field Of View is set in Radians. (default is 0.8)
  100019. */
  100020. fov: number;
  100021. /**
  100022. * Define the minimum distance the camera can see from.
  100023. * This is important to note that the depth buffer are not infinite and the closer it starts
  100024. * the more your scene might encounter depth fighting issue.
  100025. */
  100026. minZ: number;
  100027. /**
  100028. * Define the maximum distance the camera can see to.
  100029. * This is important to note that the depth buffer are not infinite and the further it end
  100030. * the more your scene might encounter depth fighting issue.
  100031. */
  100032. maxZ: number;
  100033. /**
  100034. * Define the default inertia of the camera.
  100035. * This helps giving a smooth feeling to the camera movement.
  100036. */
  100037. inertia: number;
  100038. /**
  100039. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  100040. */
  100041. mode: number;
  100042. /**
  100043. * Define whether the camera is intermediate.
  100044. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  100045. */
  100046. isIntermediate: boolean;
  100047. /**
  100048. * Define the viewport of the camera.
  100049. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  100050. */
  100051. viewport: Viewport;
  100052. /**
  100053. * Restricts the camera to viewing objects with the same layerMask.
  100054. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  100055. */
  100056. layerMask: number;
  100057. /**
  100058. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  100059. */
  100060. fovMode: number;
  100061. /**
  100062. * Rig mode of the camera.
  100063. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  100064. * This is normally controlled byt the camera themselves as internal use.
  100065. */
  100066. cameraRigMode: number;
  100067. /**
  100068. * Defines the distance between both "eyes" in case of a RIG
  100069. */
  100070. interaxialDistance: number;
  100071. /**
  100072. * Defines if stereoscopic rendering is done side by side or over under.
  100073. */
  100074. isStereoscopicSideBySide: boolean;
  100075. /**
  100076. * 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
  100077. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  100078. * else in the scene. (Eg. security camera)
  100079. *
  100080. * 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)
  100081. */
  100082. customRenderTargets: RenderTargetTexture[];
  100083. /**
  100084. * When set, the camera will render to this render target instead of the default canvas
  100085. *
  100086. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  100087. */
  100088. outputRenderTarget: Nullable<RenderTargetTexture>;
  100089. /**
  100090. * Observable triggered when the camera view matrix has changed.
  100091. */
  100092. onViewMatrixChangedObservable: Observable<Camera>;
  100093. /**
  100094. * Observable triggered when the camera Projection matrix has changed.
  100095. */
  100096. onProjectionMatrixChangedObservable: Observable<Camera>;
  100097. /**
  100098. * Observable triggered when the inputs have been processed.
  100099. */
  100100. onAfterCheckInputsObservable: Observable<Camera>;
  100101. /**
  100102. * Observable triggered when reset has been called and applied to the camera.
  100103. */
  100104. onRestoreStateObservable: Observable<Camera>;
  100105. /**
  100106. * Is this camera a part of a rig system?
  100107. */
  100108. isRigCamera: boolean;
  100109. /**
  100110. * If isRigCamera set to true this will be set with the parent camera.
  100111. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  100112. */
  100113. rigParent?: Camera;
  100114. /** @hidden */
  100115. _cameraRigParams: any;
  100116. /** @hidden */
  100117. _rigCameras: Camera[];
  100118. /** @hidden */
  100119. _rigPostProcess: Nullable<PostProcess>;
  100120. protected _webvrViewMatrix: Matrix;
  100121. /** @hidden */
  100122. _skipRendering: boolean;
  100123. /** @hidden */
  100124. _projectionMatrix: Matrix;
  100125. /** @hidden */
  100126. _postProcesses: Nullable<PostProcess>[];
  100127. /** @hidden */
  100128. _activeMeshes: SmartArray<AbstractMesh>;
  100129. protected _globalPosition: Vector3;
  100130. /** @hidden */
  100131. _computedViewMatrix: Matrix;
  100132. private _doNotComputeProjectionMatrix;
  100133. private _transformMatrix;
  100134. private _frustumPlanes;
  100135. private _refreshFrustumPlanes;
  100136. private _storedFov;
  100137. private _stateStored;
  100138. /**
  100139. * Instantiates a new camera object.
  100140. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  100141. * @see http://doc.babylonjs.com/features/cameras
  100142. * @param name Defines the name of the camera in the scene
  100143. * @param position Defines the position of the camera
  100144. * @param scene Defines the scene the camera belongs too
  100145. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  100146. */
  100147. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  100148. /**
  100149. * Store current camera state (fov, position, etc..)
  100150. * @returns the camera
  100151. */
  100152. storeState(): Camera;
  100153. /**
  100154. * Restores the camera state values if it has been stored. You must call storeState() first
  100155. */
  100156. protected _restoreStateValues(): boolean;
  100157. /**
  100158. * Restored camera state. You must call storeState() first.
  100159. * @returns true if restored and false otherwise
  100160. */
  100161. restoreState(): boolean;
  100162. /**
  100163. * Gets the class name of the camera.
  100164. * @returns the class name
  100165. */
  100166. getClassName(): string;
  100167. /** @hidden */
  100168. readonly _isCamera: boolean;
  100169. /**
  100170. * Gets a string representation of the camera useful for debug purpose.
  100171. * @param fullDetails Defines that a more verboe level of logging is required
  100172. * @returns the string representation
  100173. */
  100174. toString(fullDetails?: boolean): string;
  100175. /**
  100176. * Gets the current world space position of the camera.
  100177. */
  100178. get globalPosition(): Vector3;
  100179. /**
  100180. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  100181. * @returns the active meshe list
  100182. */
  100183. getActiveMeshes(): SmartArray<AbstractMesh>;
  100184. /**
  100185. * Check whether a mesh is part of the current active mesh list of the camera
  100186. * @param mesh Defines the mesh to check
  100187. * @returns true if active, false otherwise
  100188. */
  100189. isActiveMesh(mesh: Mesh): boolean;
  100190. /**
  100191. * Is this camera ready to be used/rendered
  100192. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  100193. * @return true if the camera is ready
  100194. */
  100195. isReady(completeCheck?: boolean): boolean;
  100196. /** @hidden */
  100197. _initCache(): void;
  100198. /** @hidden */
  100199. _updateCache(ignoreParentClass?: boolean): void;
  100200. /** @hidden */
  100201. _isSynchronized(): boolean;
  100202. /** @hidden */
  100203. _isSynchronizedViewMatrix(): boolean;
  100204. /** @hidden */
  100205. _isSynchronizedProjectionMatrix(): boolean;
  100206. /**
  100207. * Attach the input controls to a specific dom element to get the input from.
  100208. * @param element Defines the element the controls should be listened from
  100209. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  100210. */
  100211. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100212. /**
  100213. * Detach the current controls from the specified dom element.
  100214. * @param element Defines the element to stop listening the inputs from
  100215. */
  100216. detachControl(element: HTMLElement): void;
  100217. /**
  100218. * Update the camera state according to the different inputs gathered during the frame.
  100219. */
  100220. update(): void;
  100221. /** @hidden */
  100222. _checkInputs(): void;
  100223. /** @hidden */
  100224. get rigCameras(): Camera[];
  100225. /**
  100226. * Gets the post process used by the rig cameras
  100227. */
  100228. get rigPostProcess(): Nullable<PostProcess>;
  100229. /**
  100230. * Internal, gets the first post proces.
  100231. * @returns the first post process to be run on this camera.
  100232. */
  100233. _getFirstPostProcess(): Nullable<PostProcess>;
  100234. private _cascadePostProcessesToRigCams;
  100235. /**
  100236. * Attach a post process to the camera.
  100237. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100238. * @param postProcess The post process to attach to the camera
  100239. * @param insertAt The position of the post process in case several of them are in use in the scene
  100240. * @returns the position the post process has been inserted at
  100241. */
  100242. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  100243. /**
  100244. * Detach a post process to the camera.
  100245. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  100246. * @param postProcess The post process to detach from the camera
  100247. */
  100248. detachPostProcess(postProcess: PostProcess): void;
  100249. /**
  100250. * Gets the current world matrix of the camera
  100251. */
  100252. getWorldMatrix(): Matrix;
  100253. /** @hidden */
  100254. _getViewMatrix(): Matrix;
  100255. /**
  100256. * Gets the current view matrix of the camera.
  100257. * @param force forces the camera to recompute the matrix without looking at the cached state
  100258. * @returns the view matrix
  100259. */
  100260. getViewMatrix(force?: boolean): Matrix;
  100261. /**
  100262. * Freeze the projection matrix.
  100263. * It will prevent the cache check of the camera projection compute and can speed up perf
  100264. * if no parameter of the camera are meant to change
  100265. * @param projection Defines manually a projection if necessary
  100266. */
  100267. freezeProjectionMatrix(projection?: Matrix): void;
  100268. /**
  100269. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  100270. */
  100271. unfreezeProjectionMatrix(): void;
  100272. /**
  100273. * Gets the current projection matrix of the camera.
  100274. * @param force forces the camera to recompute the matrix without looking at the cached state
  100275. * @returns the projection matrix
  100276. */
  100277. getProjectionMatrix(force?: boolean): Matrix;
  100278. /**
  100279. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  100280. * @returns a Matrix
  100281. */
  100282. getTransformationMatrix(): Matrix;
  100283. private _updateFrustumPlanes;
  100284. /**
  100285. * Checks if a cullable object (mesh...) is in the camera frustum
  100286. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  100287. * @param target The object to check
  100288. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  100289. * @returns true if the object is in frustum otherwise false
  100290. */
  100291. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  100292. /**
  100293. * Checks if a cullable object (mesh...) is in the camera frustum
  100294. * Unlike isInFrustum this cheks the full bounding box
  100295. * @param target The object to check
  100296. * @returns true if the object is in frustum otherwise false
  100297. */
  100298. isCompletelyInFrustum(target: ICullable): boolean;
  100299. /**
  100300. * Gets a ray in the forward direction from the camera.
  100301. * @param length Defines the length of the ray to create
  100302. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  100303. * @param origin Defines the start point of the ray which defaults to the camera position
  100304. * @returns the forward ray
  100305. */
  100306. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  100307. /**
  100308. * Releases resources associated with this node.
  100309. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  100310. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  100311. */
  100312. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  100313. /** @hidden */
  100314. _isLeftCamera: boolean;
  100315. /**
  100316. * Gets the left camera of a rig setup in case of Rigged Camera
  100317. */
  100318. get isLeftCamera(): boolean;
  100319. /** @hidden */
  100320. _isRightCamera: boolean;
  100321. /**
  100322. * Gets the right camera of a rig setup in case of Rigged Camera
  100323. */
  100324. get isRightCamera(): boolean;
  100325. /**
  100326. * Gets the left camera of a rig setup in case of Rigged Camera
  100327. */
  100328. get leftCamera(): Nullable<FreeCamera>;
  100329. /**
  100330. * Gets the right camera of a rig setup in case of Rigged Camera
  100331. */
  100332. get rightCamera(): Nullable<FreeCamera>;
  100333. /**
  100334. * Gets the left camera target of a rig setup in case of Rigged Camera
  100335. * @returns the target position
  100336. */
  100337. getLeftTarget(): Nullable<Vector3>;
  100338. /**
  100339. * Gets the right camera target of a rig setup in case of Rigged Camera
  100340. * @returns the target position
  100341. */
  100342. getRightTarget(): Nullable<Vector3>;
  100343. /**
  100344. * @hidden
  100345. */
  100346. setCameraRigMode(mode: number, rigParams: any): void;
  100347. /** @hidden */
  100348. static _setStereoscopicRigMode(camera: Camera): void;
  100349. /** @hidden */
  100350. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  100351. /** @hidden */
  100352. static _setVRRigMode(camera: Camera, rigParams: any): void;
  100353. /** @hidden */
  100354. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  100355. /** @hidden */
  100356. _getVRProjectionMatrix(): Matrix;
  100357. protected _updateCameraRotationMatrix(): void;
  100358. protected _updateWebVRCameraRotationMatrix(): void;
  100359. /**
  100360. * This function MUST be overwritten by the different WebVR cameras available.
  100361. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100362. * @hidden
  100363. */
  100364. _getWebVRProjectionMatrix(): Matrix;
  100365. /**
  100366. * This function MUST be overwritten by the different WebVR cameras available.
  100367. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  100368. * @hidden
  100369. */
  100370. _getWebVRViewMatrix(): Matrix;
  100371. /** @hidden */
  100372. setCameraRigParameter(name: string, value: any): void;
  100373. /**
  100374. * needs to be overridden by children so sub has required properties to be copied
  100375. * @hidden
  100376. */
  100377. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  100378. /**
  100379. * May need to be overridden by children
  100380. * @hidden
  100381. */
  100382. _updateRigCameras(): void;
  100383. /** @hidden */
  100384. _setupInputs(): void;
  100385. /**
  100386. * Serialiaze the camera setup to a json represention
  100387. * @returns the JSON representation
  100388. */
  100389. serialize(): any;
  100390. /**
  100391. * Clones the current camera.
  100392. * @param name The cloned camera name
  100393. * @returns the cloned camera
  100394. */
  100395. clone(name: string): Camera;
  100396. /**
  100397. * Gets the direction of the camera relative to a given local axis.
  100398. * @param localAxis Defines the reference axis to provide a relative direction.
  100399. * @return the direction
  100400. */
  100401. getDirection(localAxis: Vector3): Vector3;
  100402. /**
  100403. * Returns the current camera absolute rotation
  100404. */
  100405. get absoluteRotation(): Quaternion;
  100406. /**
  100407. * Gets the direction of the camera relative to a given local axis into a passed vector.
  100408. * @param localAxis Defines the reference axis to provide a relative direction.
  100409. * @param result Defines the vector to store the result in
  100410. */
  100411. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  100412. /**
  100413. * Gets a camera constructor for a given camera type
  100414. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  100415. * @param name The name of the camera the result will be able to instantiate
  100416. * @param scene The scene the result will construct the camera in
  100417. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  100418. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  100419. * @returns a factory method to construc the camera
  100420. */
  100421. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  100422. /**
  100423. * Compute the world matrix of the camera.
  100424. * @returns the camera world matrix
  100425. */
  100426. computeWorldMatrix(): Matrix;
  100427. /**
  100428. * Parse a JSON and creates the camera from the parsed information
  100429. * @param parsedCamera The JSON to parse
  100430. * @param scene The scene to instantiate the camera in
  100431. * @returns the newly constructed camera
  100432. */
  100433. static Parse(parsedCamera: any, scene: Scene): Camera;
  100434. }
  100435. }
  100436. declare module BABYLON {
  100437. /**
  100438. * Class containing static functions to help procedurally build meshes
  100439. */
  100440. export class DiscBuilder {
  100441. /**
  100442. * Creates a plane polygonal mesh. By default, this is a disc
  100443. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  100444. * * 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
  100445. * * 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
  100446. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100447. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100448. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100449. * @param name defines the name of the mesh
  100450. * @param options defines the options used to create the mesh
  100451. * @param scene defines the hosting scene
  100452. * @returns the plane polygonal mesh
  100453. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  100454. */
  100455. static CreateDisc(name: string, options: {
  100456. radius?: number;
  100457. tessellation?: number;
  100458. arc?: number;
  100459. updatable?: boolean;
  100460. sideOrientation?: number;
  100461. frontUVs?: Vector4;
  100462. backUVs?: Vector4;
  100463. }, scene?: Nullable<Scene>): Mesh;
  100464. }
  100465. }
  100466. declare module BABYLON {
  100467. /**
  100468. * Options to be used when creating a FresnelParameters.
  100469. */
  100470. export type IFresnelParametersCreationOptions = {
  100471. /**
  100472. * Define the color used on edges (grazing angle)
  100473. */
  100474. leftColor?: Color3;
  100475. /**
  100476. * Define the color used on center
  100477. */
  100478. rightColor?: Color3;
  100479. /**
  100480. * Define bias applied to computed fresnel term
  100481. */
  100482. bias?: number;
  100483. /**
  100484. * Defined the power exponent applied to fresnel term
  100485. */
  100486. power?: number;
  100487. /**
  100488. * Define if the fresnel effect is enable or not.
  100489. */
  100490. isEnabled?: boolean;
  100491. };
  100492. /**
  100493. * Serialized format for FresnelParameters.
  100494. */
  100495. export type IFresnelParametersSerialized = {
  100496. /**
  100497. * Define the color used on edges (grazing angle) [as an array]
  100498. */
  100499. leftColor: number[];
  100500. /**
  100501. * Define the color used on center [as an array]
  100502. */
  100503. rightColor: number[];
  100504. /**
  100505. * Define bias applied to computed fresnel term
  100506. */
  100507. bias: number;
  100508. /**
  100509. * Defined the power exponent applied to fresnel term
  100510. */
  100511. power?: number;
  100512. /**
  100513. * Define if the fresnel effect is enable or not.
  100514. */
  100515. isEnabled: boolean;
  100516. };
  100517. /**
  100518. * This represents all the required information to add a fresnel effect on a material:
  100519. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  100520. */
  100521. export class FresnelParameters {
  100522. private _isEnabled;
  100523. /**
  100524. * Define if the fresnel effect is enable or not.
  100525. */
  100526. get isEnabled(): boolean;
  100527. set isEnabled(value: boolean);
  100528. /**
  100529. * Define the color used on edges (grazing angle)
  100530. */
  100531. leftColor: Color3;
  100532. /**
  100533. * Define the color used on center
  100534. */
  100535. rightColor: Color3;
  100536. /**
  100537. * Define bias applied to computed fresnel term
  100538. */
  100539. bias: number;
  100540. /**
  100541. * Defined the power exponent applied to fresnel term
  100542. */
  100543. power: number;
  100544. /**
  100545. * Creates a new FresnelParameters object.
  100546. *
  100547. * @param options provide your own settings to optionally to override defaults
  100548. */
  100549. constructor(options?: IFresnelParametersCreationOptions);
  100550. /**
  100551. * Clones the current fresnel and its valuues
  100552. * @returns a clone fresnel configuration
  100553. */
  100554. clone(): FresnelParameters;
  100555. /**
  100556. * Determines equality between FresnelParameters objects
  100557. * @param otherFresnelParameters defines the second operand
  100558. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  100559. */
  100560. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  100561. /**
  100562. * Serializes the current fresnel parameters to a JSON representation.
  100563. * @return the JSON serialization
  100564. */
  100565. serialize(): IFresnelParametersSerialized;
  100566. /**
  100567. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  100568. * @param parsedFresnelParameters Define the JSON representation
  100569. * @returns the parsed parameters
  100570. */
  100571. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  100572. }
  100573. }
  100574. declare module BABYLON {
  100575. /**
  100576. * Base class of materials working in push mode in babylon JS
  100577. * @hidden
  100578. */
  100579. export class PushMaterial extends Material {
  100580. protected _activeEffect: Effect;
  100581. protected _normalMatrix: Matrix;
  100582. /**
  100583. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  100584. * This means that the material can keep using a previous shader while a new one is being compiled.
  100585. * This is mostly used when shader parallel compilation is supported (true by default)
  100586. */
  100587. allowShaderHotSwapping: boolean;
  100588. constructor(name: string, scene: Scene);
  100589. getEffect(): Effect;
  100590. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  100591. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  100592. /**
  100593. * Binds the given world matrix to the active effect
  100594. *
  100595. * @param world the matrix to bind
  100596. */
  100597. bindOnlyWorldMatrix(world: Matrix): void;
  100598. /**
  100599. * Binds the given normal matrix to the active effect
  100600. *
  100601. * @param normalMatrix the matrix to bind
  100602. */
  100603. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  100604. bind(world: Matrix, mesh?: Mesh): void;
  100605. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  100606. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  100607. }
  100608. }
  100609. declare module BABYLON {
  100610. /**
  100611. * This groups all the flags used to control the materials channel.
  100612. */
  100613. export class MaterialFlags {
  100614. private static _DiffuseTextureEnabled;
  100615. /**
  100616. * Are diffuse textures enabled in the application.
  100617. */
  100618. static get DiffuseTextureEnabled(): boolean;
  100619. static set DiffuseTextureEnabled(value: boolean);
  100620. private static _AmbientTextureEnabled;
  100621. /**
  100622. * Are ambient textures enabled in the application.
  100623. */
  100624. static get AmbientTextureEnabled(): boolean;
  100625. static set AmbientTextureEnabled(value: boolean);
  100626. private static _OpacityTextureEnabled;
  100627. /**
  100628. * Are opacity textures enabled in the application.
  100629. */
  100630. static get OpacityTextureEnabled(): boolean;
  100631. static set OpacityTextureEnabled(value: boolean);
  100632. private static _ReflectionTextureEnabled;
  100633. /**
  100634. * Are reflection textures enabled in the application.
  100635. */
  100636. static get ReflectionTextureEnabled(): boolean;
  100637. static set ReflectionTextureEnabled(value: boolean);
  100638. private static _EmissiveTextureEnabled;
  100639. /**
  100640. * Are emissive textures enabled in the application.
  100641. */
  100642. static get EmissiveTextureEnabled(): boolean;
  100643. static set EmissiveTextureEnabled(value: boolean);
  100644. private static _SpecularTextureEnabled;
  100645. /**
  100646. * Are specular textures enabled in the application.
  100647. */
  100648. static get SpecularTextureEnabled(): boolean;
  100649. static set SpecularTextureEnabled(value: boolean);
  100650. private static _BumpTextureEnabled;
  100651. /**
  100652. * Are bump textures enabled in the application.
  100653. */
  100654. static get BumpTextureEnabled(): boolean;
  100655. static set BumpTextureEnabled(value: boolean);
  100656. private static _LightmapTextureEnabled;
  100657. /**
  100658. * Are lightmap textures enabled in the application.
  100659. */
  100660. static get LightmapTextureEnabled(): boolean;
  100661. static set LightmapTextureEnabled(value: boolean);
  100662. private static _RefractionTextureEnabled;
  100663. /**
  100664. * Are refraction textures enabled in the application.
  100665. */
  100666. static get RefractionTextureEnabled(): boolean;
  100667. static set RefractionTextureEnabled(value: boolean);
  100668. private static _ColorGradingTextureEnabled;
  100669. /**
  100670. * Are color grading textures enabled in the application.
  100671. */
  100672. static get ColorGradingTextureEnabled(): boolean;
  100673. static set ColorGradingTextureEnabled(value: boolean);
  100674. private static _FresnelEnabled;
  100675. /**
  100676. * Are fresnels enabled in the application.
  100677. */
  100678. static get FresnelEnabled(): boolean;
  100679. static set FresnelEnabled(value: boolean);
  100680. private static _ClearCoatTextureEnabled;
  100681. /**
  100682. * Are clear coat textures enabled in the application.
  100683. */
  100684. static get ClearCoatTextureEnabled(): boolean;
  100685. static set ClearCoatTextureEnabled(value: boolean);
  100686. private static _ClearCoatBumpTextureEnabled;
  100687. /**
  100688. * Are clear coat bump textures enabled in the application.
  100689. */
  100690. static get ClearCoatBumpTextureEnabled(): boolean;
  100691. static set ClearCoatBumpTextureEnabled(value: boolean);
  100692. private static _ClearCoatTintTextureEnabled;
  100693. /**
  100694. * Are clear coat tint textures enabled in the application.
  100695. */
  100696. static get ClearCoatTintTextureEnabled(): boolean;
  100697. static set ClearCoatTintTextureEnabled(value: boolean);
  100698. private static _SheenTextureEnabled;
  100699. /**
  100700. * Are sheen textures enabled in the application.
  100701. */
  100702. static get SheenTextureEnabled(): boolean;
  100703. static set SheenTextureEnabled(value: boolean);
  100704. private static _AnisotropicTextureEnabled;
  100705. /**
  100706. * Are anisotropic textures enabled in the application.
  100707. */
  100708. static get AnisotropicTextureEnabled(): boolean;
  100709. static set AnisotropicTextureEnabled(value: boolean);
  100710. private static _ThicknessTextureEnabled;
  100711. /**
  100712. * Are thickness textures enabled in the application.
  100713. */
  100714. static get ThicknessTextureEnabled(): boolean;
  100715. static set ThicknessTextureEnabled(value: boolean);
  100716. }
  100717. }
  100718. declare module BABYLON {
  100719. /** @hidden */
  100720. export var defaultFragmentDeclaration: {
  100721. name: string;
  100722. shader: string;
  100723. };
  100724. }
  100725. declare module BABYLON {
  100726. /** @hidden */
  100727. export var defaultUboDeclaration: {
  100728. name: string;
  100729. shader: string;
  100730. };
  100731. }
  100732. declare module BABYLON {
  100733. /** @hidden */
  100734. export var lightFragmentDeclaration: {
  100735. name: string;
  100736. shader: string;
  100737. };
  100738. }
  100739. declare module BABYLON {
  100740. /** @hidden */
  100741. export var lightUboDeclaration: {
  100742. name: string;
  100743. shader: string;
  100744. };
  100745. }
  100746. declare module BABYLON {
  100747. /** @hidden */
  100748. export var lightsFragmentFunctions: {
  100749. name: string;
  100750. shader: string;
  100751. };
  100752. }
  100753. declare module BABYLON {
  100754. /** @hidden */
  100755. export var shadowsFragmentFunctions: {
  100756. name: string;
  100757. shader: string;
  100758. };
  100759. }
  100760. declare module BABYLON {
  100761. /** @hidden */
  100762. export var fresnelFunction: {
  100763. name: string;
  100764. shader: string;
  100765. };
  100766. }
  100767. declare module BABYLON {
  100768. /** @hidden */
  100769. export var reflectionFunction: {
  100770. name: string;
  100771. shader: string;
  100772. };
  100773. }
  100774. declare module BABYLON {
  100775. /** @hidden */
  100776. export var bumpFragmentFunctions: {
  100777. name: string;
  100778. shader: string;
  100779. };
  100780. }
  100781. declare module BABYLON {
  100782. /** @hidden */
  100783. export var logDepthDeclaration: {
  100784. name: string;
  100785. shader: string;
  100786. };
  100787. }
  100788. declare module BABYLON {
  100789. /** @hidden */
  100790. export var bumpFragment: {
  100791. name: string;
  100792. shader: string;
  100793. };
  100794. }
  100795. declare module BABYLON {
  100796. /** @hidden */
  100797. export var depthPrePass: {
  100798. name: string;
  100799. shader: string;
  100800. };
  100801. }
  100802. declare module BABYLON {
  100803. /** @hidden */
  100804. export var lightFragment: {
  100805. name: string;
  100806. shader: string;
  100807. };
  100808. }
  100809. declare module BABYLON {
  100810. /** @hidden */
  100811. export var logDepthFragment: {
  100812. name: string;
  100813. shader: string;
  100814. };
  100815. }
  100816. declare module BABYLON {
  100817. /** @hidden */
  100818. export var defaultPixelShader: {
  100819. name: string;
  100820. shader: string;
  100821. };
  100822. }
  100823. declare module BABYLON {
  100824. /** @hidden */
  100825. export var defaultVertexDeclaration: {
  100826. name: string;
  100827. shader: string;
  100828. };
  100829. }
  100830. declare module BABYLON {
  100831. /** @hidden */
  100832. export var bumpVertexDeclaration: {
  100833. name: string;
  100834. shader: string;
  100835. };
  100836. }
  100837. declare module BABYLON {
  100838. /** @hidden */
  100839. export var bumpVertex: {
  100840. name: string;
  100841. shader: string;
  100842. };
  100843. }
  100844. declare module BABYLON {
  100845. /** @hidden */
  100846. export var fogVertex: {
  100847. name: string;
  100848. shader: string;
  100849. };
  100850. }
  100851. declare module BABYLON {
  100852. /** @hidden */
  100853. export var shadowsVertex: {
  100854. name: string;
  100855. shader: string;
  100856. };
  100857. }
  100858. declare module BABYLON {
  100859. /** @hidden */
  100860. export var pointCloudVertex: {
  100861. name: string;
  100862. shader: string;
  100863. };
  100864. }
  100865. declare module BABYLON {
  100866. /** @hidden */
  100867. export var logDepthVertex: {
  100868. name: string;
  100869. shader: string;
  100870. };
  100871. }
  100872. declare module BABYLON {
  100873. /** @hidden */
  100874. export var defaultVertexShader: {
  100875. name: string;
  100876. shader: string;
  100877. };
  100878. }
  100879. declare module BABYLON {
  100880. /** @hidden */
  100881. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  100882. MAINUV1: boolean;
  100883. MAINUV2: boolean;
  100884. DIFFUSE: boolean;
  100885. DIFFUSEDIRECTUV: number;
  100886. AMBIENT: boolean;
  100887. AMBIENTDIRECTUV: number;
  100888. OPACITY: boolean;
  100889. OPACITYDIRECTUV: number;
  100890. OPACITYRGB: boolean;
  100891. REFLECTION: boolean;
  100892. EMISSIVE: boolean;
  100893. EMISSIVEDIRECTUV: number;
  100894. SPECULAR: boolean;
  100895. SPECULARDIRECTUV: number;
  100896. BUMP: boolean;
  100897. BUMPDIRECTUV: number;
  100898. PARALLAX: boolean;
  100899. PARALLAXOCCLUSION: boolean;
  100900. SPECULAROVERALPHA: boolean;
  100901. CLIPPLANE: boolean;
  100902. CLIPPLANE2: boolean;
  100903. CLIPPLANE3: boolean;
  100904. CLIPPLANE4: boolean;
  100905. CLIPPLANE5: boolean;
  100906. CLIPPLANE6: boolean;
  100907. ALPHATEST: boolean;
  100908. DEPTHPREPASS: boolean;
  100909. ALPHAFROMDIFFUSE: boolean;
  100910. POINTSIZE: boolean;
  100911. FOG: boolean;
  100912. SPECULARTERM: boolean;
  100913. DIFFUSEFRESNEL: boolean;
  100914. OPACITYFRESNEL: boolean;
  100915. REFLECTIONFRESNEL: boolean;
  100916. REFRACTIONFRESNEL: boolean;
  100917. EMISSIVEFRESNEL: boolean;
  100918. FRESNEL: boolean;
  100919. NORMAL: boolean;
  100920. UV1: boolean;
  100921. UV2: boolean;
  100922. VERTEXCOLOR: boolean;
  100923. VERTEXALPHA: boolean;
  100924. NUM_BONE_INFLUENCERS: number;
  100925. BonesPerMesh: number;
  100926. BONETEXTURE: boolean;
  100927. INSTANCES: boolean;
  100928. GLOSSINESS: boolean;
  100929. ROUGHNESS: boolean;
  100930. EMISSIVEASILLUMINATION: boolean;
  100931. LINKEMISSIVEWITHDIFFUSE: boolean;
  100932. REFLECTIONFRESNELFROMSPECULAR: boolean;
  100933. LIGHTMAP: boolean;
  100934. LIGHTMAPDIRECTUV: number;
  100935. OBJECTSPACE_NORMALMAP: boolean;
  100936. USELIGHTMAPASSHADOWMAP: boolean;
  100937. REFLECTIONMAP_3D: boolean;
  100938. REFLECTIONMAP_SPHERICAL: boolean;
  100939. REFLECTIONMAP_PLANAR: boolean;
  100940. REFLECTIONMAP_CUBIC: boolean;
  100941. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  100942. REFLECTIONMAP_PROJECTION: boolean;
  100943. REFLECTIONMAP_SKYBOX: boolean;
  100944. REFLECTIONMAP_EXPLICIT: boolean;
  100945. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  100946. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  100947. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  100948. INVERTCUBICMAP: boolean;
  100949. LOGARITHMICDEPTH: boolean;
  100950. REFRACTION: boolean;
  100951. REFRACTIONMAP_3D: boolean;
  100952. REFLECTIONOVERALPHA: boolean;
  100953. TWOSIDEDLIGHTING: boolean;
  100954. SHADOWFLOAT: boolean;
  100955. MORPHTARGETS: boolean;
  100956. MORPHTARGETS_NORMAL: boolean;
  100957. MORPHTARGETS_TANGENT: boolean;
  100958. MORPHTARGETS_UV: boolean;
  100959. NUM_MORPH_INFLUENCERS: number;
  100960. NONUNIFORMSCALING: boolean;
  100961. PREMULTIPLYALPHA: boolean;
  100962. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  100963. ALPHABLEND: boolean;
  100964. IMAGEPROCESSING: boolean;
  100965. VIGNETTE: boolean;
  100966. VIGNETTEBLENDMODEMULTIPLY: boolean;
  100967. VIGNETTEBLENDMODEOPAQUE: boolean;
  100968. TONEMAPPING: boolean;
  100969. TONEMAPPING_ACES: boolean;
  100970. CONTRAST: boolean;
  100971. COLORCURVES: boolean;
  100972. COLORGRADING: boolean;
  100973. COLORGRADING3D: boolean;
  100974. SAMPLER3DGREENDEPTH: boolean;
  100975. SAMPLER3DBGRMAP: boolean;
  100976. IMAGEPROCESSINGPOSTPROCESS: boolean;
  100977. MULTIVIEW: boolean;
  100978. /**
  100979. * If the reflection texture on this material is in linear color space
  100980. * @hidden
  100981. */
  100982. IS_REFLECTION_LINEAR: boolean;
  100983. /**
  100984. * If the refraction texture on this material is in linear color space
  100985. * @hidden
  100986. */
  100987. IS_REFRACTION_LINEAR: boolean;
  100988. EXPOSURE: boolean;
  100989. constructor();
  100990. setReflectionMode(modeToEnable: string): void;
  100991. }
  100992. /**
  100993. * This is the default material used in Babylon. It is the best trade off between quality
  100994. * and performances.
  100995. * @see http://doc.babylonjs.com/babylon101/materials
  100996. */
  100997. export class StandardMaterial extends PushMaterial {
  100998. private _diffuseTexture;
  100999. /**
  101000. * The basic texture of the material as viewed under a light.
  101001. */
  101002. diffuseTexture: Nullable<BaseTexture>;
  101003. private _ambientTexture;
  101004. /**
  101005. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  101006. */
  101007. ambientTexture: Nullable<BaseTexture>;
  101008. private _opacityTexture;
  101009. /**
  101010. * Define the transparency of the material from a texture.
  101011. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  101012. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  101013. */
  101014. opacityTexture: Nullable<BaseTexture>;
  101015. private _reflectionTexture;
  101016. /**
  101017. * Define the texture used to display the reflection.
  101018. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101019. */
  101020. reflectionTexture: Nullable<BaseTexture>;
  101021. private _emissiveTexture;
  101022. /**
  101023. * Define texture of the material as if self lit.
  101024. * This will be mixed in the final result even in the absence of light.
  101025. */
  101026. emissiveTexture: Nullable<BaseTexture>;
  101027. private _specularTexture;
  101028. /**
  101029. * Define how the color and intensity of the highlight given by the light in the material.
  101030. */
  101031. specularTexture: Nullable<BaseTexture>;
  101032. private _bumpTexture;
  101033. /**
  101034. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  101035. * 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.
  101036. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  101037. */
  101038. bumpTexture: Nullable<BaseTexture>;
  101039. private _lightmapTexture;
  101040. /**
  101041. * Complex lighting can be computationally expensive to compute at runtime.
  101042. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  101043. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  101044. */
  101045. lightmapTexture: Nullable<BaseTexture>;
  101046. private _refractionTexture;
  101047. /**
  101048. * Define the texture used to display the refraction.
  101049. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101050. */
  101051. refractionTexture: Nullable<BaseTexture>;
  101052. /**
  101053. * The color of the material lit by the environmental background lighting.
  101054. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  101055. */
  101056. ambientColor: Color3;
  101057. /**
  101058. * The basic color of the material as viewed under a light.
  101059. */
  101060. diffuseColor: Color3;
  101061. /**
  101062. * Define how the color and intensity of the highlight given by the light in the material.
  101063. */
  101064. specularColor: Color3;
  101065. /**
  101066. * Define the color of the material as if self lit.
  101067. * This will be mixed in the final result even in the absence of light.
  101068. */
  101069. emissiveColor: Color3;
  101070. /**
  101071. * Defines how sharp are the highlights in the material.
  101072. * The bigger the value the sharper giving a more glossy feeling to the result.
  101073. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  101074. */
  101075. specularPower: number;
  101076. private _useAlphaFromDiffuseTexture;
  101077. /**
  101078. * Does the transparency come from the diffuse texture alpha channel.
  101079. */
  101080. useAlphaFromDiffuseTexture: boolean;
  101081. private _useEmissiveAsIllumination;
  101082. /**
  101083. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  101084. */
  101085. useEmissiveAsIllumination: boolean;
  101086. private _linkEmissiveWithDiffuse;
  101087. /**
  101088. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  101089. * the emissive level when the final color is close to one.
  101090. */
  101091. linkEmissiveWithDiffuse: boolean;
  101092. private _useSpecularOverAlpha;
  101093. /**
  101094. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  101095. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  101096. */
  101097. useSpecularOverAlpha: boolean;
  101098. private _useReflectionOverAlpha;
  101099. /**
  101100. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  101101. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  101102. */
  101103. useReflectionOverAlpha: boolean;
  101104. private _disableLighting;
  101105. /**
  101106. * Does lights from the scene impacts this material.
  101107. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  101108. */
  101109. disableLighting: boolean;
  101110. private _useObjectSpaceNormalMap;
  101111. /**
  101112. * Allows using an object space normal map (instead of tangent space).
  101113. */
  101114. useObjectSpaceNormalMap: boolean;
  101115. private _useParallax;
  101116. /**
  101117. * Is parallax enabled or not.
  101118. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101119. */
  101120. useParallax: boolean;
  101121. private _useParallaxOcclusion;
  101122. /**
  101123. * Is parallax occlusion enabled or not.
  101124. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  101125. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  101126. */
  101127. useParallaxOcclusion: boolean;
  101128. /**
  101129. * 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.
  101130. */
  101131. parallaxScaleBias: number;
  101132. private _roughness;
  101133. /**
  101134. * Helps to define how blurry the reflections should appears in the material.
  101135. */
  101136. roughness: number;
  101137. /**
  101138. * In case of refraction, define the value of the index of refraction.
  101139. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101140. */
  101141. indexOfRefraction: number;
  101142. /**
  101143. * Invert the refraction texture alongside the y axis.
  101144. * It can be useful with procedural textures or probe for instance.
  101145. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  101146. */
  101147. invertRefractionY: boolean;
  101148. /**
  101149. * Defines the alpha limits in alpha test mode.
  101150. */
  101151. alphaCutOff: number;
  101152. private _useLightmapAsShadowmap;
  101153. /**
  101154. * In case of light mapping, define whether the map contains light or shadow informations.
  101155. */
  101156. useLightmapAsShadowmap: boolean;
  101157. private _diffuseFresnelParameters;
  101158. /**
  101159. * Define the diffuse fresnel parameters of the material.
  101160. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101161. */
  101162. diffuseFresnelParameters: FresnelParameters;
  101163. private _opacityFresnelParameters;
  101164. /**
  101165. * Define the opacity fresnel parameters of the material.
  101166. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101167. */
  101168. opacityFresnelParameters: FresnelParameters;
  101169. private _reflectionFresnelParameters;
  101170. /**
  101171. * Define the reflection fresnel parameters of the material.
  101172. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101173. */
  101174. reflectionFresnelParameters: FresnelParameters;
  101175. private _refractionFresnelParameters;
  101176. /**
  101177. * Define the refraction fresnel parameters of the material.
  101178. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101179. */
  101180. refractionFresnelParameters: FresnelParameters;
  101181. private _emissiveFresnelParameters;
  101182. /**
  101183. * Define the emissive fresnel parameters of the material.
  101184. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101185. */
  101186. emissiveFresnelParameters: FresnelParameters;
  101187. private _useReflectionFresnelFromSpecular;
  101188. /**
  101189. * If true automatically deducts the fresnels values from the material specularity.
  101190. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  101191. */
  101192. useReflectionFresnelFromSpecular: boolean;
  101193. private _useGlossinessFromSpecularMapAlpha;
  101194. /**
  101195. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  101196. */
  101197. useGlossinessFromSpecularMapAlpha: boolean;
  101198. private _maxSimultaneousLights;
  101199. /**
  101200. * Defines the maximum number of lights that can be used in the material
  101201. */
  101202. maxSimultaneousLights: number;
  101203. private _invertNormalMapX;
  101204. /**
  101205. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  101206. */
  101207. invertNormalMapX: boolean;
  101208. private _invertNormalMapY;
  101209. /**
  101210. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  101211. */
  101212. invertNormalMapY: boolean;
  101213. private _twoSidedLighting;
  101214. /**
  101215. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  101216. */
  101217. twoSidedLighting: boolean;
  101218. /**
  101219. * Default configuration related to image processing available in the standard Material.
  101220. */
  101221. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  101222. /**
  101223. * Gets the image processing configuration used either in this material.
  101224. */
  101225. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  101226. /**
  101227. * Sets the Default image processing configuration used either in the this material.
  101228. *
  101229. * If sets to null, the scene one is in use.
  101230. */
  101231. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  101232. /**
  101233. * Keep track of the image processing observer to allow dispose and replace.
  101234. */
  101235. private _imageProcessingObserver;
  101236. /**
  101237. * Attaches a new image processing configuration to the Standard Material.
  101238. * @param configuration
  101239. */
  101240. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  101241. /**
  101242. * Gets wether the color curves effect is enabled.
  101243. */
  101244. get cameraColorCurvesEnabled(): boolean;
  101245. /**
  101246. * Sets wether the color curves effect is enabled.
  101247. */
  101248. set cameraColorCurvesEnabled(value: boolean);
  101249. /**
  101250. * Gets wether the color grading effect is enabled.
  101251. */
  101252. get cameraColorGradingEnabled(): boolean;
  101253. /**
  101254. * Gets wether the color grading effect is enabled.
  101255. */
  101256. set cameraColorGradingEnabled(value: boolean);
  101257. /**
  101258. * Gets wether tonemapping is enabled or not.
  101259. */
  101260. get cameraToneMappingEnabled(): boolean;
  101261. /**
  101262. * Sets wether tonemapping is enabled or not
  101263. */
  101264. set cameraToneMappingEnabled(value: boolean);
  101265. /**
  101266. * The camera exposure used on this material.
  101267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101268. * This corresponds to a photographic exposure.
  101269. */
  101270. get cameraExposure(): number;
  101271. /**
  101272. * The camera exposure used on this material.
  101273. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  101274. * This corresponds to a photographic exposure.
  101275. */
  101276. set cameraExposure(value: number);
  101277. /**
  101278. * Gets The camera contrast used on this material.
  101279. */
  101280. get cameraContrast(): number;
  101281. /**
  101282. * Sets The camera contrast used on this material.
  101283. */
  101284. set cameraContrast(value: number);
  101285. /**
  101286. * Gets the Color Grading 2D Lookup Texture.
  101287. */
  101288. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  101289. /**
  101290. * Sets the Color Grading 2D Lookup Texture.
  101291. */
  101292. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  101293. /**
  101294. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101295. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101296. * 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;
  101297. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101298. */
  101299. get cameraColorCurves(): Nullable<ColorCurves>;
  101300. /**
  101301. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  101302. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  101303. * 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;
  101304. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  101305. */
  101306. set cameraColorCurves(value: Nullable<ColorCurves>);
  101307. /**
  101308. * Custom callback helping to override the default shader used in the material.
  101309. */
  101310. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines, attributes?: string[]) => string;
  101311. protected _renderTargets: SmartArray<RenderTargetTexture>;
  101312. protected _worldViewProjectionMatrix: Matrix;
  101313. protected _globalAmbientColor: Color3;
  101314. protected _useLogarithmicDepth: boolean;
  101315. protected _rebuildInParallel: boolean;
  101316. /**
  101317. * Instantiates a new standard material.
  101318. * This is the default material used in Babylon. It is the best trade off between quality
  101319. * and performances.
  101320. * @see http://doc.babylonjs.com/babylon101/materials
  101321. * @param name Define the name of the material in the scene
  101322. * @param scene Define the scene the material belong to
  101323. */
  101324. constructor(name: string, scene: Scene);
  101325. /**
  101326. * Gets a boolean indicating that current material needs to register RTT
  101327. */
  101328. get hasRenderTargetTextures(): boolean;
  101329. /**
  101330. * Gets the current class name of the material e.g. "StandardMaterial"
  101331. * Mainly use in serialization.
  101332. * @returns the class name
  101333. */
  101334. getClassName(): string;
  101335. /**
  101336. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  101337. * You can try switching to logarithmic depth.
  101338. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  101339. */
  101340. get useLogarithmicDepth(): boolean;
  101341. set useLogarithmicDepth(value: boolean);
  101342. /**
  101343. * Specifies if the material will require alpha blending
  101344. * @returns a boolean specifying if alpha blending is needed
  101345. */
  101346. needAlphaBlending(): boolean;
  101347. /**
  101348. * Specifies if this material should be rendered in alpha test mode
  101349. * @returns a boolean specifying if an alpha test is needed.
  101350. */
  101351. needAlphaTesting(): boolean;
  101352. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  101353. /**
  101354. * Get the texture used for alpha test purpose.
  101355. * @returns the diffuse texture in case of the standard material.
  101356. */
  101357. getAlphaTestTexture(): Nullable<BaseTexture>;
  101358. /**
  101359. * Get if the submesh is ready to be used and all its information available.
  101360. * Child classes can use it to update shaders
  101361. * @param mesh defines the mesh to check
  101362. * @param subMesh defines which submesh to check
  101363. * @param useInstances specifies that instances should be used
  101364. * @returns a boolean indicating that the submesh is ready or not
  101365. */
  101366. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  101367. /**
  101368. * Builds the material UBO layouts.
  101369. * Used internally during the effect preparation.
  101370. */
  101371. buildUniformLayout(): void;
  101372. /**
  101373. * Unbinds the material from the mesh
  101374. */
  101375. unbind(): void;
  101376. /**
  101377. * Binds the submesh to this material by preparing the effect and shader to draw
  101378. * @param world defines the world transformation matrix
  101379. * @param mesh defines the mesh containing the submesh
  101380. * @param subMesh defines the submesh to bind the material to
  101381. */
  101382. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  101383. /**
  101384. * Get the list of animatables in the material.
  101385. * @returns the list of animatables object used in the material
  101386. */
  101387. getAnimatables(): IAnimatable[];
  101388. /**
  101389. * Gets the active textures from the material
  101390. * @returns an array of textures
  101391. */
  101392. getActiveTextures(): BaseTexture[];
  101393. /**
  101394. * Specifies if the material uses a texture
  101395. * @param texture defines the texture to check against the material
  101396. * @returns a boolean specifying if the material uses the texture
  101397. */
  101398. hasTexture(texture: BaseTexture): boolean;
  101399. /**
  101400. * Disposes the material
  101401. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  101402. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  101403. */
  101404. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  101405. /**
  101406. * Makes a duplicate of the material, and gives it a new name
  101407. * @param name defines the new name for the duplicated material
  101408. * @returns the cloned material
  101409. */
  101410. clone(name: string): StandardMaterial;
  101411. /**
  101412. * Serializes this material in a JSON representation
  101413. * @returns the serialized material object
  101414. */
  101415. serialize(): any;
  101416. /**
  101417. * Creates a standard material from parsed material data
  101418. * @param source defines the JSON representation of the material
  101419. * @param scene defines the hosting scene
  101420. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  101421. * @returns a new standard material
  101422. */
  101423. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  101424. /**
  101425. * Are diffuse textures enabled in the application.
  101426. */
  101427. static get DiffuseTextureEnabled(): boolean;
  101428. static set DiffuseTextureEnabled(value: boolean);
  101429. /**
  101430. * Are ambient textures enabled in the application.
  101431. */
  101432. static get AmbientTextureEnabled(): boolean;
  101433. static set AmbientTextureEnabled(value: boolean);
  101434. /**
  101435. * Are opacity textures enabled in the application.
  101436. */
  101437. static get OpacityTextureEnabled(): boolean;
  101438. static set OpacityTextureEnabled(value: boolean);
  101439. /**
  101440. * Are reflection textures enabled in the application.
  101441. */
  101442. static get ReflectionTextureEnabled(): boolean;
  101443. static set ReflectionTextureEnabled(value: boolean);
  101444. /**
  101445. * Are emissive textures enabled in the application.
  101446. */
  101447. static get EmissiveTextureEnabled(): boolean;
  101448. static set EmissiveTextureEnabled(value: boolean);
  101449. /**
  101450. * Are specular textures enabled in the application.
  101451. */
  101452. static get SpecularTextureEnabled(): boolean;
  101453. static set SpecularTextureEnabled(value: boolean);
  101454. /**
  101455. * Are bump textures enabled in the application.
  101456. */
  101457. static get BumpTextureEnabled(): boolean;
  101458. static set BumpTextureEnabled(value: boolean);
  101459. /**
  101460. * Are lightmap textures enabled in the application.
  101461. */
  101462. static get LightmapTextureEnabled(): boolean;
  101463. static set LightmapTextureEnabled(value: boolean);
  101464. /**
  101465. * Are refraction textures enabled in the application.
  101466. */
  101467. static get RefractionTextureEnabled(): boolean;
  101468. static set RefractionTextureEnabled(value: boolean);
  101469. /**
  101470. * Are color grading textures enabled in the application.
  101471. */
  101472. static get ColorGradingTextureEnabled(): boolean;
  101473. static set ColorGradingTextureEnabled(value: boolean);
  101474. /**
  101475. * Are fresnels enabled in the application.
  101476. */
  101477. static get FresnelEnabled(): boolean;
  101478. static set FresnelEnabled(value: boolean);
  101479. }
  101480. }
  101481. declare module BABYLON {
  101482. /**
  101483. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  101484. *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.
  101485. * The SPS is also a particle system. It provides some methods to manage the particles.
  101486. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  101487. *
  101488. * Full documentation here : http://doc.babylonjs.com/how_to/Solid_Particle_System
  101489. */
  101490. export class SolidParticleSystem implements IDisposable {
  101491. /**
  101492. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  101493. * Example : var p = SPS.particles[i];
  101494. */
  101495. particles: SolidParticle[];
  101496. /**
  101497. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  101498. */
  101499. nbParticles: number;
  101500. /**
  101501. * If the particles must ever face the camera (default false). Useful for planar particles.
  101502. */
  101503. billboard: boolean;
  101504. /**
  101505. * Recompute normals when adding a shape
  101506. */
  101507. recomputeNormals: boolean;
  101508. /**
  101509. * This a counter ofr your own usage. It's not set by any SPS functions.
  101510. */
  101511. counter: number;
  101512. /**
  101513. * The SPS name. This name is also given to the underlying mesh.
  101514. */
  101515. name: string;
  101516. /**
  101517. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  101518. */
  101519. mesh: Mesh;
  101520. /**
  101521. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  101522. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  101523. */
  101524. vars: any;
  101525. /**
  101526. * This array is populated when the SPS is set as 'pickable'.
  101527. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  101528. * Each element of this array is an object `{idx: int, faceId: int}`.
  101529. * `idx` is the picked particle index in the `SPS.particles` array
  101530. * `faceId` is the picked face index counted within this particle.
  101531. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  101532. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  101533. * Use the method SPS.pickedParticle(pickingInfo) instead.
  101534. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101535. */
  101536. pickedParticles: {
  101537. idx: number;
  101538. faceId: number;
  101539. }[];
  101540. /**
  101541. * This array is populated when the SPS is set as 'pickable'
  101542. * Each key of this array is a submesh index.
  101543. * Each element of this array is a second array defined like this :
  101544. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  101545. * Each element of this second array is an object `{idx: int, faceId: int}`.
  101546. * `idx` is the picked particle index in the `SPS.particles` array
  101547. * `faceId` is the picked face index counted within this particle.
  101548. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  101549. * Please read : http://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  101550. */
  101551. pickedBySubMesh: {
  101552. idx: number;
  101553. faceId: number;
  101554. }[][];
  101555. /**
  101556. * This array is populated when `enableDepthSort` is set to true.
  101557. * Each element of this array is an instance of the class DepthSortedParticle.
  101558. */
  101559. depthSortedParticles: DepthSortedParticle[];
  101560. /**
  101561. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  101562. * @hidden
  101563. */
  101564. _bSphereOnly: boolean;
  101565. /**
  101566. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  101567. * @hidden
  101568. */
  101569. _bSphereRadiusFactor: number;
  101570. private _scene;
  101571. private _positions;
  101572. private _indices;
  101573. private _normals;
  101574. private _colors;
  101575. private _uvs;
  101576. private _indices32;
  101577. private _positions32;
  101578. private _normals32;
  101579. private _fixedNormal32;
  101580. private _colors32;
  101581. private _uvs32;
  101582. private _index;
  101583. private _updatable;
  101584. private _pickable;
  101585. private _isVisibilityBoxLocked;
  101586. private _alwaysVisible;
  101587. private _depthSort;
  101588. private _expandable;
  101589. private _shapeCounter;
  101590. private _copy;
  101591. private _color;
  101592. private _computeParticleColor;
  101593. private _computeParticleTexture;
  101594. private _computeParticleRotation;
  101595. private _computeParticleVertex;
  101596. private _computeBoundingBox;
  101597. private _depthSortParticles;
  101598. private _camera;
  101599. private _mustUnrotateFixedNormals;
  101600. private _particlesIntersect;
  101601. private _needs32Bits;
  101602. private _isNotBuilt;
  101603. private _lastParticleId;
  101604. private _idxOfId;
  101605. private _multimaterialEnabled;
  101606. private _useModelMaterial;
  101607. private _indicesByMaterial;
  101608. private _materialIndexes;
  101609. private _depthSortFunction;
  101610. private _materialSortFunction;
  101611. private _materials;
  101612. private _multimaterial;
  101613. private _materialIndexesById;
  101614. private _defaultMaterial;
  101615. private _autoUpdateSubMeshes;
  101616. /**
  101617. * Creates a SPS (Solid Particle System) object.
  101618. * @param name (String) is the SPS name, this will be the underlying mesh name.
  101619. * @param scene (Scene) is the scene in which the SPS is added.
  101620. * @param options defines the options of the sps e.g.
  101621. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  101622. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  101623. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  101624. * * 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.
  101625. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  101626. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  101627. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  101628. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  101629. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  101630. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  101631. */
  101632. constructor(name: string, scene: Scene, options?: {
  101633. updatable?: boolean;
  101634. isPickable?: boolean;
  101635. enableDepthSort?: boolean;
  101636. particleIntersection?: boolean;
  101637. boundingSphereOnly?: boolean;
  101638. bSphereRadiusFactor?: number;
  101639. expandable?: boolean;
  101640. useModelMaterial?: boolean;
  101641. enableMultiMaterial?: boolean;
  101642. });
  101643. /**
  101644. * Builds the SPS underlying mesh. Returns a standard Mesh.
  101645. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  101646. * @returns the created mesh
  101647. */
  101648. buildMesh(): Mesh;
  101649. /**
  101650. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  101651. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  101652. * Thus the particles generated from `digest()` have their property `position` set yet.
  101653. * @param mesh ( Mesh ) is the mesh to be digested
  101654. * @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
  101655. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  101656. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  101657. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101658. * @returns the current SPS
  101659. */
  101660. digest(mesh: Mesh, options?: {
  101661. facetNb?: number;
  101662. number?: number;
  101663. delta?: number;
  101664. storage?: [];
  101665. }): SolidParticleSystem;
  101666. /**
  101667. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  101668. * @hidden
  101669. */
  101670. private _unrotateFixedNormals;
  101671. /**
  101672. * Resets the temporary working copy particle
  101673. * @hidden
  101674. */
  101675. private _resetCopy;
  101676. /**
  101677. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  101678. * @param p the current index in the positions array to be updated
  101679. * @param ind the current index in the indices array
  101680. * @param shape a Vector3 array, the shape geometry
  101681. * @param positions the positions array to be updated
  101682. * @param meshInd the shape indices array
  101683. * @param indices the indices array to be updated
  101684. * @param meshUV the shape uv array
  101685. * @param uvs the uv array to be updated
  101686. * @param meshCol the shape color array
  101687. * @param colors the color array to be updated
  101688. * @param meshNor the shape normals array
  101689. * @param normals the normals array to be updated
  101690. * @param idx the particle index
  101691. * @param idxInShape the particle index in its shape
  101692. * @param options the addShape() method passed options
  101693. * @model the particle model
  101694. * @hidden
  101695. */
  101696. private _meshBuilder;
  101697. /**
  101698. * Returns a shape Vector3 array from positions float array
  101699. * @param positions float array
  101700. * @returns a vector3 array
  101701. * @hidden
  101702. */
  101703. private _posToShape;
  101704. /**
  101705. * Returns a shapeUV array from a float uvs (array deep copy)
  101706. * @param uvs as a float array
  101707. * @returns a shapeUV array
  101708. * @hidden
  101709. */
  101710. private _uvsToShapeUV;
  101711. /**
  101712. * Adds a new particle object in the particles array
  101713. * @param idx particle index in particles array
  101714. * @param id particle id
  101715. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  101716. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  101717. * @param model particle ModelShape object
  101718. * @param shapeId model shape identifier
  101719. * @param idxInShape index of the particle in the current model
  101720. * @param bInfo model bounding info object
  101721. * @param storage target storage array, if any
  101722. * @hidden
  101723. */
  101724. private _addParticle;
  101725. /**
  101726. * Adds some particles to the SPS from the model shape. Returns the shape id.
  101727. * Please read the doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  101728. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  101729. * @param nb (positive integer) the number of particles to be created from this model
  101730. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  101731. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  101732. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  101733. * @returns the number of shapes in the system
  101734. */
  101735. addShape(mesh: Mesh, nb: number, options?: {
  101736. positionFunction?: any;
  101737. vertexFunction?: any;
  101738. storage?: [];
  101739. }): number;
  101740. /**
  101741. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  101742. * @hidden
  101743. */
  101744. private _rebuildParticle;
  101745. /**
  101746. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  101747. * @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.
  101748. * @returns the SPS.
  101749. */
  101750. rebuildMesh(reset?: boolean): SolidParticleSystem;
  101751. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  101752. * Returns an array with the removed particles.
  101753. * 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.
  101754. * The SPS can't be empty so at least one particle needs to remain in place.
  101755. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  101756. * @param start index of the first particle to remove
  101757. * @param end index of the last particle to remove (included)
  101758. * @returns an array populated with the removed particles
  101759. */
  101760. removeParticles(start: number, end: number): SolidParticle[];
  101761. /**
  101762. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  101763. * @param solidParticleArray an array populated with Solid Particles objects
  101764. * @returns the SPS
  101765. */
  101766. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  101767. /**
  101768. * Creates a new particle and modifies the SPS mesh geometry :
  101769. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  101770. * - calls _addParticle() to populate the particle array
  101771. * factorized code from addShape() and insertParticlesFromArray()
  101772. * @param idx particle index in the particles array
  101773. * @param i particle index in its shape
  101774. * @param modelShape particle ModelShape object
  101775. * @param shape shape vertex array
  101776. * @param meshInd shape indices array
  101777. * @param meshUV shape uv array
  101778. * @param meshCol shape color array
  101779. * @param meshNor shape normals array
  101780. * @param bbInfo shape bounding info
  101781. * @param storage target particle storage
  101782. * @options addShape() passed options
  101783. * @hidden
  101784. */
  101785. private _insertNewParticle;
  101786. /**
  101787. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  101788. * This method calls `updateParticle()` for each particle of the SPS.
  101789. * For an animated SPS, it is usually called within the render loop.
  101790. * 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.
  101791. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  101792. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  101793. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  101794. * @returns the SPS.
  101795. */
  101796. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  101797. /**
  101798. * Disposes the SPS.
  101799. */
  101800. dispose(): void;
  101801. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  101802. * idx is the particle index in the SPS
  101803. * faceId is the picked face index counted within this particle.
  101804. * Returns null if the pickInfo can't identify a picked particle.
  101805. * @param pickingInfo (PickingInfo object)
  101806. * @returns {idx: number, faceId: number} or null
  101807. */
  101808. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  101809. idx: number;
  101810. faceId: number;
  101811. }>;
  101812. /**
  101813. * Returns a SolidParticle object from its identifier : particle.id
  101814. * @param id (integer) the particle Id
  101815. * @returns the searched particle or null if not found in the SPS.
  101816. */
  101817. getParticleById(id: number): Nullable<SolidParticle>;
  101818. /**
  101819. * Returns a new array populated with the particles having the passed shapeId.
  101820. * @param shapeId (integer) the shape identifier
  101821. * @returns a new solid particle array
  101822. */
  101823. getParticlesByShapeId(shapeId: number): SolidParticle[];
  101824. /**
  101825. * Populates the passed array "ref" with the particles having the passed shapeId.
  101826. * @param shapeId the shape identifier
  101827. * @returns the SPS
  101828. * @param ref
  101829. */
  101830. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  101831. /**
  101832. * Computes the required SubMeshes according the materials assigned to the particles.
  101833. * @returns the solid particle system.
  101834. * Does nothing if called before the SPS mesh is built.
  101835. */
  101836. computeSubMeshes(): SolidParticleSystem;
  101837. /**
  101838. * Sorts the solid particles by material when MultiMaterial is enabled.
  101839. * Updates the indices32 array.
  101840. * Updates the indicesByMaterial array.
  101841. * Updates the mesh indices array.
  101842. * @returns the SPS
  101843. * @hidden
  101844. */
  101845. private _sortParticlesByMaterial;
  101846. /**
  101847. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  101848. * @hidden
  101849. */
  101850. private _setMaterialIndexesById;
  101851. /**
  101852. * Returns an array with unique values of Materials from the passed array
  101853. * @param array the material array to be checked and filtered
  101854. * @hidden
  101855. */
  101856. private _filterUniqueMaterialId;
  101857. /**
  101858. * Sets a new Standard Material as _defaultMaterial if not already set.
  101859. * @hidden
  101860. */
  101861. private _setDefaultMaterial;
  101862. /**
  101863. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  101864. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101865. * @returns the SPS.
  101866. */
  101867. refreshVisibleSize(): SolidParticleSystem;
  101868. /**
  101869. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  101870. * @param size the size (float) of the visibility box
  101871. * note : this doesn't lock the SPS mesh bounding box.
  101872. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101873. */
  101874. setVisibilityBox(size: number): void;
  101875. /**
  101876. * Gets whether the SPS as always visible or not
  101877. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101878. */
  101879. get isAlwaysVisible(): boolean;
  101880. /**
  101881. * Sets the SPS as always visible or not
  101882. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101883. */
  101884. set isAlwaysVisible(val: boolean);
  101885. /**
  101886. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101887. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101888. */
  101889. set isVisibilityBoxLocked(val: boolean);
  101890. /**
  101891. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  101892. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  101893. */
  101894. get isVisibilityBoxLocked(): boolean;
  101895. /**
  101896. * Tells to `setParticles()` to compute the particle rotations or not.
  101897. * Default value : true. The SPS is faster when it's set to false.
  101898. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101899. */
  101900. set computeParticleRotation(val: boolean);
  101901. /**
  101902. * Tells to `setParticles()` to compute the particle colors or not.
  101903. * Default value : true. The SPS is faster when it's set to false.
  101904. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101905. */
  101906. set computeParticleColor(val: boolean);
  101907. set computeParticleTexture(val: boolean);
  101908. /**
  101909. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  101910. * Default value : false. The SPS is faster when it's set to false.
  101911. * Note : the particle custom vertex positions aren't stored values.
  101912. */
  101913. set computeParticleVertex(val: boolean);
  101914. /**
  101915. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  101916. */
  101917. set computeBoundingBox(val: boolean);
  101918. /**
  101919. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  101920. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101921. * Default : `true`
  101922. */
  101923. set depthSortParticles(val: boolean);
  101924. /**
  101925. * Gets if `setParticles()` computes the particle rotations or not.
  101926. * Default value : true. The SPS is faster when it's set to false.
  101927. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  101928. */
  101929. get computeParticleRotation(): boolean;
  101930. /**
  101931. * Gets if `setParticles()` computes the particle colors or not.
  101932. * Default value : true. The SPS is faster when it's set to false.
  101933. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  101934. */
  101935. get computeParticleColor(): boolean;
  101936. /**
  101937. * Gets if `setParticles()` computes the particle textures or not.
  101938. * Default value : true. The SPS is faster when it's set to false.
  101939. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  101940. */
  101941. get computeParticleTexture(): boolean;
  101942. /**
  101943. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  101944. * Default value : false. The SPS is faster when it's set to false.
  101945. * Note : the particle custom vertex positions aren't stored values.
  101946. */
  101947. get computeParticleVertex(): boolean;
  101948. /**
  101949. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  101950. */
  101951. get computeBoundingBox(): boolean;
  101952. /**
  101953. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  101954. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  101955. * Default : `true`
  101956. */
  101957. get depthSortParticles(): boolean;
  101958. /**
  101959. * Gets if the SPS is created as expandable at construction time.
  101960. * Default : `false`
  101961. */
  101962. get expandable(): boolean;
  101963. /**
  101964. * Gets if the SPS supports the Multi Materials
  101965. */
  101966. get multimaterialEnabled(): boolean;
  101967. /**
  101968. * Gets if the SPS uses the model materials for its own multimaterial.
  101969. */
  101970. get useModelMaterial(): boolean;
  101971. /**
  101972. * The SPS used material array.
  101973. */
  101974. get materials(): Material[];
  101975. /**
  101976. * Sets the SPS MultiMaterial from the passed materials.
  101977. * Note : the passed array is internally copied and not used then by reference.
  101978. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  101979. */
  101980. setMultiMaterial(materials: Material[]): void;
  101981. /**
  101982. * The SPS computed multimaterial object
  101983. */
  101984. get multimaterial(): MultiMaterial;
  101985. set multimaterial(mm: MultiMaterial);
  101986. /**
  101987. * If the subMeshes must be updated on the next call to setParticles()
  101988. */
  101989. get autoUpdateSubMeshes(): boolean;
  101990. set autoUpdateSubMeshes(val: boolean);
  101991. /**
  101992. * This function does nothing. It may be overwritten to set all the particle first values.
  101993. * The SPS doesn't call this function, you may have to call it by your own.
  101994. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  101995. */
  101996. initParticles(): void;
  101997. /**
  101998. * This function does nothing. It may be overwritten to recycle a particle.
  101999. * The SPS doesn't call this function, you may have to call it by your own.
  102000. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102001. * @param particle The particle to recycle
  102002. * @returns the recycled particle
  102003. */
  102004. recycleParticle(particle: SolidParticle): SolidParticle;
  102005. /**
  102006. * Updates a particle : this function should be overwritten by the user.
  102007. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  102008. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  102009. * @example : just set a particle position or velocity and recycle conditions
  102010. * @param particle The particle to update
  102011. * @returns the updated particle
  102012. */
  102013. updateParticle(particle: SolidParticle): SolidParticle;
  102014. /**
  102015. * Updates a vertex of a particle : it can be overwritten by the user.
  102016. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  102017. * @param particle the current particle
  102018. * @param vertex the current index of the current particle
  102019. * @param pt the index of the current vertex in the particle shape
  102020. * doc : http://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  102021. * @example : just set a vertex particle position
  102022. * @returns the updated vertex
  102023. */
  102024. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  102025. /**
  102026. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  102027. * This does nothing and may be overwritten by the user.
  102028. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102029. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102030. * @param update the boolean update value actually passed to setParticles()
  102031. */
  102032. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102033. /**
  102034. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  102035. * This will be passed three parameters.
  102036. * This does nothing and may be overwritten by the user.
  102037. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102038. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  102039. * @param update the boolean update value actually passed to setParticles()
  102040. */
  102041. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  102042. }
  102043. }
  102044. declare module BABYLON {
  102045. /**
  102046. * Represents one particle of a solid particle system.
  102047. */
  102048. export class SolidParticle {
  102049. /**
  102050. * particle global index
  102051. */
  102052. idx: number;
  102053. /**
  102054. * particle identifier
  102055. */
  102056. id: number;
  102057. /**
  102058. * The color of the particle
  102059. */
  102060. color: Nullable<Color4>;
  102061. /**
  102062. * The world space position of the particle.
  102063. */
  102064. position: Vector3;
  102065. /**
  102066. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  102067. */
  102068. rotation: Vector3;
  102069. /**
  102070. * The world space rotation quaternion of the particle.
  102071. */
  102072. rotationQuaternion: Nullable<Quaternion>;
  102073. /**
  102074. * The scaling of the particle.
  102075. */
  102076. scaling: Vector3;
  102077. /**
  102078. * The uvs of the particle.
  102079. */
  102080. uvs: Vector4;
  102081. /**
  102082. * The current speed of the particle.
  102083. */
  102084. velocity: Vector3;
  102085. /**
  102086. * The pivot point in the particle local space.
  102087. */
  102088. pivot: Vector3;
  102089. /**
  102090. * Must the particle be translated from its pivot point in its local space ?
  102091. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  102092. * Default : false
  102093. */
  102094. translateFromPivot: boolean;
  102095. /**
  102096. * Is the particle active or not ?
  102097. */
  102098. alive: boolean;
  102099. /**
  102100. * Is the particle visible or not ?
  102101. */
  102102. isVisible: boolean;
  102103. /**
  102104. * Index of this particle in the global "positions" array (Internal use)
  102105. * @hidden
  102106. */
  102107. _pos: number;
  102108. /**
  102109. * @hidden Index of this particle in the global "indices" array (Internal use)
  102110. */
  102111. _ind: number;
  102112. /**
  102113. * @hidden ModelShape of this particle (Internal use)
  102114. */
  102115. _model: ModelShape;
  102116. /**
  102117. * ModelShape id of this particle
  102118. */
  102119. shapeId: number;
  102120. /**
  102121. * Index of the particle in its shape id
  102122. */
  102123. idxInShape: number;
  102124. /**
  102125. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  102126. */
  102127. _modelBoundingInfo: BoundingInfo;
  102128. /**
  102129. * @hidden Particle BoundingInfo object (Internal use)
  102130. */
  102131. _boundingInfo: BoundingInfo;
  102132. /**
  102133. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  102134. */
  102135. _sps: SolidParticleSystem;
  102136. /**
  102137. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  102138. */
  102139. _stillInvisible: boolean;
  102140. /**
  102141. * @hidden Last computed particle rotation matrix
  102142. */
  102143. _rotationMatrix: number[];
  102144. /**
  102145. * Parent particle Id, if any.
  102146. * Default null.
  102147. */
  102148. parentId: Nullable<number>;
  102149. /**
  102150. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  102151. */
  102152. materialIndex: Nullable<number>;
  102153. /**
  102154. * Custom object or properties.
  102155. */
  102156. props: Nullable<any>;
  102157. /**
  102158. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  102159. * The possible values are :
  102160. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102161. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102162. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102163. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102164. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102165. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  102166. * */
  102167. cullingStrategy: number;
  102168. /**
  102169. * @hidden Internal global position in the SPS.
  102170. */
  102171. _globalPosition: Vector3;
  102172. /**
  102173. * Creates a Solid Particle object.
  102174. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  102175. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  102176. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  102177. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  102178. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  102179. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  102180. * @param shapeId (integer) is the model shape identifier in the SPS.
  102181. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  102182. * @param sps defines the sps it is associated to
  102183. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  102184. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  102185. */
  102186. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  102187. /**
  102188. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  102189. * @param target the particle target
  102190. * @returns the current particle
  102191. */
  102192. copyToRef(target: SolidParticle): SolidParticle;
  102193. /**
  102194. * Legacy support, changed scale to scaling
  102195. */
  102196. get scale(): Vector3;
  102197. /**
  102198. * Legacy support, changed scale to scaling
  102199. */
  102200. set scale(scale: Vector3);
  102201. /**
  102202. * Legacy support, changed quaternion to rotationQuaternion
  102203. */
  102204. get quaternion(): Nullable<Quaternion>;
  102205. /**
  102206. * Legacy support, changed quaternion to rotationQuaternion
  102207. */
  102208. set quaternion(q: Nullable<Quaternion>);
  102209. /**
  102210. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  102211. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  102212. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  102213. * @returns true if it intersects
  102214. */
  102215. intersectsMesh(target: Mesh | SolidParticle): boolean;
  102216. /**
  102217. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  102218. * A particle is in the frustum if its bounding box intersects the frustum
  102219. * @param frustumPlanes defines the frustum to test
  102220. * @returns true if the particle is in the frustum planes
  102221. */
  102222. isInFrustum(frustumPlanes: Plane[]): boolean;
  102223. /**
  102224. * get the rotation matrix of the particle
  102225. * @hidden
  102226. */
  102227. getRotationMatrix(m: Matrix): void;
  102228. }
  102229. /**
  102230. * Represents the shape of the model used by one particle of a solid particle system.
  102231. * SPS internal tool, don't use it manually.
  102232. */
  102233. export class ModelShape {
  102234. /**
  102235. * The shape id
  102236. * @hidden
  102237. */
  102238. shapeID: number;
  102239. /**
  102240. * flat array of model positions (internal use)
  102241. * @hidden
  102242. */
  102243. _shape: Vector3[];
  102244. /**
  102245. * flat array of model UVs (internal use)
  102246. * @hidden
  102247. */
  102248. _shapeUV: number[];
  102249. /**
  102250. * color array of the model
  102251. * @hidden
  102252. */
  102253. _shapeColors: number[];
  102254. /**
  102255. * indices array of the model
  102256. * @hidden
  102257. */
  102258. _indices: number[];
  102259. /**
  102260. * normals array of the model
  102261. * @hidden
  102262. */
  102263. _normals: number[];
  102264. /**
  102265. * length of the shape in the model indices array (internal use)
  102266. * @hidden
  102267. */
  102268. _indicesLength: number;
  102269. /**
  102270. * Custom position function (internal use)
  102271. * @hidden
  102272. */
  102273. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  102274. /**
  102275. * Custom vertex function (internal use)
  102276. * @hidden
  102277. */
  102278. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  102279. /**
  102280. * Model material (internal use)
  102281. * @hidden
  102282. */
  102283. _material: Nullable<Material>;
  102284. /**
  102285. * 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.
  102286. * SPS internal tool, don't use it manually.
  102287. * @hidden
  102288. */
  102289. 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>);
  102290. }
  102291. /**
  102292. * Represents a Depth Sorted Particle in the solid particle system.
  102293. * @hidden
  102294. */
  102295. export class DepthSortedParticle {
  102296. /**
  102297. * Particle index
  102298. */
  102299. idx: number;
  102300. /**
  102301. * Index of the particle in the "indices" array
  102302. */
  102303. ind: number;
  102304. /**
  102305. * Length of the particle shape in the "indices" array
  102306. */
  102307. indicesLength: number;
  102308. /**
  102309. * Squared distance from the particle to the camera
  102310. */
  102311. sqDistance: number;
  102312. /**
  102313. * Material index when used with MultiMaterials
  102314. */
  102315. materialIndex: number;
  102316. /**
  102317. * Creates a new sorted particle
  102318. * @param materialIndex
  102319. */
  102320. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  102321. }
  102322. }
  102323. declare module BABYLON {
  102324. /**
  102325. * @hidden
  102326. */
  102327. export class _MeshCollisionData {
  102328. _checkCollisions: boolean;
  102329. _collisionMask: number;
  102330. _collisionGroup: number;
  102331. _surroundingMeshes: Nullable<AbstractMesh[]>;
  102332. _collider: Nullable<Collider>;
  102333. _oldPositionForCollisions: Vector3;
  102334. _diffPositionForCollisions: Vector3;
  102335. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  102336. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  102337. }
  102338. }
  102339. declare module BABYLON {
  102340. /** @hidden */
  102341. class _FacetDataStorage {
  102342. facetPositions: Vector3[];
  102343. facetNormals: Vector3[];
  102344. facetPartitioning: number[][];
  102345. facetNb: number;
  102346. partitioningSubdivisions: number;
  102347. partitioningBBoxRatio: number;
  102348. facetDataEnabled: boolean;
  102349. facetParameters: any;
  102350. bbSize: Vector3;
  102351. subDiv: {
  102352. max: number;
  102353. X: number;
  102354. Y: number;
  102355. Z: number;
  102356. };
  102357. facetDepthSort: boolean;
  102358. facetDepthSortEnabled: boolean;
  102359. depthSortedIndices: IndicesArray;
  102360. depthSortedFacets: {
  102361. ind: number;
  102362. sqDistance: number;
  102363. }[];
  102364. facetDepthSortFunction: (f1: {
  102365. ind: number;
  102366. sqDistance: number;
  102367. }, f2: {
  102368. ind: number;
  102369. sqDistance: number;
  102370. }) => number;
  102371. facetDepthSortFrom: Vector3;
  102372. facetDepthSortOrigin: Vector3;
  102373. invertedMatrix: Matrix;
  102374. }
  102375. /**
  102376. * @hidden
  102377. **/
  102378. class _InternalAbstractMeshDataInfo {
  102379. _hasVertexAlpha: boolean;
  102380. _useVertexColors: boolean;
  102381. _numBoneInfluencers: number;
  102382. _applyFog: boolean;
  102383. _receiveShadows: boolean;
  102384. _facetData: _FacetDataStorage;
  102385. _visibility: number;
  102386. _skeleton: Nullable<Skeleton>;
  102387. _layerMask: number;
  102388. _computeBonesUsingShaders: boolean;
  102389. _isActive: boolean;
  102390. _onlyForInstances: boolean;
  102391. _isActiveIntermediate: boolean;
  102392. _onlyForInstancesIntermediate: boolean;
  102393. _actAsRegularMesh: boolean;
  102394. }
  102395. /**
  102396. * Class used to store all common mesh properties
  102397. */
  102398. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  102399. /** No occlusion */
  102400. static OCCLUSION_TYPE_NONE: number;
  102401. /** Occlusion set to optimisitic */
  102402. static OCCLUSION_TYPE_OPTIMISTIC: number;
  102403. /** Occlusion set to strict */
  102404. static OCCLUSION_TYPE_STRICT: number;
  102405. /** Use an accurante occlusion algorithm */
  102406. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  102407. /** Use a conservative occlusion algorithm */
  102408. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  102409. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  102410. * Test order :
  102411. * Is the bounding sphere outside the frustum ?
  102412. * If not, are the bounding box vertices outside the frustum ?
  102413. * It not, then the cullable object is in the frustum.
  102414. */
  102415. static readonly CULLINGSTRATEGY_STANDARD: number;
  102416. /** Culling strategy : Bounding Sphere Only.
  102417. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  102418. * It's also less accurate than the standard because some not visible objects can still be selected.
  102419. * Test : is the bounding sphere outside the frustum ?
  102420. * If not, then the cullable object is in the frustum.
  102421. */
  102422. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  102423. /** Culling strategy : Optimistic Inclusion.
  102424. * This in an inclusion test first, then the standard exclusion test.
  102425. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  102426. * 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.
  102427. * Anyway, it's as accurate as the standard strategy.
  102428. * Test :
  102429. * Is the cullable object bounding sphere center in the frustum ?
  102430. * If not, apply the default culling strategy.
  102431. */
  102432. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  102433. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  102434. * This in an inclusion test first, then the bounding sphere only exclusion test.
  102435. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  102436. * 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.
  102437. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  102438. * Test :
  102439. * Is the cullable object bounding sphere center in the frustum ?
  102440. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  102441. */
  102442. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  102443. /**
  102444. * No billboard
  102445. */
  102446. static get BILLBOARDMODE_NONE(): number;
  102447. /** Billboard on X axis */
  102448. static get BILLBOARDMODE_X(): number;
  102449. /** Billboard on Y axis */
  102450. static get BILLBOARDMODE_Y(): number;
  102451. /** Billboard on Z axis */
  102452. static get BILLBOARDMODE_Z(): number;
  102453. /** Billboard on all axes */
  102454. static get BILLBOARDMODE_ALL(): number;
  102455. /** Billboard on using position instead of orientation */
  102456. static get BILLBOARDMODE_USE_POSITION(): number;
  102457. /** @hidden */
  102458. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  102459. /**
  102460. * The culling strategy to use to check whether the mesh must be rendered or not.
  102461. * This value can be changed at any time and will be used on the next render mesh selection.
  102462. * The possible values are :
  102463. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  102464. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  102465. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  102466. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  102467. * Please read each static variable documentation to get details about the culling process.
  102468. * */
  102469. cullingStrategy: number;
  102470. /**
  102471. * Gets the number of facets in the mesh
  102472. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102473. */
  102474. get facetNb(): number;
  102475. /**
  102476. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  102477. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102478. */
  102479. get partitioningSubdivisions(): number;
  102480. set partitioningSubdivisions(nb: number);
  102481. /**
  102482. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  102483. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  102484. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  102485. */
  102486. get partitioningBBoxRatio(): number;
  102487. set partitioningBBoxRatio(ratio: number);
  102488. /**
  102489. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  102490. * Works only for updatable meshes.
  102491. * Doesn't work with multi-materials
  102492. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102493. */
  102494. get mustDepthSortFacets(): boolean;
  102495. set mustDepthSortFacets(sort: boolean);
  102496. /**
  102497. * The location (Vector3) where the facet depth sort must be computed from.
  102498. * By default, the active camera position.
  102499. * Used only when facet depth sort is enabled
  102500. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  102501. */
  102502. get facetDepthSortFrom(): Vector3;
  102503. set facetDepthSortFrom(location: Vector3);
  102504. /**
  102505. * gets a boolean indicating if facetData is enabled
  102506. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  102507. */
  102508. get isFacetDataEnabled(): boolean;
  102509. /** @hidden */
  102510. _updateNonUniformScalingState(value: boolean): boolean;
  102511. /**
  102512. * An event triggered when this mesh collides with another one
  102513. */
  102514. onCollideObservable: Observable<AbstractMesh>;
  102515. /** Set a function to call when this mesh collides with another one */
  102516. set onCollide(callback: () => void);
  102517. /**
  102518. * An event triggered when the collision's position changes
  102519. */
  102520. onCollisionPositionChangeObservable: Observable<Vector3>;
  102521. /** Set a function to call when the collision's position changes */
  102522. set onCollisionPositionChange(callback: () => void);
  102523. /**
  102524. * An event triggered when material is changed
  102525. */
  102526. onMaterialChangedObservable: Observable<AbstractMesh>;
  102527. /**
  102528. * Gets or sets the orientation for POV movement & rotation
  102529. */
  102530. definedFacingForward: boolean;
  102531. /** @hidden */
  102532. _occlusionQuery: Nullable<WebGLQuery>;
  102533. /** @hidden */
  102534. _renderingGroup: Nullable<RenderingGroup>;
  102535. /**
  102536. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102537. */
  102538. get visibility(): number;
  102539. /**
  102540. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  102541. */
  102542. set visibility(value: number);
  102543. /** Gets or sets the alpha index used to sort transparent meshes
  102544. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  102545. */
  102546. alphaIndex: number;
  102547. /**
  102548. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  102549. */
  102550. isVisible: boolean;
  102551. /**
  102552. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  102553. */
  102554. isPickable: boolean;
  102555. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  102556. showSubMeshesBoundingBox: boolean;
  102557. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  102558. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  102559. */
  102560. isBlocker: boolean;
  102561. /**
  102562. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  102563. */
  102564. enablePointerMoveEvents: boolean;
  102565. /**
  102566. * Specifies the rendering group id for this mesh (0 by default)
  102567. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  102568. */
  102569. renderingGroupId: number;
  102570. private _material;
  102571. /** Gets or sets current material */
  102572. get material(): Nullable<Material>;
  102573. set material(value: Nullable<Material>);
  102574. /**
  102575. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  102576. * @see http://doc.babylonjs.com/babylon101/shadows
  102577. */
  102578. get receiveShadows(): boolean;
  102579. set receiveShadows(value: boolean);
  102580. /** Defines color to use when rendering outline */
  102581. outlineColor: Color3;
  102582. /** Define width to use when rendering outline */
  102583. outlineWidth: number;
  102584. /** Defines color to use when rendering overlay */
  102585. overlayColor: Color3;
  102586. /** Defines alpha to use when rendering overlay */
  102587. overlayAlpha: number;
  102588. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  102589. get hasVertexAlpha(): boolean;
  102590. set hasVertexAlpha(value: boolean);
  102591. /** 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) */
  102592. get useVertexColors(): boolean;
  102593. set useVertexColors(value: boolean);
  102594. /**
  102595. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  102596. */
  102597. get computeBonesUsingShaders(): boolean;
  102598. set computeBonesUsingShaders(value: boolean);
  102599. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  102600. get numBoneInfluencers(): number;
  102601. set numBoneInfluencers(value: number);
  102602. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  102603. get applyFog(): boolean;
  102604. set applyFog(value: boolean);
  102605. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  102606. useOctreeForRenderingSelection: boolean;
  102607. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  102608. useOctreeForPicking: boolean;
  102609. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  102610. useOctreeForCollisions: boolean;
  102611. /**
  102612. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  102613. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  102614. */
  102615. get layerMask(): number;
  102616. set layerMask(value: number);
  102617. /**
  102618. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  102619. */
  102620. alwaysSelectAsActiveMesh: boolean;
  102621. /**
  102622. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  102623. */
  102624. doNotSyncBoundingInfo: boolean;
  102625. /**
  102626. * Gets or sets the current action manager
  102627. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  102628. */
  102629. actionManager: Nullable<AbstractActionManager>;
  102630. private _meshCollisionData;
  102631. /**
  102632. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  102633. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102634. */
  102635. ellipsoid: Vector3;
  102636. /**
  102637. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  102638. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102639. */
  102640. ellipsoidOffset: Vector3;
  102641. /**
  102642. * Gets or sets a collision mask used to mask collisions (default is -1).
  102643. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102644. */
  102645. get collisionMask(): number;
  102646. set collisionMask(mask: number);
  102647. /**
  102648. * Gets or sets the current collision group mask (-1 by default).
  102649. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  102650. */
  102651. get collisionGroup(): number;
  102652. set collisionGroup(mask: number);
  102653. /**
  102654. * Gets or sets current surrounding meshes (null by default).
  102655. *
  102656. * By default collision detection is tested against every mesh in the scene.
  102657. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  102658. * meshes will be tested for the collision.
  102659. *
  102660. * Note: if set to an empty array no collision will happen when this mesh is moved.
  102661. */
  102662. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  102663. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  102664. /**
  102665. * Defines edge width used when edgesRenderer is enabled
  102666. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102667. */
  102668. edgesWidth: number;
  102669. /**
  102670. * Defines edge color used when edgesRenderer is enabled
  102671. * @see https://www.babylonjs-playground.com/#10OJSG#13
  102672. */
  102673. edgesColor: Color4;
  102674. /** @hidden */
  102675. _edgesRenderer: Nullable<IEdgesRenderer>;
  102676. /** @hidden */
  102677. _masterMesh: Nullable<AbstractMesh>;
  102678. /** @hidden */
  102679. _boundingInfo: Nullable<BoundingInfo>;
  102680. /** @hidden */
  102681. _renderId: number;
  102682. /**
  102683. * Gets or sets the list of subMeshes
  102684. * @see http://doc.babylonjs.com/how_to/multi_materials
  102685. */
  102686. subMeshes: SubMesh[];
  102687. /** @hidden */
  102688. _intersectionsInProgress: AbstractMesh[];
  102689. /** @hidden */
  102690. _unIndexed: boolean;
  102691. /** @hidden */
  102692. _lightSources: Light[];
  102693. /** Gets the list of lights affecting that mesh */
  102694. get lightSources(): Light[];
  102695. /** @hidden */
  102696. get _positions(): Nullable<Vector3[]>;
  102697. /** @hidden */
  102698. _waitingData: {
  102699. lods: Nullable<any>;
  102700. actions: Nullable<any>;
  102701. freezeWorldMatrix: Nullable<boolean>;
  102702. };
  102703. /** @hidden */
  102704. _bonesTransformMatrices: Nullable<Float32Array>;
  102705. /** @hidden */
  102706. _transformMatrixTexture: Nullable<RawTexture>;
  102707. /**
  102708. * Gets or sets a skeleton to apply skining transformations
  102709. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  102710. */
  102711. set skeleton(value: Nullable<Skeleton>);
  102712. get skeleton(): Nullable<Skeleton>;
  102713. /**
  102714. * An event triggered when the mesh is rebuilt.
  102715. */
  102716. onRebuildObservable: Observable<AbstractMesh>;
  102717. /**
  102718. * Creates a new AbstractMesh
  102719. * @param name defines the name of the mesh
  102720. * @param scene defines the hosting scene
  102721. */
  102722. constructor(name: string, scene?: Nullable<Scene>);
  102723. /**
  102724. * Returns the string "AbstractMesh"
  102725. * @returns "AbstractMesh"
  102726. */
  102727. getClassName(): string;
  102728. /**
  102729. * Gets a string representation of the current mesh
  102730. * @param fullDetails defines a boolean indicating if full details must be included
  102731. * @returns a string representation of the current mesh
  102732. */
  102733. toString(fullDetails?: boolean): string;
  102734. /**
  102735. * @hidden
  102736. */
  102737. protected _getEffectiveParent(): Nullable<Node>;
  102738. /** @hidden */
  102739. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  102740. /** @hidden */
  102741. _rebuild(): void;
  102742. /** @hidden */
  102743. _resyncLightSources(): void;
  102744. /** @hidden */
  102745. _resyncLightSource(light: Light): void;
  102746. /** @hidden */
  102747. _unBindEffect(): void;
  102748. /** @hidden */
  102749. _removeLightSource(light: Light, dispose: boolean): void;
  102750. private _markSubMeshesAsDirty;
  102751. /** @hidden */
  102752. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  102753. /** @hidden */
  102754. _markSubMeshesAsAttributesDirty(): void;
  102755. /** @hidden */
  102756. _markSubMeshesAsMiscDirty(): void;
  102757. /**
  102758. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  102759. */
  102760. get scaling(): Vector3;
  102761. set scaling(newScaling: Vector3);
  102762. /**
  102763. * Returns true if the mesh is blocked. Implemented by child classes
  102764. */
  102765. get isBlocked(): boolean;
  102766. /**
  102767. * Returns the mesh itself by default. Implemented by child classes
  102768. * @param camera defines the camera to use to pick the right LOD level
  102769. * @returns the currentAbstractMesh
  102770. */
  102771. getLOD(camera: Camera): Nullable<AbstractMesh>;
  102772. /**
  102773. * Returns 0 by default. Implemented by child classes
  102774. * @returns an integer
  102775. */
  102776. getTotalVertices(): number;
  102777. /**
  102778. * Returns a positive integer : the total number of indices in this mesh geometry.
  102779. * @returns the numner of indices or zero if the mesh has no geometry.
  102780. */
  102781. getTotalIndices(): number;
  102782. /**
  102783. * Returns null by default. Implemented by child classes
  102784. * @returns null
  102785. */
  102786. getIndices(): Nullable<IndicesArray>;
  102787. /**
  102788. * Returns the array of the requested vertex data kind. Implemented by child classes
  102789. * @param kind defines the vertex data kind to use
  102790. * @returns null
  102791. */
  102792. getVerticesData(kind: string): Nullable<FloatArray>;
  102793. /**
  102794. * Sets the vertex data of the mesh geometry for the requested `kind`.
  102795. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  102796. * Note that a new underlying VertexBuffer object is created each call.
  102797. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  102798. * @param kind defines vertex data kind:
  102799. * * VertexBuffer.PositionKind
  102800. * * VertexBuffer.UVKind
  102801. * * VertexBuffer.UV2Kind
  102802. * * VertexBuffer.UV3Kind
  102803. * * VertexBuffer.UV4Kind
  102804. * * VertexBuffer.UV5Kind
  102805. * * VertexBuffer.UV6Kind
  102806. * * VertexBuffer.ColorKind
  102807. * * VertexBuffer.MatricesIndicesKind
  102808. * * VertexBuffer.MatricesIndicesExtraKind
  102809. * * VertexBuffer.MatricesWeightsKind
  102810. * * VertexBuffer.MatricesWeightsExtraKind
  102811. * @param data defines the data source
  102812. * @param updatable defines if the data must be flagged as updatable (or static)
  102813. * @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
  102814. * @returns the current mesh
  102815. */
  102816. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  102817. /**
  102818. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  102819. * If the mesh has no geometry, it is simply returned as it is.
  102820. * @param kind defines vertex data kind:
  102821. * * VertexBuffer.PositionKind
  102822. * * VertexBuffer.UVKind
  102823. * * VertexBuffer.UV2Kind
  102824. * * VertexBuffer.UV3Kind
  102825. * * VertexBuffer.UV4Kind
  102826. * * VertexBuffer.UV5Kind
  102827. * * VertexBuffer.UV6Kind
  102828. * * VertexBuffer.ColorKind
  102829. * * VertexBuffer.MatricesIndicesKind
  102830. * * VertexBuffer.MatricesIndicesExtraKind
  102831. * * VertexBuffer.MatricesWeightsKind
  102832. * * VertexBuffer.MatricesWeightsExtraKind
  102833. * @param data defines the data source
  102834. * @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
  102835. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  102836. * @returns the current mesh
  102837. */
  102838. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  102839. /**
  102840. * Sets the mesh indices,
  102841. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  102842. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  102843. * @param totalVertices Defines the total number of vertices
  102844. * @returns the current mesh
  102845. */
  102846. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  102847. /**
  102848. * Gets a boolean indicating if specific vertex data is present
  102849. * @param kind defines the vertex data kind to use
  102850. * @returns true is data kind is present
  102851. */
  102852. isVerticesDataPresent(kind: string): boolean;
  102853. /**
  102854. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  102855. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  102856. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  102857. * @returns a BoundingInfo
  102858. */
  102859. getBoundingInfo(): BoundingInfo;
  102860. /**
  102861. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  102862. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  102863. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  102864. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  102865. * @returns the current mesh
  102866. */
  102867. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  102868. /**
  102869. * Overwrite the current bounding info
  102870. * @param boundingInfo defines the new bounding info
  102871. * @returns the current mesh
  102872. */
  102873. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  102874. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  102875. get useBones(): boolean;
  102876. /** @hidden */
  102877. _preActivate(): void;
  102878. /** @hidden */
  102879. _preActivateForIntermediateRendering(renderId: number): void;
  102880. /** @hidden */
  102881. _activate(renderId: number, intermediateRendering: boolean): boolean;
  102882. /** @hidden */
  102883. _postActivate(): void;
  102884. /** @hidden */
  102885. _freeze(): void;
  102886. /** @hidden */
  102887. _unFreeze(): void;
  102888. /**
  102889. * Gets the current world matrix
  102890. * @returns a Matrix
  102891. */
  102892. getWorldMatrix(): Matrix;
  102893. /** @hidden */
  102894. _getWorldMatrixDeterminant(): number;
  102895. /**
  102896. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  102897. */
  102898. get isAnInstance(): boolean;
  102899. /**
  102900. * Gets a boolean indicating if this mesh has instances
  102901. */
  102902. get hasInstances(): boolean;
  102903. /**
  102904. * Perform relative position change from the point of view of behind the front of the mesh.
  102905. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102906. * Supports definition of mesh facing forward or backward
  102907. * @param amountRight defines the distance on the right axis
  102908. * @param amountUp defines the distance on the up axis
  102909. * @param amountForward defines the distance on the forward axis
  102910. * @returns the current mesh
  102911. */
  102912. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  102913. /**
  102914. * Calculate relative position change from the point of view of behind the front of the mesh.
  102915. * This is performed taking into account the meshes current rotation, so you do not have to care.
  102916. * Supports definition of mesh facing forward or backward
  102917. * @param amountRight defines the distance on the right axis
  102918. * @param amountUp defines the distance on the up axis
  102919. * @param amountForward defines the distance on the forward axis
  102920. * @returns the new displacement vector
  102921. */
  102922. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  102923. /**
  102924. * Perform relative rotation change from the point of view of behind the front of the mesh.
  102925. * Supports definition of mesh facing forward or backward
  102926. * @param flipBack defines the flip
  102927. * @param twirlClockwise defines the twirl
  102928. * @param tiltRight defines the tilt
  102929. * @returns the current mesh
  102930. */
  102931. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  102932. /**
  102933. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  102934. * Supports definition of mesh facing forward or backward.
  102935. * @param flipBack defines the flip
  102936. * @param twirlClockwise defines the twirl
  102937. * @param tiltRight defines the tilt
  102938. * @returns the new rotation vector
  102939. */
  102940. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  102941. /**
  102942. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  102943. * This means the mesh underlying bounding box and sphere are recomputed.
  102944. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  102945. * @returns the current mesh
  102946. */
  102947. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  102948. /** @hidden */
  102949. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  102950. /** @hidden */
  102951. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  102952. /** @hidden */
  102953. _updateBoundingInfo(): AbstractMesh;
  102954. /** @hidden */
  102955. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  102956. /** @hidden */
  102957. protected _afterComputeWorldMatrix(): void;
  102958. /** @hidden */
  102959. get _effectiveMesh(): AbstractMesh;
  102960. /**
  102961. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  102962. * A mesh is in the frustum if its bounding box intersects the frustum
  102963. * @param frustumPlanes defines the frustum to test
  102964. * @returns true if the mesh is in the frustum planes
  102965. */
  102966. isInFrustum(frustumPlanes: Plane[]): boolean;
  102967. /**
  102968. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  102969. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  102970. * @param frustumPlanes defines the frustum to test
  102971. * @returns true if the mesh is completely in the frustum planes
  102972. */
  102973. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  102974. /**
  102975. * True if the mesh intersects another mesh or a SolidParticle object
  102976. * @param mesh defines a target mesh or SolidParticle to test
  102977. * @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)
  102978. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  102979. * @returns true if there is an intersection
  102980. */
  102981. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  102982. /**
  102983. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  102984. * @param point defines the point to test
  102985. * @returns true if there is an intersection
  102986. */
  102987. intersectsPoint(point: Vector3): boolean;
  102988. /**
  102989. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  102990. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102991. */
  102992. get checkCollisions(): boolean;
  102993. set checkCollisions(collisionEnabled: boolean);
  102994. /**
  102995. * Gets Collider object used to compute collisions (not physics)
  102996. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  102997. */
  102998. get collider(): Nullable<Collider>;
  102999. /**
  103000. * Move the mesh using collision engine
  103001. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  103002. * @param displacement defines the requested displacement vector
  103003. * @returns the current mesh
  103004. */
  103005. moveWithCollisions(displacement: Vector3): AbstractMesh;
  103006. private _onCollisionPositionChange;
  103007. /** @hidden */
  103008. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  103009. /** @hidden */
  103010. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  103011. /** @hidden */
  103012. _checkCollision(collider: Collider): AbstractMesh;
  103013. /** @hidden */
  103014. _generatePointsArray(): boolean;
  103015. /**
  103016. * Checks if the passed Ray intersects with the mesh
  103017. * @param ray defines the ray to use
  103018. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  103019. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  103020. * @returns the picking info
  103021. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  103022. */
  103023. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  103024. /**
  103025. * Clones the current mesh
  103026. * @param name defines the mesh name
  103027. * @param newParent defines the new mesh parent
  103028. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  103029. * @returns the new mesh
  103030. */
  103031. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  103032. /**
  103033. * Disposes all the submeshes of the current meshnp
  103034. * @returns the current mesh
  103035. */
  103036. releaseSubMeshes(): AbstractMesh;
  103037. /**
  103038. * Releases resources associated with this abstract mesh.
  103039. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103040. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103041. */
  103042. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103043. /**
  103044. * Adds the passed mesh as a child to the current mesh
  103045. * @param mesh defines the child mesh
  103046. * @returns the current mesh
  103047. */
  103048. addChild(mesh: AbstractMesh): AbstractMesh;
  103049. /**
  103050. * Removes the passed mesh from the current mesh children list
  103051. * @param mesh defines the child mesh
  103052. * @returns the current mesh
  103053. */
  103054. removeChild(mesh: AbstractMesh): AbstractMesh;
  103055. /** @hidden */
  103056. private _initFacetData;
  103057. /**
  103058. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  103059. * This method can be called within the render loop.
  103060. * 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
  103061. * @returns the current mesh
  103062. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103063. */
  103064. updateFacetData(): AbstractMesh;
  103065. /**
  103066. * Returns the facetLocalNormals array.
  103067. * The normals are expressed in the mesh local spac
  103068. * @returns an array of Vector3
  103069. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103070. */
  103071. getFacetLocalNormals(): Vector3[];
  103072. /**
  103073. * Returns the facetLocalPositions array.
  103074. * The facet positions are expressed in the mesh local space
  103075. * @returns an array of Vector3
  103076. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103077. */
  103078. getFacetLocalPositions(): Vector3[];
  103079. /**
  103080. * Returns the facetLocalPartioning array
  103081. * @returns an array of array of numbers
  103082. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103083. */
  103084. getFacetLocalPartitioning(): number[][];
  103085. /**
  103086. * Returns the i-th facet position in the world system.
  103087. * This method allocates a new Vector3 per call
  103088. * @param i defines the facet index
  103089. * @returns a new Vector3
  103090. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103091. */
  103092. getFacetPosition(i: number): Vector3;
  103093. /**
  103094. * Sets the reference Vector3 with the i-th facet position in the world system
  103095. * @param i defines the facet index
  103096. * @param ref defines the target vector
  103097. * @returns the current mesh
  103098. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103099. */
  103100. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  103101. /**
  103102. * Returns the i-th facet normal in the world system.
  103103. * This method allocates a new Vector3 per call
  103104. * @param i defines the facet index
  103105. * @returns a new Vector3
  103106. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103107. */
  103108. getFacetNormal(i: number): Vector3;
  103109. /**
  103110. * Sets the reference Vector3 with the i-th facet normal in the world system
  103111. * @param i defines the facet index
  103112. * @param ref defines the target vector
  103113. * @returns the current mesh
  103114. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103115. */
  103116. getFacetNormalToRef(i: number, ref: Vector3): this;
  103117. /**
  103118. * 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)
  103119. * @param x defines x coordinate
  103120. * @param y defines y coordinate
  103121. * @param z defines z coordinate
  103122. * @returns the array of facet indexes
  103123. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103124. */
  103125. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  103126. /**
  103127. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  103128. * @param projected sets as the (x,y,z) world projection on the facet
  103129. * @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
  103130. * @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
  103131. * @param x defines x coordinate
  103132. * @param y defines y coordinate
  103133. * @param z defines z coordinate
  103134. * @returns the face index if found (or null instead)
  103135. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103136. */
  103137. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103138. /**
  103139. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  103140. * @param projected sets as the (x,y,z) local projection on the facet
  103141. * @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
  103142. * @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
  103143. * @param x defines x coordinate
  103144. * @param y defines y coordinate
  103145. * @param z defines z coordinate
  103146. * @returns the face index if found (or null instead)
  103147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103148. */
  103149. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  103150. /**
  103151. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  103152. * @returns the parameters
  103153. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103154. */
  103155. getFacetDataParameters(): any;
  103156. /**
  103157. * Disables the feature FacetData and frees the related memory
  103158. * @returns the current mesh
  103159. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  103160. */
  103161. disableFacetData(): AbstractMesh;
  103162. /**
  103163. * Updates the AbstractMesh indices array
  103164. * @param indices defines the data source
  103165. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  103166. * @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)
  103167. * @returns the current mesh
  103168. */
  103169. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  103170. /**
  103171. * Creates new normals data for the mesh
  103172. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  103173. * @returns the current mesh
  103174. */
  103175. createNormals(updatable: boolean): AbstractMesh;
  103176. /**
  103177. * Align the mesh with a normal
  103178. * @param normal defines the normal to use
  103179. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  103180. * @returns the current mesh
  103181. */
  103182. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  103183. /** @hidden */
  103184. _checkOcclusionQuery(): boolean;
  103185. /**
  103186. * Disables the mesh edge rendering mode
  103187. * @returns the currentAbstractMesh
  103188. */
  103189. disableEdgesRendering(): AbstractMesh;
  103190. /**
  103191. * Enables the edge rendering mode on the mesh.
  103192. * This mode makes the mesh edges visible
  103193. * @param epsilon defines the maximal distance between two angles to detect a face
  103194. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  103195. * @returns the currentAbstractMesh
  103196. * @see https://www.babylonjs-playground.com/#19O9TU#0
  103197. */
  103198. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  103199. }
  103200. }
  103201. declare module BABYLON {
  103202. /**
  103203. * Interface used to define ActionEvent
  103204. */
  103205. export interface IActionEvent {
  103206. /** The mesh or sprite that triggered the action */
  103207. source: any;
  103208. /** The X mouse cursor position at the time of the event */
  103209. pointerX: number;
  103210. /** The Y mouse cursor position at the time of the event */
  103211. pointerY: number;
  103212. /** The mesh that is currently pointed at (can be null) */
  103213. meshUnderPointer: Nullable<AbstractMesh>;
  103214. /** the original (browser) event that triggered the ActionEvent */
  103215. sourceEvent?: any;
  103216. /** additional data for the event */
  103217. additionalData?: any;
  103218. }
  103219. /**
  103220. * ActionEvent is the event being sent when an action is triggered.
  103221. */
  103222. export class ActionEvent implements IActionEvent {
  103223. /** The mesh or sprite that triggered the action */
  103224. source: any;
  103225. /** The X mouse cursor position at the time of the event */
  103226. pointerX: number;
  103227. /** The Y mouse cursor position at the time of the event */
  103228. pointerY: number;
  103229. /** The mesh that is currently pointed at (can be null) */
  103230. meshUnderPointer: Nullable<AbstractMesh>;
  103231. /** the original (browser) event that triggered the ActionEvent */
  103232. sourceEvent?: any;
  103233. /** additional data for the event */
  103234. additionalData?: any;
  103235. /**
  103236. * Creates a new ActionEvent
  103237. * @param source The mesh or sprite that triggered the action
  103238. * @param pointerX The X mouse cursor position at the time of the event
  103239. * @param pointerY The Y mouse cursor position at the time of the event
  103240. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  103241. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  103242. * @param additionalData additional data for the event
  103243. */
  103244. constructor(
  103245. /** The mesh or sprite that triggered the action */
  103246. source: any,
  103247. /** The X mouse cursor position at the time of the event */
  103248. pointerX: number,
  103249. /** The Y mouse cursor position at the time of the event */
  103250. pointerY: number,
  103251. /** The mesh that is currently pointed at (can be null) */
  103252. meshUnderPointer: Nullable<AbstractMesh>,
  103253. /** the original (browser) event that triggered the ActionEvent */
  103254. sourceEvent?: any,
  103255. /** additional data for the event */
  103256. additionalData?: any);
  103257. /**
  103258. * Helper function to auto-create an ActionEvent from a source mesh.
  103259. * @param source The source mesh that triggered the event
  103260. * @param evt The original (browser) event
  103261. * @param additionalData additional data for the event
  103262. * @returns the new ActionEvent
  103263. */
  103264. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  103265. /**
  103266. * Helper function to auto-create an ActionEvent from a source sprite
  103267. * @param source The source sprite that triggered the event
  103268. * @param scene Scene associated with the sprite
  103269. * @param evt The original (browser) event
  103270. * @param additionalData additional data for the event
  103271. * @returns the new ActionEvent
  103272. */
  103273. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  103274. /**
  103275. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  103276. * @param scene the scene where the event occurred
  103277. * @param evt The original (browser) event
  103278. * @returns the new ActionEvent
  103279. */
  103280. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  103281. /**
  103282. * Helper function to auto-create an ActionEvent from a primitive
  103283. * @param prim defines the target primitive
  103284. * @param pointerPos defines the pointer position
  103285. * @param evt The original (browser) event
  103286. * @param additionalData additional data for the event
  103287. * @returns the new ActionEvent
  103288. */
  103289. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  103290. }
  103291. }
  103292. declare module BABYLON {
  103293. /**
  103294. * Abstract class used to decouple action Manager from scene and meshes.
  103295. * Do not instantiate.
  103296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  103297. */
  103298. export abstract class AbstractActionManager implements IDisposable {
  103299. /** Gets the list of active triggers */
  103300. static Triggers: {
  103301. [key: string]: number;
  103302. };
  103303. /** Gets the cursor to use when hovering items */
  103304. hoverCursor: string;
  103305. /** Gets the list of actions */
  103306. actions: IAction[];
  103307. /**
  103308. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  103309. */
  103310. isRecursive: boolean;
  103311. /**
  103312. * Releases all associated resources
  103313. */
  103314. abstract dispose(): void;
  103315. /**
  103316. * Does this action manager has pointer triggers
  103317. */
  103318. abstract get hasPointerTriggers(): boolean;
  103319. /**
  103320. * Does this action manager has pick triggers
  103321. */
  103322. abstract get hasPickTriggers(): boolean;
  103323. /**
  103324. * Process a specific trigger
  103325. * @param trigger defines the trigger to process
  103326. * @param evt defines the event details to be processed
  103327. */
  103328. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  103329. /**
  103330. * Does this action manager handles actions of any of the given triggers
  103331. * @param triggers defines the triggers to be tested
  103332. * @return a boolean indicating whether one (or more) of the triggers is handled
  103333. */
  103334. abstract hasSpecificTriggers(triggers: number[]): boolean;
  103335. /**
  103336. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  103337. * speed.
  103338. * @param triggerA defines the trigger to be tested
  103339. * @param triggerB defines the trigger to be tested
  103340. * @return a boolean indicating whether one (or more) of the triggers is handled
  103341. */
  103342. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  103343. /**
  103344. * Does this action manager handles actions of a given trigger
  103345. * @param trigger defines the trigger to be tested
  103346. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  103347. * @return whether the trigger is handled
  103348. */
  103349. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  103350. /**
  103351. * Serialize this manager to a JSON object
  103352. * @param name defines the property name to store this manager
  103353. * @returns a JSON representation of this manager
  103354. */
  103355. abstract serialize(name: string): any;
  103356. /**
  103357. * Registers an action to this action manager
  103358. * @param action defines the action to be registered
  103359. * @return the action amended (prepared) after registration
  103360. */
  103361. abstract registerAction(action: IAction): Nullable<IAction>;
  103362. /**
  103363. * Unregisters an action to this action manager
  103364. * @param action defines the action to be unregistered
  103365. * @return a boolean indicating whether the action has been unregistered
  103366. */
  103367. abstract unregisterAction(action: IAction): Boolean;
  103368. /**
  103369. * Does exist one action manager with at least one trigger
  103370. **/
  103371. static get HasTriggers(): boolean;
  103372. /**
  103373. * Does exist one action manager with at least one pick trigger
  103374. **/
  103375. static get HasPickTriggers(): boolean;
  103376. /**
  103377. * Does exist one action manager that handles actions of a given trigger
  103378. * @param trigger defines the trigger to be tested
  103379. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  103380. **/
  103381. static HasSpecificTrigger(trigger: number): boolean;
  103382. }
  103383. }
  103384. declare module BABYLON {
  103385. /**
  103386. * Defines how a node can be built from a string name.
  103387. */
  103388. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  103389. /**
  103390. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  103391. */
  103392. export class Node implements IBehaviorAware<Node> {
  103393. /** @hidden */
  103394. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  103395. private static _NodeConstructors;
  103396. /**
  103397. * Add a new node constructor
  103398. * @param type defines the type name of the node to construct
  103399. * @param constructorFunc defines the constructor function
  103400. */
  103401. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  103402. /**
  103403. * Returns a node constructor based on type name
  103404. * @param type defines the type name
  103405. * @param name defines the new node name
  103406. * @param scene defines the hosting scene
  103407. * @param options defines optional options to transmit to constructors
  103408. * @returns the new constructor or null
  103409. */
  103410. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  103411. /**
  103412. * Gets or sets the name of the node
  103413. */
  103414. name: string;
  103415. /**
  103416. * Gets or sets the id of the node
  103417. */
  103418. id: string;
  103419. /**
  103420. * Gets or sets the unique id of the node
  103421. */
  103422. uniqueId: number;
  103423. /**
  103424. * Gets or sets a string used to store user defined state for the node
  103425. */
  103426. state: string;
  103427. /**
  103428. * Gets or sets an object used to store user defined information for the node
  103429. */
  103430. metadata: any;
  103431. /**
  103432. * For internal use only. Please do not use.
  103433. */
  103434. reservedDataStore: any;
  103435. /**
  103436. * List of inspectable custom properties (used by the Inspector)
  103437. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103438. */
  103439. inspectableCustomProperties: IInspectable[];
  103440. private _doNotSerialize;
  103441. /**
  103442. * Gets or sets a boolean used to define if the node must be serialized
  103443. */
  103444. get doNotSerialize(): boolean;
  103445. set doNotSerialize(value: boolean);
  103446. /** @hidden */
  103447. _isDisposed: boolean;
  103448. /**
  103449. * Gets a list of Animations associated with the node
  103450. */
  103451. animations: Animation[];
  103452. protected _ranges: {
  103453. [name: string]: Nullable<AnimationRange>;
  103454. };
  103455. /**
  103456. * Callback raised when the node is ready to be used
  103457. */
  103458. onReady: Nullable<(node: Node) => void>;
  103459. private _isEnabled;
  103460. private _isParentEnabled;
  103461. private _isReady;
  103462. /** @hidden */
  103463. _currentRenderId: number;
  103464. private _parentUpdateId;
  103465. /** @hidden */
  103466. _childUpdateId: number;
  103467. /** @hidden */
  103468. _waitingParentId: Nullable<string>;
  103469. /** @hidden */
  103470. _scene: Scene;
  103471. /** @hidden */
  103472. _cache: any;
  103473. private _parentNode;
  103474. private _children;
  103475. /** @hidden */
  103476. _worldMatrix: Matrix;
  103477. /** @hidden */
  103478. _worldMatrixDeterminant: number;
  103479. /** @hidden */
  103480. _worldMatrixDeterminantIsDirty: boolean;
  103481. /** @hidden */
  103482. private _sceneRootNodesIndex;
  103483. /**
  103484. * Gets a boolean indicating if the node has been disposed
  103485. * @returns true if the node was disposed
  103486. */
  103487. isDisposed(): boolean;
  103488. /**
  103489. * Gets or sets the parent of the node (without keeping the current position in the scene)
  103490. * @see https://doc.babylonjs.com/how_to/parenting
  103491. */
  103492. set parent(parent: Nullable<Node>);
  103493. get parent(): Nullable<Node>;
  103494. /** @hidden */
  103495. _addToSceneRootNodes(): void;
  103496. /** @hidden */
  103497. _removeFromSceneRootNodes(): void;
  103498. private _animationPropertiesOverride;
  103499. /**
  103500. * Gets or sets the animation properties override
  103501. */
  103502. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  103503. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  103504. /**
  103505. * Gets a string idenfifying the name of the class
  103506. * @returns "Node" string
  103507. */
  103508. getClassName(): string;
  103509. /** @hidden */
  103510. readonly _isNode: boolean;
  103511. /**
  103512. * An event triggered when the mesh is disposed
  103513. */
  103514. onDisposeObservable: Observable<Node>;
  103515. private _onDisposeObserver;
  103516. /**
  103517. * Sets a callback that will be raised when the node will be disposed
  103518. */
  103519. set onDispose(callback: () => void);
  103520. /**
  103521. * Creates a new Node
  103522. * @param name the name and id to be given to this node
  103523. * @param scene the scene this node will be added to
  103524. */
  103525. constructor(name: string, scene?: Nullable<Scene>);
  103526. /**
  103527. * Gets the scene of the node
  103528. * @returns a scene
  103529. */
  103530. getScene(): Scene;
  103531. /**
  103532. * Gets the engine of the node
  103533. * @returns a Engine
  103534. */
  103535. getEngine(): Engine;
  103536. private _behaviors;
  103537. /**
  103538. * Attach a behavior to the node
  103539. * @see http://doc.babylonjs.com/features/behaviour
  103540. * @param behavior defines the behavior to attach
  103541. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  103542. * @returns the current Node
  103543. */
  103544. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  103545. /**
  103546. * Remove an attached behavior
  103547. * @see http://doc.babylonjs.com/features/behaviour
  103548. * @param behavior defines the behavior to attach
  103549. * @returns the current Node
  103550. */
  103551. removeBehavior(behavior: Behavior<Node>): Node;
  103552. /**
  103553. * Gets the list of attached behaviors
  103554. * @see http://doc.babylonjs.com/features/behaviour
  103555. */
  103556. get behaviors(): Behavior<Node>[];
  103557. /**
  103558. * Gets an attached behavior by name
  103559. * @param name defines the name of the behavior to look for
  103560. * @see http://doc.babylonjs.com/features/behaviour
  103561. * @returns null if behavior was not found else the requested behavior
  103562. */
  103563. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  103564. /**
  103565. * Returns the latest update of the World matrix
  103566. * @returns a Matrix
  103567. */
  103568. getWorldMatrix(): Matrix;
  103569. /** @hidden */
  103570. _getWorldMatrixDeterminant(): number;
  103571. /**
  103572. * Returns directly the latest state of the mesh World matrix.
  103573. * A Matrix is returned.
  103574. */
  103575. get worldMatrixFromCache(): Matrix;
  103576. /** @hidden */
  103577. _initCache(): void;
  103578. /** @hidden */
  103579. updateCache(force?: boolean): void;
  103580. /** @hidden */
  103581. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  103582. /** @hidden */
  103583. _updateCache(ignoreParentClass?: boolean): void;
  103584. /** @hidden */
  103585. _isSynchronized(): boolean;
  103586. /** @hidden */
  103587. _markSyncedWithParent(): void;
  103588. /** @hidden */
  103589. isSynchronizedWithParent(): boolean;
  103590. /** @hidden */
  103591. isSynchronized(): boolean;
  103592. /**
  103593. * Is this node ready to be used/rendered
  103594. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  103595. * @return true if the node is ready
  103596. */
  103597. isReady(completeCheck?: boolean): boolean;
  103598. /**
  103599. * Is this node enabled?
  103600. * 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
  103601. * @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
  103602. * @return whether this node (and its parent) is enabled
  103603. */
  103604. isEnabled(checkAncestors?: boolean): boolean;
  103605. /** @hidden */
  103606. protected _syncParentEnabledState(): void;
  103607. /**
  103608. * Set the enabled state of this node
  103609. * @param value defines the new enabled state
  103610. */
  103611. setEnabled(value: boolean): void;
  103612. /**
  103613. * Is this node a descendant of the given node?
  103614. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  103615. * @param ancestor defines the parent node to inspect
  103616. * @returns a boolean indicating if this node is a descendant of the given node
  103617. */
  103618. isDescendantOf(ancestor: Node): boolean;
  103619. /** @hidden */
  103620. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  103621. /**
  103622. * Will return all nodes that have this node as ascendant
  103623. * @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
  103624. * @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
  103625. * @return all children nodes of all types
  103626. */
  103627. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  103628. /**
  103629. * Get all child-meshes of this node
  103630. * @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)
  103631. * @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
  103632. * @returns an array of AbstractMesh
  103633. */
  103634. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  103635. /**
  103636. * Get all direct children of this node
  103637. * @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
  103638. * @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)
  103639. * @returns an array of Node
  103640. */
  103641. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  103642. /** @hidden */
  103643. _setReady(state: boolean): void;
  103644. /**
  103645. * Get an animation by name
  103646. * @param name defines the name of the animation to look for
  103647. * @returns null if not found else the requested animation
  103648. */
  103649. getAnimationByName(name: string): Nullable<Animation>;
  103650. /**
  103651. * Creates an animation range for this node
  103652. * @param name defines the name of the range
  103653. * @param from defines the starting key
  103654. * @param to defines the end key
  103655. */
  103656. createAnimationRange(name: string, from: number, to: number): void;
  103657. /**
  103658. * Delete a specific animation range
  103659. * @param name defines the name of the range to delete
  103660. * @param deleteFrames defines if animation frames from the range must be deleted as well
  103661. */
  103662. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  103663. /**
  103664. * Get an animation range by name
  103665. * @param name defines the name of the animation range to look for
  103666. * @returns null if not found else the requested animation range
  103667. */
  103668. getAnimationRange(name: string): Nullable<AnimationRange>;
  103669. /**
  103670. * Gets the list of all animation ranges defined on this node
  103671. * @returns an array
  103672. */
  103673. getAnimationRanges(): Nullable<AnimationRange>[];
  103674. /**
  103675. * Will start the animation sequence
  103676. * @param name defines the range frames for animation sequence
  103677. * @param loop defines if the animation should loop (false by default)
  103678. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  103679. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  103680. * @returns the object created for this animation. If range does not exist, it will return null
  103681. */
  103682. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  103683. /**
  103684. * Serialize animation ranges into a JSON compatible object
  103685. * @returns serialization object
  103686. */
  103687. serializeAnimationRanges(): any;
  103688. /**
  103689. * Computes the world matrix of the node
  103690. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  103691. * @returns the world matrix
  103692. */
  103693. computeWorldMatrix(force?: boolean): Matrix;
  103694. /**
  103695. * Releases resources associated with this node.
  103696. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103697. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103698. */
  103699. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103700. /**
  103701. * Parse animation range data from a serialization object and store them into a given node
  103702. * @param node defines where to store the animation ranges
  103703. * @param parsedNode defines the serialization object to read data from
  103704. * @param scene defines the hosting scene
  103705. */
  103706. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  103707. /**
  103708. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  103709. * @param includeDescendants Include bounding info from descendants as well (true by default)
  103710. * @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
  103711. * @returns the new bounding vectors
  103712. */
  103713. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  103714. min: Vector3;
  103715. max: Vector3;
  103716. };
  103717. }
  103718. }
  103719. declare module BABYLON {
  103720. /**
  103721. * @hidden
  103722. */
  103723. export class _IAnimationState {
  103724. key: number;
  103725. repeatCount: number;
  103726. workValue?: any;
  103727. loopMode?: number;
  103728. offsetValue?: any;
  103729. highLimitValue?: any;
  103730. }
  103731. /**
  103732. * Class used to store any kind of animation
  103733. */
  103734. export class Animation {
  103735. /**Name of the animation */
  103736. name: string;
  103737. /**Property to animate */
  103738. targetProperty: string;
  103739. /**The frames per second of the animation */
  103740. framePerSecond: number;
  103741. /**The data type of the animation */
  103742. dataType: number;
  103743. /**The loop mode of the animation */
  103744. loopMode?: number | undefined;
  103745. /**Specifies if blending should be enabled */
  103746. enableBlending?: boolean | undefined;
  103747. /**
  103748. * Use matrix interpolation instead of using direct key value when animating matrices
  103749. */
  103750. static AllowMatricesInterpolation: boolean;
  103751. /**
  103752. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  103753. */
  103754. static AllowMatrixDecomposeForInterpolation: boolean;
  103755. /**
  103756. * Stores the key frames of the animation
  103757. */
  103758. private _keys;
  103759. /**
  103760. * Stores the easing function of the animation
  103761. */
  103762. private _easingFunction;
  103763. /**
  103764. * @hidden Internal use only
  103765. */
  103766. _runtimeAnimations: RuntimeAnimation[];
  103767. /**
  103768. * The set of event that will be linked to this animation
  103769. */
  103770. private _events;
  103771. /**
  103772. * Stores an array of target property paths
  103773. */
  103774. targetPropertyPath: string[];
  103775. /**
  103776. * Stores the blending speed of the animation
  103777. */
  103778. blendingSpeed: number;
  103779. /**
  103780. * Stores the animation ranges for the animation
  103781. */
  103782. private _ranges;
  103783. /**
  103784. * @hidden Internal use
  103785. */
  103786. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  103787. /**
  103788. * Sets up an animation
  103789. * @param property The property to animate
  103790. * @param animationType The animation type to apply
  103791. * @param framePerSecond The frames per second of the animation
  103792. * @param easingFunction The easing function used in the animation
  103793. * @returns The created animation
  103794. */
  103795. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  103796. /**
  103797. * Create and start an animation on a node
  103798. * @param name defines the name of the global animation that will be run on all nodes
  103799. * @param node defines the root node where the animation will take place
  103800. * @param targetProperty defines property to animate
  103801. * @param framePerSecond defines the number of frame per second yo use
  103802. * @param totalFrame defines the number of frames in total
  103803. * @param from defines the initial value
  103804. * @param to defines the final value
  103805. * @param loopMode defines which loop mode you want to use (off by default)
  103806. * @param easingFunction defines the easing function to use (linear by default)
  103807. * @param onAnimationEnd defines the callback to call when animation end
  103808. * @returns the animatable created for this animation
  103809. */
  103810. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103811. /**
  103812. * Create and start an animation on a node and its descendants
  103813. * @param name defines the name of the global animation that will be run on all nodes
  103814. * @param node defines the root node where the animation will take place
  103815. * @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
  103816. * @param targetProperty defines property to animate
  103817. * @param framePerSecond defines the number of frame per second to use
  103818. * @param totalFrame defines the number of frames in total
  103819. * @param from defines the initial value
  103820. * @param to defines the final value
  103821. * @param loopMode defines which loop mode you want to use (off by default)
  103822. * @param easingFunction defines the easing function to use (linear by default)
  103823. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  103824. * @returns the list of animatables created for all nodes
  103825. * @example https://www.babylonjs-playground.com/#MH0VLI
  103826. */
  103827. 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[]>;
  103828. /**
  103829. * Creates a new animation, merges it with the existing animations and starts it
  103830. * @param name Name of the animation
  103831. * @param node Node which contains the scene that begins the animations
  103832. * @param targetProperty Specifies which property to animate
  103833. * @param framePerSecond The frames per second of the animation
  103834. * @param totalFrame The total number of frames
  103835. * @param from The frame at the beginning of the animation
  103836. * @param to The frame at the end of the animation
  103837. * @param loopMode Specifies the loop mode of the animation
  103838. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  103839. * @param onAnimationEnd Callback to run once the animation is complete
  103840. * @returns Nullable animation
  103841. */
  103842. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  103843. /**
  103844. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  103845. * @param sourceAnimation defines the Animation containing keyframes to convert
  103846. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  103847. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  103848. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  103849. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  103850. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  103851. */
  103852. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  103853. /**
  103854. * Transition property of an host to the target Value
  103855. * @param property The property to transition
  103856. * @param targetValue The target Value of the property
  103857. * @param host The object where the property to animate belongs
  103858. * @param scene Scene used to run the animation
  103859. * @param frameRate Framerate (in frame/s) to use
  103860. * @param transition The transition type we want to use
  103861. * @param duration The duration of the animation, in milliseconds
  103862. * @param onAnimationEnd Callback trigger at the end of the animation
  103863. * @returns Nullable animation
  103864. */
  103865. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  103866. /**
  103867. * Return the array of runtime animations currently using this animation
  103868. */
  103869. get runtimeAnimations(): RuntimeAnimation[];
  103870. /**
  103871. * Specifies if any of the runtime animations are currently running
  103872. */
  103873. get hasRunningRuntimeAnimations(): boolean;
  103874. /**
  103875. * Initializes the animation
  103876. * @param name Name of the animation
  103877. * @param targetProperty Property to animate
  103878. * @param framePerSecond The frames per second of the animation
  103879. * @param dataType The data type of the animation
  103880. * @param loopMode The loop mode of the animation
  103881. * @param enableBlending Specifies if blending should be enabled
  103882. */
  103883. constructor(
  103884. /**Name of the animation */
  103885. name: string,
  103886. /**Property to animate */
  103887. targetProperty: string,
  103888. /**The frames per second of the animation */
  103889. framePerSecond: number,
  103890. /**The data type of the animation */
  103891. dataType: number,
  103892. /**The loop mode of the animation */
  103893. loopMode?: number | undefined,
  103894. /**Specifies if blending should be enabled */
  103895. enableBlending?: boolean | undefined);
  103896. /**
  103897. * Converts the animation to a string
  103898. * @param fullDetails support for multiple levels of logging within scene loading
  103899. * @returns String form of the animation
  103900. */
  103901. toString(fullDetails?: boolean): string;
  103902. /**
  103903. * Add an event to this animation
  103904. * @param event Event to add
  103905. */
  103906. addEvent(event: AnimationEvent): void;
  103907. /**
  103908. * Remove all events found at the given frame
  103909. * @param frame The frame to remove events from
  103910. */
  103911. removeEvents(frame: number): void;
  103912. /**
  103913. * Retrieves all the events from the animation
  103914. * @returns Events from the animation
  103915. */
  103916. getEvents(): AnimationEvent[];
  103917. /**
  103918. * Creates an animation range
  103919. * @param name Name of the animation range
  103920. * @param from Starting frame of the animation range
  103921. * @param to Ending frame of the animation
  103922. */
  103923. createRange(name: string, from: number, to: number): void;
  103924. /**
  103925. * Deletes an animation range by name
  103926. * @param name Name of the animation range to delete
  103927. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  103928. */
  103929. deleteRange(name: string, deleteFrames?: boolean): void;
  103930. /**
  103931. * Gets the animation range by name, or null if not defined
  103932. * @param name Name of the animation range
  103933. * @returns Nullable animation range
  103934. */
  103935. getRange(name: string): Nullable<AnimationRange>;
  103936. /**
  103937. * Gets the key frames from the animation
  103938. * @returns The key frames of the animation
  103939. */
  103940. getKeys(): Array<IAnimationKey>;
  103941. /**
  103942. * Gets the highest frame rate of the animation
  103943. * @returns Highest frame rate of the animation
  103944. */
  103945. getHighestFrame(): number;
  103946. /**
  103947. * Gets the easing function of the animation
  103948. * @returns Easing function of the animation
  103949. */
  103950. getEasingFunction(): IEasingFunction;
  103951. /**
  103952. * Sets the easing function of the animation
  103953. * @param easingFunction A custom mathematical formula for animation
  103954. */
  103955. setEasingFunction(easingFunction: EasingFunction): void;
  103956. /**
  103957. * Interpolates a scalar linearly
  103958. * @param startValue Start value of the animation curve
  103959. * @param endValue End value of the animation curve
  103960. * @param gradient Scalar amount to interpolate
  103961. * @returns Interpolated scalar value
  103962. */
  103963. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  103964. /**
  103965. * Interpolates a scalar cubically
  103966. * @param startValue Start value of the animation curve
  103967. * @param outTangent End tangent of the animation
  103968. * @param endValue End value of the animation curve
  103969. * @param inTangent Start tangent of the animation curve
  103970. * @param gradient Scalar amount to interpolate
  103971. * @returns Interpolated scalar value
  103972. */
  103973. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  103974. /**
  103975. * Interpolates a quaternion using a spherical linear interpolation
  103976. * @param startValue Start value of the animation curve
  103977. * @param endValue End value of the animation curve
  103978. * @param gradient Scalar amount to interpolate
  103979. * @returns Interpolated quaternion value
  103980. */
  103981. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  103982. /**
  103983. * Interpolates a quaternion cubically
  103984. * @param startValue Start value of the animation curve
  103985. * @param outTangent End tangent of the animation curve
  103986. * @param endValue End value of the animation curve
  103987. * @param inTangent Start tangent of the animation curve
  103988. * @param gradient Scalar amount to interpolate
  103989. * @returns Interpolated quaternion value
  103990. */
  103991. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  103992. /**
  103993. * Interpolates a Vector3 linearl
  103994. * @param startValue Start value of the animation curve
  103995. * @param endValue End value of the animation curve
  103996. * @param gradient Scalar amount to interpolate
  103997. * @returns Interpolated scalar value
  103998. */
  103999. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  104000. /**
  104001. * Interpolates a Vector3 cubically
  104002. * @param startValue Start value of the animation curve
  104003. * @param outTangent End tangent of the animation
  104004. * @param endValue End value of the animation curve
  104005. * @param inTangent Start tangent of the animation curve
  104006. * @param gradient Scalar amount to interpolate
  104007. * @returns InterpolatedVector3 value
  104008. */
  104009. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  104010. /**
  104011. * Interpolates a Vector2 linearly
  104012. * @param startValue Start value of the animation curve
  104013. * @param endValue End value of the animation curve
  104014. * @param gradient Scalar amount to interpolate
  104015. * @returns Interpolated Vector2 value
  104016. */
  104017. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  104018. /**
  104019. * Interpolates a Vector2 cubically
  104020. * @param startValue Start value of the animation curve
  104021. * @param outTangent End tangent of the animation
  104022. * @param endValue End value of the animation curve
  104023. * @param inTangent Start tangent of the animation curve
  104024. * @param gradient Scalar amount to interpolate
  104025. * @returns Interpolated Vector2 value
  104026. */
  104027. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  104028. /**
  104029. * Interpolates a size linearly
  104030. * @param startValue Start value of the animation curve
  104031. * @param endValue End value of the animation curve
  104032. * @param gradient Scalar amount to interpolate
  104033. * @returns Interpolated Size value
  104034. */
  104035. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  104036. /**
  104037. * Interpolates a Color3 linearly
  104038. * @param startValue Start value of the animation curve
  104039. * @param endValue End value of the animation curve
  104040. * @param gradient Scalar amount to interpolate
  104041. * @returns Interpolated Color3 value
  104042. */
  104043. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  104044. /**
  104045. * Interpolates a Color4 linearly
  104046. * @param startValue Start value of the animation curve
  104047. * @param endValue End value of the animation curve
  104048. * @param gradient Scalar amount to interpolate
  104049. * @returns Interpolated Color3 value
  104050. */
  104051. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  104052. /**
  104053. * @hidden Internal use only
  104054. */
  104055. _getKeyValue(value: any): any;
  104056. /**
  104057. * @hidden Internal use only
  104058. */
  104059. _interpolate(currentFrame: number, state: _IAnimationState): any;
  104060. /**
  104061. * Defines the function to use to interpolate matrices
  104062. * @param startValue defines the start matrix
  104063. * @param endValue defines the end matrix
  104064. * @param gradient defines the gradient between both matrices
  104065. * @param result defines an optional target matrix where to store the interpolation
  104066. * @returns the interpolated matrix
  104067. */
  104068. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  104069. /**
  104070. * Makes a copy of the animation
  104071. * @returns Cloned animation
  104072. */
  104073. clone(): Animation;
  104074. /**
  104075. * Sets the key frames of the animation
  104076. * @param values The animation key frames to set
  104077. */
  104078. setKeys(values: Array<IAnimationKey>): void;
  104079. /**
  104080. * Serializes the animation to an object
  104081. * @returns Serialized object
  104082. */
  104083. serialize(): any;
  104084. /**
  104085. * Float animation type
  104086. */
  104087. static readonly ANIMATIONTYPE_FLOAT: number;
  104088. /**
  104089. * Vector3 animation type
  104090. */
  104091. static readonly ANIMATIONTYPE_VECTOR3: number;
  104092. /**
  104093. * Quaternion animation type
  104094. */
  104095. static readonly ANIMATIONTYPE_QUATERNION: number;
  104096. /**
  104097. * Matrix animation type
  104098. */
  104099. static readonly ANIMATIONTYPE_MATRIX: number;
  104100. /**
  104101. * Color3 animation type
  104102. */
  104103. static readonly ANIMATIONTYPE_COLOR3: number;
  104104. /**
  104105. * Color3 animation type
  104106. */
  104107. static readonly ANIMATIONTYPE_COLOR4: number;
  104108. /**
  104109. * Vector2 animation type
  104110. */
  104111. static readonly ANIMATIONTYPE_VECTOR2: number;
  104112. /**
  104113. * Size animation type
  104114. */
  104115. static readonly ANIMATIONTYPE_SIZE: number;
  104116. /**
  104117. * Relative Loop Mode
  104118. */
  104119. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  104120. /**
  104121. * Cycle Loop Mode
  104122. */
  104123. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  104124. /**
  104125. * Constant Loop Mode
  104126. */
  104127. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  104128. /** @hidden */
  104129. static _UniversalLerp(left: any, right: any, amount: number): any;
  104130. /**
  104131. * Parses an animation object and creates an animation
  104132. * @param parsedAnimation Parsed animation object
  104133. * @returns Animation object
  104134. */
  104135. static Parse(parsedAnimation: any): Animation;
  104136. /**
  104137. * Appends the serialized animations from the source animations
  104138. * @param source Source containing the animations
  104139. * @param destination Target to store the animations
  104140. */
  104141. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104142. }
  104143. }
  104144. declare module BABYLON {
  104145. /**
  104146. * Interface containing an array of animations
  104147. */
  104148. export interface IAnimatable {
  104149. /**
  104150. * Array of animations
  104151. */
  104152. animations: Nullable<Array<Animation>>;
  104153. }
  104154. }
  104155. declare module BABYLON {
  104156. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  104157. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104158. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104159. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104160. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104161. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104162. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104163. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104164. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104165. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104166. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104167. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104168. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104169. /**
  104170. * Decorator used to define property that can be serialized as reference to a camera
  104171. * @param sourceName defines the name of the property to decorate
  104172. */
  104173. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  104174. /**
  104175. * Class used to help serialization objects
  104176. */
  104177. export class SerializationHelper {
  104178. /** @hidden */
  104179. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  104180. /** @hidden */
  104181. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  104182. /** @hidden */
  104183. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  104184. /** @hidden */
  104185. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  104186. /**
  104187. * Appends the serialized animations from the source animations
  104188. * @param source Source containing the animations
  104189. * @param destination Target to store the animations
  104190. */
  104191. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  104192. /**
  104193. * Static function used to serialized a specific entity
  104194. * @param entity defines the entity to serialize
  104195. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  104196. * @returns a JSON compatible object representing the serialization of the entity
  104197. */
  104198. static Serialize<T>(entity: T, serializationObject?: any): any;
  104199. /**
  104200. * Creates a new entity from a serialization data object
  104201. * @param creationFunction defines a function used to instanciated the new entity
  104202. * @param source defines the source serialization data
  104203. * @param scene defines the hosting scene
  104204. * @param rootUrl defines the root url for resources
  104205. * @returns a new entity
  104206. */
  104207. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  104208. /**
  104209. * Clones an object
  104210. * @param creationFunction defines the function used to instanciate the new object
  104211. * @param source defines the source object
  104212. * @returns the cloned object
  104213. */
  104214. static Clone<T>(creationFunction: () => T, source: T): T;
  104215. /**
  104216. * Instanciates a new object based on a source one (some data will be shared between both object)
  104217. * @param creationFunction defines the function used to instanciate the new object
  104218. * @param source defines the source object
  104219. * @returns the new object
  104220. */
  104221. static Instanciate<T>(creationFunction: () => T, source: T): T;
  104222. }
  104223. }
  104224. declare module BABYLON {
  104225. /**
  104226. * Class used to manipulate GUIDs
  104227. */
  104228. export class GUID {
  104229. /**
  104230. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  104231. * Be aware Math.random() could cause collisions, but:
  104232. * "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"
  104233. * @returns a pseudo random id
  104234. */
  104235. static RandomId(): string;
  104236. }
  104237. }
  104238. declare module BABYLON {
  104239. /**
  104240. * Base class of all the textures in babylon.
  104241. * It groups all the common properties the materials, post process, lights... might need
  104242. * in order to make a correct use of the texture.
  104243. */
  104244. export class BaseTexture implements IAnimatable {
  104245. /**
  104246. * Default anisotropic filtering level for the application.
  104247. * It is set to 4 as a good tradeoff between perf and quality.
  104248. */
  104249. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  104250. /**
  104251. * Gets or sets the unique id of the texture
  104252. */
  104253. uniqueId: number;
  104254. /**
  104255. * Define the name of the texture.
  104256. */
  104257. name: string;
  104258. /**
  104259. * Gets or sets an object used to store user defined information.
  104260. */
  104261. metadata: any;
  104262. /**
  104263. * For internal use only. Please do not use.
  104264. */
  104265. reservedDataStore: any;
  104266. private _hasAlpha;
  104267. /**
  104268. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  104269. */
  104270. set hasAlpha(value: boolean);
  104271. get hasAlpha(): boolean;
  104272. /**
  104273. * Defines if the alpha value should be determined via the rgb values.
  104274. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  104275. */
  104276. getAlphaFromRGB: boolean;
  104277. /**
  104278. * Intensity or strength of the texture.
  104279. * It is commonly used by materials to fine tune the intensity of the texture
  104280. */
  104281. level: number;
  104282. /**
  104283. * Define the UV chanel to use starting from 0 and defaulting to 0.
  104284. * This is part of the texture as textures usually maps to one uv set.
  104285. */
  104286. coordinatesIndex: number;
  104287. private _coordinatesMode;
  104288. /**
  104289. * How a texture is mapped.
  104290. *
  104291. * | Value | Type | Description |
  104292. * | ----- | ----------------------------------- | ----------- |
  104293. * | 0 | EXPLICIT_MODE | |
  104294. * | 1 | SPHERICAL_MODE | |
  104295. * | 2 | PLANAR_MODE | |
  104296. * | 3 | CUBIC_MODE | |
  104297. * | 4 | PROJECTION_MODE | |
  104298. * | 5 | SKYBOX_MODE | |
  104299. * | 6 | INVCUBIC_MODE | |
  104300. * | 7 | EQUIRECTANGULAR_MODE | |
  104301. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  104302. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  104303. */
  104304. set coordinatesMode(value: number);
  104305. get coordinatesMode(): number;
  104306. /**
  104307. * | Value | Type | Description |
  104308. * | ----- | ------------------ | ----------- |
  104309. * | 0 | CLAMP_ADDRESSMODE | |
  104310. * | 1 | WRAP_ADDRESSMODE | |
  104311. * | 2 | MIRROR_ADDRESSMODE | |
  104312. */
  104313. wrapU: number;
  104314. /**
  104315. * | Value | Type | Description |
  104316. * | ----- | ------------------ | ----------- |
  104317. * | 0 | CLAMP_ADDRESSMODE | |
  104318. * | 1 | WRAP_ADDRESSMODE | |
  104319. * | 2 | MIRROR_ADDRESSMODE | |
  104320. */
  104321. wrapV: number;
  104322. /**
  104323. * | Value | Type | Description |
  104324. * | ----- | ------------------ | ----------- |
  104325. * | 0 | CLAMP_ADDRESSMODE | |
  104326. * | 1 | WRAP_ADDRESSMODE | |
  104327. * | 2 | MIRROR_ADDRESSMODE | |
  104328. */
  104329. wrapR: number;
  104330. /**
  104331. * With compliant hardware and browser (supporting anisotropic filtering)
  104332. * this defines the level of anisotropic filtering in the texture.
  104333. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  104334. */
  104335. anisotropicFilteringLevel: number;
  104336. /**
  104337. * Define if the texture is a cube texture or if false a 2d texture.
  104338. */
  104339. get isCube(): boolean;
  104340. set isCube(value: boolean);
  104341. /**
  104342. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  104343. */
  104344. get is3D(): boolean;
  104345. set is3D(value: boolean);
  104346. /**
  104347. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  104348. */
  104349. get is2DArray(): boolean;
  104350. set is2DArray(value: boolean);
  104351. /**
  104352. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  104353. * HDR texture are usually stored in linear space.
  104354. * This only impacts the PBR and Background materials
  104355. */
  104356. gammaSpace: boolean;
  104357. /**
  104358. * Gets or sets whether or not the texture contains RGBD data.
  104359. */
  104360. get isRGBD(): boolean;
  104361. set isRGBD(value: boolean);
  104362. /**
  104363. * Is Z inverted in the texture (useful in a cube texture).
  104364. */
  104365. invertZ: boolean;
  104366. /**
  104367. * Are mip maps generated for this texture or not.
  104368. */
  104369. get noMipmap(): boolean;
  104370. /**
  104371. * @hidden
  104372. */
  104373. lodLevelInAlpha: boolean;
  104374. /**
  104375. * With prefiltered texture, defined the offset used during the prefiltering steps.
  104376. */
  104377. get lodGenerationOffset(): number;
  104378. set lodGenerationOffset(value: number);
  104379. /**
  104380. * With prefiltered texture, defined the scale used during the prefiltering steps.
  104381. */
  104382. get lodGenerationScale(): number;
  104383. set lodGenerationScale(value: number);
  104384. /**
  104385. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  104386. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  104387. * average roughness values.
  104388. */
  104389. get linearSpecularLOD(): boolean;
  104390. set linearSpecularLOD(value: boolean);
  104391. /**
  104392. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  104393. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  104394. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  104395. */
  104396. get irradianceTexture(): Nullable<BaseTexture>;
  104397. set irradianceTexture(value: Nullable<BaseTexture>);
  104398. /**
  104399. * Define if the texture is a render target.
  104400. */
  104401. isRenderTarget: boolean;
  104402. /**
  104403. * Define the unique id of the texture in the scene.
  104404. */
  104405. get uid(): string;
  104406. /**
  104407. * Return a string representation of the texture.
  104408. * @returns the texture as a string
  104409. */
  104410. toString(): string;
  104411. /**
  104412. * Get the class name of the texture.
  104413. * @returns "BaseTexture"
  104414. */
  104415. getClassName(): string;
  104416. /**
  104417. * Define the list of animation attached to the texture.
  104418. */
  104419. animations: Animation[];
  104420. /**
  104421. * An event triggered when the texture is disposed.
  104422. */
  104423. onDisposeObservable: Observable<BaseTexture>;
  104424. private _onDisposeObserver;
  104425. /**
  104426. * Callback triggered when the texture has been disposed.
  104427. * Kept for back compatibility, you can use the onDisposeObservable instead.
  104428. */
  104429. set onDispose(callback: () => void);
  104430. /**
  104431. * Define the current state of the loading sequence when in delayed load mode.
  104432. */
  104433. delayLoadState: number;
  104434. private _scene;
  104435. /** @hidden */
  104436. _texture: Nullable<InternalTexture>;
  104437. private _uid;
  104438. /**
  104439. * Define if the texture is preventinga material to render or not.
  104440. * If not and the texture is not ready, the engine will use a default black texture instead.
  104441. */
  104442. get isBlocking(): boolean;
  104443. /**
  104444. * Instantiates a new BaseTexture.
  104445. * Base class of all the textures in babylon.
  104446. * It groups all the common properties the materials, post process, lights... might need
  104447. * in order to make a correct use of the texture.
  104448. * @param scene Define the scene the texture blongs to
  104449. */
  104450. constructor(scene: Nullable<Scene>);
  104451. /**
  104452. * Get the scene the texture belongs to.
  104453. * @returns the scene or null if undefined
  104454. */
  104455. getScene(): Nullable<Scene>;
  104456. /**
  104457. * Get the texture transform matrix used to offset tile the texture for istance.
  104458. * @returns the transformation matrix
  104459. */
  104460. getTextureMatrix(): Matrix;
  104461. /**
  104462. * Get the texture reflection matrix used to rotate/transform the reflection.
  104463. * @returns the reflection matrix
  104464. */
  104465. getReflectionTextureMatrix(): Matrix;
  104466. /**
  104467. * Get the underlying lower level texture from Babylon.
  104468. * @returns the insternal texture
  104469. */
  104470. getInternalTexture(): Nullable<InternalTexture>;
  104471. /**
  104472. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  104473. * @returns true if ready or not blocking
  104474. */
  104475. isReadyOrNotBlocking(): boolean;
  104476. /**
  104477. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  104478. * @returns true if fully ready
  104479. */
  104480. isReady(): boolean;
  104481. private _cachedSize;
  104482. /**
  104483. * Get the size of the texture.
  104484. * @returns the texture size.
  104485. */
  104486. getSize(): ISize;
  104487. /**
  104488. * Get the base size of the texture.
  104489. * It can be different from the size if the texture has been resized for POT for instance
  104490. * @returns the base size
  104491. */
  104492. getBaseSize(): ISize;
  104493. /**
  104494. * Update the sampling mode of the texture.
  104495. * Default is Trilinear mode.
  104496. *
  104497. * | Value | Type | Description |
  104498. * | ----- | ------------------ | ----------- |
  104499. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  104500. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  104501. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  104502. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  104503. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  104504. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  104505. * | 7 | NEAREST_LINEAR | |
  104506. * | 8 | NEAREST_NEAREST | |
  104507. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  104508. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  104509. * | 11 | LINEAR_LINEAR | |
  104510. * | 12 | LINEAR_NEAREST | |
  104511. *
  104512. * > _mag_: magnification filter (close to the viewer)
  104513. * > _min_: minification filter (far from the viewer)
  104514. * > _mip_: filter used between mip map levels
  104515. *@param samplingMode Define the new sampling mode of the texture
  104516. */
  104517. updateSamplingMode(samplingMode: number): void;
  104518. /**
  104519. * Scales the texture if is `canRescale()`
  104520. * @param ratio the resize factor we want to use to rescale
  104521. */
  104522. scale(ratio: number): void;
  104523. /**
  104524. * Get if the texture can rescale.
  104525. */
  104526. get canRescale(): boolean;
  104527. /** @hidden */
  104528. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  104529. /** @hidden */
  104530. _rebuild(): void;
  104531. /**
  104532. * Triggers the load sequence in delayed load mode.
  104533. */
  104534. delayLoad(): void;
  104535. /**
  104536. * Clones the texture.
  104537. * @returns the cloned texture
  104538. */
  104539. clone(): Nullable<BaseTexture>;
  104540. /**
  104541. * Get the texture underlying type (INT, FLOAT...)
  104542. */
  104543. get textureType(): number;
  104544. /**
  104545. * Get the texture underlying format (RGB, RGBA...)
  104546. */
  104547. get textureFormat(): number;
  104548. /**
  104549. * Indicates that textures need to be re-calculated for all materials
  104550. */
  104551. protected _markAllSubMeshesAsTexturesDirty(): void;
  104552. /**
  104553. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  104554. * This will returns an RGBA array buffer containing either in values (0-255) or
  104555. * float values (0-1) depending of the underlying buffer type.
  104556. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  104557. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  104558. * @param buffer defines a user defined buffer to fill with data (can be null)
  104559. * @returns The Array buffer containing the pixels data.
  104560. */
  104561. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  104562. /**
  104563. * Release and destroy the underlying lower level texture aka internalTexture.
  104564. */
  104565. releaseInternalTexture(): void;
  104566. /** @hidden */
  104567. get _lodTextureHigh(): Nullable<BaseTexture>;
  104568. /** @hidden */
  104569. get _lodTextureMid(): Nullable<BaseTexture>;
  104570. /** @hidden */
  104571. get _lodTextureLow(): Nullable<BaseTexture>;
  104572. /**
  104573. * Dispose the texture and release its associated resources.
  104574. */
  104575. dispose(): void;
  104576. /**
  104577. * Serialize the texture into a JSON representation that can be parsed later on.
  104578. * @returns the JSON representation of the texture
  104579. */
  104580. serialize(): any;
  104581. /**
  104582. * Helper function to be called back once a list of texture contains only ready textures.
  104583. * @param textures Define the list of textures to wait for
  104584. * @param callback Define the callback triggered once the entire list will be ready
  104585. */
  104586. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  104587. }
  104588. }
  104589. declare module BABYLON {
  104590. /**
  104591. * Options to be used when creating an effect.
  104592. */
  104593. export interface IEffectCreationOptions {
  104594. /**
  104595. * Atrributes that will be used in the shader.
  104596. */
  104597. attributes: string[];
  104598. /**
  104599. * Uniform varible names that will be set in the shader.
  104600. */
  104601. uniformsNames: string[];
  104602. /**
  104603. * Uniform buffer variable names that will be set in the shader.
  104604. */
  104605. uniformBuffersNames: string[];
  104606. /**
  104607. * Sampler texture variable names that will be set in the shader.
  104608. */
  104609. samplers: string[];
  104610. /**
  104611. * Define statements that will be set in the shader.
  104612. */
  104613. defines: any;
  104614. /**
  104615. * Possible fallbacks for this effect to improve performance when needed.
  104616. */
  104617. fallbacks: Nullable<IEffectFallbacks>;
  104618. /**
  104619. * Callback that will be called when the shader is compiled.
  104620. */
  104621. onCompiled: Nullable<(effect: Effect) => void>;
  104622. /**
  104623. * Callback that will be called if an error occurs during shader compilation.
  104624. */
  104625. onError: Nullable<(effect: Effect, errors: string) => void>;
  104626. /**
  104627. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104628. */
  104629. indexParameters?: any;
  104630. /**
  104631. * Max number of lights that can be used in the shader.
  104632. */
  104633. maxSimultaneousLights?: number;
  104634. /**
  104635. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  104636. */
  104637. transformFeedbackVaryings?: Nullable<string[]>;
  104638. }
  104639. /**
  104640. * Effect containing vertex and fragment shader that can be executed on an object.
  104641. */
  104642. export class Effect implements IDisposable {
  104643. /**
  104644. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  104645. */
  104646. static ShadersRepository: string;
  104647. /**
  104648. * Enable logging of the shader code when a compilation error occurs
  104649. */
  104650. static LogShaderCodeOnCompilationError: boolean;
  104651. /**
  104652. * Name of the effect.
  104653. */
  104654. name: any;
  104655. /**
  104656. * String container all the define statements that should be set on the shader.
  104657. */
  104658. defines: string;
  104659. /**
  104660. * Callback that will be called when the shader is compiled.
  104661. */
  104662. onCompiled: Nullable<(effect: Effect) => void>;
  104663. /**
  104664. * Callback that will be called if an error occurs during shader compilation.
  104665. */
  104666. onError: Nullable<(effect: Effect, errors: string) => void>;
  104667. /**
  104668. * Callback that will be called when effect is bound.
  104669. */
  104670. onBind: Nullable<(effect: Effect) => void>;
  104671. /**
  104672. * Unique ID of the effect.
  104673. */
  104674. uniqueId: number;
  104675. /**
  104676. * Observable that will be called when the shader is compiled.
  104677. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  104678. */
  104679. onCompileObservable: Observable<Effect>;
  104680. /**
  104681. * Observable that will be called if an error occurs during shader compilation.
  104682. */
  104683. onErrorObservable: Observable<Effect>;
  104684. /** @hidden */
  104685. _onBindObservable: Nullable<Observable<Effect>>;
  104686. /**
  104687. * @hidden
  104688. * Specifies if the effect was previously ready
  104689. */
  104690. _wasPreviouslyReady: boolean;
  104691. /**
  104692. * Observable that will be called when effect is bound.
  104693. */
  104694. get onBindObservable(): Observable<Effect>;
  104695. /** @hidden */
  104696. _bonesComputationForcedToCPU: boolean;
  104697. private static _uniqueIdSeed;
  104698. private _engine;
  104699. private _uniformBuffersNames;
  104700. private _uniformsNames;
  104701. private _samplerList;
  104702. private _samplers;
  104703. private _isReady;
  104704. private _compilationError;
  104705. private _allFallbacksProcessed;
  104706. private _attributesNames;
  104707. private _attributes;
  104708. private _attributeLocationByName;
  104709. private _uniforms;
  104710. /**
  104711. * Key for the effect.
  104712. * @hidden
  104713. */
  104714. _key: string;
  104715. private _indexParameters;
  104716. private _fallbacks;
  104717. private _vertexSourceCode;
  104718. private _fragmentSourceCode;
  104719. private _vertexSourceCodeOverride;
  104720. private _fragmentSourceCodeOverride;
  104721. private _transformFeedbackVaryings;
  104722. /**
  104723. * Compiled shader to webGL program.
  104724. * @hidden
  104725. */
  104726. _pipelineContext: Nullable<IPipelineContext>;
  104727. private _valueCache;
  104728. private static _baseCache;
  104729. /**
  104730. * Instantiates an effect.
  104731. * An effect can be used to create/manage/execute vertex and fragment shaders.
  104732. * @param baseName Name of the effect.
  104733. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  104734. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  104735. * @param samplers List of sampler variables that will be passed to the shader.
  104736. * @param engine Engine to be used to render the effect
  104737. * @param defines Define statements to be added to the shader.
  104738. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  104739. * @param onCompiled Callback that will be called when the shader is compiled.
  104740. * @param onError Callback that will be called if an error occurs during shader compilation.
  104741. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  104742. */
  104743. 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);
  104744. private _useFinalCode;
  104745. /**
  104746. * Unique key for this effect
  104747. */
  104748. get key(): string;
  104749. /**
  104750. * If the effect has been compiled and prepared.
  104751. * @returns if the effect is compiled and prepared.
  104752. */
  104753. isReady(): boolean;
  104754. private _isReadyInternal;
  104755. /**
  104756. * The engine the effect was initialized with.
  104757. * @returns the engine.
  104758. */
  104759. getEngine(): Engine;
  104760. /**
  104761. * The pipeline context for this effect
  104762. * @returns the associated pipeline context
  104763. */
  104764. getPipelineContext(): Nullable<IPipelineContext>;
  104765. /**
  104766. * The set of names of attribute variables for the shader.
  104767. * @returns An array of attribute names.
  104768. */
  104769. getAttributesNames(): string[];
  104770. /**
  104771. * Returns the attribute at the given index.
  104772. * @param index The index of the attribute.
  104773. * @returns The location of the attribute.
  104774. */
  104775. getAttributeLocation(index: number): number;
  104776. /**
  104777. * Returns the attribute based on the name of the variable.
  104778. * @param name of the attribute to look up.
  104779. * @returns the attribute location.
  104780. */
  104781. getAttributeLocationByName(name: string): number;
  104782. /**
  104783. * The number of attributes.
  104784. * @returns the numnber of attributes.
  104785. */
  104786. getAttributesCount(): number;
  104787. /**
  104788. * Gets the index of a uniform variable.
  104789. * @param uniformName of the uniform to look up.
  104790. * @returns the index.
  104791. */
  104792. getUniformIndex(uniformName: string): number;
  104793. /**
  104794. * Returns the attribute based on the name of the variable.
  104795. * @param uniformName of the uniform to look up.
  104796. * @returns the location of the uniform.
  104797. */
  104798. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  104799. /**
  104800. * Returns an array of sampler variable names
  104801. * @returns The array of sampler variable neames.
  104802. */
  104803. getSamplers(): string[];
  104804. /**
  104805. * The error from the last compilation.
  104806. * @returns the error string.
  104807. */
  104808. getCompilationError(): string;
  104809. /**
  104810. * Gets a boolean indicating that all fallbacks were used during compilation
  104811. * @returns true if all fallbacks were used
  104812. */
  104813. allFallbacksProcessed(): boolean;
  104814. /**
  104815. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  104816. * @param func The callback to be used.
  104817. */
  104818. executeWhenCompiled(func: (effect: Effect) => void): void;
  104819. private _checkIsReady;
  104820. private _loadShader;
  104821. /**
  104822. * Recompiles the webGL program
  104823. * @param vertexSourceCode The source code for the vertex shader.
  104824. * @param fragmentSourceCode The source code for the fragment shader.
  104825. * @param onCompiled Callback called when completed.
  104826. * @param onError Callback called on error.
  104827. * @hidden
  104828. */
  104829. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  104830. /**
  104831. * Prepares the effect
  104832. * @hidden
  104833. */
  104834. _prepareEffect(): void;
  104835. private _getShaderCodeAndErrorLine;
  104836. private _processCompilationErrors;
  104837. /**
  104838. * Checks if the effect is supported. (Must be called after compilation)
  104839. */
  104840. get isSupported(): boolean;
  104841. /**
  104842. * Binds a texture to the engine to be used as output of the shader.
  104843. * @param channel Name of the output variable.
  104844. * @param texture Texture to bind.
  104845. * @hidden
  104846. */
  104847. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  104848. /**
  104849. * Sets a texture on the engine to be used in the shader.
  104850. * @param channel Name of the sampler variable.
  104851. * @param texture Texture to set.
  104852. */
  104853. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  104854. /**
  104855. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  104856. * @param channel Name of the sampler variable.
  104857. * @param texture Texture to set.
  104858. */
  104859. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  104860. /**
  104861. * Sets an array of textures on the engine to be used in the shader.
  104862. * @param channel Name of the variable.
  104863. * @param textures Textures to set.
  104864. */
  104865. setTextureArray(channel: string, textures: BaseTexture[]): void;
  104866. /**
  104867. * 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)
  104868. * @param channel Name of the sampler variable.
  104869. * @param postProcess Post process to get the input texture from.
  104870. */
  104871. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  104872. /**
  104873. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  104874. * 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)
  104875. * @param channel Name of the sampler variable.
  104876. * @param postProcess Post process to get the output texture from.
  104877. */
  104878. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  104879. /** @hidden */
  104880. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  104881. /** @hidden */
  104882. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  104883. /** @hidden */
  104884. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  104885. /** @hidden */
  104886. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  104887. /**
  104888. * Binds a buffer to a uniform.
  104889. * @param buffer Buffer to bind.
  104890. * @param name Name of the uniform variable to bind to.
  104891. */
  104892. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  104893. /**
  104894. * Binds block to a uniform.
  104895. * @param blockName Name of the block to bind.
  104896. * @param index Index to bind.
  104897. */
  104898. bindUniformBlock(blockName: string, index: number): void;
  104899. /**
  104900. * Sets an interger value on a uniform variable.
  104901. * @param uniformName Name of the variable.
  104902. * @param value Value to be set.
  104903. * @returns this effect.
  104904. */
  104905. setInt(uniformName: string, value: number): Effect;
  104906. /**
  104907. * Sets an int array on a uniform variable.
  104908. * @param uniformName Name of the variable.
  104909. * @param array array to be set.
  104910. * @returns this effect.
  104911. */
  104912. setIntArray(uniformName: string, array: Int32Array): Effect;
  104913. /**
  104914. * 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)
  104915. * @param uniformName Name of the variable.
  104916. * @param array array to be set.
  104917. * @returns this effect.
  104918. */
  104919. setIntArray2(uniformName: string, array: Int32Array): Effect;
  104920. /**
  104921. * 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)
  104922. * @param uniformName Name of the variable.
  104923. * @param array array to be set.
  104924. * @returns this effect.
  104925. */
  104926. setIntArray3(uniformName: string, array: Int32Array): Effect;
  104927. /**
  104928. * 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)
  104929. * @param uniformName Name of the variable.
  104930. * @param array array to be set.
  104931. * @returns this effect.
  104932. */
  104933. setIntArray4(uniformName: string, array: Int32Array): Effect;
  104934. /**
  104935. * Sets an float array on a uniform variable.
  104936. * @param uniformName Name of the variable.
  104937. * @param array array to be set.
  104938. * @returns this effect.
  104939. */
  104940. setFloatArray(uniformName: string, array: Float32Array): Effect;
  104941. /**
  104942. * 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)
  104943. * @param uniformName Name of the variable.
  104944. * @param array array to be set.
  104945. * @returns this effect.
  104946. */
  104947. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  104948. /**
  104949. * 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)
  104950. * @param uniformName Name of the variable.
  104951. * @param array array to be set.
  104952. * @returns this effect.
  104953. */
  104954. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  104955. /**
  104956. * 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)
  104957. * @param uniformName Name of the variable.
  104958. * @param array array to be set.
  104959. * @returns this effect.
  104960. */
  104961. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  104962. /**
  104963. * Sets an array on a uniform variable.
  104964. * @param uniformName Name of the variable.
  104965. * @param array array to be set.
  104966. * @returns this effect.
  104967. */
  104968. setArray(uniformName: string, array: number[]): Effect;
  104969. /**
  104970. * 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)
  104971. * @param uniformName Name of the variable.
  104972. * @param array array to be set.
  104973. * @returns this effect.
  104974. */
  104975. setArray2(uniformName: string, array: number[]): Effect;
  104976. /**
  104977. * 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)
  104978. * @param uniformName Name of the variable.
  104979. * @param array array to be set.
  104980. * @returns this effect.
  104981. */
  104982. setArray3(uniformName: string, array: number[]): Effect;
  104983. /**
  104984. * 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)
  104985. * @param uniformName Name of the variable.
  104986. * @param array array to be set.
  104987. * @returns this effect.
  104988. */
  104989. setArray4(uniformName: string, array: number[]): Effect;
  104990. /**
  104991. * Sets matrices on a uniform variable.
  104992. * @param uniformName Name of the variable.
  104993. * @param matrices matrices to be set.
  104994. * @returns this effect.
  104995. */
  104996. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  104997. /**
  104998. * Sets matrix on a uniform variable.
  104999. * @param uniformName Name of the variable.
  105000. * @param matrix matrix to be set.
  105001. * @returns this effect.
  105002. */
  105003. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  105004. /**
  105005. * 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)
  105006. * @param uniformName Name of the variable.
  105007. * @param matrix matrix to be set.
  105008. * @returns this effect.
  105009. */
  105010. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  105011. /**
  105012. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  105013. * @param uniformName Name of the variable.
  105014. * @param matrix matrix to be set.
  105015. * @returns this effect.
  105016. */
  105017. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  105018. /**
  105019. * Sets a float on a uniform variable.
  105020. * @param uniformName Name of the variable.
  105021. * @param value value to be set.
  105022. * @returns this effect.
  105023. */
  105024. setFloat(uniformName: string, value: number): Effect;
  105025. /**
  105026. * Sets a boolean on a uniform variable.
  105027. * @param uniformName Name of the variable.
  105028. * @param bool value to be set.
  105029. * @returns this effect.
  105030. */
  105031. setBool(uniformName: string, bool: boolean): Effect;
  105032. /**
  105033. * Sets a Vector2 on a uniform variable.
  105034. * @param uniformName Name of the variable.
  105035. * @param vector2 vector2 to be set.
  105036. * @returns this effect.
  105037. */
  105038. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  105039. /**
  105040. * Sets a float2 on a uniform variable.
  105041. * @param uniformName Name of the variable.
  105042. * @param x First float in float2.
  105043. * @param y Second float in float2.
  105044. * @returns this effect.
  105045. */
  105046. setFloat2(uniformName: string, x: number, y: number): Effect;
  105047. /**
  105048. * Sets a Vector3 on a uniform variable.
  105049. * @param uniformName Name of the variable.
  105050. * @param vector3 Value to be set.
  105051. * @returns this effect.
  105052. */
  105053. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  105054. /**
  105055. * Sets a float3 on a uniform variable.
  105056. * @param uniformName Name of the variable.
  105057. * @param x First float in float3.
  105058. * @param y Second float in float3.
  105059. * @param z Third float in float3.
  105060. * @returns this effect.
  105061. */
  105062. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  105063. /**
  105064. * Sets a Vector4 on a uniform variable.
  105065. * @param uniformName Name of the variable.
  105066. * @param vector4 Value to be set.
  105067. * @returns this effect.
  105068. */
  105069. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  105070. /**
  105071. * Sets a float4 on a uniform variable.
  105072. * @param uniformName Name of the variable.
  105073. * @param x First float in float4.
  105074. * @param y Second float in float4.
  105075. * @param z Third float in float4.
  105076. * @param w Fourth float in float4.
  105077. * @returns this effect.
  105078. */
  105079. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  105080. /**
  105081. * Sets a Color3 on a uniform variable.
  105082. * @param uniformName Name of the variable.
  105083. * @param color3 Value to be set.
  105084. * @returns this effect.
  105085. */
  105086. setColor3(uniformName: string, color3: IColor3Like): Effect;
  105087. /**
  105088. * Sets a Color4 on a uniform variable.
  105089. * @param uniformName Name of the variable.
  105090. * @param color3 Value to be set.
  105091. * @param alpha Alpha value to be set.
  105092. * @returns this effect.
  105093. */
  105094. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  105095. /**
  105096. * Sets a Color4 on a uniform variable
  105097. * @param uniformName defines the name of the variable
  105098. * @param color4 defines the value to be set
  105099. * @returns this effect.
  105100. */
  105101. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  105102. /** Release all associated resources */
  105103. dispose(): void;
  105104. /**
  105105. * This function will add a new shader to the shader store
  105106. * @param name the name of the shader
  105107. * @param pixelShader optional pixel shader content
  105108. * @param vertexShader optional vertex shader content
  105109. */
  105110. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  105111. /**
  105112. * Store of each shader (The can be looked up using effect.key)
  105113. */
  105114. static ShadersStore: {
  105115. [key: string]: string;
  105116. };
  105117. /**
  105118. * Store of each included file for a shader (The can be looked up using effect.key)
  105119. */
  105120. static IncludesShadersStore: {
  105121. [key: string]: string;
  105122. };
  105123. /**
  105124. * Resets the cache of effects.
  105125. */
  105126. static ResetCache(): void;
  105127. }
  105128. }
  105129. declare module BABYLON {
  105130. /**
  105131. * Interface used to describe the capabilities of the engine relatively to the current browser
  105132. */
  105133. export interface EngineCapabilities {
  105134. /** Maximum textures units per fragment shader */
  105135. maxTexturesImageUnits: number;
  105136. /** Maximum texture units per vertex shader */
  105137. maxVertexTextureImageUnits: number;
  105138. /** Maximum textures units in the entire pipeline */
  105139. maxCombinedTexturesImageUnits: number;
  105140. /** Maximum texture size */
  105141. maxTextureSize: number;
  105142. /** Maximum texture samples */
  105143. maxSamples?: number;
  105144. /** Maximum cube texture size */
  105145. maxCubemapTextureSize: number;
  105146. /** Maximum render texture size */
  105147. maxRenderTextureSize: number;
  105148. /** Maximum number of vertex attributes */
  105149. maxVertexAttribs: number;
  105150. /** Maximum number of varyings */
  105151. maxVaryingVectors: number;
  105152. /** Maximum number of uniforms per vertex shader */
  105153. maxVertexUniformVectors: number;
  105154. /** Maximum number of uniforms per fragment shader */
  105155. maxFragmentUniformVectors: number;
  105156. /** Defines if standard derivates (dx/dy) are supported */
  105157. standardDerivatives: boolean;
  105158. /** Defines if s3tc texture compression is supported */
  105159. s3tc?: WEBGL_compressed_texture_s3tc;
  105160. /** Defines if pvrtc texture compression is supported */
  105161. pvrtc: any;
  105162. /** Defines if etc1 texture compression is supported */
  105163. etc1: any;
  105164. /** Defines if etc2 texture compression is supported */
  105165. etc2: any;
  105166. /** Defines if astc texture compression is supported */
  105167. astc: any;
  105168. /** Defines if float textures are supported */
  105169. textureFloat: boolean;
  105170. /** Defines if vertex array objects are supported */
  105171. vertexArrayObject: boolean;
  105172. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  105173. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  105174. /** Gets the maximum level of anisotropy supported */
  105175. maxAnisotropy: number;
  105176. /** Defines if instancing is supported */
  105177. instancedArrays: boolean;
  105178. /** Defines if 32 bits indices are supported */
  105179. uintIndices: boolean;
  105180. /** Defines if high precision shaders are supported */
  105181. highPrecisionShaderSupported: boolean;
  105182. /** Defines if depth reading in the fragment shader is supported */
  105183. fragmentDepthSupported: boolean;
  105184. /** Defines if float texture linear filtering is supported*/
  105185. textureFloatLinearFiltering: boolean;
  105186. /** Defines if rendering to float textures is supported */
  105187. textureFloatRender: boolean;
  105188. /** Defines if half float textures are supported*/
  105189. textureHalfFloat: boolean;
  105190. /** Defines if half float texture linear filtering is supported*/
  105191. textureHalfFloatLinearFiltering: boolean;
  105192. /** Defines if rendering to half float textures is supported */
  105193. textureHalfFloatRender: boolean;
  105194. /** Defines if textureLOD shader command is supported */
  105195. textureLOD: boolean;
  105196. /** Defines if draw buffers extension is supported */
  105197. drawBuffersExtension: boolean;
  105198. /** Defines if depth textures are supported */
  105199. depthTextureExtension: boolean;
  105200. /** Defines if float color buffer are supported */
  105201. colorBufferFloat: boolean;
  105202. /** Gets disjoint timer query extension (null if not supported) */
  105203. timerQuery?: EXT_disjoint_timer_query;
  105204. /** Defines if timestamp can be used with timer query */
  105205. canUseTimestampForTimerQuery: boolean;
  105206. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  105207. multiview?: any;
  105208. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  105209. oculusMultiview?: any;
  105210. /** Function used to let the system compiles shaders in background */
  105211. parallelShaderCompile?: {
  105212. COMPLETION_STATUS_KHR: number;
  105213. };
  105214. /** Max number of texture samples for MSAA */
  105215. maxMSAASamples: number;
  105216. /** Defines if the blend min max extension is supported */
  105217. blendMinMax: boolean;
  105218. }
  105219. }
  105220. declare module BABYLON {
  105221. /**
  105222. * @hidden
  105223. **/
  105224. export class DepthCullingState {
  105225. private _isDepthTestDirty;
  105226. private _isDepthMaskDirty;
  105227. private _isDepthFuncDirty;
  105228. private _isCullFaceDirty;
  105229. private _isCullDirty;
  105230. private _isZOffsetDirty;
  105231. private _isFrontFaceDirty;
  105232. private _depthTest;
  105233. private _depthMask;
  105234. private _depthFunc;
  105235. private _cull;
  105236. private _cullFace;
  105237. private _zOffset;
  105238. private _frontFace;
  105239. /**
  105240. * Initializes the state.
  105241. */
  105242. constructor();
  105243. get isDirty(): boolean;
  105244. get zOffset(): number;
  105245. set zOffset(value: number);
  105246. get cullFace(): Nullable<number>;
  105247. set cullFace(value: Nullable<number>);
  105248. get cull(): Nullable<boolean>;
  105249. set cull(value: Nullable<boolean>);
  105250. get depthFunc(): Nullable<number>;
  105251. set depthFunc(value: Nullable<number>);
  105252. get depthMask(): boolean;
  105253. set depthMask(value: boolean);
  105254. get depthTest(): boolean;
  105255. set depthTest(value: boolean);
  105256. get frontFace(): Nullable<number>;
  105257. set frontFace(value: Nullable<number>);
  105258. reset(): void;
  105259. apply(gl: WebGLRenderingContext): void;
  105260. }
  105261. }
  105262. declare module BABYLON {
  105263. /**
  105264. * @hidden
  105265. **/
  105266. export class StencilState {
  105267. /** 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 */
  105268. static readonly ALWAYS: number;
  105269. /** Passed to stencilOperation to specify that stencil value must be kept */
  105270. static readonly KEEP: number;
  105271. /** Passed to stencilOperation to specify that stencil value must be replaced */
  105272. static readonly REPLACE: number;
  105273. private _isStencilTestDirty;
  105274. private _isStencilMaskDirty;
  105275. private _isStencilFuncDirty;
  105276. private _isStencilOpDirty;
  105277. private _stencilTest;
  105278. private _stencilMask;
  105279. private _stencilFunc;
  105280. private _stencilFuncRef;
  105281. private _stencilFuncMask;
  105282. private _stencilOpStencilFail;
  105283. private _stencilOpDepthFail;
  105284. private _stencilOpStencilDepthPass;
  105285. get isDirty(): boolean;
  105286. get stencilFunc(): number;
  105287. set stencilFunc(value: number);
  105288. get stencilFuncRef(): number;
  105289. set stencilFuncRef(value: number);
  105290. get stencilFuncMask(): number;
  105291. set stencilFuncMask(value: number);
  105292. get stencilOpStencilFail(): number;
  105293. set stencilOpStencilFail(value: number);
  105294. get stencilOpDepthFail(): number;
  105295. set stencilOpDepthFail(value: number);
  105296. get stencilOpStencilDepthPass(): number;
  105297. set stencilOpStencilDepthPass(value: number);
  105298. get stencilMask(): number;
  105299. set stencilMask(value: number);
  105300. get stencilTest(): boolean;
  105301. set stencilTest(value: boolean);
  105302. constructor();
  105303. reset(): void;
  105304. apply(gl: WebGLRenderingContext): void;
  105305. }
  105306. }
  105307. declare module BABYLON {
  105308. /**
  105309. * @hidden
  105310. **/
  105311. export class AlphaState {
  105312. private _isAlphaBlendDirty;
  105313. private _isBlendFunctionParametersDirty;
  105314. private _isBlendEquationParametersDirty;
  105315. private _isBlendConstantsDirty;
  105316. private _alphaBlend;
  105317. private _blendFunctionParameters;
  105318. private _blendEquationParameters;
  105319. private _blendConstants;
  105320. /**
  105321. * Initializes the state.
  105322. */
  105323. constructor();
  105324. get isDirty(): boolean;
  105325. get alphaBlend(): boolean;
  105326. set alphaBlend(value: boolean);
  105327. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  105328. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  105329. setAlphaEquationParameters(rgb: number, alpha: number): void;
  105330. reset(): void;
  105331. apply(gl: WebGLRenderingContext): void;
  105332. }
  105333. }
  105334. declare module BABYLON {
  105335. /** @hidden */
  105336. export class WebGL2ShaderProcessor implements IShaderProcessor {
  105337. attributeProcessor(attribute: string): string;
  105338. varyingProcessor(varying: string, isFragment: boolean): string;
  105339. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  105340. }
  105341. }
  105342. declare module BABYLON {
  105343. /**
  105344. * Interface for attribute information associated with buffer instanciation
  105345. */
  105346. export interface InstancingAttributeInfo {
  105347. /**
  105348. * Name of the GLSL attribute
  105349. * if attribute index is not specified, this is used to retrieve the index from the effect
  105350. */
  105351. attributeName: string;
  105352. /**
  105353. * Index/offset of the attribute in the vertex shader
  105354. * if not specified, this will be computes from the name.
  105355. */
  105356. index?: number;
  105357. /**
  105358. * size of the attribute, 1, 2, 3 or 4
  105359. */
  105360. attributeSize: number;
  105361. /**
  105362. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  105363. */
  105364. offset: number;
  105365. /**
  105366. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  105367. * default to 1
  105368. */
  105369. divisor?: number;
  105370. /**
  105371. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  105372. * default is FLOAT
  105373. */
  105374. attributeType?: number;
  105375. /**
  105376. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  105377. */
  105378. normalized?: boolean;
  105379. }
  105380. }
  105381. declare module BABYLON {
  105382. interface ThinEngine {
  105383. /**
  105384. * Update a video texture
  105385. * @param texture defines the texture to update
  105386. * @param video defines the video element to use
  105387. * @param invertY defines if data must be stored with Y axis inverted
  105388. */
  105389. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  105390. }
  105391. }
  105392. declare module BABYLON {
  105393. /**
  105394. * Settings for finer control over video usage
  105395. */
  105396. export interface VideoTextureSettings {
  105397. /**
  105398. * Applies `autoplay` to video, if specified
  105399. */
  105400. autoPlay?: boolean;
  105401. /**
  105402. * Applies `loop` to video, if specified
  105403. */
  105404. loop?: boolean;
  105405. /**
  105406. * Automatically updates internal texture from video at every frame in the render loop
  105407. */
  105408. autoUpdateTexture: boolean;
  105409. /**
  105410. * Image src displayed during the video loading or until the user interacts with the video.
  105411. */
  105412. poster?: string;
  105413. }
  105414. /**
  105415. * If you want to display a video in your scene, this is the special texture for that.
  105416. * This special texture works similar to other textures, with the exception of a few parameters.
  105417. * @see https://doc.babylonjs.com/how_to/video_texture
  105418. */
  105419. export class VideoTexture extends Texture {
  105420. /**
  105421. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  105422. */
  105423. readonly autoUpdateTexture: boolean;
  105424. /**
  105425. * The video instance used by the texture internally
  105426. */
  105427. readonly video: HTMLVideoElement;
  105428. private _onUserActionRequestedObservable;
  105429. /**
  105430. * Event triggerd when a dom action is required by the user to play the video.
  105431. * This happens due to recent changes in browser policies preventing video to auto start.
  105432. */
  105433. get onUserActionRequestedObservable(): Observable<Texture>;
  105434. private _generateMipMaps;
  105435. private _engine;
  105436. private _stillImageCaptured;
  105437. private _displayingPosterTexture;
  105438. private _settings;
  105439. private _createInternalTextureOnEvent;
  105440. private _frameId;
  105441. private _currentSrc;
  105442. /**
  105443. * Creates a video texture.
  105444. * If you want to display a video in your scene, this is the special texture for that.
  105445. * This special texture works similar to other textures, with the exception of a few parameters.
  105446. * @see https://doc.babylonjs.com/how_to/video_texture
  105447. * @param name optional name, will detect from video source, if not defined
  105448. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  105449. * @param scene is obviously the current scene.
  105450. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  105451. * @param invertY is false by default but can be used to invert video on Y axis
  105452. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  105453. * @param settings allows finer control over video usage
  105454. */
  105455. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  105456. private _getName;
  105457. private _getVideo;
  105458. private _createInternalTexture;
  105459. private reset;
  105460. /**
  105461. * @hidden Internal method to initiate `update`.
  105462. */
  105463. _rebuild(): void;
  105464. /**
  105465. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  105466. */
  105467. update(): void;
  105468. /**
  105469. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  105470. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  105471. */
  105472. updateTexture(isVisible: boolean): void;
  105473. protected _updateInternalTexture: () => void;
  105474. /**
  105475. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  105476. * @param url New url.
  105477. */
  105478. updateURL(url: string): void;
  105479. /**
  105480. * Clones the texture.
  105481. * @returns the cloned texture
  105482. */
  105483. clone(): VideoTexture;
  105484. /**
  105485. * Dispose the texture and release its associated resources.
  105486. */
  105487. dispose(): void;
  105488. /**
  105489. * Creates a video texture straight from a stream.
  105490. * @param scene Define the scene the texture should be created in
  105491. * @param stream Define the stream the texture should be created from
  105492. * @returns The created video texture as a promise
  105493. */
  105494. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  105495. /**
  105496. * Creates a video texture straight from your WebCam video feed.
  105497. * @param scene Define the scene the texture should be created in
  105498. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105499. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105500. * @returns The created video texture as a promise
  105501. */
  105502. static CreateFromWebCamAsync(scene: Scene, constraints: {
  105503. minWidth: number;
  105504. maxWidth: number;
  105505. minHeight: number;
  105506. maxHeight: number;
  105507. deviceId: string;
  105508. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  105509. /**
  105510. * Creates a video texture straight from your WebCam video feed.
  105511. * @param scene Define the scene the texture should be created in
  105512. * @param onReady Define a callback to triggered once the texture will be ready
  105513. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  105514. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  105515. */
  105516. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  105517. minWidth: number;
  105518. maxWidth: number;
  105519. minHeight: number;
  105520. maxHeight: number;
  105521. deviceId: string;
  105522. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  105523. }
  105524. }
  105525. declare module BABYLON {
  105526. /**
  105527. * Defines the interface used by objects working like Scene
  105528. * @hidden
  105529. */
  105530. export interface ISceneLike {
  105531. _addPendingData(data: any): void;
  105532. _removePendingData(data: any): void;
  105533. offlineProvider: IOfflineProvider;
  105534. }
  105535. /** Interface defining initialization parameters for Engine class */
  105536. export interface EngineOptions extends WebGLContextAttributes {
  105537. /**
  105538. * Defines if the engine should no exceed a specified device ratio
  105539. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  105540. */
  105541. limitDeviceRatio?: number;
  105542. /**
  105543. * Defines if webvr should be enabled automatically
  105544. * @see http://doc.babylonjs.com/how_to/webvr_camera
  105545. */
  105546. autoEnableWebVR?: boolean;
  105547. /**
  105548. * Defines if webgl2 should be turned off even if supported
  105549. * @see http://doc.babylonjs.com/features/webgl2
  105550. */
  105551. disableWebGL2Support?: boolean;
  105552. /**
  105553. * Defines if webaudio should be initialized as well
  105554. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  105555. */
  105556. audioEngine?: boolean;
  105557. /**
  105558. * Defines if animations should run using a deterministic lock step
  105559. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  105560. */
  105561. deterministicLockstep?: boolean;
  105562. /** Defines the maximum steps to use with deterministic lock step mode */
  105563. lockstepMaxSteps?: number;
  105564. /** Defines the seconds between each deterministic lock step */
  105565. timeStep?: number;
  105566. /**
  105567. * Defines that engine should ignore context lost events
  105568. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  105569. */
  105570. doNotHandleContextLost?: boolean;
  105571. /**
  105572. * Defines that engine should ignore modifying touch action attribute and style
  105573. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  105574. */
  105575. doNotHandleTouchAction?: boolean;
  105576. /**
  105577. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  105578. */
  105579. useHighPrecisionFloats?: boolean;
  105580. }
  105581. /**
  105582. * The base engine class (root of all engines)
  105583. */
  105584. export class ThinEngine {
  105585. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  105586. static ExceptionList: ({
  105587. key: string;
  105588. capture: string;
  105589. captureConstraint: number;
  105590. targets: string[];
  105591. } | {
  105592. key: string;
  105593. capture: null;
  105594. captureConstraint: null;
  105595. targets: string[];
  105596. })[];
  105597. /** @hidden */
  105598. static _TextureLoaders: IInternalTextureLoader[];
  105599. /**
  105600. * Returns the current npm package of the sdk
  105601. */
  105602. static get NpmPackage(): string;
  105603. /**
  105604. * Returns the current version of the framework
  105605. */
  105606. static get Version(): string;
  105607. /**
  105608. * Returns a string describing the current engine
  105609. */
  105610. get description(): string;
  105611. /**
  105612. * Gets or sets the epsilon value used by collision engine
  105613. */
  105614. static CollisionsEpsilon: number;
  105615. /**
  105616. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  105617. */
  105618. static get ShadersRepository(): string;
  105619. static set ShadersRepository(value: string);
  105620. /** @hidden */
  105621. _shaderProcessor: IShaderProcessor;
  105622. /**
  105623. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  105624. */
  105625. forcePOTTextures: boolean;
  105626. /**
  105627. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  105628. */
  105629. isFullscreen: boolean;
  105630. /**
  105631. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  105632. */
  105633. cullBackFaces: boolean;
  105634. /**
  105635. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  105636. */
  105637. renderEvenInBackground: boolean;
  105638. /**
  105639. * Gets or sets a boolean indicating that cache can be kept between frames
  105640. */
  105641. preventCacheWipeBetweenFrames: boolean;
  105642. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  105643. validateShaderPrograms: boolean;
  105644. /**
  105645. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  105646. * This can provide greater z depth for distant objects.
  105647. */
  105648. useReverseDepthBuffer: boolean;
  105649. /**
  105650. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  105651. */
  105652. disableUniformBuffers: boolean;
  105653. /** @hidden */
  105654. _uniformBuffers: UniformBuffer[];
  105655. /**
  105656. * Gets a boolean indicating that the engine supports uniform buffers
  105657. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  105658. */
  105659. get supportsUniformBuffers(): boolean;
  105660. /** @hidden */
  105661. _gl: WebGLRenderingContext;
  105662. /** @hidden */
  105663. _webGLVersion: number;
  105664. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  105665. protected _windowIsBackground: boolean;
  105666. protected _creationOptions: EngineOptions;
  105667. protected _highPrecisionShadersAllowed: boolean;
  105668. /** @hidden */
  105669. get _shouldUseHighPrecisionShader(): boolean;
  105670. /**
  105671. * Gets a boolean indicating that only power of 2 textures are supported
  105672. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  105673. */
  105674. get needPOTTextures(): boolean;
  105675. /** @hidden */
  105676. _badOS: boolean;
  105677. /** @hidden */
  105678. _badDesktopOS: boolean;
  105679. private _hardwareScalingLevel;
  105680. /** @hidden */
  105681. _caps: EngineCapabilities;
  105682. private _isStencilEnable;
  105683. private _glVersion;
  105684. private _glRenderer;
  105685. private _glVendor;
  105686. /** @hidden */
  105687. _videoTextureSupported: boolean;
  105688. protected _renderingQueueLaunched: boolean;
  105689. protected _activeRenderLoops: (() => void)[];
  105690. /**
  105691. * Observable signaled when a context lost event is raised
  105692. */
  105693. onContextLostObservable: Observable<ThinEngine>;
  105694. /**
  105695. * Observable signaled when a context restored event is raised
  105696. */
  105697. onContextRestoredObservable: Observable<ThinEngine>;
  105698. private _onContextLost;
  105699. private _onContextRestored;
  105700. protected _contextWasLost: boolean;
  105701. /** @hidden */
  105702. _doNotHandleContextLost: boolean;
  105703. /**
  105704. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  105705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  105706. */
  105707. get doNotHandleContextLost(): boolean;
  105708. set doNotHandleContextLost(value: boolean);
  105709. /**
  105710. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  105711. */
  105712. disableVertexArrayObjects: boolean;
  105713. /** @hidden */
  105714. protected _colorWrite: boolean;
  105715. /** @hidden */
  105716. protected _colorWriteChanged: boolean;
  105717. /** @hidden */
  105718. protected _depthCullingState: DepthCullingState;
  105719. /** @hidden */
  105720. protected _stencilState: StencilState;
  105721. /** @hidden */
  105722. _alphaState: AlphaState;
  105723. /** @hidden */
  105724. _alphaMode: number;
  105725. /** @hidden */
  105726. _alphaEquation: number;
  105727. /** @hidden */
  105728. _internalTexturesCache: InternalTexture[];
  105729. /** @hidden */
  105730. protected _activeChannel: number;
  105731. private _currentTextureChannel;
  105732. /** @hidden */
  105733. protected _boundTexturesCache: {
  105734. [key: string]: Nullable<InternalTexture>;
  105735. };
  105736. /** @hidden */
  105737. protected _currentEffect: Nullable<Effect>;
  105738. /** @hidden */
  105739. protected _currentProgram: Nullable<WebGLProgram>;
  105740. private _compiledEffects;
  105741. private _vertexAttribArraysEnabled;
  105742. /** @hidden */
  105743. protected _cachedViewport: Nullable<IViewportLike>;
  105744. private _cachedVertexArrayObject;
  105745. /** @hidden */
  105746. protected _cachedVertexBuffers: any;
  105747. /** @hidden */
  105748. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  105749. /** @hidden */
  105750. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  105751. /** @hidden */
  105752. _currentRenderTarget: Nullable<InternalTexture>;
  105753. private _uintIndicesCurrentlySet;
  105754. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  105755. /** @hidden */
  105756. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  105757. private _currentBufferPointers;
  105758. private _currentInstanceLocations;
  105759. private _currentInstanceBuffers;
  105760. private _textureUnits;
  105761. /** @hidden */
  105762. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  105763. /** @hidden */
  105764. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  105765. /** @hidden */
  105766. _boundRenderFunction: any;
  105767. private _vaoRecordInProgress;
  105768. private _mustWipeVertexAttributes;
  105769. private _emptyTexture;
  105770. private _emptyCubeTexture;
  105771. private _emptyTexture3D;
  105772. private _emptyTexture2DArray;
  105773. /** @hidden */
  105774. _frameHandler: number;
  105775. private _nextFreeTextureSlots;
  105776. private _maxSimultaneousTextures;
  105777. private _activeRequests;
  105778. /** @hidden */
  105779. _transformTextureUrl: Nullable<(url: string) => string>;
  105780. protected get _supportsHardwareTextureRescaling(): boolean;
  105781. private _framebufferDimensionsObject;
  105782. /**
  105783. * sets the object from which width and height will be taken from when getting render width and height
  105784. * Will fallback to the gl object
  105785. * @param dimensions the framebuffer width and height that will be used.
  105786. */
  105787. set framebufferDimensionsObject(dimensions: Nullable<{
  105788. framebufferWidth: number;
  105789. framebufferHeight: number;
  105790. }>);
  105791. /**
  105792. * Gets the current viewport
  105793. */
  105794. get currentViewport(): Nullable<IViewportLike>;
  105795. /**
  105796. * Gets the default empty texture
  105797. */
  105798. get emptyTexture(): InternalTexture;
  105799. /**
  105800. * Gets the default empty 3D texture
  105801. */
  105802. get emptyTexture3D(): InternalTexture;
  105803. /**
  105804. * Gets the default empty 2D array texture
  105805. */
  105806. get emptyTexture2DArray(): InternalTexture;
  105807. /**
  105808. * Gets the default empty cube texture
  105809. */
  105810. get emptyCubeTexture(): InternalTexture;
  105811. /**
  105812. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  105813. */
  105814. readonly premultipliedAlpha: boolean;
  105815. /**
  105816. * Observable event triggered before each texture is initialized
  105817. */
  105818. onBeforeTextureInitObservable: Observable<Texture>;
  105819. /**
  105820. * Creates a new engine
  105821. * @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
  105822. * @param antialias defines enable antialiasing (default: false)
  105823. * @param options defines further options to be sent to the getContext() function
  105824. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  105825. */
  105826. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  105827. private _rebuildInternalTextures;
  105828. private _rebuildEffects;
  105829. /**
  105830. * Gets a boolean indicating if all created effects are ready
  105831. * @returns true if all effects are ready
  105832. */
  105833. areAllEffectsReady(): boolean;
  105834. protected _rebuildBuffers(): void;
  105835. protected _initGLContext(): void;
  105836. /**
  105837. * Gets version of the current webGL context
  105838. */
  105839. get webGLVersion(): number;
  105840. /**
  105841. * Gets a string idenfifying the name of the class
  105842. * @returns "Engine" string
  105843. */
  105844. getClassName(): string;
  105845. /**
  105846. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  105847. */
  105848. get isStencilEnable(): boolean;
  105849. /** @hidden */
  105850. _prepareWorkingCanvas(): void;
  105851. /**
  105852. * Reset the texture cache to empty state
  105853. */
  105854. resetTextureCache(): void;
  105855. /**
  105856. * Gets an object containing information about the current webGL context
  105857. * @returns an object containing the vender, the renderer and the version of the current webGL context
  105858. */
  105859. getGlInfo(): {
  105860. vendor: string;
  105861. renderer: string;
  105862. version: string;
  105863. };
  105864. /**
  105865. * Defines the hardware scaling level.
  105866. * By default the hardware scaling level is computed from the window device ratio.
  105867. * 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.
  105868. * @param level defines the level to use
  105869. */
  105870. setHardwareScalingLevel(level: number): void;
  105871. /**
  105872. * Gets the current hardware scaling level.
  105873. * By default the hardware scaling level is computed from the window device ratio.
  105874. * 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.
  105875. * @returns a number indicating the current hardware scaling level
  105876. */
  105877. getHardwareScalingLevel(): number;
  105878. /**
  105879. * Gets the list of loaded textures
  105880. * @returns an array containing all loaded textures
  105881. */
  105882. getLoadedTexturesCache(): InternalTexture[];
  105883. /**
  105884. * Gets the object containing all engine capabilities
  105885. * @returns the EngineCapabilities object
  105886. */
  105887. getCaps(): EngineCapabilities;
  105888. /**
  105889. * stop executing a render loop function and remove it from the execution array
  105890. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  105891. */
  105892. stopRenderLoop(renderFunction?: () => void): void;
  105893. /** @hidden */
  105894. _renderLoop(): void;
  105895. /**
  105896. * Gets the HTML canvas attached with the current webGL context
  105897. * @returns a HTML canvas
  105898. */
  105899. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  105900. /**
  105901. * Gets host window
  105902. * @returns the host window object
  105903. */
  105904. getHostWindow(): Nullable<Window>;
  105905. /**
  105906. * Gets the current render width
  105907. * @param useScreen defines if screen size must be used (or the current render target if any)
  105908. * @returns a number defining the current render width
  105909. */
  105910. getRenderWidth(useScreen?: boolean): number;
  105911. /**
  105912. * Gets the current render height
  105913. * @param useScreen defines if screen size must be used (or the current render target if any)
  105914. * @returns a number defining the current render height
  105915. */
  105916. getRenderHeight(useScreen?: boolean): number;
  105917. /**
  105918. * Can be used to override the current requestAnimationFrame requester.
  105919. * @hidden
  105920. */
  105921. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  105922. /**
  105923. * Register and execute a render loop. The engine can have more than one render function
  105924. * @param renderFunction defines the function to continuously execute
  105925. */
  105926. runRenderLoop(renderFunction: () => void): void;
  105927. /**
  105928. * Clear the current render buffer or the current render target (if any is set up)
  105929. * @param color defines the color to use
  105930. * @param backBuffer defines if the back buffer must be cleared
  105931. * @param depth defines if the depth buffer must be cleared
  105932. * @param stencil defines if the stencil buffer must be cleared
  105933. */
  105934. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  105935. private _viewportCached;
  105936. /** @hidden */
  105937. _viewport(x: number, y: number, width: number, height: number): void;
  105938. /**
  105939. * Set the WebGL's viewport
  105940. * @param viewport defines the viewport element to be used
  105941. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  105942. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  105943. */
  105944. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  105945. /**
  105946. * Begin a new frame
  105947. */
  105948. beginFrame(): void;
  105949. /**
  105950. * Enf the current frame
  105951. */
  105952. endFrame(): void;
  105953. /**
  105954. * Resize the view according to the canvas' size
  105955. */
  105956. resize(): void;
  105957. /**
  105958. * Force a specific size of the canvas
  105959. * @param width defines the new canvas' width
  105960. * @param height defines the new canvas' height
  105961. */
  105962. setSize(width: number, height: number): void;
  105963. /**
  105964. * Binds the frame buffer to the specified texture.
  105965. * @param texture The texture to render to or null for the default canvas
  105966. * @param faceIndex The face of the texture to render to in case of cube texture
  105967. * @param requiredWidth The width of the target to render to
  105968. * @param requiredHeight The height of the target to render to
  105969. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  105970. * @param lodLevel defines the lod level to bind to the frame buffer
  105971. * @param layer defines the 2d array index to bind to frame buffer to
  105972. */
  105973. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  105974. /** @hidden */
  105975. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  105976. /**
  105977. * Unbind the current render target texture from the webGL context
  105978. * @param texture defines the render target texture to unbind
  105979. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  105980. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  105981. */
  105982. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  105983. /**
  105984. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  105985. */
  105986. flushFramebuffer(): void;
  105987. /**
  105988. * Unbind the current render target and bind the default framebuffer
  105989. */
  105990. restoreDefaultFramebuffer(): void;
  105991. /** @hidden */
  105992. protected _resetVertexBufferBinding(): void;
  105993. /**
  105994. * Creates a vertex buffer
  105995. * @param data the data for the vertex buffer
  105996. * @returns the new WebGL static buffer
  105997. */
  105998. createVertexBuffer(data: DataArray): DataBuffer;
  105999. private _createVertexBuffer;
  106000. /**
  106001. * Creates a dynamic vertex buffer
  106002. * @param data the data for the dynamic vertex buffer
  106003. * @returns the new WebGL dynamic buffer
  106004. */
  106005. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  106006. protected _resetIndexBufferBinding(): void;
  106007. /**
  106008. * Creates a new index buffer
  106009. * @param indices defines the content of the index buffer
  106010. * @param updatable defines if the index buffer must be updatable
  106011. * @returns a new webGL buffer
  106012. */
  106013. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  106014. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  106015. /**
  106016. * Bind a webGL buffer to the webGL context
  106017. * @param buffer defines the buffer to bind
  106018. */
  106019. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  106020. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  106021. private bindBuffer;
  106022. /**
  106023. * update the bound buffer with the given data
  106024. * @param data defines the data to update
  106025. */
  106026. updateArrayBuffer(data: Float32Array): void;
  106027. private _vertexAttribPointer;
  106028. /** @hidden */
  106029. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  106030. private _bindVertexBuffersAttributes;
  106031. /**
  106032. * Records a vertex array object
  106033. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106034. * @param vertexBuffers defines the list of vertex buffers to store
  106035. * @param indexBuffer defines the index buffer to store
  106036. * @param effect defines the effect to store
  106037. * @returns the new vertex array object
  106038. */
  106039. recordVertexArrayObject(vertexBuffers: {
  106040. [key: string]: VertexBuffer;
  106041. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  106042. /**
  106043. * Bind a specific vertex array object
  106044. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  106045. * @param vertexArrayObject defines the vertex array object to bind
  106046. * @param indexBuffer defines the index buffer to bind
  106047. */
  106048. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  106049. /**
  106050. * Bind webGl buffers directly to the webGL context
  106051. * @param vertexBuffer defines the vertex buffer to bind
  106052. * @param indexBuffer defines the index buffer to bind
  106053. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  106054. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  106055. * @param effect defines the effect associated with the vertex buffer
  106056. */
  106057. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  106058. private _unbindVertexArrayObject;
  106059. /**
  106060. * Bind a list of vertex buffers to the webGL context
  106061. * @param vertexBuffers defines the list of vertex buffers to bind
  106062. * @param indexBuffer defines the index buffer to bind
  106063. * @param effect defines the effect associated with the vertex buffers
  106064. */
  106065. bindBuffers(vertexBuffers: {
  106066. [key: string]: Nullable<VertexBuffer>;
  106067. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  106068. /**
  106069. * Unbind all instance attributes
  106070. */
  106071. unbindInstanceAttributes(): void;
  106072. /**
  106073. * Release and free the memory of a vertex array object
  106074. * @param vao defines the vertex array object to delete
  106075. */
  106076. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  106077. /** @hidden */
  106078. _releaseBuffer(buffer: DataBuffer): boolean;
  106079. protected _deleteBuffer(buffer: DataBuffer): void;
  106080. /**
  106081. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  106082. * @param instancesBuffer defines the webGL buffer to update and bind
  106083. * @param data defines the data to store in the buffer
  106084. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  106085. */
  106086. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  106087. /**
  106088. * Bind the content of a webGL buffer used with instantiation
  106089. * @param instancesBuffer defines the webGL buffer to bind
  106090. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  106091. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  106092. */
  106093. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  106094. /**
  106095. * Disable the instance attribute corresponding to the name in parameter
  106096. * @param name defines the name of the attribute to disable
  106097. */
  106098. disableInstanceAttributeByName(name: string): void;
  106099. /**
  106100. * Disable the instance attribute corresponding to the location in parameter
  106101. * @param attributeLocation defines the attribute location of the attribute to disable
  106102. */
  106103. disableInstanceAttribute(attributeLocation: number): void;
  106104. /**
  106105. * Disable the attribute corresponding to the location in parameter
  106106. * @param attributeLocation defines the attribute location of the attribute to disable
  106107. */
  106108. disableAttributeByIndex(attributeLocation: number): void;
  106109. /**
  106110. * Send a draw order
  106111. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106112. * @param indexStart defines the starting index
  106113. * @param indexCount defines the number of index to draw
  106114. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106115. */
  106116. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  106117. /**
  106118. * Draw a list of points
  106119. * @param verticesStart defines the index of first vertex to draw
  106120. * @param verticesCount defines the count of vertices to draw
  106121. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106122. */
  106123. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106124. /**
  106125. * Draw a list of unindexed primitives
  106126. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  106127. * @param verticesStart defines the index of first vertex to draw
  106128. * @param verticesCount defines the count of vertices to draw
  106129. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106130. */
  106131. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106132. /**
  106133. * Draw a list of indexed primitives
  106134. * @param fillMode defines the primitive to use
  106135. * @param indexStart defines the starting index
  106136. * @param indexCount defines the number of index to draw
  106137. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106138. */
  106139. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  106140. /**
  106141. * Draw a list of unindexed primitives
  106142. * @param fillMode defines the primitive to use
  106143. * @param verticesStart defines the index of first vertex to draw
  106144. * @param verticesCount defines the count of vertices to draw
  106145. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  106146. */
  106147. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  106148. private _drawMode;
  106149. /** @hidden */
  106150. protected _reportDrawCall(): void;
  106151. /** @hidden */
  106152. _releaseEffect(effect: Effect): void;
  106153. /** @hidden */
  106154. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  106155. /**
  106156. * Create a new effect (used to store vertex/fragment shaders)
  106157. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  106158. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  106159. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  106160. * @param samplers defines an array of string used to represent textures
  106161. * @param defines defines the string containing the defines to use to compile the shaders
  106162. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  106163. * @param onCompiled defines a function to call when the effect creation is successful
  106164. * @param onError defines a function to call when the effect creation has failed
  106165. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  106166. * @returns the new Effect
  106167. */
  106168. 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;
  106169. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  106170. private _compileShader;
  106171. private _compileRawShader;
  106172. /** @hidden */
  106173. _getShaderSource(shader: WebGLShader): Nullable<string>;
  106174. /**
  106175. * Directly creates a webGL program
  106176. * @param pipelineContext defines the pipeline context to attach to
  106177. * @param vertexCode defines the vertex shader code to use
  106178. * @param fragmentCode defines the fragment shader code to use
  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. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106184. /**
  106185. * Creates a webGL program
  106186. * @param pipelineContext defines the pipeline context to attach to
  106187. * @param vertexCode defines the vertex shader code to use
  106188. * @param fragmentCode defines the fragment shader code to use
  106189. * @param defines defines the string containing the defines to use to compile the shaders
  106190. * @param context defines the webGL context to use (if not set, the current one will be used)
  106191. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  106192. * @returns the new webGL program
  106193. */
  106194. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106195. /**
  106196. * Creates a new pipeline context
  106197. * @returns the new pipeline
  106198. */
  106199. createPipelineContext(): IPipelineContext;
  106200. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  106201. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  106202. /** @hidden */
  106203. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  106204. /** @hidden */
  106205. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  106206. /** @hidden */
  106207. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  106208. /**
  106209. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  106210. * @param pipelineContext defines the pipeline context to use
  106211. * @param uniformsNames defines the list of uniform names
  106212. * @returns an array of webGL uniform locations
  106213. */
  106214. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  106215. /**
  106216. * Gets the lsit of active attributes for a given webGL program
  106217. * @param pipelineContext defines the pipeline context to use
  106218. * @param attributesNames defines the list of attribute names to get
  106219. * @returns an array of indices indicating the offset of each attribute
  106220. */
  106221. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  106222. /**
  106223. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  106224. * @param effect defines the effect to activate
  106225. */
  106226. enableEffect(effect: Nullable<Effect>): void;
  106227. /**
  106228. * Set the value of an uniform to a number (int)
  106229. * @param uniform defines the webGL uniform location where to store the value
  106230. * @param value defines the int number to store
  106231. */
  106232. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106233. /**
  106234. * Set the value of an uniform to an array of int32
  106235. * @param uniform defines the webGL uniform location where to store the value
  106236. * @param array defines the array of int32 to store
  106237. */
  106238. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106239. /**
  106240. * Set the value of an uniform to an array of int32 (stored as vec2)
  106241. * @param uniform defines the webGL uniform location where to store the value
  106242. * @param array defines the array of int32 to store
  106243. */
  106244. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106245. /**
  106246. * Set the value of an uniform to an array of int32 (stored as vec3)
  106247. * @param uniform defines the webGL uniform location where to store the value
  106248. * @param array defines the array of int32 to store
  106249. */
  106250. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106251. /**
  106252. * Set the value of an uniform to an array of int32 (stored as vec4)
  106253. * @param uniform defines the webGL uniform location where to store the value
  106254. * @param array defines the array of int32 to store
  106255. */
  106256. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  106257. /**
  106258. * Set the value of an uniform to an array of number
  106259. * @param uniform defines the webGL uniform location where to store the value
  106260. * @param array defines the array of number to store
  106261. */
  106262. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106263. /**
  106264. * Set the value of an uniform to an array of number (stored as vec2)
  106265. * @param uniform defines the webGL uniform location where to store the value
  106266. * @param array defines the array of number to store
  106267. */
  106268. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106269. /**
  106270. * Set the value of an uniform to an array of number (stored as vec3)
  106271. * @param uniform defines the webGL uniform location where to store the value
  106272. * @param array defines the array of number to store
  106273. */
  106274. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106275. /**
  106276. * Set the value of an uniform to an array of number (stored as vec4)
  106277. * @param uniform defines the webGL uniform location where to store the value
  106278. * @param array defines the array of number to store
  106279. */
  106280. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): void;
  106281. /**
  106282. * Set the value of an uniform to an array of float32 (stored as matrices)
  106283. * @param uniform defines the webGL uniform location where to store the value
  106284. * @param matrices defines the array of float32 to store
  106285. */
  106286. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  106287. /**
  106288. * Set the value of an uniform to a matrix (3x3)
  106289. * @param uniform defines the webGL uniform location where to store the value
  106290. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  106291. */
  106292. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106293. /**
  106294. * Set the value of an uniform to a matrix (2x2)
  106295. * @param uniform defines the webGL uniform location where to store the value
  106296. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  106297. */
  106298. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  106299. /**
  106300. * Set the value of an uniform to a number (float)
  106301. * @param uniform defines the webGL uniform location where to store the value
  106302. * @param value defines the float number to store
  106303. */
  106304. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  106305. /**
  106306. * Set the value of an uniform to a vec2
  106307. * @param uniform defines the webGL uniform location where to store the value
  106308. * @param x defines the 1st component of the value
  106309. * @param y defines the 2nd component of the value
  106310. */
  106311. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  106312. /**
  106313. * Set the value of an uniform to a vec3
  106314. * @param uniform defines the webGL uniform location where to store the value
  106315. * @param x defines the 1st component of the value
  106316. * @param y defines the 2nd component of the value
  106317. * @param z defines the 3rd component of the value
  106318. */
  106319. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  106320. /**
  106321. * Set the value of an uniform to a vec4
  106322. * @param uniform defines the webGL uniform location where to store the value
  106323. * @param x defines the 1st component of the value
  106324. * @param y defines the 2nd component of the value
  106325. * @param z defines the 3rd component of the value
  106326. * @param w defines the 4th component of the value
  106327. */
  106328. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  106329. /**
  106330. * Apply all cached states (depth, culling, stencil and alpha)
  106331. */
  106332. applyStates(): void;
  106333. /**
  106334. * Enable or disable color writing
  106335. * @param enable defines the state to set
  106336. */
  106337. setColorWrite(enable: boolean): void;
  106338. /**
  106339. * Gets a boolean indicating if color writing is enabled
  106340. * @returns the current color writing state
  106341. */
  106342. getColorWrite(): boolean;
  106343. /**
  106344. * Gets the depth culling state manager
  106345. */
  106346. get depthCullingState(): DepthCullingState;
  106347. /**
  106348. * Gets the alpha state manager
  106349. */
  106350. get alphaState(): AlphaState;
  106351. /**
  106352. * Gets the stencil state manager
  106353. */
  106354. get stencilState(): StencilState;
  106355. /**
  106356. * Clears the list of texture accessible through engine.
  106357. * This can help preventing texture load conflict due to name collision.
  106358. */
  106359. clearInternalTexturesCache(): void;
  106360. /**
  106361. * Force the entire cache to be cleared
  106362. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  106363. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  106364. */
  106365. wipeCaches(bruteForce?: boolean): void;
  106366. /** @hidden */
  106367. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  106368. min: number;
  106369. mag: number;
  106370. };
  106371. /** @hidden */
  106372. _createTexture(): WebGLTexture;
  106373. /**
  106374. * Usually called from Texture.ts.
  106375. * Passed information to create a WebGLTexture
  106376. * @param url defines a value which contains one of the following:
  106377. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  106378. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  106379. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  106380. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  106381. * @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)
  106382. * @param scene needed for loading to the correct scene
  106383. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  106384. * @param onLoad optional callback to be called upon successful completion
  106385. * @param onError optional callback to be called upon failure
  106386. * @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
  106387. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  106388. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  106389. * @param forcedExtension defines the extension to use to pick the right loader
  106390. * @param mimeType defines an optional mime type
  106391. * @returns a InternalTexture for assignment back into BABYLON.Texture
  106392. */
  106393. 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;
  106394. /**
  106395. * Loads an image as an HTMLImageElement.
  106396. * @param input url string, ArrayBuffer, or Blob to load
  106397. * @param onLoad callback called when the image successfully loads
  106398. * @param onError callback called when the image fails to load
  106399. * @param offlineProvider offline provider for caching
  106400. * @param mimeType optional mime type
  106401. * @returns the HTMLImageElement of the loaded image
  106402. * @hidden
  106403. */
  106404. 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>;
  106405. /**
  106406. * @hidden
  106407. */
  106408. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  106409. /**
  106410. * Creates a raw texture
  106411. * @param data defines the data to store in the texture
  106412. * @param width defines the width of the texture
  106413. * @param height defines the height of the texture
  106414. * @param format defines the format of the data
  106415. * @param generateMipMaps defines if the engine should generate the mip levels
  106416. * @param invertY defines if data must be stored with Y axis inverted
  106417. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  106418. * @param compression defines the compression used (null by default)
  106419. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  106420. * @returns the raw texture inside an InternalTexture
  106421. */
  106422. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, type?: number): InternalTexture;
  106423. /**
  106424. * Creates a new raw cube texture
  106425. * @param data defines the array of data to use to create each face
  106426. * @param size defines the size of the textures
  106427. * @param format defines the format of the data
  106428. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  106429. * @param generateMipMaps defines if the engine should generate the mip levels
  106430. * @param invertY defines if data must be stored with Y axis inverted
  106431. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106432. * @param compression defines the compression used (null by default)
  106433. * @returns the cube texture as an InternalTexture
  106434. */
  106435. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>): InternalTexture;
  106436. /**
  106437. * Creates a new raw 3D texture
  106438. * @param data defines the data used to create the texture
  106439. * @param width defines the width of the texture
  106440. * @param height defines the height of the texture
  106441. * @param depth defines the depth of the texture
  106442. * @param format defines the format of the texture
  106443. * @param generateMipMaps defines if the engine must generate mip levels
  106444. * @param invertY defines if data must be stored with Y axis inverted
  106445. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106446. * @param compression defines the compressed used (can be null)
  106447. * @param textureType defines the compressed used (can be null)
  106448. * @returns a new raw 3D texture (stored in an InternalTexture)
  106449. */
  106450. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106451. /**
  106452. * Creates a new raw 2D array texture
  106453. * @param data defines the data used to create the texture
  106454. * @param width defines the width of the texture
  106455. * @param height defines the height of the texture
  106456. * @param depth defines the number of layers of the texture
  106457. * @param format defines the format of the texture
  106458. * @param generateMipMaps defines if the engine must generate mip levels
  106459. * @param invertY defines if data must be stored with Y axis inverted
  106460. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  106461. * @param compression defines the compressed used (can be null)
  106462. * @param textureType defines the compressed used (can be null)
  106463. * @returns a new raw 2D array texture (stored in an InternalTexture)
  106464. */
  106465. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression?: Nullable<string>, textureType?: number): InternalTexture;
  106466. private _unpackFlipYCached;
  106467. /**
  106468. * In case you are sharing the context with other applications, it might
  106469. * be interested to not cache the unpack flip y state to ensure a consistent
  106470. * value would be set.
  106471. */
  106472. enableUnpackFlipYCached: boolean;
  106473. /** @hidden */
  106474. _unpackFlipY(value: boolean): void;
  106475. /** @hidden */
  106476. _getUnpackAlignement(): number;
  106477. private _getTextureTarget;
  106478. /**
  106479. * Update the sampling mode of a given texture
  106480. * @param samplingMode defines the required sampling mode
  106481. * @param texture defines the texture to update
  106482. * @param generateMipMaps defines whether to generate mipmaps for the texture
  106483. */
  106484. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  106485. /**
  106486. * Update the sampling mode of a given texture
  106487. * @param texture defines the texture to update
  106488. * @param wrapU defines the texture wrap mode of the u coordinates
  106489. * @param wrapV defines the texture wrap mode of the v coordinates
  106490. * @param wrapR defines the texture wrap mode of the r coordinates
  106491. */
  106492. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  106493. /** @hidden */
  106494. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  106495. width: number;
  106496. height: number;
  106497. layers?: number;
  106498. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  106499. /** @hidden */
  106500. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106501. /** @hidden */
  106502. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  106503. /**
  106504. * Update a portion of an internal texture
  106505. * @param texture defines the texture to update
  106506. * @param imageData defines the data to store into the texture
  106507. * @param xOffset defines the x coordinates of the update rectangle
  106508. * @param yOffset defines the y coordinates of the update rectangle
  106509. * @param width defines the width of the update rectangle
  106510. * @param height defines the height of the update rectangle
  106511. * @param faceIndex defines the face index if texture is a cube (0 by default)
  106512. * @param lod defines the lod level to update (0 by default)
  106513. */
  106514. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  106515. /** @hidden */
  106516. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  106517. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  106518. private _prepareWebGLTexture;
  106519. /** @hidden */
  106520. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  106521. private _getDepthStencilBuffer;
  106522. /** @hidden */
  106523. _releaseFramebufferObjects(texture: InternalTexture): void;
  106524. /** @hidden */
  106525. _releaseTexture(texture: InternalTexture): void;
  106526. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  106527. protected _setProgram(program: WebGLProgram): void;
  106528. protected _boundUniforms: {
  106529. [key: number]: WebGLUniformLocation;
  106530. };
  106531. /**
  106532. * Binds an effect to the webGL context
  106533. * @param effect defines the effect to bind
  106534. */
  106535. bindSamplers(effect: Effect): void;
  106536. private _activateCurrentTexture;
  106537. /** @hidden */
  106538. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  106539. /** @hidden */
  106540. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  106541. /**
  106542. * Unbind all textures from the webGL context
  106543. */
  106544. unbindAllTextures(): void;
  106545. /**
  106546. * Sets a texture to the according uniform.
  106547. * @param channel The texture channel
  106548. * @param uniform The uniform to set
  106549. * @param texture The texture to apply
  106550. */
  106551. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  106552. private _bindSamplerUniformToChannel;
  106553. private _getTextureWrapMode;
  106554. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  106555. /**
  106556. * Sets an array of texture to the webGL context
  106557. * @param channel defines the channel where the texture array must be set
  106558. * @param uniform defines the associated uniform location
  106559. * @param textures defines the array of textures to bind
  106560. */
  106561. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  106562. /** @hidden */
  106563. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  106564. private _setTextureParameterFloat;
  106565. private _setTextureParameterInteger;
  106566. /**
  106567. * Unbind all vertex attributes from the webGL context
  106568. */
  106569. unbindAllAttributes(): void;
  106570. /**
  106571. * 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
  106572. */
  106573. releaseEffects(): void;
  106574. /**
  106575. * Dispose and release all associated resources
  106576. */
  106577. dispose(): void;
  106578. /**
  106579. * Attach a new callback raised when context lost event is fired
  106580. * @param callback defines the callback to call
  106581. */
  106582. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106583. /**
  106584. * Attach a new callback raised when context restored event is fired
  106585. * @param callback defines the callback to call
  106586. */
  106587. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  106588. /**
  106589. * Get the current error code of the webGL context
  106590. * @returns the error code
  106591. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  106592. */
  106593. getError(): number;
  106594. private _canRenderToFloatFramebuffer;
  106595. private _canRenderToHalfFloatFramebuffer;
  106596. private _canRenderToFramebuffer;
  106597. /** @hidden */
  106598. _getWebGLTextureType(type: number): number;
  106599. /** @hidden */
  106600. _getInternalFormat(format: number): number;
  106601. /** @hidden */
  106602. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  106603. /** @hidden */
  106604. _getRGBAMultiSampleBufferFormat(type: number): number;
  106605. /** @hidden */
  106606. _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;
  106607. /**
  106608. * Loads a file from a url
  106609. * @param url url to load
  106610. * @param onSuccess callback called when the file successfully loads
  106611. * @param onProgress callback called while file is loading (if the server supports this mode)
  106612. * @param offlineProvider defines the offline provider for caching
  106613. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  106614. * @param onError callback called when the file fails to load
  106615. * @returns a file request object
  106616. * @hidden
  106617. */
  106618. 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;
  106619. /**
  106620. * Reads pixels from the current frame buffer. Please note that this function can be slow
  106621. * @param x defines the x coordinate of the rectangle where pixels must be read
  106622. * @param y defines the y coordinate of the rectangle where pixels must be read
  106623. * @param width defines the width of the rectangle where pixels must be read
  106624. * @param height defines the height of the rectangle where pixels must be read
  106625. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  106626. * @returns a Uint8Array containing RGBA colors
  106627. */
  106628. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  106629. private static _isSupported;
  106630. /**
  106631. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  106632. * @returns true if the engine can be created
  106633. * @ignorenaming
  106634. */
  106635. static isSupported(): boolean;
  106636. /**
  106637. * Find the next highest power of two.
  106638. * @param x Number to start search from.
  106639. * @return Next highest power of two.
  106640. */
  106641. static CeilingPOT(x: number): number;
  106642. /**
  106643. * Find the next lowest power of two.
  106644. * @param x Number to start search from.
  106645. * @return Next lowest power of two.
  106646. */
  106647. static FloorPOT(x: number): number;
  106648. /**
  106649. * Find the nearest power of two.
  106650. * @param x Number to start search from.
  106651. * @return Next nearest power of two.
  106652. */
  106653. static NearestPOT(x: number): number;
  106654. /**
  106655. * Get the closest exponent of two
  106656. * @param value defines the value to approximate
  106657. * @param max defines the maximum value to return
  106658. * @param mode defines how to define the closest value
  106659. * @returns closest exponent of two of the given value
  106660. */
  106661. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  106662. /**
  106663. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  106664. * @param func - the function to be called
  106665. * @param requester - the object that will request the next frame. Falls back to window.
  106666. * @returns frame number
  106667. */
  106668. static QueueNewFrame(func: () => void, requester?: any): number;
  106669. /**
  106670. * Gets host document
  106671. * @returns the host document object
  106672. */
  106673. getHostDocument(): Nullable<Document>;
  106674. }
  106675. }
  106676. declare module BABYLON {
  106677. /**
  106678. * Class representing spherical harmonics coefficients to the 3rd degree
  106679. */
  106680. export class SphericalHarmonics {
  106681. /**
  106682. * Defines whether or not the harmonics have been prescaled for rendering.
  106683. */
  106684. preScaled: boolean;
  106685. /**
  106686. * The l0,0 coefficients of the spherical harmonics
  106687. */
  106688. l00: Vector3;
  106689. /**
  106690. * The l1,-1 coefficients of the spherical harmonics
  106691. */
  106692. l1_1: Vector3;
  106693. /**
  106694. * The l1,0 coefficients of the spherical harmonics
  106695. */
  106696. l10: Vector3;
  106697. /**
  106698. * The l1,1 coefficients of the spherical harmonics
  106699. */
  106700. l11: Vector3;
  106701. /**
  106702. * The l2,-2 coefficients of the spherical harmonics
  106703. */
  106704. l2_2: Vector3;
  106705. /**
  106706. * The l2,-1 coefficients of the spherical harmonics
  106707. */
  106708. l2_1: Vector3;
  106709. /**
  106710. * The l2,0 coefficients of the spherical harmonics
  106711. */
  106712. l20: Vector3;
  106713. /**
  106714. * The l2,1 coefficients of the spherical harmonics
  106715. */
  106716. l21: Vector3;
  106717. /**
  106718. * The l2,2 coefficients of the spherical harmonics
  106719. */
  106720. l22: Vector3;
  106721. /**
  106722. * Adds a light to the spherical harmonics
  106723. * @param direction the direction of the light
  106724. * @param color the color of the light
  106725. * @param deltaSolidAngle the delta solid angle of the light
  106726. */
  106727. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  106728. /**
  106729. * Scales the spherical harmonics by the given amount
  106730. * @param scale the amount to scale
  106731. */
  106732. scaleInPlace(scale: number): void;
  106733. /**
  106734. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  106735. *
  106736. * ```
  106737. * E_lm = A_l * L_lm
  106738. * ```
  106739. *
  106740. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  106741. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  106742. * the scaling factors are given in equation 9.
  106743. */
  106744. convertIncidentRadianceToIrradiance(): void;
  106745. /**
  106746. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  106747. *
  106748. * ```
  106749. * L = (1/pi) * E * rho
  106750. * ```
  106751. *
  106752. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  106753. */
  106754. convertIrradianceToLambertianRadiance(): void;
  106755. /**
  106756. * Integrates the reconstruction coefficients directly in to the SH preventing further
  106757. * required operations at run time.
  106758. *
  106759. * This is simply done by scaling back the SH with Ylm constants parameter.
  106760. * The trigonometric part being applied by the shader at run time.
  106761. */
  106762. preScaleForRendering(): void;
  106763. /**
  106764. * Constructs a spherical harmonics from an array.
  106765. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  106766. * @returns the spherical harmonics
  106767. */
  106768. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  106769. /**
  106770. * Gets the spherical harmonics from polynomial
  106771. * @param polynomial the spherical polynomial
  106772. * @returns the spherical harmonics
  106773. */
  106774. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  106775. }
  106776. /**
  106777. * Class representing spherical polynomial coefficients to the 3rd degree
  106778. */
  106779. export class SphericalPolynomial {
  106780. private _harmonics;
  106781. /**
  106782. * The spherical harmonics used to create the polynomials.
  106783. */
  106784. get preScaledHarmonics(): SphericalHarmonics;
  106785. /**
  106786. * The x coefficients of the spherical polynomial
  106787. */
  106788. x: Vector3;
  106789. /**
  106790. * The y coefficients of the spherical polynomial
  106791. */
  106792. y: Vector3;
  106793. /**
  106794. * The z coefficients of the spherical polynomial
  106795. */
  106796. z: Vector3;
  106797. /**
  106798. * The xx coefficients of the spherical polynomial
  106799. */
  106800. xx: Vector3;
  106801. /**
  106802. * The yy coefficients of the spherical polynomial
  106803. */
  106804. yy: Vector3;
  106805. /**
  106806. * The zz coefficients of the spherical polynomial
  106807. */
  106808. zz: Vector3;
  106809. /**
  106810. * The xy coefficients of the spherical polynomial
  106811. */
  106812. xy: Vector3;
  106813. /**
  106814. * The yz coefficients of the spherical polynomial
  106815. */
  106816. yz: Vector3;
  106817. /**
  106818. * The zx coefficients of the spherical polynomial
  106819. */
  106820. zx: Vector3;
  106821. /**
  106822. * Adds an ambient color to the spherical polynomial
  106823. * @param color the color to add
  106824. */
  106825. addAmbient(color: Color3): void;
  106826. /**
  106827. * Scales the spherical polynomial by the given amount
  106828. * @param scale the amount to scale
  106829. */
  106830. scaleInPlace(scale: number): void;
  106831. /**
  106832. * Gets the spherical polynomial from harmonics
  106833. * @param harmonics the spherical harmonics
  106834. * @returns the spherical polynomial
  106835. */
  106836. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  106837. /**
  106838. * Constructs a spherical polynomial from an array.
  106839. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  106840. * @returns the spherical polynomial
  106841. */
  106842. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  106843. }
  106844. }
  106845. declare module BABYLON {
  106846. /**
  106847. * Defines the source of the internal texture
  106848. */
  106849. export enum InternalTextureSource {
  106850. /**
  106851. * The source of the texture data is unknown
  106852. */
  106853. Unknown = 0,
  106854. /**
  106855. * Texture data comes from an URL
  106856. */
  106857. Url = 1,
  106858. /**
  106859. * Texture data is only used for temporary storage
  106860. */
  106861. Temp = 2,
  106862. /**
  106863. * Texture data comes from raw data (ArrayBuffer)
  106864. */
  106865. Raw = 3,
  106866. /**
  106867. * Texture content is dynamic (video or dynamic texture)
  106868. */
  106869. Dynamic = 4,
  106870. /**
  106871. * Texture content is generated by rendering to it
  106872. */
  106873. RenderTarget = 5,
  106874. /**
  106875. * Texture content is part of a multi render target process
  106876. */
  106877. MultiRenderTarget = 6,
  106878. /**
  106879. * Texture data comes from a cube data file
  106880. */
  106881. Cube = 7,
  106882. /**
  106883. * Texture data comes from a raw cube data
  106884. */
  106885. CubeRaw = 8,
  106886. /**
  106887. * Texture data come from a prefiltered cube data file
  106888. */
  106889. CubePrefiltered = 9,
  106890. /**
  106891. * Texture content is raw 3D data
  106892. */
  106893. Raw3D = 10,
  106894. /**
  106895. * Texture content is raw 2D array data
  106896. */
  106897. Raw2DArray = 11,
  106898. /**
  106899. * Texture content is a depth texture
  106900. */
  106901. Depth = 12,
  106902. /**
  106903. * Texture data comes from a raw cube data encoded with RGBD
  106904. */
  106905. CubeRawRGBD = 13
  106906. }
  106907. /**
  106908. * Class used to store data associated with WebGL texture data for the engine
  106909. * This class should not be used directly
  106910. */
  106911. export class InternalTexture {
  106912. /** @hidden */
  106913. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  106914. /**
  106915. * Defines if the texture is ready
  106916. */
  106917. isReady: boolean;
  106918. /**
  106919. * Defines if the texture is a cube texture
  106920. */
  106921. isCube: boolean;
  106922. /**
  106923. * Defines if the texture contains 3D data
  106924. */
  106925. is3D: boolean;
  106926. /**
  106927. * Defines if the texture contains 2D array data
  106928. */
  106929. is2DArray: boolean;
  106930. /**
  106931. * Defines if the texture contains multiview data
  106932. */
  106933. isMultiview: boolean;
  106934. /**
  106935. * Gets the URL used to load this texture
  106936. */
  106937. url: string;
  106938. /**
  106939. * Gets the sampling mode of the texture
  106940. */
  106941. samplingMode: number;
  106942. /**
  106943. * Gets a boolean indicating if the texture needs mipmaps generation
  106944. */
  106945. generateMipMaps: boolean;
  106946. /**
  106947. * Gets the number of samples used by the texture (WebGL2+ only)
  106948. */
  106949. samples: number;
  106950. /**
  106951. * Gets the type of the texture (int, float...)
  106952. */
  106953. type: number;
  106954. /**
  106955. * Gets the format of the texture (RGB, RGBA...)
  106956. */
  106957. format: number;
  106958. /**
  106959. * Observable called when the texture is loaded
  106960. */
  106961. onLoadedObservable: Observable<InternalTexture>;
  106962. /**
  106963. * Gets the width of the texture
  106964. */
  106965. width: number;
  106966. /**
  106967. * Gets the height of the texture
  106968. */
  106969. height: number;
  106970. /**
  106971. * Gets the depth of the texture
  106972. */
  106973. depth: number;
  106974. /**
  106975. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  106976. */
  106977. baseWidth: number;
  106978. /**
  106979. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  106980. */
  106981. baseHeight: number;
  106982. /**
  106983. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  106984. */
  106985. baseDepth: number;
  106986. /**
  106987. * Gets a boolean indicating if the texture is inverted on Y axis
  106988. */
  106989. invertY: boolean;
  106990. /** @hidden */
  106991. _invertVScale: boolean;
  106992. /** @hidden */
  106993. _associatedChannel: number;
  106994. /** @hidden */
  106995. _source: InternalTextureSource;
  106996. /** @hidden */
  106997. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  106998. /** @hidden */
  106999. _bufferView: Nullable<ArrayBufferView>;
  107000. /** @hidden */
  107001. _bufferViewArray: Nullable<ArrayBufferView[]>;
  107002. /** @hidden */
  107003. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  107004. /** @hidden */
  107005. _size: number;
  107006. /** @hidden */
  107007. _extension: string;
  107008. /** @hidden */
  107009. _files: Nullable<string[]>;
  107010. /** @hidden */
  107011. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  107012. /** @hidden */
  107013. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  107014. /** @hidden */
  107015. _framebuffer: Nullable<WebGLFramebuffer>;
  107016. /** @hidden */
  107017. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  107018. /** @hidden */
  107019. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  107020. /** @hidden */
  107021. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  107022. /** @hidden */
  107023. _attachments: Nullable<number[]>;
  107024. /** @hidden */
  107025. _cachedCoordinatesMode: Nullable<number>;
  107026. /** @hidden */
  107027. _cachedWrapU: Nullable<number>;
  107028. /** @hidden */
  107029. _cachedWrapV: Nullable<number>;
  107030. /** @hidden */
  107031. _cachedWrapR: Nullable<number>;
  107032. /** @hidden */
  107033. _cachedAnisotropicFilteringLevel: Nullable<number>;
  107034. /** @hidden */
  107035. _isDisabled: boolean;
  107036. /** @hidden */
  107037. _compression: Nullable<string>;
  107038. /** @hidden */
  107039. _generateStencilBuffer: boolean;
  107040. /** @hidden */
  107041. _generateDepthBuffer: boolean;
  107042. /** @hidden */
  107043. _comparisonFunction: number;
  107044. /** @hidden */
  107045. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  107046. /** @hidden */
  107047. _lodGenerationScale: number;
  107048. /** @hidden */
  107049. _lodGenerationOffset: number;
  107050. /** @hidden */
  107051. _depthStencilTexture: Nullable<InternalTexture>;
  107052. /** @hidden */
  107053. _colorTextureArray: Nullable<WebGLTexture>;
  107054. /** @hidden */
  107055. _depthStencilTextureArray: Nullable<WebGLTexture>;
  107056. /** @hidden */
  107057. _lodTextureHigh: Nullable<BaseTexture>;
  107058. /** @hidden */
  107059. _lodTextureMid: Nullable<BaseTexture>;
  107060. /** @hidden */
  107061. _lodTextureLow: Nullable<BaseTexture>;
  107062. /** @hidden */
  107063. _isRGBD: boolean;
  107064. /** @hidden */
  107065. _linearSpecularLOD: boolean;
  107066. /** @hidden */
  107067. _irradianceTexture: Nullable<BaseTexture>;
  107068. /** @hidden */
  107069. _webGLTexture: Nullable<WebGLTexture>;
  107070. /** @hidden */
  107071. _references: number;
  107072. private _engine;
  107073. /**
  107074. * Gets the Engine the texture belongs to.
  107075. * @returns The babylon engine
  107076. */
  107077. getEngine(): ThinEngine;
  107078. /**
  107079. * Gets the data source type of the texture
  107080. */
  107081. get source(): InternalTextureSource;
  107082. /**
  107083. * Creates a new InternalTexture
  107084. * @param engine defines the engine to use
  107085. * @param source defines the type of data that will be used
  107086. * @param delayAllocation if the texture allocation should be delayed (default: false)
  107087. */
  107088. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  107089. /**
  107090. * Increments the number of references (ie. the number of Texture that point to it)
  107091. */
  107092. incrementReferences(): void;
  107093. /**
  107094. * Change the size of the texture (not the size of the content)
  107095. * @param width defines the new width
  107096. * @param height defines the new height
  107097. * @param depth defines the new depth (1 by default)
  107098. */
  107099. updateSize(width: int, height: int, depth?: int): void;
  107100. /** @hidden */
  107101. _rebuild(): void;
  107102. /** @hidden */
  107103. _swapAndDie(target: InternalTexture): void;
  107104. /**
  107105. * Dispose the current allocated resources
  107106. */
  107107. dispose(): void;
  107108. }
  107109. }
  107110. declare module BABYLON {
  107111. /**
  107112. * Class used to work with sound analyzer using fast fourier transform (FFT)
  107113. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107114. */
  107115. export class Analyser {
  107116. /**
  107117. * Gets or sets the smoothing
  107118. * @ignorenaming
  107119. */
  107120. SMOOTHING: number;
  107121. /**
  107122. * Gets or sets the FFT table size
  107123. * @ignorenaming
  107124. */
  107125. FFT_SIZE: number;
  107126. /**
  107127. * Gets or sets the bar graph amplitude
  107128. * @ignorenaming
  107129. */
  107130. BARGRAPHAMPLITUDE: number;
  107131. /**
  107132. * Gets or sets the position of the debug canvas
  107133. * @ignorenaming
  107134. */
  107135. DEBUGCANVASPOS: {
  107136. x: number;
  107137. y: number;
  107138. };
  107139. /**
  107140. * Gets or sets the debug canvas size
  107141. * @ignorenaming
  107142. */
  107143. DEBUGCANVASSIZE: {
  107144. width: number;
  107145. height: number;
  107146. };
  107147. private _byteFreqs;
  107148. private _byteTime;
  107149. private _floatFreqs;
  107150. private _webAudioAnalyser;
  107151. private _debugCanvas;
  107152. private _debugCanvasContext;
  107153. private _scene;
  107154. private _registerFunc;
  107155. private _audioEngine;
  107156. /**
  107157. * Creates a new analyser
  107158. * @param scene defines hosting scene
  107159. */
  107160. constructor(scene: Scene);
  107161. /**
  107162. * Get the number of data values you will have to play with for the visualization
  107163. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  107164. * @returns a number
  107165. */
  107166. getFrequencyBinCount(): number;
  107167. /**
  107168. * Gets the current frequency data as a byte array
  107169. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107170. * @returns a Uint8Array
  107171. */
  107172. getByteFrequencyData(): Uint8Array;
  107173. /**
  107174. * Gets the current waveform as a byte array
  107175. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  107176. * @returns a Uint8Array
  107177. */
  107178. getByteTimeDomainData(): Uint8Array;
  107179. /**
  107180. * Gets the current frequency data as a float array
  107181. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  107182. * @returns a Float32Array
  107183. */
  107184. getFloatFrequencyData(): Float32Array;
  107185. /**
  107186. * Renders the debug canvas
  107187. */
  107188. drawDebugCanvas(): void;
  107189. /**
  107190. * Stops rendering the debug canvas and removes it
  107191. */
  107192. stopDebugCanvas(): void;
  107193. /**
  107194. * Connects two audio nodes
  107195. * @param inputAudioNode defines first node to connect
  107196. * @param outputAudioNode defines second node to connect
  107197. */
  107198. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  107199. /**
  107200. * Releases all associated resources
  107201. */
  107202. dispose(): void;
  107203. }
  107204. }
  107205. declare module BABYLON {
  107206. /**
  107207. * This represents an audio engine and it is responsible
  107208. * to play, synchronize and analyse sounds throughout the application.
  107209. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107210. */
  107211. export interface IAudioEngine extends IDisposable {
  107212. /**
  107213. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107214. */
  107215. readonly canUseWebAudio: boolean;
  107216. /**
  107217. * Gets the current AudioContext if available.
  107218. */
  107219. readonly audioContext: Nullable<AudioContext>;
  107220. /**
  107221. * The master gain node defines the global audio volume of your audio engine.
  107222. */
  107223. readonly masterGain: GainNode;
  107224. /**
  107225. * Gets whether or not mp3 are supported by your browser.
  107226. */
  107227. readonly isMP3supported: boolean;
  107228. /**
  107229. * Gets whether or not ogg are supported by your browser.
  107230. */
  107231. readonly isOGGsupported: boolean;
  107232. /**
  107233. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107234. * @ignoreNaming
  107235. */
  107236. WarnedWebAudioUnsupported: boolean;
  107237. /**
  107238. * Defines if the audio engine relies on a custom unlocked button.
  107239. * In this case, the embedded button will not be displayed.
  107240. */
  107241. useCustomUnlockedButton: boolean;
  107242. /**
  107243. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  107244. */
  107245. readonly unlocked: boolean;
  107246. /**
  107247. * Event raised when audio has been unlocked on the browser.
  107248. */
  107249. onAudioUnlockedObservable: Observable<AudioEngine>;
  107250. /**
  107251. * Event raised when audio has been locked on the browser.
  107252. */
  107253. onAudioLockedObservable: Observable<AudioEngine>;
  107254. /**
  107255. * Flags the audio engine in Locked state.
  107256. * This happens due to new browser policies preventing audio to autoplay.
  107257. */
  107258. lock(): void;
  107259. /**
  107260. * Unlocks the audio engine once a user action has been done on the dom.
  107261. * This is helpful to resume play once browser policies have been satisfied.
  107262. */
  107263. unlock(): void;
  107264. /**
  107265. * Gets the global volume sets on the master gain.
  107266. * @returns the global volume if set or -1 otherwise
  107267. */
  107268. getGlobalVolume(): number;
  107269. /**
  107270. * Sets the global volume of your experience (sets on the master gain).
  107271. * @param newVolume Defines the new global volume of the application
  107272. */
  107273. setGlobalVolume(newVolume: number): void;
  107274. /**
  107275. * Connect the audio engine to an audio analyser allowing some amazing
  107276. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107278. * @param analyser The analyser to connect to the engine
  107279. */
  107280. connectToAnalyser(analyser: Analyser): void;
  107281. }
  107282. /**
  107283. * This represents the default audio engine used in babylon.
  107284. * It is responsible to play, synchronize and analyse sounds throughout the application.
  107285. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  107286. */
  107287. export class AudioEngine implements IAudioEngine {
  107288. private _audioContext;
  107289. private _audioContextInitialized;
  107290. private _muteButton;
  107291. private _hostElement;
  107292. /**
  107293. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  107294. */
  107295. canUseWebAudio: boolean;
  107296. /**
  107297. * The master gain node defines the global audio volume of your audio engine.
  107298. */
  107299. masterGain: GainNode;
  107300. /**
  107301. * Defines if Babylon should emit a warning if WebAudio is not supported.
  107302. * @ignoreNaming
  107303. */
  107304. WarnedWebAudioUnsupported: boolean;
  107305. /**
  107306. * Gets whether or not mp3 are supported by your browser.
  107307. */
  107308. isMP3supported: boolean;
  107309. /**
  107310. * Gets whether or not ogg are supported by your browser.
  107311. */
  107312. isOGGsupported: boolean;
  107313. /**
  107314. * Gets whether audio has been unlocked on the device.
  107315. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  107316. * a user interaction has happened.
  107317. */
  107318. unlocked: boolean;
  107319. /**
  107320. * Defines if the audio engine relies on a custom unlocked button.
  107321. * In this case, the embedded button will not be displayed.
  107322. */
  107323. useCustomUnlockedButton: boolean;
  107324. /**
  107325. * Event raised when audio has been unlocked on the browser.
  107326. */
  107327. onAudioUnlockedObservable: Observable<AudioEngine>;
  107328. /**
  107329. * Event raised when audio has been locked on the browser.
  107330. */
  107331. onAudioLockedObservable: Observable<AudioEngine>;
  107332. /**
  107333. * Gets the current AudioContext if available.
  107334. */
  107335. get audioContext(): Nullable<AudioContext>;
  107336. private _connectedAnalyser;
  107337. /**
  107338. * Instantiates a new audio engine.
  107339. *
  107340. * There should be only one per page as some browsers restrict the number
  107341. * of audio contexts you can create.
  107342. * @param hostElement defines the host element where to display the mute icon if necessary
  107343. */
  107344. constructor(hostElement?: Nullable<HTMLElement>);
  107345. /**
  107346. * Flags the audio engine in Locked state.
  107347. * This happens due to new browser policies preventing audio to autoplay.
  107348. */
  107349. lock(): void;
  107350. /**
  107351. * Unlocks the audio engine once a user action has been done on the dom.
  107352. * This is helpful to resume play once browser policies have been satisfied.
  107353. */
  107354. unlock(): void;
  107355. private _resumeAudioContext;
  107356. private _initializeAudioContext;
  107357. private _tryToRun;
  107358. private _triggerRunningState;
  107359. private _triggerSuspendedState;
  107360. private _displayMuteButton;
  107361. private _moveButtonToTopLeft;
  107362. private _onResize;
  107363. private _hideMuteButton;
  107364. /**
  107365. * Destroy and release the resources associated with the audio ccontext.
  107366. */
  107367. dispose(): void;
  107368. /**
  107369. * Gets the global volume sets on the master gain.
  107370. * @returns the global volume if set or -1 otherwise
  107371. */
  107372. getGlobalVolume(): number;
  107373. /**
  107374. * Sets the global volume of your experience (sets on the master gain).
  107375. * @param newVolume Defines the new global volume of the application
  107376. */
  107377. setGlobalVolume(newVolume: number): void;
  107378. /**
  107379. * Connect the audio engine to an audio analyser allowing some amazing
  107380. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  107381. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  107382. * @param analyser The analyser to connect to the engine
  107383. */
  107384. connectToAnalyser(analyser: Analyser): void;
  107385. }
  107386. }
  107387. declare module BABYLON {
  107388. /**
  107389. * Interface used to present a loading screen while loading a scene
  107390. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107391. */
  107392. export interface ILoadingScreen {
  107393. /**
  107394. * Function called to display the loading screen
  107395. */
  107396. displayLoadingUI: () => void;
  107397. /**
  107398. * Function called to hide the loading screen
  107399. */
  107400. hideLoadingUI: () => void;
  107401. /**
  107402. * Gets or sets the color to use for the background
  107403. */
  107404. loadingUIBackgroundColor: string;
  107405. /**
  107406. * Gets or sets the text to display while loading
  107407. */
  107408. loadingUIText: string;
  107409. }
  107410. /**
  107411. * Class used for the default loading screen
  107412. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  107413. */
  107414. export class DefaultLoadingScreen implements ILoadingScreen {
  107415. private _renderingCanvas;
  107416. private _loadingText;
  107417. private _loadingDivBackgroundColor;
  107418. private _loadingDiv;
  107419. private _loadingTextDiv;
  107420. /** Gets or sets the logo url to use for the default loading screen */
  107421. static DefaultLogoUrl: string;
  107422. /** Gets or sets the spinner url to use for the default loading screen */
  107423. static DefaultSpinnerUrl: string;
  107424. /**
  107425. * Creates a new default loading screen
  107426. * @param _renderingCanvas defines the canvas used to render the scene
  107427. * @param _loadingText defines the default text to display
  107428. * @param _loadingDivBackgroundColor defines the default background color
  107429. */
  107430. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  107431. /**
  107432. * Function called to display the loading screen
  107433. */
  107434. displayLoadingUI(): void;
  107435. /**
  107436. * Function called to hide the loading screen
  107437. */
  107438. hideLoadingUI(): void;
  107439. /**
  107440. * Gets or sets the text to display while loading
  107441. */
  107442. set loadingUIText(text: string);
  107443. get loadingUIText(): string;
  107444. /**
  107445. * Gets or sets the color to use for the background
  107446. */
  107447. get loadingUIBackgroundColor(): string;
  107448. set loadingUIBackgroundColor(color: string);
  107449. private _resizeLoadingUI;
  107450. }
  107451. }
  107452. declare module BABYLON {
  107453. /**
  107454. * Interface for any object that can request an animation frame
  107455. */
  107456. export interface ICustomAnimationFrameRequester {
  107457. /**
  107458. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  107459. */
  107460. renderFunction?: Function;
  107461. /**
  107462. * Called to request the next frame to render to
  107463. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  107464. */
  107465. requestAnimationFrame: Function;
  107466. /**
  107467. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  107468. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  107469. */
  107470. requestID?: number;
  107471. }
  107472. }
  107473. declare module BABYLON {
  107474. /**
  107475. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  107476. */
  107477. export class PerformanceMonitor {
  107478. private _enabled;
  107479. private _rollingFrameTime;
  107480. private _lastFrameTimeMs;
  107481. /**
  107482. * constructor
  107483. * @param frameSampleSize The number of samples required to saturate the sliding window
  107484. */
  107485. constructor(frameSampleSize?: number);
  107486. /**
  107487. * Samples current frame
  107488. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  107489. */
  107490. sampleFrame(timeMs?: number): void;
  107491. /**
  107492. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107493. */
  107494. get averageFrameTime(): number;
  107495. /**
  107496. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  107497. */
  107498. get averageFrameTimeVariance(): number;
  107499. /**
  107500. * Returns the frame time of the most recent frame
  107501. */
  107502. get instantaneousFrameTime(): number;
  107503. /**
  107504. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  107505. */
  107506. get averageFPS(): number;
  107507. /**
  107508. * Returns the average framerate in frames per second using the most recent frame time
  107509. */
  107510. get instantaneousFPS(): number;
  107511. /**
  107512. * Returns true if enough samples have been taken to completely fill the sliding window
  107513. */
  107514. get isSaturated(): boolean;
  107515. /**
  107516. * Enables contributions to the sliding window sample set
  107517. */
  107518. enable(): void;
  107519. /**
  107520. * Disables contributions to the sliding window sample set
  107521. * Samples will not be interpolated over the disabled period
  107522. */
  107523. disable(): void;
  107524. /**
  107525. * Returns true if sampling is enabled
  107526. */
  107527. get isEnabled(): boolean;
  107528. /**
  107529. * Resets performance monitor
  107530. */
  107531. reset(): void;
  107532. }
  107533. /**
  107534. * RollingAverage
  107535. *
  107536. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  107537. */
  107538. export class RollingAverage {
  107539. /**
  107540. * Current average
  107541. */
  107542. average: number;
  107543. /**
  107544. * Current variance
  107545. */
  107546. variance: number;
  107547. protected _samples: Array<number>;
  107548. protected _sampleCount: number;
  107549. protected _pos: number;
  107550. protected _m2: number;
  107551. /**
  107552. * constructor
  107553. * @param length The number of samples required to saturate the sliding window
  107554. */
  107555. constructor(length: number);
  107556. /**
  107557. * Adds a sample to the sample set
  107558. * @param v The sample value
  107559. */
  107560. add(v: number): void;
  107561. /**
  107562. * Returns previously added values or null if outside of history or outside the sliding window domain
  107563. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  107564. * @return Value previously recorded with add() or null if outside of range
  107565. */
  107566. history(i: number): number;
  107567. /**
  107568. * Returns true if enough samples have been taken to completely fill the sliding window
  107569. * @return true if sample-set saturated
  107570. */
  107571. isSaturated(): boolean;
  107572. /**
  107573. * Resets the rolling average (equivalent to 0 samples taken so far)
  107574. */
  107575. reset(): void;
  107576. /**
  107577. * Wraps a value around the sample range boundaries
  107578. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  107579. * @return Wrapped position in sample range
  107580. */
  107581. protected _wrapPosition(i: number): number;
  107582. }
  107583. }
  107584. declare module BABYLON {
  107585. /**
  107586. * This class is used to track a performance counter which is number based.
  107587. * The user has access to many properties which give statistics of different nature.
  107588. *
  107589. * The implementer can track two kinds of Performance Counter: time and count.
  107590. * 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.
  107591. * 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.
  107592. */
  107593. export class PerfCounter {
  107594. /**
  107595. * Gets or sets a global boolean to turn on and off all the counters
  107596. */
  107597. static Enabled: boolean;
  107598. /**
  107599. * Returns the smallest value ever
  107600. */
  107601. get min(): number;
  107602. /**
  107603. * Returns the biggest value ever
  107604. */
  107605. get max(): number;
  107606. /**
  107607. * Returns the average value since the performance counter is running
  107608. */
  107609. get average(): number;
  107610. /**
  107611. * Returns the average value of the last second the counter was monitored
  107612. */
  107613. get lastSecAverage(): number;
  107614. /**
  107615. * Returns the current value
  107616. */
  107617. get current(): number;
  107618. /**
  107619. * Gets the accumulated total
  107620. */
  107621. get total(): number;
  107622. /**
  107623. * Gets the total value count
  107624. */
  107625. get count(): number;
  107626. /**
  107627. * Creates a new counter
  107628. */
  107629. constructor();
  107630. /**
  107631. * Call this method to start monitoring a new frame.
  107632. * 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.
  107633. */
  107634. fetchNewFrame(): void;
  107635. /**
  107636. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  107637. * @param newCount the count value to add to the monitored count
  107638. * @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.
  107639. */
  107640. addCount(newCount: number, fetchResult: boolean): void;
  107641. /**
  107642. * Start monitoring this performance counter
  107643. */
  107644. beginMonitoring(): void;
  107645. /**
  107646. * Compute the time lapsed since the previous beginMonitoring() call.
  107647. * @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
  107648. */
  107649. endMonitoring(newFrame?: boolean): void;
  107650. private _fetchResult;
  107651. private _startMonitoringTime;
  107652. private _min;
  107653. private _max;
  107654. private _average;
  107655. private _current;
  107656. private _totalValueCount;
  107657. private _totalAccumulated;
  107658. private _lastSecAverage;
  107659. private _lastSecAccumulated;
  107660. private _lastSecTime;
  107661. private _lastSecValueCount;
  107662. }
  107663. }
  107664. declare module BABYLON {
  107665. interface ThinEngine {
  107666. /**
  107667. * Sets alpha constants used by some alpha blending modes
  107668. * @param r defines the red component
  107669. * @param g defines the green component
  107670. * @param b defines the blue component
  107671. * @param a defines the alpha component
  107672. */
  107673. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  107674. /**
  107675. * Sets the current alpha mode
  107676. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  107677. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  107678. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107679. */
  107680. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  107681. /**
  107682. * Gets the current alpha mode
  107683. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  107684. * @returns the current alpha mode
  107685. */
  107686. getAlphaMode(): number;
  107687. /**
  107688. * Sets the current alpha equation
  107689. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  107690. */
  107691. setAlphaEquation(equation: number): void;
  107692. /**
  107693. * Gets the current alpha equation.
  107694. * @returns the current alpha equation
  107695. */
  107696. getAlphaEquation(): number;
  107697. }
  107698. }
  107699. declare module BABYLON {
  107700. /**
  107701. * Defines the interface used by display changed events
  107702. */
  107703. export interface IDisplayChangedEventArgs {
  107704. /** Gets the vrDisplay object (if any) */
  107705. vrDisplay: Nullable<any>;
  107706. /** Gets a boolean indicating if webVR is supported */
  107707. vrSupported: boolean;
  107708. }
  107709. /**
  107710. * Defines the interface used by objects containing a viewport (like a camera)
  107711. */
  107712. interface IViewportOwnerLike {
  107713. /**
  107714. * Gets or sets the viewport
  107715. */
  107716. viewport: IViewportLike;
  107717. }
  107718. /**
  107719. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  107720. */
  107721. export class Engine extends ThinEngine {
  107722. /** Defines that alpha blending is disabled */
  107723. static readonly ALPHA_DISABLE: number;
  107724. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  107725. static readonly ALPHA_ADD: number;
  107726. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  107727. static readonly ALPHA_COMBINE: number;
  107728. /** Defines that alpha blending to DEST - SRC * DEST */
  107729. static readonly ALPHA_SUBTRACT: number;
  107730. /** Defines that alpha blending to SRC * DEST */
  107731. static readonly ALPHA_MULTIPLY: number;
  107732. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  107733. static readonly ALPHA_MAXIMIZED: number;
  107734. /** Defines that alpha blending to SRC + DEST */
  107735. static readonly ALPHA_ONEONE: number;
  107736. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  107737. static readonly ALPHA_PREMULTIPLIED: number;
  107738. /**
  107739. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  107740. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  107741. */
  107742. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  107743. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  107744. static readonly ALPHA_INTERPOLATE: number;
  107745. /**
  107746. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  107747. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  107748. */
  107749. static readonly ALPHA_SCREENMODE: number;
  107750. /** Defines that the ressource is not delayed*/
  107751. static readonly DELAYLOADSTATE_NONE: number;
  107752. /** Defines that the ressource was successfully delay loaded */
  107753. static readonly DELAYLOADSTATE_LOADED: number;
  107754. /** Defines that the ressource is currently delay loading */
  107755. static readonly DELAYLOADSTATE_LOADING: number;
  107756. /** Defines that the ressource is delayed and has not started loading */
  107757. static readonly DELAYLOADSTATE_NOTLOADED: number;
  107758. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  107759. static readonly NEVER: number;
  107760. /** 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 */
  107761. static readonly ALWAYS: number;
  107762. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  107763. static readonly LESS: number;
  107764. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  107765. static readonly EQUAL: number;
  107766. /** 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 */
  107767. static readonly LEQUAL: number;
  107768. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  107769. static readonly GREATER: number;
  107770. /** 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 */
  107771. static readonly GEQUAL: number;
  107772. /** 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 */
  107773. static readonly NOTEQUAL: number;
  107774. /** Passed to stencilOperation to specify that stencil value must be kept */
  107775. static readonly KEEP: number;
  107776. /** Passed to stencilOperation to specify that stencil value must be replaced */
  107777. static readonly REPLACE: number;
  107778. /** Passed to stencilOperation to specify that stencil value must be incremented */
  107779. static readonly INCR: number;
  107780. /** Passed to stencilOperation to specify that stencil value must be decremented */
  107781. static readonly DECR: number;
  107782. /** Passed to stencilOperation to specify that stencil value must be inverted */
  107783. static readonly INVERT: number;
  107784. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  107785. static readonly INCR_WRAP: number;
  107786. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  107787. static readonly DECR_WRAP: number;
  107788. /** Texture is not repeating outside of 0..1 UVs */
  107789. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  107790. /** Texture is repeating outside of 0..1 UVs */
  107791. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  107792. /** Texture is repeating and mirrored */
  107793. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  107794. /** ALPHA */
  107795. static readonly TEXTUREFORMAT_ALPHA: number;
  107796. /** LUMINANCE */
  107797. static readonly TEXTUREFORMAT_LUMINANCE: number;
  107798. /** LUMINANCE_ALPHA */
  107799. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  107800. /** RGB */
  107801. static readonly TEXTUREFORMAT_RGB: number;
  107802. /** RGBA */
  107803. static readonly TEXTUREFORMAT_RGBA: number;
  107804. /** RED */
  107805. static readonly TEXTUREFORMAT_RED: number;
  107806. /** RED (2nd reference) */
  107807. static readonly TEXTUREFORMAT_R: number;
  107808. /** RG */
  107809. static readonly TEXTUREFORMAT_RG: number;
  107810. /** RED_INTEGER */
  107811. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  107812. /** RED_INTEGER (2nd reference) */
  107813. static readonly TEXTUREFORMAT_R_INTEGER: number;
  107814. /** RG_INTEGER */
  107815. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  107816. /** RGB_INTEGER */
  107817. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  107818. /** RGBA_INTEGER */
  107819. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  107820. /** UNSIGNED_BYTE */
  107821. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  107822. /** UNSIGNED_BYTE (2nd reference) */
  107823. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  107824. /** FLOAT */
  107825. static readonly TEXTURETYPE_FLOAT: number;
  107826. /** HALF_FLOAT */
  107827. static readonly TEXTURETYPE_HALF_FLOAT: number;
  107828. /** BYTE */
  107829. static readonly TEXTURETYPE_BYTE: number;
  107830. /** SHORT */
  107831. static readonly TEXTURETYPE_SHORT: number;
  107832. /** UNSIGNED_SHORT */
  107833. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  107834. /** INT */
  107835. static readonly TEXTURETYPE_INT: number;
  107836. /** UNSIGNED_INT */
  107837. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  107838. /** UNSIGNED_SHORT_4_4_4_4 */
  107839. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  107840. /** UNSIGNED_SHORT_5_5_5_1 */
  107841. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  107842. /** UNSIGNED_SHORT_5_6_5 */
  107843. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  107844. /** UNSIGNED_INT_2_10_10_10_REV */
  107845. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  107846. /** UNSIGNED_INT_24_8 */
  107847. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  107848. /** UNSIGNED_INT_10F_11F_11F_REV */
  107849. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  107850. /** UNSIGNED_INT_5_9_9_9_REV */
  107851. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  107852. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  107853. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  107854. /** nearest is mag = nearest and min = nearest and mip = linear */
  107855. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  107856. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107857. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  107858. /** Trilinear is mag = linear and min = linear and mip = linear */
  107859. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  107860. /** nearest is mag = nearest and min = nearest and mip = linear */
  107861. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  107862. /** Bilinear is mag = linear and min = linear and mip = nearest */
  107863. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  107864. /** Trilinear is mag = linear and min = linear and mip = linear */
  107865. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  107866. /** mag = nearest and min = nearest and mip = nearest */
  107867. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  107868. /** mag = nearest and min = linear and mip = nearest */
  107869. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  107870. /** mag = nearest and min = linear and mip = linear */
  107871. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  107872. /** mag = nearest and min = linear and mip = none */
  107873. static readonly TEXTURE_NEAREST_LINEAR: number;
  107874. /** mag = nearest and min = nearest and mip = none */
  107875. static readonly TEXTURE_NEAREST_NEAREST: number;
  107876. /** mag = linear and min = nearest and mip = nearest */
  107877. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  107878. /** mag = linear and min = nearest and mip = linear */
  107879. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  107880. /** mag = linear and min = linear and mip = none */
  107881. static readonly TEXTURE_LINEAR_LINEAR: number;
  107882. /** mag = linear and min = nearest and mip = none */
  107883. static readonly TEXTURE_LINEAR_NEAREST: number;
  107884. /** Explicit coordinates mode */
  107885. static readonly TEXTURE_EXPLICIT_MODE: number;
  107886. /** Spherical coordinates mode */
  107887. static readonly TEXTURE_SPHERICAL_MODE: number;
  107888. /** Planar coordinates mode */
  107889. static readonly TEXTURE_PLANAR_MODE: number;
  107890. /** Cubic coordinates mode */
  107891. static readonly TEXTURE_CUBIC_MODE: number;
  107892. /** Projection coordinates mode */
  107893. static readonly TEXTURE_PROJECTION_MODE: number;
  107894. /** Skybox coordinates mode */
  107895. static readonly TEXTURE_SKYBOX_MODE: number;
  107896. /** Inverse Cubic coordinates mode */
  107897. static readonly TEXTURE_INVCUBIC_MODE: number;
  107898. /** Equirectangular coordinates mode */
  107899. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  107900. /** Equirectangular Fixed coordinates mode */
  107901. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  107902. /** Equirectangular Fixed Mirrored coordinates mode */
  107903. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  107904. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  107905. static readonly SCALEMODE_FLOOR: number;
  107906. /** Defines that texture rescaling will look for the nearest power of 2 size */
  107907. static readonly SCALEMODE_NEAREST: number;
  107908. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  107909. static readonly SCALEMODE_CEILING: number;
  107910. /**
  107911. * Returns the current npm package of the sdk
  107912. */
  107913. static get NpmPackage(): string;
  107914. /**
  107915. * Returns the current version of the framework
  107916. */
  107917. static get Version(): string;
  107918. /** Gets the list of created engines */
  107919. static get Instances(): Engine[];
  107920. /**
  107921. * Gets the latest created engine
  107922. */
  107923. static get LastCreatedEngine(): Nullable<Engine>;
  107924. /**
  107925. * Gets the latest created scene
  107926. */
  107927. static get LastCreatedScene(): Nullable<Scene>;
  107928. /**
  107929. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  107930. * @param flag defines which part of the materials must be marked as dirty
  107931. * @param predicate defines a predicate used to filter which materials should be affected
  107932. */
  107933. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  107934. /**
  107935. * Method called to create the default loading screen.
  107936. * This can be overriden in your own app.
  107937. * @param canvas The rendering canvas element
  107938. * @returns The loading screen
  107939. */
  107940. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  107941. /**
  107942. * Method called to create the default rescale post process on each engine.
  107943. */
  107944. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  107945. /**
  107946. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  107947. **/
  107948. enableOfflineSupport: boolean;
  107949. /**
  107950. * 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)
  107951. **/
  107952. disableManifestCheck: boolean;
  107953. /**
  107954. * Gets the list of created scenes
  107955. */
  107956. scenes: Scene[];
  107957. /**
  107958. * Event raised when a new scene is created
  107959. */
  107960. onNewSceneAddedObservable: Observable<Scene>;
  107961. /**
  107962. * Gets the list of created postprocesses
  107963. */
  107964. postProcesses: PostProcess[];
  107965. /**
  107966. * Gets a boolean indicating if the pointer is currently locked
  107967. */
  107968. isPointerLock: boolean;
  107969. /**
  107970. * Observable event triggered each time the rendering canvas is resized
  107971. */
  107972. onResizeObservable: Observable<Engine>;
  107973. /**
  107974. * Observable event triggered each time the canvas loses focus
  107975. */
  107976. onCanvasBlurObservable: Observable<Engine>;
  107977. /**
  107978. * Observable event triggered each time the canvas gains focus
  107979. */
  107980. onCanvasFocusObservable: Observable<Engine>;
  107981. /**
  107982. * Observable event triggered each time the canvas receives pointerout event
  107983. */
  107984. onCanvasPointerOutObservable: Observable<PointerEvent>;
  107985. /**
  107986. * Observable raised when the engine begins a new frame
  107987. */
  107988. onBeginFrameObservable: Observable<Engine>;
  107989. /**
  107990. * If set, will be used to request the next animation frame for the render loop
  107991. */
  107992. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  107993. /**
  107994. * Observable raised when the engine ends the current frame
  107995. */
  107996. onEndFrameObservable: Observable<Engine>;
  107997. /**
  107998. * Observable raised when the engine is about to compile a shader
  107999. */
  108000. onBeforeShaderCompilationObservable: Observable<Engine>;
  108001. /**
  108002. * Observable raised when the engine has jsut compiled a shader
  108003. */
  108004. onAfterShaderCompilationObservable: Observable<Engine>;
  108005. /**
  108006. * Gets the audio engine
  108007. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  108008. * @ignorenaming
  108009. */
  108010. static audioEngine: IAudioEngine;
  108011. /**
  108012. * Default AudioEngine factory responsible of creating the Audio Engine.
  108013. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  108014. */
  108015. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  108016. /**
  108017. * Default offline support factory responsible of creating a tool used to store data locally.
  108018. * By default, this will create a Database object if the workload has been embedded.
  108019. */
  108020. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  108021. private _loadingScreen;
  108022. private _pointerLockRequested;
  108023. private _dummyFramebuffer;
  108024. private _rescalePostProcess;
  108025. private _deterministicLockstep;
  108026. private _lockstepMaxSteps;
  108027. private _timeStep;
  108028. protected get _supportsHardwareTextureRescaling(): boolean;
  108029. private _fps;
  108030. private _deltaTime;
  108031. /** @hidden */
  108032. _drawCalls: PerfCounter;
  108033. /** 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 */
  108034. canvasTabIndex: number;
  108035. /**
  108036. * Turn this value on if you want to pause FPS computation when in background
  108037. */
  108038. disablePerformanceMonitorInBackground: boolean;
  108039. private _performanceMonitor;
  108040. /**
  108041. * Gets the performance monitor attached to this engine
  108042. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  108043. */
  108044. get performanceMonitor(): PerformanceMonitor;
  108045. private _onFocus;
  108046. private _onBlur;
  108047. private _onCanvasPointerOut;
  108048. private _onCanvasBlur;
  108049. private _onCanvasFocus;
  108050. private _onFullscreenChange;
  108051. private _onPointerLockChange;
  108052. /**
  108053. * Gets the HTML element used to attach event listeners
  108054. * @returns a HTML element
  108055. */
  108056. getInputElement(): Nullable<HTMLElement>;
  108057. /**
  108058. * Creates a new engine
  108059. * @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
  108060. * @param antialias defines enable antialiasing (default: false)
  108061. * @param options defines further options to be sent to the getContext() function
  108062. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  108063. */
  108064. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  108065. /**
  108066. * Gets current aspect ratio
  108067. * @param viewportOwner defines the camera to use to get the aspect ratio
  108068. * @param useScreen defines if screen size must be used (or the current render target if any)
  108069. * @returns a number defining the aspect ratio
  108070. */
  108071. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  108072. /**
  108073. * Gets current screen aspect ratio
  108074. * @returns a number defining the aspect ratio
  108075. */
  108076. getScreenAspectRatio(): number;
  108077. /**
  108078. * Gets the client rect of the HTML canvas attached with the current webGL context
  108079. * @returns a client rectanglee
  108080. */
  108081. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  108082. /**
  108083. * Gets the client rect of the HTML element used for events
  108084. * @returns a client rectanglee
  108085. */
  108086. getInputElementClientRect(): Nullable<ClientRect>;
  108087. /**
  108088. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  108089. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108090. * @returns true if engine is in deterministic lock step mode
  108091. */
  108092. isDeterministicLockStep(): boolean;
  108093. /**
  108094. * Gets the max steps when engine is running in deterministic lock step
  108095. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  108096. * @returns the max steps
  108097. */
  108098. getLockstepMaxSteps(): number;
  108099. /**
  108100. * Returns the time in ms between steps when using deterministic lock step.
  108101. * @returns time step in (ms)
  108102. */
  108103. getTimeStep(): number;
  108104. /**
  108105. * Force the mipmap generation for the given render target texture
  108106. * @param texture defines the render target texture to use
  108107. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  108108. */
  108109. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  108110. /** States */
  108111. /**
  108112. * Set various states to the webGL context
  108113. * @param culling defines backface culling state
  108114. * @param zOffset defines the value to apply to zOffset (0 by default)
  108115. * @param force defines if states must be applied even if cache is up to date
  108116. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  108117. */
  108118. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  108119. /**
  108120. * Set the z offset to apply to current rendering
  108121. * @param value defines the offset to apply
  108122. */
  108123. setZOffset(value: number): void;
  108124. /**
  108125. * Gets the current value of the zOffset
  108126. * @returns the current zOffset state
  108127. */
  108128. getZOffset(): number;
  108129. /**
  108130. * Enable or disable depth buffering
  108131. * @param enable defines the state to set
  108132. */
  108133. setDepthBuffer(enable: boolean): void;
  108134. /**
  108135. * Gets a boolean indicating if depth writing is enabled
  108136. * @returns the current depth writing state
  108137. */
  108138. getDepthWrite(): boolean;
  108139. /**
  108140. * Enable or disable depth writing
  108141. * @param enable defines the state to set
  108142. */
  108143. setDepthWrite(enable: boolean): void;
  108144. /**
  108145. * Gets a boolean indicating if stencil buffer is enabled
  108146. * @returns the current stencil buffer state
  108147. */
  108148. getStencilBuffer(): boolean;
  108149. /**
  108150. * Enable or disable the stencil buffer
  108151. * @param enable defines if the stencil buffer must be enabled or disabled
  108152. */
  108153. setStencilBuffer(enable: boolean): void;
  108154. /**
  108155. * Gets the current stencil mask
  108156. * @returns a number defining the new stencil mask to use
  108157. */
  108158. getStencilMask(): number;
  108159. /**
  108160. * Sets the current stencil mask
  108161. * @param mask defines the new stencil mask to use
  108162. */
  108163. setStencilMask(mask: number): void;
  108164. /**
  108165. * Gets the current stencil function
  108166. * @returns a number defining the stencil function to use
  108167. */
  108168. getStencilFunction(): number;
  108169. /**
  108170. * Gets the current stencil reference value
  108171. * @returns a number defining the stencil reference value to use
  108172. */
  108173. getStencilFunctionReference(): number;
  108174. /**
  108175. * Gets the current stencil mask
  108176. * @returns a number defining the stencil mask to use
  108177. */
  108178. getStencilFunctionMask(): number;
  108179. /**
  108180. * Sets the current stencil function
  108181. * @param stencilFunc defines the new stencil function to use
  108182. */
  108183. setStencilFunction(stencilFunc: number): void;
  108184. /**
  108185. * Sets the current stencil reference
  108186. * @param reference defines the new stencil reference to use
  108187. */
  108188. setStencilFunctionReference(reference: number): void;
  108189. /**
  108190. * Sets the current stencil mask
  108191. * @param mask defines the new stencil mask to use
  108192. */
  108193. setStencilFunctionMask(mask: number): void;
  108194. /**
  108195. * Gets the current stencil operation when stencil fails
  108196. * @returns a number defining stencil operation to use when stencil fails
  108197. */
  108198. getStencilOperationFail(): number;
  108199. /**
  108200. * Gets the current stencil operation when depth fails
  108201. * @returns a number defining stencil operation to use when depth fails
  108202. */
  108203. getStencilOperationDepthFail(): number;
  108204. /**
  108205. * Gets the current stencil operation when stencil passes
  108206. * @returns a number defining stencil operation to use when stencil passes
  108207. */
  108208. getStencilOperationPass(): number;
  108209. /**
  108210. * Sets the stencil operation to use when stencil fails
  108211. * @param operation defines the stencil operation to use when stencil fails
  108212. */
  108213. setStencilOperationFail(operation: number): void;
  108214. /**
  108215. * Sets the stencil operation to use when depth fails
  108216. * @param operation defines the stencil operation to use when depth fails
  108217. */
  108218. setStencilOperationDepthFail(operation: number): void;
  108219. /**
  108220. * Sets the stencil operation to use when stencil passes
  108221. * @param operation defines the stencil operation to use when stencil passes
  108222. */
  108223. setStencilOperationPass(operation: number): void;
  108224. /**
  108225. * Sets a boolean indicating if the dithering state is enabled or disabled
  108226. * @param value defines the dithering state
  108227. */
  108228. setDitheringState(value: boolean): void;
  108229. /**
  108230. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  108231. * @param value defines the rasterizer state
  108232. */
  108233. setRasterizerState(value: boolean): void;
  108234. /**
  108235. * Gets the current depth function
  108236. * @returns a number defining the depth function
  108237. */
  108238. getDepthFunction(): Nullable<number>;
  108239. /**
  108240. * Sets the current depth function
  108241. * @param depthFunc defines the function to use
  108242. */
  108243. setDepthFunction(depthFunc: number): void;
  108244. /**
  108245. * Sets the current depth function to GREATER
  108246. */
  108247. setDepthFunctionToGreater(): void;
  108248. /**
  108249. * Sets the current depth function to GEQUAL
  108250. */
  108251. setDepthFunctionToGreaterOrEqual(): void;
  108252. /**
  108253. * Sets the current depth function to LESS
  108254. */
  108255. setDepthFunctionToLess(): void;
  108256. /**
  108257. * Sets the current depth function to LEQUAL
  108258. */
  108259. setDepthFunctionToLessOrEqual(): void;
  108260. private _cachedStencilBuffer;
  108261. private _cachedStencilFunction;
  108262. private _cachedStencilMask;
  108263. private _cachedStencilOperationPass;
  108264. private _cachedStencilOperationFail;
  108265. private _cachedStencilOperationDepthFail;
  108266. private _cachedStencilReference;
  108267. /**
  108268. * Caches the the state of the stencil buffer
  108269. */
  108270. cacheStencilState(): void;
  108271. /**
  108272. * Restores the state of the stencil buffer
  108273. */
  108274. restoreStencilState(): void;
  108275. /**
  108276. * Directly set the WebGL Viewport
  108277. * @param x defines the x coordinate of the viewport (in screen space)
  108278. * @param y defines the y coordinate of the viewport (in screen space)
  108279. * @param width defines the width of the viewport (in screen space)
  108280. * @param height defines the height of the viewport (in screen space)
  108281. * @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
  108282. */
  108283. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  108284. /**
  108285. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  108286. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108287. * @param y defines the y-coordinate of the corner of the clear rectangle
  108288. * @param width defines the width of the clear rectangle
  108289. * @param height defines the height of the clear rectangle
  108290. * @param clearColor defines the clear color
  108291. */
  108292. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  108293. /**
  108294. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  108295. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  108296. * @param y defines the y-coordinate of the corner of the clear rectangle
  108297. * @param width defines the width of the clear rectangle
  108298. * @param height defines the height of the clear rectangle
  108299. */
  108300. enableScissor(x: number, y: number, width: number, height: number): void;
  108301. /**
  108302. * Disable previously set scissor test rectangle
  108303. */
  108304. disableScissor(): void;
  108305. protected _reportDrawCall(): void;
  108306. /**
  108307. * Initializes a webVR display and starts listening to display change events
  108308. * The onVRDisplayChangedObservable will be notified upon these changes
  108309. * @returns The onVRDisplayChangedObservable
  108310. */
  108311. initWebVR(): Observable<IDisplayChangedEventArgs>;
  108312. /** @hidden */
  108313. _prepareVRComponent(): void;
  108314. /** @hidden */
  108315. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  108316. /** @hidden */
  108317. _submitVRFrame(): void;
  108318. /**
  108319. * Call this function to leave webVR mode
  108320. * Will do nothing if webVR is not supported or if there is no webVR device
  108321. * @see http://doc.babylonjs.com/how_to/webvr_camera
  108322. */
  108323. disableVR(): void;
  108324. /**
  108325. * Gets a boolean indicating that the system is in VR mode and is presenting
  108326. * @returns true if VR mode is engaged
  108327. */
  108328. isVRPresenting(): boolean;
  108329. /** @hidden */
  108330. _requestVRFrame(): void;
  108331. /** @hidden */
  108332. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  108333. /**
  108334. * Gets the source code of the vertex shader associated with a specific webGL program
  108335. * @param program defines the program to use
  108336. * @returns a string containing the source code of the vertex shader associated with the program
  108337. */
  108338. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  108339. /**
  108340. * Gets the source code of the fragment shader associated with a specific webGL program
  108341. * @param program defines the program to use
  108342. * @returns a string containing the source code of the fragment shader associated with the program
  108343. */
  108344. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  108345. /**
  108346. * Sets a depth stencil texture from a render target to the according uniform.
  108347. * @param channel The texture channel
  108348. * @param uniform The uniform to set
  108349. * @param texture The render target texture containing the depth stencil texture to apply
  108350. */
  108351. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  108352. /**
  108353. * Sets a texture to the webGL context from a postprocess
  108354. * @param channel defines the channel to use
  108355. * @param postProcess defines the source postprocess
  108356. */
  108357. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  108358. /**
  108359. * Binds the output of the passed in post process to the texture channel specified
  108360. * @param channel The channel the texture should be bound to
  108361. * @param postProcess The post process which's output should be bound
  108362. */
  108363. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  108364. /** @hidden */
  108365. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  108366. protected _rebuildBuffers(): void;
  108367. /** @hidden */
  108368. _renderFrame(): void;
  108369. _renderLoop(): void;
  108370. /** @hidden */
  108371. _renderViews(): boolean;
  108372. /**
  108373. * Toggle full screen mode
  108374. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108375. */
  108376. switchFullscreen(requestPointerLock: boolean): void;
  108377. /**
  108378. * Enters full screen mode
  108379. * @param requestPointerLock defines if a pointer lock should be requested from the user
  108380. */
  108381. enterFullscreen(requestPointerLock: boolean): void;
  108382. /**
  108383. * Exits full screen mode
  108384. */
  108385. exitFullscreen(): void;
  108386. /**
  108387. * Enters Pointerlock mode
  108388. */
  108389. enterPointerlock(): void;
  108390. /**
  108391. * Exits Pointerlock mode
  108392. */
  108393. exitPointerlock(): void;
  108394. /**
  108395. * Begin a new frame
  108396. */
  108397. beginFrame(): void;
  108398. /**
  108399. * Enf the current frame
  108400. */
  108401. endFrame(): void;
  108402. resize(): void;
  108403. /**
  108404. * Force a specific size of the canvas
  108405. * @param width defines the new canvas' width
  108406. * @param height defines the new canvas' height
  108407. */
  108408. setSize(width: number, height: number): void;
  108409. /**
  108410. * Updates a dynamic vertex buffer.
  108411. * @param vertexBuffer the vertex buffer to update
  108412. * @param data the data used to update the vertex buffer
  108413. * @param byteOffset the byte offset of the data
  108414. * @param byteLength the byte length of the data
  108415. */
  108416. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  108417. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  108418. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108419. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  108420. _releaseTexture(texture: InternalTexture): void;
  108421. /**
  108422. * @hidden
  108423. * Rescales a texture
  108424. * @param source input texutre
  108425. * @param destination destination texture
  108426. * @param scene scene to use to render the resize
  108427. * @param internalFormat format to use when resizing
  108428. * @param onComplete callback to be called when resize has completed
  108429. */
  108430. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  108431. /**
  108432. * Gets the current framerate
  108433. * @returns a number representing the framerate
  108434. */
  108435. getFps(): number;
  108436. /**
  108437. * Gets the time spent between current and previous frame
  108438. * @returns a number representing the delta time in ms
  108439. */
  108440. getDeltaTime(): number;
  108441. private _measureFps;
  108442. /** @hidden */
  108443. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  108444. /**
  108445. * Update a dynamic index buffer
  108446. * @param indexBuffer defines the target index buffer
  108447. * @param indices defines the data to update
  108448. * @param offset defines the offset in the target index buffer where update should start
  108449. */
  108450. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  108451. /**
  108452. * Updates the sample count of a render target texture
  108453. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  108454. * @param texture defines the texture to update
  108455. * @param samples defines the sample count to set
  108456. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  108457. */
  108458. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  108459. /**
  108460. * Updates a depth texture Comparison Mode and Function.
  108461. * If the comparison Function is equal to 0, the mode will be set to none.
  108462. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  108463. * @param texture The texture to set the comparison function for
  108464. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  108465. */
  108466. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  108467. /**
  108468. * Creates a webGL buffer to use with instanciation
  108469. * @param capacity defines the size of the buffer
  108470. * @returns the webGL buffer
  108471. */
  108472. createInstancesBuffer(capacity: number): DataBuffer;
  108473. /**
  108474. * Delete a webGL buffer used with instanciation
  108475. * @param buffer defines the webGL buffer to delete
  108476. */
  108477. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  108478. private _clientWaitAsync;
  108479. /** @hidden */
  108480. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  108481. /** @hidden */
  108482. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  108483. dispose(): void;
  108484. private _disableTouchAction;
  108485. /**
  108486. * Display the loading screen
  108487. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108488. */
  108489. displayLoadingUI(): void;
  108490. /**
  108491. * Hide the loading screen
  108492. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108493. */
  108494. hideLoadingUI(): void;
  108495. /**
  108496. * Gets the current loading screen object
  108497. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108498. */
  108499. get loadingScreen(): ILoadingScreen;
  108500. /**
  108501. * Sets the current loading screen object
  108502. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108503. */
  108504. set loadingScreen(loadingScreen: ILoadingScreen);
  108505. /**
  108506. * Sets the current loading screen text
  108507. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108508. */
  108509. set loadingUIText(text: string);
  108510. /**
  108511. * Sets the current loading screen background color
  108512. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  108513. */
  108514. set loadingUIBackgroundColor(color: string);
  108515. /** Pointerlock and fullscreen */
  108516. /**
  108517. * Ask the browser to promote the current element to pointerlock mode
  108518. * @param element defines the DOM element to promote
  108519. */
  108520. static _RequestPointerlock(element: HTMLElement): void;
  108521. /**
  108522. * Asks the browser to exit pointerlock mode
  108523. */
  108524. static _ExitPointerlock(): void;
  108525. /**
  108526. * Ask the browser to promote the current element to fullscreen rendering mode
  108527. * @param element defines the DOM element to promote
  108528. */
  108529. static _RequestFullscreen(element: HTMLElement): void;
  108530. /**
  108531. * Asks the browser to exit fullscreen mode
  108532. */
  108533. static _ExitFullscreen(): void;
  108534. }
  108535. }
  108536. declare module BABYLON {
  108537. /**
  108538. * The engine store class is responsible to hold all the instances of Engine and Scene created
  108539. * during the life time of the application.
  108540. */
  108541. export class EngineStore {
  108542. /** Gets the list of created engines */
  108543. static Instances: Engine[];
  108544. /** @hidden */
  108545. static _LastCreatedScene: Nullable<Scene>;
  108546. /**
  108547. * Gets the latest created engine
  108548. */
  108549. static get LastCreatedEngine(): Nullable<Engine>;
  108550. /**
  108551. * Gets the latest created scene
  108552. */
  108553. static get LastCreatedScene(): Nullable<Scene>;
  108554. /**
  108555. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108556. * @ignorenaming
  108557. */
  108558. static UseFallbackTexture: boolean;
  108559. /**
  108560. * Texture content used if a texture cannot loaded
  108561. * @ignorenaming
  108562. */
  108563. static FallbackTexture: string;
  108564. }
  108565. }
  108566. declare module BABYLON {
  108567. /**
  108568. * Helper class that provides a small promise polyfill
  108569. */
  108570. export class PromisePolyfill {
  108571. /**
  108572. * Static function used to check if the polyfill is required
  108573. * If this is the case then the function will inject the polyfill to window.Promise
  108574. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  108575. */
  108576. static Apply(force?: boolean): void;
  108577. }
  108578. }
  108579. declare module BABYLON {
  108580. /**
  108581. * Interface for screenshot methods with describe argument called `size` as object with options
  108582. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  108583. */
  108584. export interface IScreenshotSize {
  108585. /**
  108586. * number in pixels for canvas height
  108587. */
  108588. height?: number;
  108589. /**
  108590. * multiplier allowing render at a higher or lower resolution
  108591. * If value is defined then height and width will be ignored and taken from camera
  108592. */
  108593. precision?: number;
  108594. /**
  108595. * number in pixels for canvas width
  108596. */
  108597. width?: number;
  108598. }
  108599. }
  108600. declare module BABYLON {
  108601. interface IColor4Like {
  108602. r: float;
  108603. g: float;
  108604. b: float;
  108605. a: float;
  108606. }
  108607. /**
  108608. * Class containing a set of static utilities functions
  108609. */
  108610. export class Tools {
  108611. /**
  108612. * Gets or sets the base URL to use to load assets
  108613. */
  108614. static get BaseUrl(): string;
  108615. static set BaseUrl(value: string);
  108616. /**
  108617. * Enable/Disable Custom HTTP Request Headers globally.
  108618. * default = false
  108619. * @see CustomRequestHeaders
  108620. */
  108621. static UseCustomRequestHeaders: boolean;
  108622. /**
  108623. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  108624. * i.e. when loading files, where the server/service expects an Authorization header
  108625. */
  108626. static CustomRequestHeaders: {
  108627. [key: string]: string;
  108628. };
  108629. /**
  108630. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  108631. */
  108632. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  108633. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  108634. /**
  108635. * Default behaviour for cors in the application.
  108636. * It can be a string if the expected behavior is identical in the entire app.
  108637. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  108638. */
  108639. static get CorsBehavior(): string | ((url: string | string[]) => string);
  108640. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  108641. /**
  108642. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  108643. * @ignorenaming
  108644. */
  108645. static get UseFallbackTexture(): boolean;
  108646. static set UseFallbackTexture(value: boolean);
  108647. /**
  108648. * Use this object to register external classes like custom textures or material
  108649. * to allow the laoders to instantiate them
  108650. */
  108651. static get RegisteredExternalClasses(): {
  108652. [key: string]: Object;
  108653. };
  108654. static set RegisteredExternalClasses(classes: {
  108655. [key: string]: Object;
  108656. });
  108657. /**
  108658. * Texture content used if a texture cannot loaded
  108659. * @ignorenaming
  108660. */
  108661. static get fallbackTexture(): string;
  108662. static set fallbackTexture(value: string);
  108663. /**
  108664. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  108665. * @param u defines the coordinate on X axis
  108666. * @param v defines the coordinate on Y axis
  108667. * @param width defines the width of the source data
  108668. * @param height defines the height of the source data
  108669. * @param pixels defines the source byte array
  108670. * @param color defines the output color
  108671. */
  108672. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  108673. /**
  108674. * Interpolates between a and b via alpha
  108675. * @param a The lower value (returned when alpha = 0)
  108676. * @param b The upper value (returned when alpha = 1)
  108677. * @param alpha The interpolation-factor
  108678. * @return The mixed value
  108679. */
  108680. static Mix(a: number, b: number, alpha: number): number;
  108681. /**
  108682. * Tries to instantiate a new object from a given class name
  108683. * @param className defines the class name to instantiate
  108684. * @returns the new object or null if the system was not able to do the instantiation
  108685. */
  108686. static Instantiate(className: string): any;
  108687. /**
  108688. * Provides a slice function that will work even on IE
  108689. * @param data defines the array to slice
  108690. * @param start defines the start of the data (optional)
  108691. * @param end defines the end of the data (optional)
  108692. * @returns the new sliced array
  108693. */
  108694. static Slice<T>(data: T, start?: number, end?: number): T;
  108695. /**
  108696. * Polyfill for setImmediate
  108697. * @param action defines the action to execute after the current execution block
  108698. */
  108699. static SetImmediate(action: () => void): void;
  108700. /**
  108701. * Function indicating if a number is an exponent of 2
  108702. * @param value defines the value to test
  108703. * @returns true if the value is an exponent of 2
  108704. */
  108705. static IsExponentOfTwo(value: number): boolean;
  108706. private static _tmpFloatArray;
  108707. /**
  108708. * Returns the nearest 32-bit single precision float representation of a Number
  108709. * @param value A Number. If the parameter is of a different type, it will get converted
  108710. * to a number or to NaN if it cannot be converted
  108711. * @returns number
  108712. */
  108713. static FloatRound(value: number): number;
  108714. /**
  108715. * Extracts the filename from a path
  108716. * @param path defines the path to use
  108717. * @returns the filename
  108718. */
  108719. static GetFilename(path: string): string;
  108720. /**
  108721. * Extracts the "folder" part of a path (everything before the filename).
  108722. * @param uri The URI to extract the info from
  108723. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  108724. * @returns The "folder" part of the path
  108725. */
  108726. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  108727. /**
  108728. * Extracts text content from a DOM element hierarchy
  108729. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  108730. */
  108731. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  108732. /**
  108733. * Convert an angle in radians to degrees
  108734. * @param angle defines the angle to convert
  108735. * @returns the angle in degrees
  108736. */
  108737. static ToDegrees(angle: number): number;
  108738. /**
  108739. * Convert an angle in degrees to radians
  108740. * @param angle defines the angle to convert
  108741. * @returns the angle in radians
  108742. */
  108743. static ToRadians(angle: number): number;
  108744. /**
  108745. * Returns an array if obj is not an array
  108746. * @param obj defines the object to evaluate as an array
  108747. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  108748. * @returns either obj directly if obj is an array or a new array containing obj
  108749. */
  108750. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  108751. /**
  108752. * Gets the pointer prefix to use
  108753. * @returns "pointer" if touch is enabled. Else returns "mouse"
  108754. */
  108755. static GetPointerPrefix(): string;
  108756. /**
  108757. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  108758. * @param url define the url we are trying
  108759. * @param element define the dom element where to configure the cors policy
  108760. */
  108761. static SetCorsBehavior(url: string | string[], element: {
  108762. crossOrigin: string | null;
  108763. }): void;
  108764. /**
  108765. * Removes unwanted characters from an url
  108766. * @param url defines the url to clean
  108767. * @returns the cleaned url
  108768. */
  108769. static CleanUrl(url: string): string;
  108770. /**
  108771. * Gets or sets a function used to pre-process url before using them to load assets
  108772. */
  108773. static get PreprocessUrl(): (url: string) => string;
  108774. static set PreprocessUrl(processor: (url: string) => string);
  108775. /**
  108776. * Loads an image as an HTMLImageElement.
  108777. * @param input url string, ArrayBuffer, or Blob to load
  108778. * @param onLoad callback called when the image successfully loads
  108779. * @param onError callback called when the image fails to load
  108780. * @param offlineProvider offline provider for caching
  108781. * @param mimeType optional mime type
  108782. * @returns the HTMLImageElement of the loaded image
  108783. */
  108784. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  108785. /**
  108786. * Loads a file from a url
  108787. * @param url url string, ArrayBuffer, or Blob to load
  108788. * @param onSuccess callback called when the file successfully loads
  108789. * @param onProgress callback called while file is loading (if the server supports this mode)
  108790. * @param offlineProvider defines the offline provider for caching
  108791. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108792. * @param onError callback called when the file fails to load
  108793. * @returns a file request object
  108794. */
  108795. 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;
  108796. /**
  108797. * Loads a file from a url
  108798. * @param url the file url to load
  108799. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  108800. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  108801. */
  108802. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  108803. /**
  108804. * Load a script (identified by an url). When the url returns, the
  108805. * content of this file is added into a new script element, attached to the DOM (body element)
  108806. * @param scriptUrl defines the url of the script to laod
  108807. * @param onSuccess defines the callback called when the script is loaded
  108808. * @param onError defines the callback to call if an error occurs
  108809. * @param scriptId defines the id of the script element
  108810. */
  108811. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  108812. /**
  108813. * Load an asynchronous script (identified by an url). When the url returns, the
  108814. * content of this file is added into a new script element, attached to the DOM (body element)
  108815. * @param scriptUrl defines the url of the script to laod
  108816. * @param scriptId defines the id of the script element
  108817. * @returns a promise request object
  108818. */
  108819. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  108820. /**
  108821. * Loads a file from a blob
  108822. * @param fileToLoad defines the blob to use
  108823. * @param callback defines the callback to call when data is loaded
  108824. * @param progressCallback defines the callback to call during loading process
  108825. * @returns a file request object
  108826. */
  108827. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  108828. /**
  108829. * Reads a file from a File object
  108830. * @param file defines the file to load
  108831. * @param onSuccess defines the callback to call when data is loaded
  108832. * @param onProgress defines the callback to call during loading process
  108833. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  108834. * @param onError defines the callback to call when an error occurs
  108835. * @returns a file request object
  108836. */
  108837. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  108838. /**
  108839. * Creates a data url from a given string content
  108840. * @param content defines the content to convert
  108841. * @returns the new data url link
  108842. */
  108843. static FileAsURL(content: string): string;
  108844. /**
  108845. * Format the given number to a specific decimal format
  108846. * @param value defines the number to format
  108847. * @param decimals defines the number of decimals to use
  108848. * @returns the formatted string
  108849. */
  108850. static Format(value: number, decimals?: number): string;
  108851. /**
  108852. * Tries to copy an object by duplicating every property
  108853. * @param source defines the source object
  108854. * @param destination defines the target object
  108855. * @param doNotCopyList defines a list of properties to avoid
  108856. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  108857. */
  108858. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  108859. /**
  108860. * Gets a boolean indicating if the given object has no own property
  108861. * @param obj defines the object to test
  108862. * @returns true if object has no own property
  108863. */
  108864. static IsEmpty(obj: any): boolean;
  108865. /**
  108866. * Function used to register events at window level
  108867. * @param windowElement defines the Window object to use
  108868. * @param events defines the events to register
  108869. */
  108870. static RegisterTopRootEvents(windowElement: Window, events: {
  108871. name: string;
  108872. handler: Nullable<(e: FocusEvent) => any>;
  108873. }[]): void;
  108874. /**
  108875. * Function used to unregister events from window level
  108876. * @param windowElement defines the Window object to use
  108877. * @param events defines the events to unregister
  108878. */
  108879. static UnregisterTopRootEvents(windowElement: Window, events: {
  108880. name: string;
  108881. handler: Nullable<(e: FocusEvent) => any>;
  108882. }[]): void;
  108883. /**
  108884. * @ignore
  108885. */
  108886. static _ScreenshotCanvas: HTMLCanvasElement;
  108887. /**
  108888. * Dumps the current bound framebuffer
  108889. * @param width defines the rendering width
  108890. * @param height defines the rendering height
  108891. * @param engine defines the hosting engine
  108892. * @param successCallback defines the callback triggered once the data are available
  108893. * @param mimeType defines the mime type of the result
  108894. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  108895. */
  108896. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108897. /**
  108898. * Converts the canvas data to blob.
  108899. * This acts as a polyfill for browsers not supporting the to blob function.
  108900. * @param canvas Defines the canvas to extract the data from
  108901. * @param successCallback Defines the callback triggered once the data are available
  108902. * @param mimeType Defines the mime type of the result
  108903. */
  108904. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  108905. /**
  108906. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  108907. * @param successCallback defines the callback triggered once the data are available
  108908. * @param mimeType defines the mime type of the result
  108909. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  108910. */
  108911. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  108912. /**
  108913. * Downloads a blob in the browser
  108914. * @param blob defines the blob to download
  108915. * @param fileName defines the name of the downloaded file
  108916. */
  108917. static Download(blob: Blob, fileName: string): void;
  108918. /**
  108919. * Captures a screenshot of the current rendering
  108920. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108921. * @param engine defines the rendering engine
  108922. * @param camera defines the source camera
  108923. * @param size This parameter can be set to a single number or to an object with the
  108924. * following (optional) properties: precision, width, height. If a single number is passed,
  108925. * it will be used for both width and height. If an object is passed, the screenshot size
  108926. * will be derived from the parameters. The precision property is a multiplier allowing
  108927. * rendering at a higher or lower resolution
  108928. * @param successCallback defines the callback receives a single parameter which contains the
  108929. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108930. * src parameter of an <img> to display it
  108931. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108932. * Check your browser for supported MIME types
  108933. */
  108934. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  108935. /**
  108936. * Captures a screenshot of the current rendering
  108937. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108938. * @param engine defines the rendering engine
  108939. * @param camera defines the source camera
  108940. * @param size This parameter can be set to a single number or to an object with the
  108941. * following (optional) properties: precision, width, height. If a single number is passed,
  108942. * it will be used for both width and height. If an object is passed, the screenshot size
  108943. * will be derived from the parameters. The precision property is a multiplier allowing
  108944. * rendering at a higher or lower resolution
  108945. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  108946. * Check your browser for supported MIME types
  108947. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108948. * to the src parameter of an <img> to display it
  108949. */
  108950. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  108951. /**
  108952. * Generates an image screenshot from the specified camera.
  108953. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108954. * @param engine The engine to use for rendering
  108955. * @param camera The camera to use for rendering
  108956. * @param size This parameter can be set to a single number or to an object with the
  108957. * following (optional) properties: precision, width, height. If a single number is passed,
  108958. * it will be used for both width and height. If an object is passed, the screenshot size
  108959. * will be derived from the parameters. The precision property is a multiplier allowing
  108960. * rendering at a higher or lower resolution
  108961. * @param successCallback The callback receives a single parameter which contains the
  108962. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  108963. * src parameter of an <img> to display it
  108964. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108965. * Check your browser for supported MIME types
  108966. * @param samples Texture samples (default: 1)
  108967. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108968. * @param fileName A name for for the downloaded file.
  108969. */
  108970. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  108971. /**
  108972. * Generates an image screenshot from the specified camera.
  108973. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  108974. * @param engine The engine to use for rendering
  108975. * @param camera The camera to use for rendering
  108976. * @param size This parameter can be set to a single number or to an object with the
  108977. * following (optional) properties: precision, width, height. If a single number is passed,
  108978. * it will be used for both width and height. If an object is passed, the screenshot size
  108979. * will be derived from the parameters. The precision property is a multiplier allowing
  108980. * rendering at a higher or lower resolution
  108981. * @param mimeType The MIME type of the screenshot image (default: image/png).
  108982. * Check your browser for supported MIME types
  108983. * @param samples Texture samples (default: 1)
  108984. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  108985. * @param fileName A name for for the downloaded file.
  108986. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  108987. * to the src parameter of an <img> to display it
  108988. */
  108989. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  108990. /**
  108991. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  108992. * Be aware Math.random() could cause collisions, but:
  108993. * "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"
  108994. * @returns a pseudo random id
  108995. */
  108996. static RandomId(): string;
  108997. /**
  108998. * Test if the given uri is a base64 string
  108999. * @param uri The uri to test
  109000. * @return True if the uri is a base64 string or false otherwise
  109001. */
  109002. static IsBase64(uri: string): boolean;
  109003. /**
  109004. * Decode the given base64 uri.
  109005. * @param uri The uri to decode
  109006. * @return The decoded base64 data.
  109007. */
  109008. static DecodeBase64(uri: string): ArrayBuffer;
  109009. /**
  109010. * Gets the absolute url.
  109011. * @param url the input url
  109012. * @return the absolute url
  109013. */
  109014. static GetAbsoluteUrl(url: string): string;
  109015. /**
  109016. * No log
  109017. */
  109018. static readonly NoneLogLevel: number;
  109019. /**
  109020. * Only message logs
  109021. */
  109022. static readonly MessageLogLevel: number;
  109023. /**
  109024. * Only warning logs
  109025. */
  109026. static readonly WarningLogLevel: number;
  109027. /**
  109028. * Only error logs
  109029. */
  109030. static readonly ErrorLogLevel: number;
  109031. /**
  109032. * All logs
  109033. */
  109034. static readonly AllLogLevel: number;
  109035. /**
  109036. * Gets a value indicating the number of loading errors
  109037. * @ignorenaming
  109038. */
  109039. static get errorsCount(): number;
  109040. /**
  109041. * Callback called when a new log is added
  109042. */
  109043. static OnNewCacheEntry: (entry: string) => void;
  109044. /**
  109045. * Log a message to the console
  109046. * @param message defines the message to log
  109047. */
  109048. static Log(message: string): void;
  109049. /**
  109050. * Write a warning message to the console
  109051. * @param message defines the message to log
  109052. */
  109053. static Warn(message: string): void;
  109054. /**
  109055. * Write an error message to the console
  109056. * @param message defines the message to log
  109057. */
  109058. static Error(message: string): void;
  109059. /**
  109060. * Gets current log cache (list of logs)
  109061. */
  109062. static get LogCache(): string;
  109063. /**
  109064. * Clears the log cache
  109065. */
  109066. static ClearLogCache(): void;
  109067. /**
  109068. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  109069. */
  109070. static set LogLevels(level: number);
  109071. /**
  109072. * Checks if the window object exists
  109073. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  109074. */
  109075. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  109076. /**
  109077. * No performance log
  109078. */
  109079. static readonly PerformanceNoneLogLevel: number;
  109080. /**
  109081. * Use user marks to log performance
  109082. */
  109083. static readonly PerformanceUserMarkLogLevel: number;
  109084. /**
  109085. * Log performance to the console
  109086. */
  109087. static readonly PerformanceConsoleLogLevel: number;
  109088. private static _performance;
  109089. /**
  109090. * Sets the current performance log level
  109091. */
  109092. static set PerformanceLogLevel(level: number);
  109093. private static _StartPerformanceCounterDisabled;
  109094. private static _EndPerformanceCounterDisabled;
  109095. private static _StartUserMark;
  109096. private static _EndUserMark;
  109097. private static _StartPerformanceConsole;
  109098. private static _EndPerformanceConsole;
  109099. /**
  109100. * Starts a performance counter
  109101. */
  109102. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109103. /**
  109104. * Ends a specific performance coutner
  109105. */
  109106. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  109107. /**
  109108. * Gets either window.performance.now() if supported or Date.now() else
  109109. */
  109110. static get Now(): number;
  109111. /**
  109112. * This method will return the name of the class used to create the instance of the given object.
  109113. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  109114. * @param object the object to get the class name from
  109115. * @param isType defines if the object is actually a type
  109116. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  109117. */
  109118. static GetClassName(object: any, isType?: boolean): string;
  109119. /**
  109120. * Gets the first element of an array satisfying a given predicate
  109121. * @param array defines the array to browse
  109122. * @param predicate defines the predicate to use
  109123. * @returns null if not found or the element
  109124. */
  109125. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  109126. /**
  109127. * This method will return the name of the full name of the class, including its owning module (if any).
  109128. * 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).
  109129. * @param object the object to get the class name from
  109130. * @param isType defines if the object is actually a type
  109131. * @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.
  109132. * @ignorenaming
  109133. */
  109134. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  109135. /**
  109136. * Returns a promise that resolves after the given amount of time.
  109137. * @param delay Number of milliseconds to delay
  109138. * @returns Promise that resolves after the given amount of time
  109139. */
  109140. static DelayAsync(delay: number): Promise<void>;
  109141. /**
  109142. * Utility function to detect if the current user agent is Safari
  109143. * @returns whether or not the current user agent is safari
  109144. */
  109145. static IsSafari(): boolean;
  109146. }
  109147. /**
  109148. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  109149. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  109150. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  109151. * @param name The name of the class, case should be preserved
  109152. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  109153. */
  109154. export function className(name: string, module?: string): (target: Object) => void;
  109155. /**
  109156. * An implementation of a loop for asynchronous functions.
  109157. */
  109158. export class AsyncLoop {
  109159. /**
  109160. * Defines the number of iterations for the loop
  109161. */
  109162. iterations: number;
  109163. /**
  109164. * Defines the current index of the loop.
  109165. */
  109166. index: number;
  109167. private _done;
  109168. private _fn;
  109169. private _successCallback;
  109170. /**
  109171. * Constructor.
  109172. * @param iterations the number of iterations.
  109173. * @param func the function to run each iteration
  109174. * @param successCallback the callback that will be called upon succesful execution
  109175. * @param offset starting offset.
  109176. */
  109177. constructor(
  109178. /**
  109179. * Defines the number of iterations for the loop
  109180. */
  109181. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  109182. /**
  109183. * Execute the next iteration. Must be called after the last iteration was finished.
  109184. */
  109185. executeNext(): void;
  109186. /**
  109187. * Break the loop and run the success callback.
  109188. */
  109189. breakLoop(): void;
  109190. /**
  109191. * Create and run an async loop.
  109192. * @param iterations the number of iterations.
  109193. * @param fn the function to run each iteration
  109194. * @param successCallback the callback that will be called upon succesful execution
  109195. * @param offset starting offset.
  109196. * @returns the created async loop object
  109197. */
  109198. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  109199. /**
  109200. * A for-loop that will run a given number of iterations synchronous and the rest async.
  109201. * @param iterations total number of iterations
  109202. * @param syncedIterations number of synchronous iterations in each async iteration.
  109203. * @param fn the function to call each iteration.
  109204. * @param callback a success call back that will be called when iterating stops.
  109205. * @param breakFunction a break condition (optional)
  109206. * @param timeout timeout settings for the setTimeout function. default - 0.
  109207. * @returns the created async loop object
  109208. */
  109209. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  109210. }
  109211. }
  109212. declare module BABYLON {
  109213. /**
  109214. * This class implement a typical dictionary using a string as key and the generic type T as value.
  109215. * The underlying implementation relies on an associative array to ensure the best performances.
  109216. * The value can be anything including 'null' but except 'undefined'
  109217. */
  109218. export class StringDictionary<T> {
  109219. /**
  109220. * This will clear this dictionary and copy the content from the 'source' one.
  109221. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  109222. * @param source the dictionary to take the content from and copy to this dictionary
  109223. */
  109224. copyFrom(source: StringDictionary<T>): void;
  109225. /**
  109226. * Get a value based from its key
  109227. * @param key the given key to get the matching value from
  109228. * @return the value if found, otherwise undefined is returned
  109229. */
  109230. get(key: string): T | undefined;
  109231. /**
  109232. * Get a value from its key or add it if it doesn't exist.
  109233. * This method will ensure you that a given key/data will be present in the dictionary.
  109234. * @param key the given key to get the matching value from
  109235. * @param factory the factory that will create the value if the key is not present in the dictionary.
  109236. * The factory will only be invoked if there's no data for the given key.
  109237. * @return the value corresponding to the key.
  109238. */
  109239. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  109240. /**
  109241. * Get a value from its key if present in the dictionary otherwise add it
  109242. * @param key the key to get the value from
  109243. * @param val if there's no such key/value pair in the dictionary add it with this value
  109244. * @return the value corresponding to the key
  109245. */
  109246. getOrAdd(key: string, val: T): T;
  109247. /**
  109248. * Check if there's a given key in the dictionary
  109249. * @param key the key to check for
  109250. * @return true if the key is present, false otherwise
  109251. */
  109252. contains(key: string): boolean;
  109253. /**
  109254. * Add a new key and its corresponding value
  109255. * @param key the key to add
  109256. * @param value the value corresponding to the key
  109257. * @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
  109258. */
  109259. add(key: string, value: T): boolean;
  109260. /**
  109261. * Update a specific value associated to a key
  109262. * @param key defines the key to use
  109263. * @param value defines the value to store
  109264. * @returns true if the value was updated (or false if the key was not found)
  109265. */
  109266. set(key: string, value: T): boolean;
  109267. /**
  109268. * Get the element of the given key and remove it from the dictionary
  109269. * @param key defines the key to search
  109270. * @returns the value associated with the key or null if not found
  109271. */
  109272. getAndRemove(key: string): Nullable<T>;
  109273. /**
  109274. * Remove a key/value from the dictionary.
  109275. * @param key the key to remove
  109276. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  109277. */
  109278. remove(key: string): boolean;
  109279. /**
  109280. * Clear the whole content of the dictionary
  109281. */
  109282. clear(): void;
  109283. /**
  109284. * Gets the current count
  109285. */
  109286. get count(): number;
  109287. /**
  109288. * Execute a callback on each key/val of the dictionary.
  109289. * Note that you can remove any element in this dictionary in the callback implementation
  109290. * @param callback the callback to execute on a given key/value pair
  109291. */
  109292. forEach(callback: (key: string, val: T) => void): void;
  109293. /**
  109294. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  109295. * If the callback returns null or undefined the method will iterate to the next key/value pair
  109296. * Note that you can remove any element in this dictionary in the callback implementation
  109297. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  109298. * @returns the first item
  109299. */
  109300. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  109301. private _count;
  109302. private _data;
  109303. }
  109304. }
  109305. declare module BABYLON {
  109306. /** @hidden */
  109307. export interface ICollisionCoordinator {
  109308. createCollider(): Collider;
  109309. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109310. init(scene: Scene): void;
  109311. }
  109312. /** @hidden */
  109313. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  109314. private _scene;
  109315. private _scaledPosition;
  109316. private _scaledVelocity;
  109317. private _finalPosition;
  109318. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  109319. createCollider(): Collider;
  109320. init(scene: Scene): void;
  109321. private _collideWithWorld;
  109322. }
  109323. }
  109324. declare module BABYLON {
  109325. /**
  109326. * Class used to manage all inputs for the scene.
  109327. */
  109328. export class InputManager {
  109329. /** The distance in pixel that you have to move to prevent some events */
  109330. static DragMovementThreshold: number;
  109331. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  109332. static LongPressDelay: number;
  109333. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  109334. static DoubleClickDelay: number;
  109335. /** If you need to check double click without raising a single click at first click, enable this flag */
  109336. static ExclusiveDoubleClickMode: boolean;
  109337. private _wheelEventName;
  109338. private _onPointerMove;
  109339. private _onPointerDown;
  109340. private _onPointerUp;
  109341. private _initClickEvent;
  109342. private _initActionManager;
  109343. private _delayedSimpleClick;
  109344. private _delayedSimpleClickTimeout;
  109345. private _previousDelayedSimpleClickTimeout;
  109346. private _meshPickProceed;
  109347. private _previousButtonPressed;
  109348. private _currentPickResult;
  109349. private _previousPickResult;
  109350. private _totalPointersPressed;
  109351. private _doubleClickOccured;
  109352. private _pointerOverMesh;
  109353. private _pickedDownMesh;
  109354. private _pickedUpMesh;
  109355. private _pointerX;
  109356. private _pointerY;
  109357. private _unTranslatedPointerX;
  109358. private _unTranslatedPointerY;
  109359. private _startingPointerPosition;
  109360. private _previousStartingPointerPosition;
  109361. private _startingPointerTime;
  109362. private _previousStartingPointerTime;
  109363. private _pointerCaptures;
  109364. private _onKeyDown;
  109365. private _onKeyUp;
  109366. private _onCanvasFocusObserver;
  109367. private _onCanvasBlurObserver;
  109368. private _scene;
  109369. /**
  109370. * Creates a new InputManager
  109371. * @param scene defines the hosting scene
  109372. */
  109373. constructor(scene: Scene);
  109374. /**
  109375. * Gets the mesh that is currently under the pointer
  109376. */
  109377. get meshUnderPointer(): Nullable<AbstractMesh>;
  109378. /**
  109379. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  109380. */
  109381. get unTranslatedPointer(): Vector2;
  109382. /**
  109383. * Gets or sets the current on-screen X position of the pointer
  109384. */
  109385. get pointerX(): number;
  109386. set pointerX(value: number);
  109387. /**
  109388. * Gets or sets the current on-screen Y position of the pointer
  109389. */
  109390. get pointerY(): number;
  109391. set pointerY(value: number);
  109392. private _updatePointerPosition;
  109393. private _processPointerMove;
  109394. private _setRayOnPointerInfo;
  109395. private _checkPrePointerObservable;
  109396. /**
  109397. * Use this method to simulate a pointer move on a mesh
  109398. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109399. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109400. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109401. */
  109402. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109403. /**
  109404. * Use this method to simulate a pointer down on a mesh
  109405. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109406. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109407. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109408. */
  109409. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  109410. private _processPointerDown;
  109411. /** @hidden */
  109412. _isPointerSwiping(): boolean;
  109413. /**
  109414. * Use this method to simulate a pointer up on a mesh
  109415. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  109416. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  109417. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  109418. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  109419. */
  109420. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  109421. private _processPointerUp;
  109422. /**
  109423. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  109424. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  109425. * @returns true if the pointer was captured
  109426. */
  109427. isPointerCaptured(pointerId?: number): boolean;
  109428. /**
  109429. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  109430. * @param attachUp defines if you want to attach events to pointerup
  109431. * @param attachDown defines if you want to attach events to pointerdown
  109432. * @param attachMove defines if you want to attach events to pointermove
  109433. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  109434. */
  109435. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  109436. /**
  109437. * Detaches all event handlers
  109438. */
  109439. detachControl(): void;
  109440. /**
  109441. * Force the value of meshUnderPointer
  109442. * @param mesh defines the mesh to use
  109443. */
  109444. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  109445. /**
  109446. * Gets the mesh under the pointer
  109447. * @returns a Mesh or null if no mesh is under the pointer
  109448. */
  109449. getPointerOverMesh(): Nullable<AbstractMesh>;
  109450. }
  109451. }
  109452. declare module BABYLON {
  109453. /**
  109454. * Helper class used to generate session unique ID
  109455. */
  109456. export class UniqueIdGenerator {
  109457. private static _UniqueIdCounter;
  109458. /**
  109459. * Gets an unique (relatively to the current scene) Id
  109460. */
  109461. static get UniqueId(): number;
  109462. }
  109463. }
  109464. declare module BABYLON {
  109465. /**
  109466. * This class defines the direct association between an animation and a target
  109467. */
  109468. export class TargetedAnimation {
  109469. /**
  109470. * Animation to perform
  109471. */
  109472. animation: Animation;
  109473. /**
  109474. * Target to animate
  109475. */
  109476. target: any;
  109477. /**
  109478. * Serialize the object
  109479. * @returns the JSON object representing the current entity
  109480. */
  109481. serialize(): any;
  109482. }
  109483. /**
  109484. * Use this class to create coordinated animations on multiple targets
  109485. */
  109486. export class AnimationGroup implements IDisposable {
  109487. /** The name of the animation group */
  109488. name: string;
  109489. private _scene;
  109490. private _targetedAnimations;
  109491. private _animatables;
  109492. private _from;
  109493. private _to;
  109494. private _isStarted;
  109495. private _isPaused;
  109496. private _speedRatio;
  109497. private _loopAnimation;
  109498. private _isAdditive;
  109499. /**
  109500. * Gets or sets the unique id of the node
  109501. */
  109502. uniqueId: number;
  109503. /**
  109504. * This observable will notify when one animation have ended
  109505. */
  109506. onAnimationEndObservable: Observable<TargetedAnimation>;
  109507. /**
  109508. * Observer raised when one animation loops
  109509. */
  109510. onAnimationLoopObservable: Observable<TargetedAnimation>;
  109511. /**
  109512. * Observer raised when all animations have looped
  109513. */
  109514. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  109515. /**
  109516. * This observable will notify when all animations have ended.
  109517. */
  109518. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  109519. /**
  109520. * This observable will notify when all animations have paused.
  109521. */
  109522. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  109523. /**
  109524. * This observable will notify when all animations are playing.
  109525. */
  109526. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  109527. /**
  109528. * Gets the first frame
  109529. */
  109530. get from(): number;
  109531. /**
  109532. * Gets the last frame
  109533. */
  109534. get to(): number;
  109535. /**
  109536. * Define if the animations are started
  109537. */
  109538. get isStarted(): boolean;
  109539. /**
  109540. * Gets a value indicating that the current group is playing
  109541. */
  109542. get isPlaying(): boolean;
  109543. /**
  109544. * Gets or sets the speed ratio to use for all animations
  109545. */
  109546. get speedRatio(): number;
  109547. /**
  109548. * Gets or sets the speed ratio to use for all animations
  109549. */
  109550. set speedRatio(value: number);
  109551. /**
  109552. * Gets or sets if all animations should loop or not
  109553. */
  109554. get loopAnimation(): boolean;
  109555. set loopAnimation(value: boolean);
  109556. /**
  109557. * Gets or sets if all animations should be evaluated additively
  109558. */
  109559. get isAdditive(): boolean;
  109560. set isAdditive(value: boolean);
  109561. /**
  109562. * Gets the targeted animations for this animation group
  109563. */
  109564. get targetedAnimations(): Array<TargetedAnimation>;
  109565. /**
  109566. * returning the list of animatables controlled by this animation group.
  109567. */
  109568. get animatables(): Array<Animatable>;
  109569. /**
  109570. * Instantiates a new Animation Group.
  109571. * This helps managing several animations at once.
  109572. * @see http://doc.babylonjs.com/how_to/group
  109573. * @param name Defines the name of the group
  109574. * @param scene Defines the scene the group belongs to
  109575. */
  109576. constructor(
  109577. /** The name of the animation group */
  109578. name: string, scene?: Nullable<Scene>);
  109579. /**
  109580. * Add an animation (with its target) in the group
  109581. * @param animation defines the animation we want to add
  109582. * @param target defines the target of the animation
  109583. * @returns the TargetedAnimation object
  109584. */
  109585. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  109586. /**
  109587. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  109588. * It can add constant keys at begin or end
  109589. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  109590. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  109591. * @returns the animation group
  109592. */
  109593. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  109594. private _animationLoopCount;
  109595. private _animationLoopFlags;
  109596. private _processLoop;
  109597. /**
  109598. * Start all animations on given targets
  109599. * @param loop defines if animations must loop
  109600. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  109601. * @param from defines the from key (optional)
  109602. * @param to defines the to key (optional)
  109603. * @param isAdditive defines the additive state for the resulting animatables (optional)
  109604. * @returns the current animation group
  109605. */
  109606. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  109607. /**
  109608. * Pause all animations
  109609. * @returns the animation group
  109610. */
  109611. pause(): AnimationGroup;
  109612. /**
  109613. * Play all animations to initial state
  109614. * This function will start() the animations if they were not started or will restart() them if they were paused
  109615. * @param loop defines if animations must loop
  109616. * @returns the animation group
  109617. */
  109618. play(loop?: boolean): AnimationGroup;
  109619. /**
  109620. * Reset all animations to initial state
  109621. * @returns the animation group
  109622. */
  109623. reset(): AnimationGroup;
  109624. /**
  109625. * Restart animations from key 0
  109626. * @returns the animation group
  109627. */
  109628. restart(): AnimationGroup;
  109629. /**
  109630. * Stop all animations
  109631. * @returns the animation group
  109632. */
  109633. stop(): AnimationGroup;
  109634. /**
  109635. * Set animation weight for all animatables
  109636. * @param weight defines the weight to use
  109637. * @return the animationGroup
  109638. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109639. */
  109640. setWeightForAllAnimatables(weight: number): AnimationGroup;
  109641. /**
  109642. * Synchronize and normalize all animatables with a source animatable
  109643. * @param root defines the root animatable to synchronize with
  109644. * @return the animationGroup
  109645. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  109646. */
  109647. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  109648. /**
  109649. * Goes to a specific frame in this animation group
  109650. * @param frame the frame number to go to
  109651. * @return the animationGroup
  109652. */
  109653. goToFrame(frame: number): AnimationGroup;
  109654. /**
  109655. * Dispose all associated resources
  109656. */
  109657. dispose(): void;
  109658. private _checkAnimationGroupEnded;
  109659. /**
  109660. * Clone the current animation group and returns a copy
  109661. * @param newName defines the name of the new group
  109662. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  109663. * @returns the new aniamtion group
  109664. */
  109665. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  109666. /**
  109667. * Serializes the animationGroup to an object
  109668. * @returns Serialized object
  109669. */
  109670. serialize(): any;
  109671. /**
  109672. * Returns a new AnimationGroup object parsed from the source provided.
  109673. * @param parsedAnimationGroup defines the source
  109674. * @param scene defines the scene that will receive the animationGroup
  109675. * @returns a new AnimationGroup
  109676. */
  109677. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  109678. /**
  109679. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  109680. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  109681. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  109682. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  109683. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  109684. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  109685. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  109686. */
  109687. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  109688. /**
  109689. * Returns the string "AnimationGroup"
  109690. * @returns "AnimationGroup"
  109691. */
  109692. getClassName(): string;
  109693. /**
  109694. * Creates a detailled string about the object
  109695. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  109696. * @returns a string representing the object
  109697. */
  109698. toString(fullDetails?: boolean): string;
  109699. }
  109700. }
  109701. declare module BABYLON {
  109702. /**
  109703. * Define an interface for all classes that will hold resources
  109704. */
  109705. export interface IDisposable {
  109706. /**
  109707. * Releases all held resources
  109708. */
  109709. dispose(): void;
  109710. }
  109711. /** Interface defining initialization parameters for Scene class */
  109712. export interface SceneOptions {
  109713. /**
  109714. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  109715. * It will improve performance when the number of geometries becomes important.
  109716. */
  109717. useGeometryUniqueIdsMap?: boolean;
  109718. /**
  109719. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  109720. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109721. */
  109722. useMaterialMeshMap?: boolean;
  109723. /**
  109724. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  109725. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  109726. */
  109727. useClonedMeshMap?: boolean;
  109728. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  109729. virtual?: boolean;
  109730. }
  109731. /**
  109732. * Represents a scene to be rendered by the engine.
  109733. * @see http://doc.babylonjs.com/features/scene
  109734. */
  109735. export class Scene extends AbstractScene implements IAnimatable {
  109736. /** The fog is deactivated */
  109737. static readonly FOGMODE_NONE: number;
  109738. /** The fog density is following an exponential function */
  109739. static readonly FOGMODE_EXP: number;
  109740. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  109741. static readonly FOGMODE_EXP2: number;
  109742. /** The fog density is following a linear function. */
  109743. static readonly FOGMODE_LINEAR: number;
  109744. /**
  109745. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  109746. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109747. */
  109748. static MinDeltaTime: number;
  109749. /**
  109750. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  109751. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  109752. */
  109753. static MaxDeltaTime: number;
  109754. /**
  109755. * Factory used to create the default material.
  109756. * @param name The name of the material to create
  109757. * @param scene The scene to create the material for
  109758. * @returns The default material
  109759. */
  109760. static DefaultMaterialFactory(scene: Scene): Material;
  109761. /**
  109762. * Factory used to create the a collision coordinator.
  109763. * @returns The collision coordinator
  109764. */
  109765. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  109766. /** @hidden */
  109767. _inputManager: InputManager;
  109768. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  109769. cameraToUseForPointers: Nullable<Camera>;
  109770. /** @hidden */
  109771. readonly _isScene: boolean;
  109772. /** @hidden */
  109773. _blockEntityCollection: boolean;
  109774. /**
  109775. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  109776. */
  109777. autoClear: boolean;
  109778. /**
  109779. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  109780. */
  109781. autoClearDepthAndStencil: boolean;
  109782. /**
  109783. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  109784. */
  109785. clearColor: Color4;
  109786. /**
  109787. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  109788. */
  109789. ambientColor: Color3;
  109790. /**
  109791. * This is use to store the default BRDF lookup for PBR materials in your scene.
  109792. * It should only be one of the following (if not the default embedded one):
  109793. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  109794. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  109795. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  109796. * The material properties need to be setup according to the type of texture in use.
  109797. */
  109798. environmentBRDFTexture: BaseTexture;
  109799. /** @hidden */
  109800. protected _environmentTexture: Nullable<BaseTexture>;
  109801. /**
  109802. * Texture used in all pbr material as the reflection texture.
  109803. * As in the majority of the scene they are the same (exception for multi room and so on),
  109804. * this is easier to reference from here than from all the materials.
  109805. */
  109806. get environmentTexture(): Nullable<BaseTexture>;
  109807. /**
  109808. * Texture used in all pbr material as the reflection texture.
  109809. * As in the majority of the scene they are the same (exception for multi room and so on),
  109810. * this is easier to set here than in all the materials.
  109811. */
  109812. set environmentTexture(value: Nullable<BaseTexture>);
  109813. /** @hidden */
  109814. protected _environmentIntensity: number;
  109815. /**
  109816. * Intensity of the environment in all pbr material.
  109817. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109818. * As in the majority of the scene they are the same (exception for multi room and so on),
  109819. * this is easier to reference from here than from all the materials.
  109820. */
  109821. get environmentIntensity(): number;
  109822. /**
  109823. * Intensity of the environment in all pbr material.
  109824. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  109825. * As in the majority of the scene they are the same (exception for multi room and so on),
  109826. * this is easier to set here than in all the materials.
  109827. */
  109828. set environmentIntensity(value: number);
  109829. /** @hidden */
  109830. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  109831. /**
  109832. * Default image processing configuration used either in the rendering
  109833. * Forward main pass or through the imageProcessingPostProcess if present.
  109834. * As in the majority of the scene they are the same (exception for multi camera),
  109835. * this is easier to reference from here than from all the materials and post process.
  109836. *
  109837. * No setter as we it is a shared configuration, you can set the values instead.
  109838. */
  109839. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  109840. private _forceWireframe;
  109841. /**
  109842. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  109843. */
  109844. set forceWireframe(value: boolean);
  109845. get forceWireframe(): boolean;
  109846. private _skipFrustumClipping;
  109847. /**
  109848. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  109849. */
  109850. set skipFrustumClipping(value: boolean);
  109851. get skipFrustumClipping(): boolean;
  109852. private _forcePointsCloud;
  109853. /**
  109854. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  109855. */
  109856. set forcePointsCloud(value: boolean);
  109857. get forcePointsCloud(): boolean;
  109858. /**
  109859. * Gets or sets the active clipplane 1
  109860. */
  109861. clipPlane: Nullable<Plane>;
  109862. /**
  109863. * Gets or sets the active clipplane 2
  109864. */
  109865. clipPlane2: Nullable<Plane>;
  109866. /**
  109867. * Gets or sets the active clipplane 3
  109868. */
  109869. clipPlane3: Nullable<Plane>;
  109870. /**
  109871. * Gets or sets the active clipplane 4
  109872. */
  109873. clipPlane4: Nullable<Plane>;
  109874. /**
  109875. * Gets or sets the active clipplane 5
  109876. */
  109877. clipPlane5: Nullable<Plane>;
  109878. /**
  109879. * Gets or sets the active clipplane 6
  109880. */
  109881. clipPlane6: Nullable<Plane>;
  109882. /**
  109883. * Gets or sets a boolean indicating if animations are enabled
  109884. */
  109885. animationsEnabled: boolean;
  109886. private _animationPropertiesOverride;
  109887. /**
  109888. * Gets or sets the animation properties override
  109889. */
  109890. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  109891. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  109892. /**
  109893. * Gets or sets a boolean indicating if a constant deltatime has to be used
  109894. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  109895. */
  109896. useConstantAnimationDeltaTime: boolean;
  109897. /**
  109898. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  109899. * Please note that it requires to run a ray cast through the scene on every frame
  109900. */
  109901. constantlyUpdateMeshUnderPointer: boolean;
  109902. /**
  109903. * Defines the HTML cursor to use when hovering over interactive elements
  109904. */
  109905. hoverCursor: string;
  109906. /**
  109907. * Defines the HTML default cursor to use (empty by default)
  109908. */
  109909. defaultCursor: string;
  109910. /**
  109911. * Defines whether cursors are handled by the scene.
  109912. */
  109913. doNotHandleCursors: boolean;
  109914. /**
  109915. * This is used to call preventDefault() on pointer down
  109916. * in order to block unwanted artifacts like system double clicks
  109917. */
  109918. preventDefaultOnPointerDown: boolean;
  109919. /**
  109920. * This is used to call preventDefault() on pointer up
  109921. * in order to block unwanted artifacts like system double clicks
  109922. */
  109923. preventDefaultOnPointerUp: boolean;
  109924. /**
  109925. * Gets or sets user defined metadata
  109926. */
  109927. metadata: any;
  109928. /**
  109929. * For internal use only. Please do not use.
  109930. */
  109931. reservedDataStore: any;
  109932. /**
  109933. * Gets the name of the plugin used to load this scene (null by default)
  109934. */
  109935. loadingPluginName: string;
  109936. /**
  109937. * Use this array to add regular expressions used to disable offline support for specific urls
  109938. */
  109939. disableOfflineSupportExceptionRules: RegExp[];
  109940. /**
  109941. * An event triggered when the scene is disposed.
  109942. */
  109943. onDisposeObservable: Observable<Scene>;
  109944. private _onDisposeObserver;
  109945. /** Sets a function to be executed when this scene is disposed. */
  109946. set onDispose(callback: () => void);
  109947. /**
  109948. * An event triggered before rendering the scene (right after animations and physics)
  109949. */
  109950. onBeforeRenderObservable: Observable<Scene>;
  109951. private _onBeforeRenderObserver;
  109952. /** Sets a function to be executed before rendering this scene */
  109953. set beforeRender(callback: Nullable<() => void>);
  109954. /**
  109955. * An event triggered after rendering the scene
  109956. */
  109957. onAfterRenderObservable: Observable<Scene>;
  109958. /**
  109959. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  109960. */
  109961. onAfterRenderCameraObservable: Observable<Camera>;
  109962. private _onAfterRenderObserver;
  109963. /** Sets a function to be executed after rendering this scene */
  109964. set afterRender(callback: Nullable<() => void>);
  109965. /**
  109966. * An event triggered before animating the scene
  109967. */
  109968. onBeforeAnimationsObservable: Observable<Scene>;
  109969. /**
  109970. * An event triggered after animations processing
  109971. */
  109972. onAfterAnimationsObservable: Observable<Scene>;
  109973. /**
  109974. * An event triggered before draw calls are ready to be sent
  109975. */
  109976. onBeforeDrawPhaseObservable: Observable<Scene>;
  109977. /**
  109978. * An event triggered after draw calls have been sent
  109979. */
  109980. onAfterDrawPhaseObservable: Observable<Scene>;
  109981. /**
  109982. * An event triggered when the scene is ready
  109983. */
  109984. onReadyObservable: Observable<Scene>;
  109985. /**
  109986. * An event triggered before rendering a camera
  109987. */
  109988. onBeforeCameraRenderObservable: Observable<Camera>;
  109989. private _onBeforeCameraRenderObserver;
  109990. /** Sets a function to be executed before rendering a camera*/
  109991. set beforeCameraRender(callback: () => void);
  109992. /**
  109993. * An event triggered after rendering a camera
  109994. */
  109995. onAfterCameraRenderObservable: Observable<Camera>;
  109996. private _onAfterCameraRenderObserver;
  109997. /** Sets a function to be executed after rendering a camera*/
  109998. set afterCameraRender(callback: () => void);
  109999. /**
  110000. * An event triggered when active meshes evaluation is about to start
  110001. */
  110002. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  110003. /**
  110004. * An event triggered when active meshes evaluation is done
  110005. */
  110006. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  110007. /**
  110008. * An event triggered when particles rendering is about to start
  110009. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110010. */
  110011. onBeforeParticlesRenderingObservable: Observable<Scene>;
  110012. /**
  110013. * An event triggered when particles rendering is done
  110014. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  110015. */
  110016. onAfterParticlesRenderingObservable: Observable<Scene>;
  110017. /**
  110018. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  110019. */
  110020. onDataLoadedObservable: Observable<Scene>;
  110021. /**
  110022. * An event triggered when a camera is created
  110023. */
  110024. onNewCameraAddedObservable: Observable<Camera>;
  110025. /**
  110026. * An event triggered when a camera is removed
  110027. */
  110028. onCameraRemovedObservable: Observable<Camera>;
  110029. /**
  110030. * An event triggered when a light is created
  110031. */
  110032. onNewLightAddedObservable: Observable<Light>;
  110033. /**
  110034. * An event triggered when a light is removed
  110035. */
  110036. onLightRemovedObservable: Observable<Light>;
  110037. /**
  110038. * An event triggered when a geometry is created
  110039. */
  110040. onNewGeometryAddedObservable: Observable<Geometry>;
  110041. /**
  110042. * An event triggered when a geometry is removed
  110043. */
  110044. onGeometryRemovedObservable: Observable<Geometry>;
  110045. /**
  110046. * An event triggered when a transform node is created
  110047. */
  110048. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  110049. /**
  110050. * An event triggered when a transform node is removed
  110051. */
  110052. onTransformNodeRemovedObservable: Observable<TransformNode>;
  110053. /**
  110054. * An event triggered when a mesh is created
  110055. */
  110056. onNewMeshAddedObservable: Observable<AbstractMesh>;
  110057. /**
  110058. * An event triggered when a mesh is removed
  110059. */
  110060. onMeshRemovedObservable: Observable<AbstractMesh>;
  110061. /**
  110062. * An event triggered when a skeleton is created
  110063. */
  110064. onNewSkeletonAddedObservable: Observable<Skeleton>;
  110065. /**
  110066. * An event triggered when a skeleton is removed
  110067. */
  110068. onSkeletonRemovedObservable: Observable<Skeleton>;
  110069. /**
  110070. * An event triggered when a material is created
  110071. */
  110072. onNewMaterialAddedObservable: Observable<Material>;
  110073. /**
  110074. * An event triggered when a material is removed
  110075. */
  110076. onMaterialRemovedObservable: Observable<Material>;
  110077. /**
  110078. * An event triggered when a texture is created
  110079. */
  110080. onNewTextureAddedObservable: Observable<BaseTexture>;
  110081. /**
  110082. * An event triggered when a texture is removed
  110083. */
  110084. onTextureRemovedObservable: Observable<BaseTexture>;
  110085. /**
  110086. * An event triggered when render targets are about to be rendered
  110087. * Can happen multiple times per frame.
  110088. */
  110089. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  110090. /**
  110091. * An event triggered when render targets were rendered.
  110092. * Can happen multiple times per frame.
  110093. */
  110094. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  110095. /**
  110096. * An event triggered before calculating deterministic simulation step
  110097. */
  110098. onBeforeStepObservable: Observable<Scene>;
  110099. /**
  110100. * An event triggered after calculating deterministic simulation step
  110101. */
  110102. onAfterStepObservable: Observable<Scene>;
  110103. /**
  110104. * An event triggered when the activeCamera property is updated
  110105. */
  110106. onActiveCameraChanged: Observable<Scene>;
  110107. /**
  110108. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  110109. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110110. * 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)
  110111. */
  110112. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110113. /**
  110114. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  110115. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  110116. * 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)
  110117. */
  110118. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  110119. /**
  110120. * This Observable will when a mesh has been imported into the scene.
  110121. */
  110122. onMeshImportedObservable: Observable<AbstractMesh>;
  110123. /**
  110124. * This Observable will when an animation file has been imported into the scene.
  110125. */
  110126. onAnimationFileImportedObservable: Observable<Scene>;
  110127. /**
  110128. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  110129. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  110130. */
  110131. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  110132. /** @hidden */
  110133. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  110134. /**
  110135. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  110136. */
  110137. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  110138. /**
  110139. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  110140. */
  110141. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  110142. /**
  110143. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  110144. */
  110145. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  110146. /** Callback called when a pointer move is detected */
  110147. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110148. /** Callback called when a pointer down is detected */
  110149. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  110150. /** Callback called when a pointer up is detected */
  110151. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  110152. /** Callback called when a pointer pick is detected */
  110153. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  110154. /**
  110155. * 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).
  110156. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  110157. */
  110158. onPrePointerObservable: Observable<PointerInfoPre>;
  110159. /**
  110160. * Observable event triggered each time an input event is received from the rendering canvas
  110161. */
  110162. onPointerObservable: Observable<PointerInfo>;
  110163. /**
  110164. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  110165. */
  110166. get unTranslatedPointer(): Vector2;
  110167. /**
  110168. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  110169. */
  110170. static get DragMovementThreshold(): number;
  110171. static set DragMovementThreshold(value: number);
  110172. /**
  110173. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  110174. */
  110175. static get LongPressDelay(): number;
  110176. static set LongPressDelay(value: number);
  110177. /**
  110178. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  110179. */
  110180. static get DoubleClickDelay(): number;
  110181. static set DoubleClickDelay(value: number);
  110182. /** If you need to check double click without raising a single click at first click, enable this flag */
  110183. static get ExclusiveDoubleClickMode(): boolean;
  110184. static set ExclusiveDoubleClickMode(value: boolean);
  110185. /** @hidden */
  110186. _mirroredCameraPosition: Nullable<Vector3>;
  110187. /**
  110188. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  110189. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  110190. */
  110191. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  110192. /**
  110193. * Observable event triggered each time an keyboard event is received from the hosting window
  110194. */
  110195. onKeyboardObservable: Observable<KeyboardInfo>;
  110196. private _useRightHandedSystem;
  110197. /**
  110198. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  110199. */
  110200. set useRightHandedSystem(value: boolean);
  110201. get useRightHandedSystem(): boolean;
  110202. private _timeAccumulator;
  110203. private _currentStepId;
  110204. private _currentInternalStep;
  110205. /**
  110206. * Sets the step Id used by deterministic lock step
  110207. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110208. * @param newStepId defines the step Id
  110209. */
  110210. setStepId(newStepId: number): void;
  110211. /**
  110212. * Gets the step Id used by deterministic lock step
  110213. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110214. * @returns the step Id
  110215. */
  110216. getStepId(): number;
  110217. /**
  110218. * Gets the internal step used by deterministic lock step
  110219. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  110220. * @returns the internal step
  110221. */
  110222. getInternalStep(): number;
  110223. private _fogEnabled;
  110224. /**
  110225. * Gets or sets a boolean indicating if fog is enabled on this scene
  110226. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110227. * (Default is true)
  110228. */
  110229. set fogEnabled(value: boolean);
  110230. get fogEnabled(): boolean;
  110231. private _fogMode;
  110232. /**
  110233. * Gets or sets the fog mode to use
  110234. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110235. * | mode | value |
  110236. * | --- | --- |
  110237. * | FOGMODE_NONE | 0 |
  110238. * | FOGMODE_EXP | 1 |
  110239. * | FOGMODE_EXP2 | 2 |
  110240. * | FOGMODE_LINEAR | 3 |
  110241. */
  110242. set fogMode(value: number);
  110243. get fogMode(): number;
  110244. /**
  110245. * Gets or sets the fog color to use
  110246. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110247. * (Default is Color3(0.2, 0.2, 0.3))
  110248. */
  110249. fogColor: Color3;
  110250. /**
  110251. * Gets or sets the fog density to use
  110252. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110253. * (Default is 0.1)
  110254. */
  110255. fogDensity: number;
  110256. /**
  110257. * Gets or sets the fog start distance to use
  110258. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110259. * (Default is 0)
  110260. */
  110261. fogStart: number;
  110262. /**
  110263. * Gets or sets the fog end distance to use
  110264. * @see http://doc.babylonjs.com/babylon101/environment#fog
  110265. * (Default is 1000)
  110266. */
  110267. fogEnd: number;
  110268. private _shadowsEnabled;
  110269. /**
  110270. * Gets or sets a boolean indicating if shadows are enabled on this scene
  110271. */
  110272. set shadowsEnabled(value: boolean);
  110273. get shadowsEnabled(): boolean;
  110274. private _lightsEnabled;
  110275. /**
  110276. * Gets or sets a boolean indicating if lights are enabled on this scene
  110277. */
  110278. set lightsEnabled(value: boolean);
  110279. get lightsEnabled(): boolean;
  110280. /** All of the active cameras added to this scene. */
  110281. activeCameras: Camera[];
  110282. /** @hidden */
  110283. _activeCamera: Nullable<Camera>;
  110284. /** Gets or sets the current active camera */
  110285. get activeCamera(): Nullable<Camera>;
  110286. set activeCamera(value: Nullable<Camera>);
  110287. private _defaultMaterial;
  110288. /** The default material used on meshes when no material is affected */
  110289. get defaultMaterial(): Material;
  110290. /** The default material used on meshes when no material is affected */
  110291. set defaultMaterial(value: Material);
  110292. private _texturesEnabled;
  110293. /**
  110294. * Gets or sets a boolean indicating if textures are enabled on this scene
  110295. */
  110296. set texturesEnabled(value: boolean);
  110297. get texturesEnabled(): boolean;
  110298. /**
  110299. * Gets or sets a boolean indicating if particles are enabled on this scene
  110300. */
  110301. particlesEnabled: boolean;
  110302. /**
  110303. * Gets or sets a boolean indicating if sprites are enabled on this scene
  110304. */
  110305. spritesEnabled: boolean;
  110306. private _skeletonsEnabled;
  110307. /**
  110308. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  110309. */
  110310. set skeletonsEnabled(value: boolean);
  110311. get skeletonsEnabled(): boolean;
  110312. /**
  110313. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  110314. */
  110315. lensFlaresEnabled: boolean;
  110316. /**
  110317. * Gets or sets a boolean indicating if collisions are enabled on this scene
  110318. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110319. */
  110320. collisionsEnabled: boolean;
  110321. private _collisionCoordinator;
  110322. /** @hidden */
  110323. get collisionCoordinator(): ICollisionCoordinator;
  110324. /**
  110325. * Defines the gravity applied to this scene (used only for collisions)
  110326. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  110327. */
  110328. gravity: Vector3;
  110329. /**
  110330. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  110331. */
  110332. postProcessesEnabled: boolean;
  110333. /**
  110334. * The list of postprocesses added to the scene
  110335. */
  110336. postProcesses: PostProcess[];
  110337. /**
  110338. * Gets the current postprocess manager
  110339. */
  110340. postProcessManager: PostProcessManager;
  110341. /**
  110342. * Gets or sets a boolean indicating if render targets are enabled on this scene
  110343. */
  110344. renderTargetsEnabled: boolean;
  110345. /**
  110346. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  110347. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  110348. */
  110349. dumpNextRenderTargets: boolean;
  110350. /**
  110351. * The list of user defined render targets added to the scene
  110352. */
  110353. customRenderTargets: RenderTargetTexture[];
  110354. /**
  110355. * Defines if texture loading must be delayed
  110356. * If true, textures will only be loaded when they need to be rendered
  110357. */
  110358. useDelayedTextureLoading: boolean;
  110359. /**
  110360. * Gets the list of meshes imported to the scene through SceneLoader
  110361. */
  110362. importedMeshesFiles: String[];
  110363. /**
  110364. * Gets or sets a boolean indicating if probes are enabled on this scene
  110365. */
  110366. probesEnabled: boolean;
  110367. /**
  110368. * Gets or sets the current offline provider to use to store scene data
  110369. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110370. */
  110371. offlineProvider: IOfflineProvider;
  110372. /**
  110373. * Gets or sets the action manager associated with the scene
  110374. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  110375. */
  110376. actionManager: AbstractActionManager;
  110377. private _meshesForIntersections;
  110378. /**
  110379. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  110380. */
  110381. proceduralTexturesEnabled: boolean;
  110382. private _engine;
  110383. private _totalVertices;
  110384. /** @hidden */
  110385. _activeIndices: PerfCounter;
  110386. /** @hidden */
  110387. _activeParticles: PerfCounter;
  110388. /** @hidden */
  110389. _activeBones: PerfCounter;
  110390. private _animationRatio;
  110391. /** @hidden */
  110392. _animationTimeLast: number;
  110393. /** @hidden */
  110394. _animationTime: number;
  110395. /**
  110396. * Gets or sets a general scale for animation speed
  110397. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  110398. */
  110399. animationTimeScale: number;
  110400. /** @hidden */
  110401. _cachedMaterial: Nullable<Material>;
  110402. /** @hidden */
  110403. _cachedEffect: Nullable<Effect>;
  110404. /** @hidden */
  110405. _cachedVisibility: Nullable<number>;
  110406. private _renderId;
  110407. private _frameId;
  110408. private _executeWhenReadyTimeoutId;
  110409. private _intermediateRendering;
  110410. private _viewUpdateFlag;
  110411. private _projectionUpdateFlag;
  110412. /** @hidden */
  110413. _toBeDisposed: Nullable<IDisposable>[];
  110414. private _activeRequests;
  110415. /** @hidden */
  110416. _pendingData: any[];
  110417. private _isDisposed;
  110418. /**
  110419. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  110420. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  110421. */
  110422. dispatchAllSubMeshesOfActiveMeshes: boolean;
  110423. private _activeMeshes;
  110424. private _processedMaterials;
  110425. private _renderTargets;
  110426. /** @hidden */
  110427. _activeParticleSystems: SmartArray<IParticleSystem>;
  110428. private _activeSkeletons;
  110429. private _softwareSkinnedMeshes;
  110430. private _renderingManager;
  110431. /** @hidden */
  110432. _activeAnimatables: Animatable[];
  110433. private _transformMatrix;
  110434. private _sceneUbo;
  110435. /** @hidden */
  110436. _viewMatrix: Matrix;
  110437. private _projectionMatrix;
  110438. /** @hidden */
  110439. _forcedViewPosition: Nullable<Vector3>;
  110440. /** @hidden */
  110441. _frustumPlanes: Plane[];
  110442. /**
  110443. * Gets the list of frustum planes (built from the active camera)
  110444. */
  110445. get frustumPlanes(): Plane[];
  110446. /**
  110447. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  110448. * This is useful if there are more lights that the maximum simulteanous authorized
  110449. */
  110450. requireLightSorting: boolean;
  110451. /** @hidden */
  110452. readonly useMaterialMeshMap: boolean;
  110453. /** @hidden */
  110454. readonly useClonedMeshMap: boolean;
  110455. private _externalData;
  110456. private _uid;
  110457. /**
  110458. * @hidden
  110459. * Backing store of defined scene components.
  110460. */
  110461. _components: ISceneComponent[];
  110462. /**
  110463. * @hidden
  110464. * Backing store of defined scene components.
  110465. */
  110466. _serializableComponents: ISceneSerializableComponent[];
  110467. /**
  110468. * List of components to register on the next registration step.
  110469. */
  110470. private _transientComponents;
  110471. /**
  110472. * Registers the transient components if needed.
  110473. */
  110474. private _registerTransientComponents;
  110475. /**
  110476. * @hidden
  110477. * Add a component to the scene.
  110478. * Note that the ccomponent could be registered on th next frame if this is called after
  110479. * the register component stage.
  110480. * @param component Defines the component to add to the scene
  110481. */
  110482. _addComponent(component: ISceneComponent): void;
  110483. /**
  110484. * @hidden
  110485. * Gets a component from the scene.
  110486. * @param name defines the name of the component to retrieve
  110487. * @returns the component or null if not present
  110488. */
  110489. _getComponent(name: string): Nullable<ISceneComponent>;
  110490. /**
  110491. * @hidden
  110492. * Defines the actions happening before camera updates.
  110493. */
  110494. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  110495. /**
  110496. * @hidden
  110497. * Defines the actions happening before clear the canvas.
  110498. */
  110499. _beforeClearStage: Stage<SimpleStageAction>;
  110500. /**
  110501. * @hidden
  110502. * Defines the actions when collecting render targets for the frame.
  110503. */
  110504. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110505. /**
  110506. * @hidden
  110507. * Defines the actions happening for one camera in the frame.
  110508. */
  110509. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  110510. /**
  110511. * @hidden
  110512. * Defines the actions happening during the per mesh ready checks.
  110513. */
  110514. _isReadyForMeshStage: Stage<MeshStageAction>;
  110515. /**
  110516. * @hidden
  110517. * Defines the actions happening before evaluate active mesh checks.
  110518. */
  110519. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  110520. /**
  110521. * @hidden
  110522. * Defines the actions happening during the evaluate sub mesh checks.
  110523. */
  110524. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  110525. /**
  110526. * @hidden
  110527. * Defines the actions happening during the active mesh stage.
  110528. */
  110529. _activeMeshStage: Stage<ActiveMeshStageAction>;
  110530. /**
  110531. * @hidden
  110532. * Defines the actions happening during the per camera render target step.
  110533. */
  110534. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  110535. /**
  110536. * @hidden
  110537. * Defines the actions happening just before the active camera is drawing.
  110538. */
  110539. _beforeCameraDrawStage: Stage<CameraStageAction>;
  110540. /**
  110541. * @hidden
  110542. * Defines the actions happening just before a render target is drawing.
  110543. */
  110544. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110545. /**
  110546. * @hidden
  110547. * Defines the actions happening just before a rendering group is drawing.
  110548. */
  110549. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110550. /**
  110551. * @hidden
  110552. * Defines the actions happening just before a mesh is drawing.
  110553. */
  110554. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110555. /**
  110556. * @hidden
  110557. * Defines the actions happening just after a mesh has been drawn.
  110558. */
  110559. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  110560. /**
  110561. * @hidden
  110562. * Defines the actions happening just after a rendering group has been drawn.
  110563. */
  110564. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  110565. /**
  110566. * @hidden
  110567. * Defines the actions happening just after the active camera has been drawn.
  110568. */
  110569. _afterCameraDrawStage: Stage<CameraStageAction>;
  110570. /**
  110571. * @hidden
  110572. * Defines the actions happening just after a render target has been drawn.
  110573. */
  110574. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  110575. /**
  110576. * @hidden
  110577. * Defines the actions happening just after rendering all cameras and computing intersections.
  110578. */
  110579. _afterRenderStage: Stage<SimpleStageAction>;
  110580. /**
  110581. * @hidden
  110582. * Defines the actions happening when a pointer move event happens.
  110583. */
  110584. _pointerMoveStage: Stage<PointerMoveStageAction>;
  110585. /**
  110586. * @hidden
  110587. * Defines the actions happening when a pointer down event happens.
  110588. */
  110589. _pointerDownStage: Stage<PointerUpDownStageAction>;
  110590. /**
  110591. * @hidden
  110592. * Defines the actions happening when a pointer up event happens.
  110593. */
  110594. _pointerUpStage: Stage<PointerUpDownStageAction>;
  110595. /**
  110596. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  110597. */
  110598. private geometriesByUniqueId;
  110599. /**
  110600. * Creates a new Scene
  110601. * @param engine defines the engine to use to render this scene
  110602. * @param options defines the scene options
  110603. */
  110604. constructor(engine: Engine, options?: SceneOptions);
  110605. /**
  110606. * Gets a string idenfifying the name of the class
  110607. * @returns "Scene" string
  110608. */
  110609. getClassName(): string;
  110610. private _defaultMeshCandidates;
  110611. /**
  110612. * @hidden
  110613. */
  110614. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  110615. private _defaultSubMeshCandidates;
  110616. /**
  110617. * @hidden
  110618. */
  110619. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  110620. /**
  110621. * Sets the default candidate providers for the scene.
  110622. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  110623. * and getCollidingSubMeshCandidates to their default function
  110624. */
  110625. setDefaultCandidateProviders(): void;
  110626. /**
  110627. * Gets the mesh that is currently under the pointer
  110628. */
  110629. get meshUnderPointer(): Nullable<AbstractMesh>;
  110630. /**
  110631. * Gets or sets the current on-screen X position of the pointer
  110632. */
  110633. get pointerX(): number;
  110634. set pointerX(value: number);
  110635. /**
  110636. * Gets or sets the current on-screen Y position of the pointer
  110637. */
  110638. get pointerY(): number;
  110639. set pointerY(value: number);
  110640. /**
  110641. * Gets the cached material (ie. the latest rendered one)
  110642. * @returns the cached material
  110643. */
  110644. getCachedMaterial(): Nullable<Material>;
  110645. /**
  110646. * Gets the cached effect (ie. the latest rendered one)
  110647. * @returns the cached effect
  110648. */
  110649. getCachedEffect(): Nullable<Effect>;
  110650. /**
  110651. * Gets the cached visibility state (ie. the latest rendered one)
  110652. * @returns the cached visibility state
  110653. */
  110654. getCachedVisibility(): Nullable<number>;
  110655. /**
  110656. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  110657. * @param material defines the current material
  110658. * @param effect defines the current effect
  110659. * @param visibility defines the current visibility state
  110660. * @returns true if one parameter is not cached
  110661. */
  110662. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  110663. /**
  110664. * Gets the engine associated with the scene
  110665. * @returns an Engine
  110666. */
  110667. getEngine(): Engine;
  110668. /**
  110669. * Gets the total number of vertices rendered per frame
  110670. * @returns the total number of vertices rendered per frame
  110671. */
  110672. getTotalVertices(): number;
  110673. /**
  110674. * Gets the performance counter for total vertices
  110675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110676. */
  110677. get totalVerticesPerfCounter(): PerfCounter;
  110678. /**
  110679. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  110680. * @returns the total number of active indices rendered per frame
  110681. */
  110682. getActiveIndices(): number;
  110683. /**
  110684. * Gets the performance counter for active indices
  110685. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110686. */
  110687. get totalActiveIndicesPerfCounter(): PerfCounter;
  110688. /**
  110689. * Gets the total number of active particles rendered per frame
  110690. * @returns the total number of active particles rendered per frame
  110691. */
  110692. getActiveParticles(): number;
  110693. /**
  110694. * Gets the performance counter for active particles
  110695. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110696. */
  110697. get activeParticlesPerfCounter(): PerfCounter;
  110698. /**
  110699. * Gets the total number of active bones rendered per frame
  110700. * @returns the total number of active bones rendered per frame
  110701. */
  110702. getActiveBones(): number;
  110703. /**
  110704. * Gets the performance counter for active bones
  110705. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  110706. */
  110707. get activeBonesPerfCounter(): PerfCounter;
  110708. /**
  110709. * Gets the array of active meshes
  110710. * @returns an array of AbstractMesh
  110711. */
  110712. getActiveMeshes(): SmartArray<AbstractMesh>;
  110713. /**
  110714. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  110715. * @returns a number
  110716. */
  110717. getAnimationRatio(): number;
  110718. /**
  110719. * Gets an unique Id for the current render phase
  110720. * @returns a number
  110721. */
  110722. getRenderId(): number;
  110723. /**
  110724. * Gets an unique Id for the current frame
  110725. * @returns a number
  110726. */
  110727. getFrameId(): number;
  110728. /** Call this function if you want to manually increment the render Id*/
  110729. incrementRenderId(): void;
  110730. private _createUbo;
  110731. /**
  110732. * Use this method to simulate a pointer move on a mesh
  110733. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110734. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110735. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110736. * @returns the current scene
  110737. */
  110738. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110739. /**
  110740. * Use this method to simulate a pointer down on a mesh
  110741. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110742. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110743. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110744. * @returns the current scene
  110745. */
  110746. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  110747. /**
  110748. * Use this method to simulate a pointer up on a mesh
  110749. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  110750. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  110751. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  110752. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  110753. * @returns the current scene
  110754. */
  110755. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  110756. /**
  110757. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  110758. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  110759. * @returns true if the pointer was captured
  110760. */
  110761. isPointerCaptured(pointerId?: number): boolean;
  110762. /**
  110763. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  110764. * @param attachUp defines if you want to attach events to pointerup
  110765. * @param attachDown defines if you want to attach events to pointerdown
  110766. * @param attachMove defines if you want to attach events to pointermove
  110767. */
  110768. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  110769. /** Detaches all event handlers*/
  110770. detachControl(): void;
  110771. /**
  110772. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  110773. * Delay loaded resources are not taking in account
  110774. * @return true if all required resources are ready
  110775. */
  110776. isReady(): boolean;
  110777. /** Resets all cached information relative to material (including effect and visibility) */
  110778. resetCachedMaterial(): void;
  110779. /**
  110780. * Registers a function to be called before every frame render
  110781. * @param func defines the function to register
  110782. */
  110783. registerBeforeRender(func: () => void): void;
  110784. /**
  110785. * Unregisters a function called before every frame render
  110786. * @param func defines the function to unregister
  110787. */
  110788. unregisterBeforeRender(func: () => void): void;
  110789. /**
  110790. * Registers a function to be called after every frame render
  110791. * @param func defines the function to register
  110792. */
  110793. registerAfterRender(func: () => void): void;
  110794. /**
  110795. * Unregisters a function called after every frame render
  110796. * @param func defines the function to unregister
  110797. */
  110798. unregisterAfterRender(func: () => void): void;
  110799. private _executeOnceBeforeRender;
  110800. /**
  110801. * The provided function will run before render once and will be disposed afterwards.
  110802. * A timeout delay can be provided so that the function will be executed in N ms.
  110803. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  110804. * @param func The function to be executed.
  110805. * @param timeout optional delay in ms
  110806. */
  110807. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  110808. /** @hidden */
  110809. _addPendingData(data: any): void;
  110810. /** @hidden */
  110811. _removePendingData(data: any): void;
  110812. /**
  110813. * Returns the number of items waiting to be loaded
  110814. * @returns the number of items waiting to be loaded
  110815. */
  110816. getWaitingItemsCount(): number;
  110817. /**
  110818. * Returns a boolean indicating if the scene is still loading data
  110819. */
  110820. get isLoading(): boolean;
  110821. /**
  110822. * Registers a function to be executed when the scene is ready
  110823. * @param {Function} func - the function to be executed
  110824. */
  110825. executeWhenReady(func: () => void): void;
  110826. /**
  110827. * Returns a promise that resolves when the scene is ready
  110828. * @returns A promise that resolves when the scene is ready
  110829. */
  110830. whenReadyAsync(): Promise<void>;
  110831. /** @hidden */
  110832. _checkIsReady(): void;
  110833. /**
  110834. * Gets all animatable attached to the scene
  110835. */
  110836. get animatables(): Animatable[];
  110837. /**
  110838. * Resets the last animation time frame.
  110839. * Useful to override when animations start running when loading a scene for the first time.
  110840. */
  110841. resetLastAnimationTimeFrame(): void;
  110842. /**
  110843. * Gets the current view matrix
  110844. * @returns a Matrix
  110845. */
  110846. getViewMatrix(): Matrix;
  110847. /**
  110848. * Gets the current projection matrix
  110849. * @returns a Matrix
  110850. */
  110851. getProjectionMatrix(): Matrix;
  110852. /**
  110853. * Gets the current transform matrix
  110854. * @returns a Matrix made of View * Projection
  110855. */
  110856. getTransformMatrix(): Matrix;
  110857. /**
  110858. * Sets the current transform matrix
  110859. * @param viewL defines the View matrix to use
  110860. * @param projectionL defines the Projection matrix to use
  110861. * @param viewR defines the right View matrix to use (if provided)
  110862. * @param projectionR defines the right Projection matrix to use (if provided)
  110863. */
  110864. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  110865. /**
  110866. * Gets the uniform buffer used to store scene data
  110867. * @returns a UniformBuffer
  110868. */
  110869. getSceneUniformBuffer(): UniformBuffer;
  110870. /**
  110871. * Gets an unique (relatively to the current scene) Id
  110872. * @returns an unique number for the scene
  110873. */
  110874. getUniqueId(): number;
  110875. /**
  110876. * Add a mesh to the list of scene's meshes
  110877. * @param newMesh defines the mesh to add
  110878. * @param recursive if all child meshes should also be added to the scene
  110879. */
  110880. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  110881. /**
  110882. * Remove a mesh for the list of scene's meshes
  110883. * @param toRemove defines the mesh to remove
  110884. * @param recursive if all child meshes should also be removed from the scene
  110885. * @returns the index where the mesh was in the mesh list
  110886. */
  110887. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  110888. /**
  110889. * Add a transform node to the list of scene's transform nodes
  110890. * @param newTransformNode defines the transform node to add
  110891. */
  110892. addTransformNode(newTransformNode: TransformNode): void;
  110893. /**
  110894. * Remove a transform node for the list of scene's transform nodes
  110895. * @param toRemove defines the transform node to remove
  110896. * @returns the index where the transform node was in the transform node list
  110897. */
  110898. removeTransformNode(toRemove: TransformNode): number;
  110899. /**
  110900. * Remove a skeleton for the list of scene's skeletons
  110901. * @param toRemove defines the skeleton to remove
  110902. * @returns the index where the skeleton was in the skeleton list
  110903. */
  110904. removeSkeleton(toRemove: Skeleton): number;
  110905. /**
  110906. * Remove a morph target for the list of scene's morph targets
  110907. * @param toRemove defines the morph target to remove
  110908. * @returns the index where the morph target was in the morph target list
  110909. */
  110910. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  110911. /**
  110912. * Remove a light for the list of scene's lights
  110913. * @param toRemove defines the light to remove
  110914. * @returns the index where the light was in the light list
  110915. */
  110916. removeLight(toRemove: Light): number;
  110917. /**
  110918. * Remove a camera for the list of scene's cameras
  110919. * @param toRemove defines the camera to remove
  110920. * @returns the index where the camera was in the camera list
  110921. */
  110922. removeCamera(toRemove: Camera): number;
  110923. /**
  110924. * Remove a particle system for the list of scene's particle systems
  110925. * @param toRemove defines the particle system to remove
  110926. * @returns the index where the particle system was in the particle system list
  110927. */
  110928. removeParticleSystem(toRemove: IParticleSystem): number;
  110929. /**
  110930. * Remove a animation for the list of scene's animations
  110931. * @param toRemove defines the animation to remove
  110932. * @returns the index where the animation was in the animation list
  110933. */
  110934. removeAnimation(toRemove: Animation): number;
  110935. /**
  110936. * Will stop the animation of the given target
  110937. * @param target - the target
  110938. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  110939. * @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)
  110940. */
  110941. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  110942. /**
  110943. * Removes the given animation group from this scene.
  110944. * @param toRemove The animation group to remove
  110945. * @returns The index of the removed animation group
  110946. */
  110947. removeAnimationGroup(toRemove: AnimationGroup): number;
  110948. /**
  110949. * Removes the given multi-material from this scene.
  110950. * @param toRemove The multi-material to remove
  110951. * @returns The index of the removed multi-material
  110952. */
  110953. removeMultiMaterial(toRemove: MultiMaterial): number;
  110954. /**
  110955. * Removes the given material from this scene.
  110956. * @param toRemove The material to remove
  110957. * @returns The index of the removed material
  110958. */
  110959. removeMaterial(toRemove: Material): number;
  110960. /**
  110961. * Removes the given action manager from this scene.
  110962. * @param toRemove The action manager to remove
  110963. * @returns The index of the removed action manager
  110964. */
  110965. removeActionManager(toRemove: AbstractActionManager): number;
  110966. /**
  110967. * Removes the given texture from this scene.
  110968. * @param toRemove The texture to remove
  110969. * @returns The index of the removed texture
  110970. */
  110971. removeTexture(toRemove: BaseTexture): number;
  110972. /**
  110973. * Adds the given light to this scene
  110974. * @param newLight The light to add
  110975. */
  110976. addLight(newLight: Light): void;
  110977. /**
  110978. * Sorts the list list based on light priorities
  110979. */
  110980. sortLightsByPriority(): void;
  110981. /**
  110982. * Adds the given camera to this scene
  110983. * @param newCamera The camera to add
  110984. */
  110985. addCamera(newCamera: Camera): void;
  110986. /**
  110987. * Adds the given skeleton to this scene
  110988. * @param newSkeleton The skeleton to add
  110989. */
  110990. addSkeleton(newSkeleton: Skeleton): void;
  110991. /**
  110992. * Adds the given particle system to this scene
  110993. * @param newParticleSystem The particle system to add
  110994. */
  110995. addParticleSystem(newParticleSystem: IParticleSystem): void;
  110996. /**
  110997. * Adds the given animation to this scene
  110998. * @param newAnimation The animation to add
  110999. */
  111000. addAnimation(newAnimation: Animation): void;
  111001. /**
  111002. * Adds the given animation group to this scene.
  111003. * @param newAnimationGroup The animation group to add
  111004. */
  111005. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  111006. /**
  111007. * Adds the given multi-material to this scene
  111008. * @param newMultiMaterial The multi-material to add
  111009. */
  111010. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  111011. /**
  111012. * Adds the given material to this scene
  111013. * @param newMaterial The material to add
  111014. */
  111015. addMaterial(newMaterial: Material): void;
  111016. /**
  111017. * Adds the given morph target to this scene
  111018. * @param newMorphTargetManager The morph target to add
  111019. */
  111020. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  111021. /**
  111022. * Adds the given geometry to this scene
  111023. * @param newGeometry The geometry to add
  111024. */
  111025. addGeometry(newGeometry: Geometry): void;
  111026. /**
  111027. * Adds the given action manager to this scene
  111028. * @param newActionManager The action manager to add
  111029. */
  111030. addActionManager(newActionManager: AbstractActionManager): void;
  111031. /**
  111032. * Adds the given texture to this scene.
  111033. * @param newTexture The texture to add
  111034. */
  111035. addTexture(newTexture: BaseTexture): void;
  111036. /**
  111037. * Switch active camera
  111038. * @param newCamera defines the new active camera
  111039. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  111040. */
  111041. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  111042. /**
  111043. * sets the active camera of the scene using its ID
  111044. * @param id defines the camera's ID
  111045. * @return the new active camera or null if none found.
  111046. */
  111047. setActiveCameraByID(id: string): Nullable<Camera>;
  111048. /**
  111049. * sets the active camera of the scene using its name
  111050. * @param name defines the camera's name
  111051. * @returns the new active camera or null if none found.
  111052. */
  111053. setActiveCameraByName(name: string): Nullable<Camera>;
  111054. /**
  111055. * get an animation group using its name
  111056. * @param name defines the material's name
  111057. * @return the animation group or null if none found.
  111058. */
  111059. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  111060. /**
  111061. * Get a material using its unique id
  111062. * @param uniqueId defines the material's unique id
  111063. * @return the material or null if none found.
  111064. */
  111065. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  111066. /**
  111067. * get a material using its id
  111068. * @param id defines the material's ID
  111069. * @return the material or null if none found.
  111070. */
  111071. getMaterialByID(id: string): Nullable<Material>;
  111072. /**
  111073. * Gets a the last added material using a given id
  111074. * @param id defines the material's ID
  111075. * @return the last material with the given id or null if none found.
  111076. */
  111077. getLastMaterialByID(id: string): Nullable<Material>;
  111078. /**
  111079. * Gets a material using its name
  111080. * @param name defines the material's name
  111081. * @return the material or null if none found.
  111082. */
  111083. getMaterialByName(name: string): Nullable<Material>;
  111084. /**
  111085. * Get a texture using its unique id
  111086. * @param uniqueId defines the texture's unique id
  111087. * @return the texture or null if none found.
  111088. */
  111089. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  111090. /**
  111091. * Gets a camera using its id
  111092. * @param id defines the id to look for
  111093. * @returns the camera or null if not found
  111094. */
  111095. getCameraByID(id: string): Nullable<Camera>;
  111096. /**
  111097. * Gets a camera using its unique id
  111098. * @param uniqueId defines the unique id to look for
  111099. * @returns the camera or null if not found
  111100. */
  111101. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  111102. /**
  111103. * Gets a camera using its name
  111104. * @param name defines the camera's name
  111105. * @return the camera or null if none found.
  111106. */
  111107. getCameraByName(name: string): Nullable<Camera>;
  111108. /**
  111109. * Gets a bone using its id
  111110. * @param id defines the bone's id
  111111. * @return the bone or null if not found
  111112. */
  111113. getBoneByID(id: string): Nullable<Bone>;
  111114. /**
  111115. * Gets a bone using its id
  111116. * @param name defines the bone's name
  111117. * @return the bone or null if not found
  111118. */
  111119. getBoneByName(name: string): Nullable<Bone>;
  111120. /**
  111121. * Gets a light node using its name
  111122. * @param name defines the the light's name
  111123. * @return the light or null if none found.
  111124. */
  111125. getLightByName(name: string): Nullable<Light>;
  111126. /**
  111127. * Gets a light node using its id
  111128. * @param id defines the light's id
  111129. * @return the light or null if none found.
  111130. */
  111131. getLightByID(id: string): Nullable<Light>;
  111132. /**
  111133. * Gets a light node using its scene-generated unique ID
  111134. * @param uniqueId defines the light's unique id
  111135. * @return the light or null if none found.
  111136. */
  111137. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  111138. /**
  111139. * Gets a particle system by id
  111140. * @param id defines the particle system id
  111141. * @return the corresponding system or null if none found
  111142. */
  111143. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  111144. /**
  111145. * Gets a geometry using its ID
  111146. * @param id defines the geometry's id
  111147. * @return the geometry or null if none found.
  111148. */
  111149. getGeometryByID(id: string): Nullable<Geometry>;
  111150. private _getGeometryByUniqueID;
  111151. /**
  111152. * Add a new geometry to this scene
  111153. * @param geometry defines the geometry to be added to the scene.
  111154. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  111155. * @return a boolean defining if the geometry was added or not
  111156. */
  111157. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  111158. /**
  111159. * Removes an existing geometry
  111160. * @param geometry defines the geometry to be removed from the scene
  111161. * @return a boolean defining if the geometry was removed or not
  111162. */
  111163. removeGeometry(geometry: Geometry): boolean;
  111164. /**
  111165. * Gets the list of geometries attached to the scene
  111166. * @returns an array of Geometry
  111167. */
  111168. getGeometries(): Geometry[];
  111169. /**
  111170. * Gets the first added mesh found of a given ID
  111171. * @param id defines the id to search for
  111172. * @return the mesh found or null if not found at all
  111173. */
  111174. getMeshByID(id: string): Nullable<AbstractMesh>;
  111175. /**
  111176. * Gets a list of meshes using their id
  111177. * @param id defines the id to search for
  111178. * @returns a list of meshes
  111179. */
  111180. getMeshesByID(id: string): Array<AbstractMesh>;
  111181. /**
  111182. * Gets the first added transform node found of a given ID
  111183. * @param id defines the id to search for
  111184. * @return the found transform node or null if not found at all.
  111185. */
  111186. getTransformNodeByID(id: string): Nullable<TransformNode>;
  111187. /**
  111188. * Gets a transform node with its auto-generated unique id
  111189. * @param uniqueId efines the unique id to search for
  111190. * @return the found transform node or null if not found at all.
  111191. */
  111192. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  111193. /**
  111194. * Gets a list of transform nodes using their id
  111195. * @param id defines the id to search for
  111196. * @returns a list of transform nodes
  111197. */
  111198. getTransformNodesByID(id: string): Array<TransformNode>;
  111199. /**
  111200. * Gets a mesh with its auto-generated unique id
  111201. * @param uniqueId defines the unique id to search for
  111202. * @return the found mesh or null if not found at all.
  111203. */
  111204. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  111205. /**
  111206. * Gets a the last added mesh using a given id
  111207. * @param id defines the id to search for
  111208. * @return the found mesh or null if not found at all.
  111209. */
  111210. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  111211. /**
  111212. * Gets a the last added node (Mesh, Camera, Light) using a given id
  111213. * @param id defines the id to search for
  111214. * @return the found node or null if not found at all
  111215. */
  111216. getLastEntryByID(id: string): Nullable<Node>;
  111217. /**
  111218. * Gets a node (Mesh, Camera, Light) using a given id
  111219. * @param id defines the id to search for
  111220. * @return the found node or null if not found at all
  111221. */
  111222. getNodeByID(id: string): Nullable<Node>;
  111223. /**
  111224. * Gets a node (Mesh, Camera, Light) using a given name
  111225. * @param name defines the name to search for
  111226. * @return the found node or null if not found at all.
  111227. */
  111228. getNodeByName(name: string): Nullable<Node>;
  111229. /**
  111230. * Gets a mesh using a given name
  111231. * @param name defines the name to search for
  111232. * @return the found mesh or null if not found at all.
  111233. */
  111234. getMeshByName(name: string): Nullable<AbstractMesh>;
  111235. /**
  111236. * Gets a transform node using a given name
  111237. * @param name defines the name to search for
  111238. * @return the found transform node or null if not found at all.
  111239. */
  111240. getTransformNodeByName(name: string): Nullable<TransformNode>;
  111241. /**
  111242. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  111243. * @param id defines the id to search for
  111244. * @return the found skeleton or null if not found at all.
  111245. */
  111246. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  111247. /**
  111248. * Gets a skeleton using a given auto generated unique id
  111249. * @param uniqueId defines the unique id to search for
  111250. * @return the found skeleton or null if not found at all.
  111251. */
  111252. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  111253. /**
  111254. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  111255. * @param id defines the id to search for
  111256. * @return the found skeleton or null if not found at all.
  111257. */
  111258. getSkeletonById(id: string): Nullable<Skeleton>;
  111259. /**
  111260. * Gets a skeleton using a given name
  111261. * @param name defines the name to search for
  111262. * @return the found skeleton or null if not found at all.
  111263. */
  111264. getSkeletonByName(name: string): Nullable<Skeleton>;
  111265. /**
  111266. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  111267. * @param id defines the id to search for
  111268. * @return the found morph target manager or null if not found at all.
  111269. */
  111270. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  111271. /**
  111272. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  111273. * @param id defines the id to search for
  111274. * @return the found morph target or null if not found at all.
  111275. */
  111276. getMorphTargetById(id: string): Nullable<MorphTarget>;
  111277. /**
  111278. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  111279. * @param name defines the name to search for
  111280. * @return the found morph target or null if not found at all.
  111281. */
  111282. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  111283. /**
  111284. * Gets a boolean indicating if the given mesh is active
  111285. * @param mesh defines the mesh to look for
  111286. * @returns true if the mesh is in the active list
  111287. */
  111288. isActiveMesh(mesh: AbstractMesh): boolean;
  111289. /**
  111290. * Return a unique id as a string which can serve as an identifier for the scene
  111291. */
  111292. get uid(): string;
  111293. /**
  111294. * Add an externaly attached data from its key.
  111295. * This method call will fail and return false, if such key already exists.
  111296. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  111297. * @param key the unique key that identifies the data
  111298. * @param data the data object to associate to the key for this Engine instance
  111299. * @return true if no such key were already present and the data was added successfully, false otherwise
  111300. */
  111301. addExternalData<T>(key: string, data: T): boolean;
  111302. /**
  111303. * Get an externaly attached data from its key
  111304. * @param key the unique key that identifies the data
  111305. * @return the associated data, if present (can be null), or undefined if not present
  111306. */
  111307. getExternalData<T>(key: string): Nullable<T>;
  111308. /**
  111309. * Get an externaly attached data from its key, create it using a factory if it's not already present
  111310. * @param key the unique key that identifies the data
  111311. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  111312. * @return the associated data, can be null if the factory returned null.
  111313. */
  111314. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  111315. /**
  111316. * Remove an externaly attached data from the Engine instance
  111317. * @param key the unique key that identifies the data
  111318. * @return true if the data was successfully removed, false if it doesn't exist
  111319. */
  111320. removeExternalData(key: string): boolean;
  111321. private _evaluateSubMesh;
  111322. /**
  111323. * Clear the processed materials smart array preventing retention point in material dispose.
  111324. */
  111325. freeProcessedMaterials(): void;
  111326. private _preventFreeActiveMeshesAndRenderingGroups;
  111327. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  111328. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  111329. * when disposing several meshes in a row or a hierarchy of meshes.
  111330. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  111331. */
  111332. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  111333. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  111334. /**
  111335. * Clear the active meshes smart array preventing retention point in mesh dispose.
  111336. */
  111337. freeActiveMeshes(): void;
  111338. /**
  111339. * Clear the info related to rendering groups preventing retention points during dispose.
  111340. */
  111341. freeRenderingGroups(): void;
  111342. /** @hidden */
  111343. _isInIntermediateRendering(): boolean;
  111344. /**
  111345. * Lambda returning the list of potentially active meshes.
  111346. */
  111347. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  111348. /**
  111349. * Lambda returning the list of potentially active sub meshes.
  111350. */
  111351. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  111352. /**
  111353. * Lambda returning the list of potentially intersecting sub meshes.
  111354. */
  111355. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  111356. /**
  111357. * Lambda returning the list of potentially colliding sub meshes.
  111358. */
  111359. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  111360. private _activeMeshesFrozen;
  111361. private _skipEvaluateActiveMeshesCompletely;
  111362. /**
  111363. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  111364. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  111365. * @returns the current scene
  111366. */
  111367. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  111368. /**
  111369. * Use this function to restart evaluating active meshes on every frame
  111370. * @returns the current scene
  111371. */
  111372. unfreezeActiveMeshes(): Scene;
  111373. private _evaluateActiveMeshes;
  111374. private _activeMesh;
  111375. /**
  111376. * Update the transform matrix to update from the current active camera
  111377. * @param force defines a boolean used to force the update even if cache is up to date
  111378. */
  111379. updateTransformMatrix(force?: boolean): void;
  111380. private _bindFrameBuffer;
  111381. /** @hidden */
  111382. _allowPostProcessClearColor: boolean;
  111383. /** @hidden */
  111384. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  111385. private _processSubCameras;
  111386. private _checkIntersections;
  111387. /** @hidden */
  111388. _advancePhysicsEngineStep(step: number): void;
  111389. /**
  111390. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  111391. */
  111392. getDeterministicFrameTime: () => number;
  111393. /** @hidden */
  111394. _animate(): void;
  111395. /** Execute all animations (for a frame) */
  111396. animate(): void;
  111397. /**
  111398. * Render the scene
  111399. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  111400. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  111401. */
  111402. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  111403. /**
  111404. * Freeze all materials
  111405. * A frozen material will not be updatable but should be faster to render
  111406. */
  111407. freezeMaterials(): void;
  111408. /**
  111409. * Unfreeze all materials
  111410. * A frozen material will not be updatable but should be faster to render
  111411. */
  111412. unfreezeMaterials(): void;
  111413. /**
  111414. * Releases all held ressources
  111415. */
  111416. dispose(): void;
  111417. /**
  111418. * Gets if the scene is already disposed
  111419. */
  111420. get isDisposed(): boolean;
  111421. /**
  111422. * Call this function to reduce memory footprint of the scene.
  111423. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  111424. */
  111425. clearCachedVertexData(): void;
  111426. /**
  111427. * This function will remove the local cached buffer data from texture.
  111428. * It will save memory but will prevent the texture from being rebuilt
  111429. */
  111430. cleanCachedTextureBuffer(): void;
  111431. /**
  111432. * Get the world extend vectors with an optional filter
  111433. *
  111434. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  111435. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  111436. */
  111437. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  111438. min: Vector3;
  111439. max: Vector3;
  111440. };
  111441. /**
  111442. * Creates a ray that can be used to pick in the scene
  111443. * @param x defines the x coordinate of the origin (on-screen)
  111444. * @param y defines the y coordinate of the origin (on-screen)
  111445. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111446. * @param camera defines the camera to use for the picking
  111447. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111448. * @returns a Ray
  111449. */
  111450. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  111451. /**
  111452. * Creates a ray that can be used to pick in the scene
  111453. * @param x defines the x coordinate of the origin (on-screen)
  111454. * @param y defines the y coordinate of the origin (on-screen)
  111455. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  111456. * @param result defines the ray where to store the picking ray
  111457. * @param camera defines the camera to use for the picking
  111458. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  111459. * @returns the current scene
  111460. */
  111461. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  111462. /**
  111463. * Creates a ray that can be used to pick in the scene
  111464. * @param x defines the x coordinate of the origin (on-screen)
  111465. * @param y defines the y coordinate of the origin (on-screen)
  111466. * @param camera defines the camera to use for the picking
  111467. * @returns a Ray
  111468. */
  111469. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  111470. /**
  111471. * Creates a ray that can be used to pick in the scene
  111472. * @param x defines the x coordinate of the origin (on-screen)
  111473. * @param y defines the y coordinate of the origin (on-screen)
  111474. * @param result defines the ray where to store the picking ray
  111475. * @param camera defines the camera to use for the picking
  111476. * @returns the current scene
  111477. */
  111478. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  111479. /** Launch a ray to try to pick a mesh in the scene
  111480. * @param x position on screen
  111481. * @param y position on screen
  111482. * @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
  111483. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  111484. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111485. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111486. * @returns a PickingInfo
  111487. */
  111488. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111489. /** Use the given ray to pick a mesh in the scene
  111490. * @param ray The ray to use to pick meshes
  111491. * @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
  111492. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  111493. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111494. * @returns a PickingInfo
  111495. */
  111496. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  111497. /**
  111498. * Launch a ray to try to pick a mesh in the scene
  111499. * @param x X position on screen
  111500. * @param y Y position on screen
  111501. * @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
  111502. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  111503. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111504. * @returns an array of PickingInfo
  111505. */
  111506. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111507. /**
  111508. * Launch a ray to try to pick a mesh in the scene
  111509. * @param ray Ray to use
  111510. * @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
  111511. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  111512. * @returns an array of PickingInfo
  111513. */
  111514. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  111515. /**
  111516. * Force the value of meshUnderPointer
  111517. * @param mesh defines the mesh to use
  111518. */
  111519. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  111520. /**
  111521. * Gets the mesh under the pointer
  111522. * @returns a Mesh or null if no mesh is under the pointer
  111523. */
  111524. getPointerOverMesh(): Nullable<AbstractMesh>;
  111525. /** @hidden */
  111526. _rebuildGeometries(): void;
  111527. /** @hidden */
  111528. _rebuildTextures(): void;
  111529. private _getByTags;
  111530. /**
  111531. * Get a list of meshes by tags
  111532. * @param tagsQuery defines the tags query to use
  111533. * @param forEach defines a predicate used to filter results
  111534. * @returns an array of Mesh
  111535. */
  111536. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  111537. /**
  111538. * Get a list of cameras by tags
  111539. * @param tagsQuery defines the tags query to use
  111540. * @param forEach defines a predicate used to filter results
  111541. * @returns an array of Camera
  111542. */
  111543. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  111544. /**
  111545. * Get a list of lights by tags
  111546. * @param tagsQuery defines the tags query to use
  111547. * @param forEach defines a predicate used to filter results
  111548. * @returns an array of Light
  111549. */
  111550. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  111551. /**
  111552. * Get a list of materials by tags
  111553. * @param tagsQuery defines the tags query to use
  111554. * @param forEach defines a predicate used to filter results
  111555. * @returns an array of Material
  111556. */
  111557. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  111558. /**
  111559. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  111560. * This allowed control for front to back rendering or reversly depending of the special needs.
  111561. *
  111562. * @param renderingGroupId The rendering group id corresponding to its index
  111563. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  111564. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  111565. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  111566. */
  111567. 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;
  111568. /**
  111569. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  111570. *
  111571. * @param renderingGroupId The rendering group id corresponding to its index
  111572. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  111573. * @param depth Automatically clears depth between groups if true and autoClear is true.
  111574. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  111575. */
  111576. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  111577. /**
  111578. * Gets the current auto clear configuration for one rendering group of the rendering
  111579. * manager.
  111580. * @param index the rendering group index to get the information for
  111581. * @returns The auto clear setup for the requested rendering group
  111582. */
  111583. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  111584. private _blockMaterialDirtyMechanism;
  111585. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  111586. get blockMaterialDirtyMechanism(): boolean;
  111587. set blockMaterialDirtyMechanism(value: boolean);
  111588. /**
  111589. * Will flag all materials as dirty to trigger new shader compilation
  111590. * @param flag defines the flag used to specify which material part must be marked as dirty
  111591. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  111592. */
  111593. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  111594. /** @hidden */
  111595. _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;
  111596. /** @hidden */
  111597. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111598. /** @hidden */
  111599. _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;
  111600. /** @hidden */
  111601. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  111602. /** @hidden */
  111603. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  111604. /** @hidden */
  111605. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  111606. }
  111607. }
  111608. declare module BABYLON {
  111609. /**
  111610. * Set of assets to keep when moving a scene into an asset container.
  111611. */
  111612. export class KeepAssets extends AbstractScene {
  111613. }
  111614. /**
  111615. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  111616. */
  111617. export class InstantiatedEntries {
  111618. /**
  111619. * List of new root nodes (eg. nodes with no parent)
  111620. */
  111621. rootNodes: TransformNode[];
  111622. /**
  111623. * List of new skeletons
  111624. */
  111625. skeletons: Skeleton[];
  111626. /**
  111627. * List of new animation groups
  111628. */
  111629. animationGroups: AnimationGroup[];
  111630. }
  111631. /**
  111632. * Container with a set of assets that can be added or removed from a scene.
  111633. */
  111634. export class AssetContainer extends AbstractScene {
  111635. private _wasAddedToScene;
  111636. /**
  111637. * The scene the AssetContainer belongs to.
  111638. */
  111639. scene: Scene;
  111640. /**
  111641. * Instantiates an AssetContainer.
  111642. * @param scene The scene the AssetContainer belongs to.
  111643. */
  111644. constructor(scene: Scene);
  111645. /**
  111646. * Instantiate or clone all meshes and add the new ones to the scene.
  111647. * Skeletons and animation groups will all be cloned
  111648. * @param nameFunction defines an optional function used to get new names for clones
  111649. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  111650. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  111651. */
  111652. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  111653. /**
  111654. * Adds all the assets from the container to the scene.
  111655. */
  111656. addAllToScene(): void;
  111657. /**
  111658. * Removes all the assets in the container from the scene
  111659. */
  111660. removeAllFromScene(): void;
  111661. /**
  111662. * Disposes all the assets in the container
  111663. */
  111664. dispose(): void;
  111665. private _moveAssets;
  111666. /**
  111667. * Removes all the assets contained in the scene and adds them to the container.
  111668. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  111669. */
  111670. moveAllFromScene(keepAssets?: KeepAssets): void;
  111671. /**
  111672. * 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.
  111673. * @returns the root mesh
  111674. */
  111675. createRootMesh(): Mesh;
  111676. /**
  111677. * Merge animations from this asset container into a scene
  111678. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  111679. * @param animatables set of animatables to retarget to a node from the scene
  111680. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  111681. */
  111682. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): void;
  111683. }
  111684. }
  111685. declare module BABYLON {
  111686. /**
  111687. * Defines how the parser contract is defined.
  111688. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  111689. */
  111690. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  111691. /**
  111692. * Defines how the individual parser contract is defined.
  111693. * These parser can parse an individual asset
  111694. */
  111695. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  111696. /**
  111697. * Base class of the scene acting as a container for the different elements composing a scene.
  111698. * This class is dynamically extended by the different components of the scene increasing
  111699. * flexibility and reducing coupling
  111700. */
  111701. export abstract class AbstractScene {
  111702. /**
  111703. * Stores the list of available parsers in the application.
  111704. */
  111705. private static _BabylonFileParsers;
  111706. /**
  111707. * Stores the list of available individual parsers in the application.
  111708. */
  111709. private static _IndividualBabylonFileParsers;
  111710. /**
  111711. * Adds a parser in the list of available ones
  111712. * @param name Defines the name of the parser
  111713. * @param parser Defines the parser to add
  111714. */
  111715. static AddParser(name: string, parser: BabylonFileParser): void;
  111716. /**
  111717. * Gets a general parser from the list of avaialble ones
  111718. * @param name Defines the name of the parser
  111719. * @returns the requested parser or null
  111720. */
  111721. static GetParser(name: string): Nullable<BabylonFileParser>;
  111722. /**
  111723. * Adds n individual parser in the list of available ones
  111724. * @param name Defines the name of the parser
  111725. * @param parser Defines the parser to add
  111726. */
  111727. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  111728. /**
  111729. * Gets an individual parser from the list of avaialble ones
  111730. * @param name Defines the name of the parser
  111731. * @returns the requested parser or null
  111732. */
  111733. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  111734. /**
  111735. * Parser json data and populate both a scene and its associated container object
  111736. * @param jsonData Defines the data to parse
  111737. * @param scene Defines the scene to parse the data for
  111738. * @param container Defines the container attached to the parsing sequence
  111739. * @param rootUrl Defines the root url of the data
  111740. */
  111741. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  111742. /**
  111743. * Gets the list of root nodes (ie. nodes with no parent)
  111744. */
  111745. rootNodes: Node[];
  111746. /** All of the cameras added to this scene
  111747. * @see http://doc.babylonjs.com/babylon101/cameras
  111748. */
  111749. cameras: Camera[];
  111750. /**
  111751. * All of the lights added to this scene
  111752. * @see http://doc.babylonjs.com/babylon101/lights
  111753. */
  111754. lights: Light[];
  111755. /**
  111756. * All of the (abstract) meshes added to this scene
  111757. */
  111758. meshes: AbstractMesh[];
  111759. /**
  111760. * The list of skeletons added to the scene
  111761. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  111762. */
  111763. skeletons: Skeleton[];
  111764. /**
  111765. * All of the particle systems added to this scene
  111766. * @see http://doc.babylonjs.com/babylon101/particles
  111767. */
  111768. particleSystems: IParticleSystem[];
  111769. /**
  111770. * Gets a list of Animations associated with the scene
  111771. */
  111772. animations: Animation[];
  111773. /**
  111774. * All of the animation groups added to this scene
  111775. * @see http://doc.babylonjs.com/how_to/group
  111776. */
  111777. animationGroups: AnimationGroup[];
  111778. /**
  111779. * All of the multi-materials added to this scene
  111780. * @see http://doc.babylonjs.com/how_to/multi_materials
  111781. */
  111782. multiMaterials: MultiMaterial[];
  111783. /**
  111784. * All of the materials 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 addMaterial and removeMaterial Scene methods.
  111787. * Note also that the order of the Material within the array is not significant and might change.
  111788. * @see http://doc.babylonjs.com/babylon101/materials
  111789. */
  111790. materials: Material[];
  111791. /**
  111792. * The list of morph target managers added to the scene
  111793. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  111794. */
  111795. morphTargetManagers: MorphTargetManager[];
  111796. /**
  111797. * The list of geometries used in the scene.
  111798. */
  111799. geometries: Geometry[];
  111800. /**
  111801. * All of the tranform nodes added to this scene
  111802. * In the context of a Scene, it is not supposed to be modified manually.
  111803. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  111804. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  111805. * @see http://doc.babylonjs.com/how_to/transformnode
  111806. */
  111807. transformNodes: TransformNode[];
  111808. /**
  111809. * ActionManagers available on the scene.
  111810. */
  111811. actionManagers: AbstractActionManager[];
  111812. /**
  111813. * Textures to keep.
  111814. */
  111815. textures: BaseTexture[];
  111816. /**
  111817. * Environment texture for the scene
  111818. */
  111819. environmentTexture: Nullable<BaseTexture>;
  111820. /**
  111821. * @returns all meshes, lights, cameras, transformNodes and bones
  111822. */
  111823. getNodes(): Array<Node>;
  111824. }
  111825. }
  111826. declare module BABYLON {
  111827. /**
  111828. * Interface used to define options for Sound class
  111829. */
  111830. export interface ISoundOptions {
  111831. /**
  111832. * Does the sound autoplay once loaded.
  111833. */
  111834. autoplay?: boolean;
  111835. /**
  111836. * Does the sound loop after it finishes playing once.
  111837. */
  111838. loop?: boolean;
  111839. /**
  111840. * Sound's volume
  111841. */
  111842. volume?: number;
  111843. /**
  111844. * Is it a spatial sound?
  111845. */
  111846. spatialSound?: boolean;
  111847. /**
  111848. * Maximum distance to hear that sound
  111849. */
  111850. maxDistance?: number;
  111851. /**
  111852. * Uses user defined attenuation function
  111853. */
  111854. useCustomAttenuation?: boolean;
  111855. /**
  111856. * Define the roll off factor of spatial sounds.
  111857. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111858. */
  111859. rolloffFactor?: number;
  111860. /**
  111861. * Define the reference distance the sound should be heard perfectly.
  111862. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111863. */
  111864. refDistance?: number;
  111865. /**
  111866. * Define the distance attenuation model the sound will follow.
  111867. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111868. */
  111869. distanceModel?: string;
  111870. /**
  111871. * Defines the playback speed (1 by default)
  111872. */
  111873. playbackRate?: number;
  111874. /**
  111875. * Defines if the sound is from a streaming source
  111876. */
  111877. streaming?: boolean;
  111878. /**
  111879. * Defines an optional length (in seconds) inside the sound file
  111880. */
  111881. length?: number;
  111882. /**
  111883. * Defines an optional offset (in seconds) inside the sound file
  111884. */
  111885. offset?: number;
  111886. /**
  111887. * If true, URLs will not be required to state the audio file codec to use.
  111888. */
  111889. skipCodecCheck?: boolean;
  111890. }
  111891. /**
  111892. * Defines a sound that can be played in the application.
  111893. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  111894. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  111895. */
  111896. export class Sound {
  111897. /**
  111898. * The name of the sound in the scene.
  111899. */
  111900. name: string;
  111901. /**
  111902. * Does the sound autoplay once loaded.
  111903. */
  111904. autoplay: boolean;
  111905. /**
  111906. * Does the sound loop after it finishes playing once.
  111907. */
  111908. loop: boolean;
  111909. /**
  111910. * Does the sound use a custom attenuation curve to simulate the falloff
  111911. * happening when the source gets further away from the camera.
  111912. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  111913. */
  111914. useCustomAttenuation: boolean;
  111915. /**
  111916. * The sound track id this sound belongs to.
  111917. */
  111918. soundTrackId: number;
  111919. /**
  111920. * Is this sound currently played.
  111921. */
  111922. isPlaying: boolean;
  111923. /**
  111924. * Is this sound currently paused.
  111925. */
  111926. isPaused: boolean;
  111927. /**
  111928. * Does this sound enables spatial sound.
  111929. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111930. */
  111931. spatialSound: boolean;
  111932. /**
  111933. * Define the reference distance the sound should be heard perfectly.
  111934. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111935. */
  111936. refDistance: number;
  111937. /**
  111938. * Define the roll off factor of spatial sounds.
  111939. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111940. */
  111941. rolloffFactor: number;
  111942. /**
  111943. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  111944. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111945. */
  111946. maxDistance: number;
  111947. /**
  111948. * Define the distance attenuation model the sound will follow.
  111949. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  111950. */
  111951. distanceModel: string;
  111952. /**
  111953. * @hidden
  111954. * Back Compat
  111955. **/
  111956. onended: () => any;
  111957. /**
  111958. * Observable event when the current playing sound finishes.
  111959. */
  111960. onEndedObservable: Observable<Sound>;
  111961. private _panningModel;
  111962. private _playbackRate;
  111963. private _streaming;
  111964. private _startTime;
  111965. private _startOffset;
  111966. private _position;
  111967. /** @hidden */
  111968. _positionInEmitterSpace: boolean;
  111969. private _localDirection;
  111970. private _volume;
  111971. private _isReadyToPlay;
  111972. private _isDirectional;
  111973. private _readyToPlayCallback;
  111974. private _audioBuffer;
  111975. private _soundSource;
  111976. private _streamingSource;
  111977. private _soundPanner;
  111978. private _soundGain;
  111979. private _inputAudioNode;
  111980. private _outputAudioNode;
  111981. private _coneInnerAngle;
  111982. private _coneOuterAngle;
  111983. private _coneOuterGain;
  111984. private _scene;
  111985. private _connectedTransformNode;
  111986. private _customAttenuationFunction;
  111987. private _registerFunc;
  111988. private _isOutputConnected;
  111989. private _htmlAudioElement;
  111990. private _urlType;
  111991. private _length?;
  111992. private _offset?;
  111993. /** @hidden */
  111994. static _SceneComponentInitialization: (scene: Scene) => void;
  111995. /**
  111996. * Create a sound and attach it to a scene
  111997. * @param name Name of your sound
  111998. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  111999. * @param scene defines the scene the sound belongs to
  112000. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  112001. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  112002. */
  112003. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  112004. /**
  112005. * Release the sound and its associated resources
  112006. */
  112007. dispose(): void;
  112008. /**
  112009. * Gets if the sounds is ready to be played or not.
  112010. * @returns true if ready, otherwise false
  112011. */
  112012. isReady(): boolean;
  112013. private _soundLoaded;
  112014. /**
  112015. * Sets the data of the sound from an audiobuffer
  112016. * @param audioBuffer The audioBuffer containing the data
  112017. */
  112018. setAudioBuffer(audioBuffer: AudioBuffer): void;
  112019. /**
  112020. * Updates the current sounds options such as maxdistance, loop...
  112021. * @param options A JSON object containing values named as the object properties
  112022. */
  112023. updateOptions(options: ISoundOptions): void;
  112024. private _createSpatialParameters;
  112025. private _updateSpatialParameters;
  112026. /**
  112027. * Switch the panning model to HRTF:
  112028. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112029. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112030. */
  112031. switchPanningModelToHRTF(): void;
  112032. /**
  112033. * Switch the panning model to Equal Power:
  112034. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112036. */
  112037. switchPanningModelToEqualPower(): void;
  112038. private _switchPanningModel;
  112039. /**
  112040. * Connect this sound to a sound track audio node like gain...
  112041. * @param soundTrackAudioNode the sound track audio node to connect to
  112042. */
  112043. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  112044. /**
  112045. * Transform this sound into a directional source
  112046. * @param coneInnerAngle Size of the inner cone in degree
  112047. * @param coneOuterAngle Size of the outer cone in degree
  112048. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  112049. */
  112050. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  112051. /**
  112052. * Gets or sets the inner angle for the directional cone.
  112053. */
  112054. get directionalConeInnerAngle(): number;
  112055. /**
  112056. * Gets or sets the inner angle for the directional cone.
  112057. */
  112058. set directionalConeInnerAngle(value: number);
  112059. /**
  112060. * Gets or sets the outer angle for the directional cone.
  112061. */
  112062. get directionalConeOuterAngle(): number;
  112063. /**
  112064. * Gets or sets the outer angle for the directional cone.
  112065. */
  112066. set directionalConeOuterAngle(value: number);
  112067. /**
  112068. * Sets the position of the emitter if spatial sound is enabled
  112069. * @param newPosition Defines the new posisiton
  112070. */
  112071. setPosition(newPosition: Vector3): void;
  112072. /**
  112073. * Sets the local direction of the emitter if spatial sound is enabled
  112074. * @param newLocalDirection Defines the new local direction
  112075. */
  112076. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  112077. private _updateDirection;
  112078. /** @hidden */
  112079. updateDistanceFromListener(): void;
  112080. /**
  112081. * Sets a new custom attenuation function for the sound.
  112082. * @param callback Defines the function used for the attenuation
  112083. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  112084. */
  112085. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  112086. /**
  112087. * Play the sound
  112088. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  112089. * @param offset (optional) Start the sound at a specific time in seconds
  112090. * @param length (optional) Sound duration (in seconds)
  112091. */
  112092. play(time?: number, offset?: number, length?: number): void;
  112093. private _onended;
  112094. /**
  112095. * Stop the sound
  112096. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  112097. */
  112098. stop(time?: number): void;
  112099. /**
  112100. * Put the sound in pause
  112101. */
  112102. pause(): void;
  112103. /**
  112104. * Sets a dedicated volume for this sounds
  112105. * @param newVolume Define the new volume of the sound
  112106. * @param time Define time for gradual change to new volume
  112107. */
  112108. setVolume(newVolume: number, time?: number): void;
  112109. /**
  112110. * Set the sound play back rate
  112111. * @param newPlaybackRate Define the playback rate the sound should be played at
  112112. */
  112113. setPlaybackRate(newPlaybackRate: number): void;
  112114. /**
  112115. * Gets the volume of the sound.
  112116. * @returns the volume of the sound
  112117. */
  112118. getVolume(): number;
  112119. /**
  112120. * Attach the sound to a dedicated mesh
  112121. * @param transformNode The transform node to connect the sound with
  112122. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112123. */
  112124. attachToMesh(transformNode: TransformNode): void;
  112125. /**
  112126. * Detach the sound from the previously attached mesh
  112127. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  112128. */
  112129. detachFromMesh(): void;
  112130. private _onRegisterAfterWorldMatrixUpdate;
  112131. /**
  112132. * Clone the current sound in the scene.
  112133. * @returns the new sound clone
  112134. */
  112135. clone(): Nullable<Sound>;
  112136. /**
  112137. * Gets the current underlying audio buffer containing the data
  112138. * @returns the audio buffer
  112139. */
  112140. getAudioBuffer(): Nullable<AudioBuffer>;
  112141. /**
  112142. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  112143. * @returns the source node
  112144. */
  112145. getSoundSource(): Nullable<AudioBufferSourceNode>;
  112146. /**
  112147. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  112148. * @returns the gain node
  112149. */
  112150. getSoundGain(): Nullable<GainNode>;
  112151. /**
  112152. * Serializes the Sound in a JSON representation
  112153. * @returns the JSON representation of the sound
  112154. */
  112155. serialize(): any;
  112156. /**
  112157. * Parse a JSON representation of a sound to innstantiate in a given scene
  112158. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  112159. * @param scene Define the scene the new parsed sound should be created in
  112160. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  112161. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  112162. * @returns the newly parsed sound
  112163. */
  112164. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  112165. }
  112166. }
  112167. declare module BABYLON {
  112168. /**
  112169. * This defines an action helpful to play a defined sound on a triggered action.
  112170. */
  112171. export class PlaySoundAction extends Action {
  112172. private _sound;
  112173. /**
  112174. * Instantiate the action
  112175. * @param triggerOptions defines the trigger options
  112176. * @param sound defines the sound to play
  112177. * @param condition defines the trigger related conditions
  112178. */
  112179. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112180. /** @hidden */
  112181. _prepare(): void;
  112182. /**
  112183. * Execute the action and play the sound.
  112184. */
  112185. execute(): void;
  112186. /**
  112187. * Serializes the actions and its related information.
  112188. * @param parent defines the object to serialize in
  112189. * @returns the serialized object
  112190. */
  112191. serialize(parent: any): any;
  112192. }
  112193. /**
  112194. * This defines an action helpful to stop a defined sound on a triggered action.
  112195. */
  112196. export class StopSoundAction extends Action {
  112197. private _sound;
  112198. /**
  112199. * Instantiate the action
  112200. * @param triggerOptions defines the trigger options
  112201. * @param sound defines the sound to stop
  112202. * @param condition defines the trigger related conditions
  112203. */
  112204. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  112205. /** @hidden */
  112206. _prepare(): void;
  112207. /**
  112208. * Execute the action and stop the sound.
  112209. */
  112210. execute(): void;
  112211. /**
  112212. * Serializes the actions and its related information.
  112213. * @param parent defines the object to serialize in
  112214. * @returns the serialized object
  112215. */
  112216. serialize(parent: any): any;
  112217. }
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * This defines an action responsible to change the value of a property
  112222. * by interpolating between its current value and the newly set one once triggered.
  112223. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  112224. */
  112225. export class InterpolateValueAction extends Action {
  112226. /**
  112227. * Defines the path of the property where the value should be interpolated
  112228. */
  112229. propertyPath: string;
  112230. /**
  112231. * Defines the target value at the end of the interpolation.
  112232. */
  112233. value: any;
  112234. /**
  112235. * Defines the time it will take for the property to interpolate to the value.
  112236. */
  112237. duration: number;
  112238. /**
  112239. * Defines if the other scene animations should be stopped when the action has been triggered
  112240. */
  112241. stopOtherAnimations?: boolean;
  112242. /**
  112243. * Defines a callback raised once the interpolation animation has been done.
  112244. */
  112245. onInterpolationDone?: () => void;
  112246. /**
  112247. * Observable triggered once the interpolation animation has been done.
  112248. */
  112249. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  112250. private _target;
  112251. private _effectiveTarget;
  112252. private _property;
  112253. /**
  112254. * Instantiate the action
  112255. * @param triggerOptions defines the trigger options
  112256. * @param target defines the object containing the value to interpolate
  112257. * @param propertyPath defines the path to the property in the target object
  112258. * @param value defines the target value at the end of the interpolation
  112259. * @param duration deines the time it will take for the property to interpolate to the value.
  112260. * @param condition defines the trigger related conditions
  112261. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  112262. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  112263. */
  112264. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  112265. /** @hidden */
  112266. _prepare(): void;
  112267. /**
  112268. * Execute the action starts the value interpolation.
  112269. */
  112270. execute(): void;
  112271. /**
  112272. * Serializes the actions and its related information.
  112273. * @param parent defines the object to serialize in
  112274. * @returns the serialized object
  112275. */
  112276. serialize(parent: any): any;
  112277. }
  112278. }
  112279. declare module BABYLON {
  112280. /**
  112281. * Options allowed during the creation of a sound track.
  112282. */
  112283. export interface ISoundTrackOptions {
  112284. /**
  112285. * The volume the sound track should take during creation
  112286. */
  112287. volume?: number;
  112288. /**
  112289. * Define if the sound track is the main sound track of the scene
  112290. */
  112291. mainTrack?: boolean;
  112292. }
  112293. /**
  112294. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  112295. * It will be also used in a future release to apply effects on a specific track.
  112296. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112297. */
  112298. export class SoundTrack {
  112299. /**
  112300. * The unique identifier of the sound track in the scene.
  112301. */
  112302. id: number;
  112303. /**
  112304. * The list of sounds included in the sound track.
  112305. */
  112306. soundCollection: Array<Sound>;
  112307. private _outputAudioNode;
  112308. private _scene;
  112309. private _connectedAnalyser;
  112310. private _options;
  112311. private _isInitialized;
  112312. /**
  112313. * Creates a new sound track.
  112314. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  112315. * @param scene Define the scene the sound track belongs to
  112316. * @param options
  112317. */
  112318. constructor(scene: Scene, options?: ISoundTrackOptions);
  112319. private _initializeSoundTrackAudioGraph;
  112320. /**
  112321. * Release the sound track and its associated resources
  112322. */
  112323. dispose(): void;
  112324. /**
  112325. * Adds a sound to this sound track
  112326. * @param sound define the cound to add
  112327. * @ignoreNaming
  112328. */
  112329. AddSound(sound: Sound): void;
  112330. /**
  112331. * Removes a sound to this sound track
  112332. * @param sound define the cound to remove
  112333. * @ignoreNaming
  112334. */
  112335. RemoveSound(sound: Sound): void;
  112336. /**
  112337. * Set a global volume for the full sound track.
  112338. * @param newVolume Define the new volume of the sound track
  112339. */
  112340. setVolume(newVolume: number): void;
  112341. /**
  112342. * Switch the panning model to HRTF:
  112343. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  112344. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112345. */
  112346. switchPanningModelToHRTF(): void;
  112347. /**
  112348. * Switch the panning model to Equal Power:
  112349. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  112350. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  112351. */
  112352. switchPanningModelToEqualPower(): void;
  112353. /**
  112354. * Connect the sound track to an audio analyser allowing some amazing
  112355. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  112356. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  112357. * @param analyser The analyser to connect to the engine
  112358. */
  112359. connectToAnalyser(analyser: Analyser): void;
  112360. }
  112361. }
  112362. declare module BABYLON {
  112363. interface AbstractScene {
  112364. /**
  112365. * The list of sounds used in the scene.
  112366. */
  112367. sounds: Nullable<Array<Sound>>;
  112368. }
  112369. interface Scene {
  112370. /**
  112371. * @hidden
  112372. * Backing field
  112373. */
  112374. _mainSoundTrack: SoundTrack;
  112375. /**
  112376. * The main sound track played by the scene.
  112377. * It cotains your primary collection of sounds.
  112378. */
  112379. mainSoundTrack: SoundTrack;
  112380. /**
  112381. * The list of sound tracks added to the scene
  112382. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112383. */
  112384. soundTracks: Nullable<Array<SoundTrack>>;
  112385. /**
  112386. * Gets a sound using a given name
  112387. * @param name defines the name to search for
  112388. * @return the found sound or null if not found at all.
  112389. */
  112390. getSoundByName(name: string): Nullable<Sound>;
  112391. /**
  112392. * Gets or sets if audio support is enabled
  112393. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112394. */
  112395. audioEnabled: boolean;
  112396. /**
  112397. * Gets or sets if audio will be output to headphones
  112398. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112399. */
  112400. headphone: boolean;
  112401. /**
  112402. * Gets or sets custom audio listener position provider
  112403. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  112404. */
  112405. audioListenerPositionProvider: Nullable<() => Vector3>;
  112406. /**
  112407. * Gets or sets a refresh rate when using 3D audio positioning
  112408. */
  112409. audioPositioningRefreshRate: number;
  112410. }
  112411. /**
  112412. * Defines the sound scene component responsible to manage any sounds
  112413. * in a given scene.
  112414. */
  112415. export class AudioSceneComponent implements ISceneSerializableComponent {
  112416. /**
  112417. * The component name helpfull to identify the component in the list of scene components.
  112418. */
  112419. readonly name: string;
  112420. /**
  112421. * The scene the component belongs to.
  112422. */
  112423. scene: Scene;
  112424. private _audioEnabled;
  112425. /**
  112426. * Gets whether audio is enabled or not.
  112427. * Please use related enable/disable method to switch state.
  112428. */
  112429. get audioEnabled(): boolean;
  112430. private _headphone;
  112431. /**
  112432. * Gets whether audio is outputing to headphone or not.
  112433. * Please use the according Switch methods to change output.
  112434. */
  112435. get headphone(): boolean;
  112436. /**
  112437. * Gets or sets a refresh rate when using 3D audio positioning
  112438. */
  112439. audioPositioningRefreshRate: number;
  112440. private _audioListenerPositionProvider;
  112441. /**
  112442. * Gets the current audio listener position provider
  112443. */
  112444. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  112445. /**
  112446. * Sets a custom listener position for all sounds in the scene
  112447. * By default, this is the position of the first active camera
  112448. */
  112449. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  112450. /**
  112451. * Creates a new instance of the component for the given scene
  112452. * @param scene Defines the scene to register the component in
  112453. */
  112454. constructor(scene: Scene);
  112455. /**
  112456. * Registers the component in a given scene
  112457. */
  112458. register(): void;
  112459. /**
  112460. * Rebuilds the elements related to this component in case of
  112461. * context lost for instance.
  112462. */
  112463. rebuild(): void;
  112464. /**
  112465. * Serializes the component data to the specified json object
  112466. * @param serializationObject The object to serialize to
  112467. */
  112468. serialize(serializationObject: any): void;
  112469. /**
  112470. * Adds all the elements from the container to the scene
  112471. * @param container the container holding the elements
  112472. */
  112473. addFromContainer(container: AbstractScene): void;
  112474. /**
  112475. * Removes all the elements in the container from the scene
  112476. * @param container contains the elements to remove
  112477. * @param dispose if the removed element should be disposed (default: false)
  112478. */
  112479. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  112480. /**
  112481. * Disposes the component and the associated ressources.
  112482. */
  112483. dispose(): void;
  112484. /**
  112485. * Disables audio in the associated scene.
  112486. */
  112487. disableAudio(): void;
  112488. /**
  112489. * Enables audio in the associated scene.
  112490. */
  112491. enableAudio(): void;
  112492. /**
  112493. * Switch audio to headphone output.
  112494. */
  112495. switchAudioModeForHeadphones(): void;
  112496. /**
  112497. * Switch audio to normal speakers.
  112498. */
  112499. switchAudioModeForNormalSpeakers(): void;
  112500. private _cachedCameraDirection;
  112501. private _cachedCameraPosition;
  112502. private _lastCheck;
  112503. private _afterRender;
  112504. }
  112505. }
  112506. declare module BABYLON {
  112507. /**
  112508. * Wraps one or more Sound objects and selects one with random weight for playback.
  112509. */
  112510. export class WeightedSound {
  112511. /** When true a Sound will be selected and played when the current playing Sound completes. */
  112512. loop: boolean;
  112513. private _coneInnerAngle;
  112514. private _coneOuterAngle;
  112515. private _volume;
  112516. /** A Sound is currently playing. */
  112517. isPlaying: boolean;
  112518. /** A Sound is currently paused. */
  112519. isPaused: boolean;
  112520. private _sounds;
  112521. private _weights;
  112522. private _currentIndex?;
  112523. /**
  112524. * Creates a new WeightedSound from the list of sounds given.
  112525. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  112526. * @param sounds Array of Sounds that will be selected from.
  112527. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  112528. */
  112529. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  112530. /**
  112531. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  112532. */
  112533. get directionalConeInnerAngle(): number;
  112534. /**
  112535. * The size of cone in degress for a directional sound in which there will be no attenuation.
  112536. */
  112537. set directionalConeInnerAngle(value: number);
  112538. /**
  112539. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112540. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112541. */
  112542. get directionalConeOuterAngle(): number;
  112543. /**
  112544. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  112545. * Listener angles between innerAngle and outerAngle will falloff linearly.
  112546. */
  112547. set directionalConeOuterAngle(value: number);
  112548. /**
  112549. * Playback volume.
  112550. */
  112551. get volume(): number;
  112552. /**
  112553. * Playback volume.
  112554. */
  112555. set volume(value: number);
  112556. private _onended;
  112557. /**
  112558. * Suspend playback
  112559. */
  112560. pause(): void;
  112561. /**
  112562. * Stop playback
  112563. */
  112564. stop(): void;
  112565. /**
  112566. * Start playback.
  112567. * @param startOffset Position the clip head at a specific time in seconds.
  112568. */
  112569. play(startOffset?: number): void;
  112570. }
  112571. }
  112572. declare module BABYLON {
  112573. /**
  112574. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  112575. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  112576. */
  112577. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  112578. /**
  112579. * Gets the name of the behavior.
  112580. */
  112581. get name(): string;
  112582. /**
  112583. * The easing function used by animations
  112584. */
  112585. static EasingFunction: BackEase;
  112586. /**
  112587. * The easing mode used by animations
  112588. */
  112589. static EasingMode: number;
  112590. /**
  112591. * The duration of the animation, in milliseconds
  112592. */
  112593. transitionDuration: number;
  112594. /**
  112595. * Length of the distance animated by the transition when lower radius is reached
  112596. */
  112597. lowerRadiusTransitionRange: number;
  112598. /**
  112599. * Length of the distance animated by the transition when upper radius is reached
  112600. */
  112601. upperRadiusTransitionRange: number;
  112602. private _autoTransitionRange;
  112603. /**
  112604. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112605. */
  112606. get autoTransitionRange(): boolean;
  112607. /**
  112608. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  112609. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  112610. */
  112611. set autoTransitionRange(value: boolean);
  112612. private _attachedCamera;
  112613. private _onAfterCheckInputsObserver;
  112614. private _onMeshTargetChangedObserver;
  112615. /**
  112616. * Initializes the behavior.
  112617. */
  112618. init(): void;
  112619. /**
  112620. * Attaches the behavior to its arc rotate camera.
  112621. * @param camera Defines the camera to attach the behavior to
  112622. */
  112623. attach(camera: ArcRotateCamera): void;
  112624. /**
  112625. * Detaches the behavior from its current arc rotate camera.
  112626. */
  112627. detach(): void;
  112628. private _radiusIsAnimating;
  112629. private _radiusBounceTransition;
  112630. private _animatables;
  112631. private _cachedWheelPrecision;
  112632. /**
  112633. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  112634. * @param radiusLimit The limit to check against.
  112635. * @return Bool to indicate if at limit.
  112636. */
  112637. private _isRadiusAtLimit;
  112638. /**
  112639. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  112640. * @param radiusDelta The delta by which to animate to. Can be negative.
  112641. */
  112642. private _applyBoundRadiusAnimation;
  112643. /**
  112644. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  112645. */
  112646. protected _clearAnimationLocks(): void;
  112647. /**
  112648. * Stops and removes all animations that have been applied to the camera
  112649. */
  112650. stopAllAnimations(): void;
  112651. }
  112652. }
  112653. declare module BABYLON {
  112654. /**
  112655. * 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.
  112656. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  112657. */
  112658. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  112659. /**
  112660. * Gets the name of the behavior.
  112661. */
  112662. get name(): string;
  112663. private _mode;
  112664. private _radiusScale;
  112665. private _positionScale;
  112666. private _defaultElevation;
  112667. private _elevationReturnTime;
  112668. private _elevationReturnWaitTime;
  112669. private _zoomStopsAnimation;
  112670. private _framingTime;
  112671. /**
  112672. * The easing function used by animations
  112673. */
  112674. static EasingFunction: ExponentialEase;
  112675. /**
  112676. * The easing mode used by animations
  112677. */
  112678. static EasingMode: number;
  112679. /**
  112680. * Sets the current mode used by the behavior
  112681. */
  112682. set mode(mode: number);
  112683. /**
  112684. * Gets current mode used by the behavior.
  112685. */
  112686. get mode(): number;
  112687. /**
  112688. * Sets the scale applied to the radius (1 by default)
  112689. */
  112690. set radiusScale(radius: number);
  112691. /**
  112692. * Gets the scale applied to the radius
  112693. */
  112694. get radiusScale(): number;
  112695. /**
  112696. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112697. */
  112698. set positionScale(scale: number);
  112699. /**
  112700. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  112701. */
  112702. get positionScale(): number;
  112703. /**
  112704. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112705. * behaviour is triggered, in radians.
  112706. */
  112707. set defaultElevation(elevation: number);
  112708. /**
  112709. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  112710. * behaviour is triggered, in radians.
  112711. */
  112712. get defaultElevation(): number;
  112713. /**
  112714. * Sets the time (in milliseconds) taken to return to the default beta position.
  112715. * Negative value indicates camera should not return to default.
  112716. */
  112717. set elevationReturnTime(speed: number);
  112718. /**
  112719. * Gets the time (in milliseconds) taken to return to the default beta position.
  112720. * Negative value indicates camera should not return to default.
  112721. */
  112722. get elevationReturnTime(): number;
  112723. /**
  112724. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112725. */
  112726. set elevationReturnWaitTime(time: number);
  112727. /**
  112728. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  112729. */
  112730. get elevationReturnWaitTime(): number;
  112731. /**
  112732. * Sets the flag that indicates if user zooming should stop animation.
  112733. */
  112734. set zoomStopsAnimation(flag: boolean);
  112735. /**
  112736. * Gets the flag that indicates if user zooming should stop animation.
  112737. */
  112738. get zoomStopsAnimation(): boolean;
  112739. /**
  112740. * Sets the transition time when framing the mesh, in milliseconds
  112741. */
  112742. set framingTime(time: number);
  112743. /**
  112744. * Gets the transition time when framing the mesh, in milliseconds
  112745. */
  112746. get framingTime(): number;
  112747. /**
  112748. * Define if the behavior should automatically change the configured
  112749. * camera limits and sensibilities.
  112750. */
  112751. autoCorrectCameraLimitsAndSensibility: boolean;
  112752. private _onPrePointerObservableObserver;
  112753. private _onAfterCheckInputsObserver;
  112754. private _onMeshTargetChangedObserver;
  112755. private _attachedCamera;
  112756. private _isPointerDown;
  112757. private _lastInteractionTime;
  112758. /**
  112759. * Initializes the behavior.
  112760. */
  112761. init(): void;
  112762. /**
  112763. * Attaches the behavior to its arc rotate camera.
  112764. * @param camera Defines the camera to attach the behavior to
  112765. */
  112766. attach(camera: ArcRotateCamera): void;
  112767. /**
  112768. * Detaches the behavior from its current arc rotate camera.
  112769. */
  112770. detach(): void;
  112771. private _animatables;
  112772. private _betaIsAnimating;
  112773. private _betaTransition;
  112774. private _radiusTransition;
  112775. private _vectorTransition;
  112776. /**
  112777. * Targets the given mesh and updates zoom level accordingly.
  112778. * @param mesh The mesh to target.
  112779. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112780. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112781. */
  112782. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112783. /**
  112784. * Targets the given mesh with its children and updates zoom level accordingly.
  112785. * @param mesh The mesh to target.
  112786. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112787. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112788. */
  112789. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112790. /**
  112791. * Targets the given meshes with their children and updates zoom level accordingly.
  112792. * @param meshes The mesh to target.
  112793. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112794. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112795. */
  112796. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112797. /**
  112798. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  112799. * @param minimumWorld Determines the smaller position of the bounding box extend
  112800. * @param maximumWorld Determines the bigger position of the bounding box extend
  112801. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  112802. * @param onAnimationEnd Callback triggered at the end of the framing animation
  112803. */
  112804. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  112805. /**
  112806. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  112807. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  112808. * frustum width.
  112809. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  112810. * to fully enclose the mesh in the viewing frustum.
  112811. */
  112812. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  112813. /**
  112814. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  112815. * is automatically returned to its default position (expected to be above ground plane).
  112816. */
  112817. private _maintainCameraAboveGround;
  112818. /**
  112819. * Returns the frustum slope based on the canvas ratio and camera FOV
  112820. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  112821. */
  112822. private _getFrustumSlope;
  112823. /**
  112824. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  112825. */
  112826. private _clearAnimationLocks;
  112827. /**
  112828. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  112829. */
  112830. private _applyUserInteraction;
  112831. /**
  112832. * Stops and removes all animations that have been applied to the camera
  112833. */
  112834. stopAllAnimations(): void;
  112835. /**
  112836. * Gets a value indicating if the user is moving the camera
  112837. */
  112838. get isUserIsMoving(): boolean;
  112839. /**
  112840. * The camera can move all the way towards the mesh.
  112841. */
  112842. static IgnoreBoundsSizeMode: number;
  112843. /**
  112844. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  112845. */
  112846. static FitFrustumSidesMode: number;
  112847. }
  112848. }
  112849. declare module BABYLON {
  112850. /**
  112851. * Base class for Camera Pointer Inputs.
  112852. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  112853. * for example usage.
  112854. */
  112855. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  112856. /**
  112857. * Defines the camera the input is attached to.
  112858. */
  112859. abstract camera: Camera;
  112860. /**
  112861. * Whether keyboard modifier keys are pressed at time of last mouse event.
  112862. */
  112863. protected _altKey: boolean;
  112864. protected _ctrlKey: boolean;
  112865. protected _metaKey: boolean;
  112866. protected _shiftKey: boolean;
  112867. /**
  112868. * Which mouse buttons were pressed at time of last mouse event.
  112869. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  112870. */
  112871. protected _buttonsPressed: number;
  112872. /**
  112873. * Defines the buttons associated with the input to handle camera move.
  112874. */
  112875. buttons: number[];
  112876. /**
  112877. * Attach the input controls to a specific dom element to get the input from.
  112878. * @param element Defines the element the controls should be listened from
  112879. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  112880. */
  112881. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  112882. /**
  112883. * Detach the current controls from the specified dom element.
  112884. * @param element Defines the element to stop listening the inputs from
  112885. */
  112886. detachControl(element: Nullable<HTMLElement>): void;
  112887. /**
  112888. * Gets the class name of the current input.
  112889. * @returns the class name
  112890. */
  112891. getClassName(): string;
  112892. /**
  112893. * Get the friendly name associated with the input class.
  112894. * @returns the input friendly name
  112895. */
  112896. getSimpleName(): string;
  112897. /**
  112898. * Called on pointer POINTERDOUBLETAP event.
  112899. * Override this method to provide functionality on POINTERDOUBLETAP event.
  112900. */
  112901. protected onDoubleTap(type: string): void;
  112902. /**
  112903. * Called on pointer POINTERMOVE event if only a single touch is active.
  112904. * Override this method to provide functionality.
  112905. */
  112906. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  112907. /**
  112908. * Called on pointer POINTERMOVE event if multiple touches are active.
  112909. * Override this method to provide functionality.
  112910. */
  112911. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  112912. /**
  112913. * Called on JS contextmenu event.
  112914. * Override this method to provide functionality.
  112915. */
  112916. protected onContextMenu(evt: PointerEvent): void;
  112917. /**
  112918. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  112919. * press.
  112920. * Override this method to provide functionality.
  112921. */
  112922. protected onButtonDown(evt: PointerEvent): void;
  112923. /**
  112924. * Called each time a new POINTERUP event occurs. Ie, for each button
  112925. * release.
  112926. * Override this method to provide functionality.
  112927. */
  112928. protected onButtonUp(evt: PointerEvent): void;
  112929. /**
  112930. * Called when window becomes inactive.
  112931. * Override this method to provide functionality.
  112932. */
  112933. protected onLostFocus(): void;
  112934. private _pointerInput;
  112935. private _observer;
  112936. private _onLostFocus;
  112937. private pointA;
  112938. private pointB;
  112939. }
  112940. }
  112941. declare module BABYLON {
  112942. /**
  112943. * Manage the pointers inputs to control an arc rotate camera.
  112944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  112945. */
  112946. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  112947. /**
  112948. * Defines the camera the input is attached to.
  112949. */
  112950. camera: ArcRotateCamera;
  112951. /**
  112952. * Gets the class name of the current input.
  112953. * @returns the class name
  112954. */
  112955. getClassName(): string;
  112956. /**
  112957. * Defines the buttons associated with the input to handle camera move.
  112958. */
  112959. buttons: number[];
  112960. /**
  112961. * Defines the pointer angular sensibility along the X axis or how fast is
  112962. * the camera rotating.
  112963. */
  112964. angularSensibilityX: number;
  112965. /**
  112966. * Defines the pointer angular sensibility along the Y axis or how fast is
  112967. * the camera rotating.
  112968. */
  112969. angularSensibilityY: number;
  112970. /**
  112971. * Defines the pointer pinch precision or how fast is the camera zooming.
  112972. */
  112973. pinchPrecision: number;
  112974. /**
  112975. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  112976. * from 0.
  112977. * It defines the percentage of current camera.radius to use as delta when
  112978. * pinch zoom is used.
  112979. */
  112980. pinchDeltaPercentage: number;
  112981. /**
  112982. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  112983. * that any object in the plane at the camera's target point will scale
  112984. * perfectly with finger motion.
  112985. * Overrides pinchDeltaPercentage and pinchPrecision.
  112986. */
  112987. useNaturalPinchZoom: boolean;
  112988. /**
  112989. * Defines the pointer panning sensibility or how fast is the camera moving.
  112990. */
  112991. panningSensibility: number;
  112992. /**
  112993. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  112994. */
  112995. multiTouchPanning: boolean;
  112996. /**
  112997. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  112998. * zoom (pinch) through multitouch.
  112999. */
  113000. multiTouchPanAndZoom: boolean;
  113001. /**
  113002. * Revers pinch action direction.
  113003. */
  113004. pinchInwards: boolean;
  113005. private _isPanClick;
  113006. private _twoFingerActivityCount;
  113007. private _isPinching;
  113008. /**
  113009. * Called on pointer POINTERMOVE event if only a single touch is active.
  113010. */
  113011. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  113012. /**
  113013. * Called on pointer POINTERDOUBLETAP event.
  113014. */
  113015. protected onDoubleTap(type: string): void;
  113016. /**
  113017. * Called on pointer POINTERMOVE event if multiple touches are active.
  113018. */
  113019. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  113020. /**
  113021. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  113022. * press.
  113023. */
  113024. protected onButtonDown(evt: PointerEvent): void;
  113025. /**
  113026. * Called each time a new POINTERUP event occurs. Ie, for each button
  113027. * release.
  113028. */
  113029. protected onButtonUp(evt: PointerEvent): void;
  113030. /**
  113031. * Called when window becomes inactive.
  113032. */
  113033. protected onLostFocus(): void;
  113034. }
  113035. }
  113036. declare module BABYLON {
  113037. /**
  113038. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  113039. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113040. */
  113041. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  113042. /**
  113043. * Defines the camera the input is attached to.
  113044. */
  113045. camera: ArcRotateCamera;
  113046. /**
  113047. * Defines the list of key codes associated with the up action (increase alpha)
  113048. */
  113049. keysUp: number[];
  113050. /**
  113051. * Defines the list of key codes associated with the down action (decrease alpha)
  113052. */
  113053. keysDown: number[];
  113054. /**
  113055. * Defines the list of key codes associated with the left action (increase beta)
  113056. */
  113057. keysLeft: number[];
  113058. /**
  113059. * Defines the list of key codes associated with the right action (decrease beta)
  113060. */
  113061. keysRight: number[];
  113062. /**
  113063. * Defines the list of key codes associated with the reset action.
  113064. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  113065. */
  113066. keysReset: number[];
  113067. /**
  113068. * Defines the panning sensibility of the inputs.
  113069. * (How fast is the camera panning)
  113070. */
  113071. panningSensibility: number;
  113072. /**
  113073. * Defines the zooming sensibility of the inputs.
  113074. * (How fast is the camera zooming)
  113075. */
  113076. zoomingSensibility: number;
  113077. /**
  113078. * Defines whether maintaining the alt key down switch the movement mode from
  113079. * orientation to zoom.
  113080. */
  113081. useAltToZoom: boolean;
  113082. /**
  113083. * Rotation speed of the camera
  113084. */
  113085. angularSpeed: number;
  113086. private _keys;
  113087. private _ctrlPressed;
  113088. private _altPressed;
  113089. private _onCanvasBlurObserver;
  113090. private _onKeyboardObserver;
  113091. private _engine;
  113092. private _scene;
  113093. /**
  113094. * Attach the input controls to a specific dom element to get the input from.
  113095. * @param element Defines the element the controls should be listened from
  113096. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113097. */
  113098. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113099. /**
  113100. * Detach the current controls from the specified dom element.
  113101. * @param element Defines the element to stop listening the inputs from
  113102. */
  113103. detachControl(element: Nullable<HTMLElement>): void;
  113104. /**
  113105. * Update the current camera state depending on the inputs that have been used this frame.
  113106. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  113107. */
  113108. checkInputs(): void;
  113109. /**
  113110. * Gets the class name of the current intput.
  113111. * @returns the class name
  113112. */
  113113. getClassName(): string;
  113114. /**
  113115. * Get the friendly name associated with the input class.
  113116. * @returns the input friendly name
  113117. */
  113118. getSimpleName(): string;
  113119. }
  113120. }
  113121. declare module BABYLON {
  113122. /**
  113123. * Manage the mouse wheel inputs to control an arc rotate camera.
  113124. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113125. */
  113126. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  113127. /**
  113128. * Defines the camera the input is attached to.
  113129. */
  113130. camera: ArcRotateCamera;
  113131. /**
  113132. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113133. */
  113134. wheelPrecision: number;
  113135. /**
  113136. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  113137. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  113138. */
  113139. wheelDeltaPercentage: number;
  113140. private _wheel;
  113141. private _observer;
  113142. private computeDeltaFromMouseWheelLegacyEvent;
  113143. /**
  113144. * Attach the input controls to a specific dom element to get the input from.
  113145. * @param element Defines the element the controls should be listened from
  113146. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113147. */
  113148. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  113149. /**
  113150. * Detach the current controls from the specified dom element.
  113151. * @param element Defines the element to stop listening the inputs from
  113152. */
  113153. detachControl(element: Nullable<HTMLElement>): void;
  113154. /**
  113155. * Gets the class name of the current intput.
  113156. * @returns the class name
  113157. */
  113158. getClassName(): string;
  113159. /**
  113160. * Get the friendly name associated with the input class.
  113161. * @returns the input friendly name
  113162. */
  113163. getSimpleName(): string;
  113164. }
  113165. }
  113166. declare module BABYLON {
  113167. /**
  113168. * Default Inputs manager for the ArcRotateCamera.
  113169. * It groups all the default supported inputs for ease of use.
  113170. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  113171. */
  113172. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  113173. /**
  113174. * Instantiates a new ArcRotateCameraInputsManager.
  113175. * @param camera Defines the camera the inputs belong to
  113176. */
  113177. constructor(camera: ArcRotateCamera);
  113178. /**
  113179. * Add mouse wheel input support to the input manager.
  113180. * @returns the current input manager
  113181. */
  113182. addMouseWheel(): ArcRotateCameraInputsManager;
  113183. /**
  113184. * Add pointers input support to the input manager.
  113185. * @returns the current input manager
  113186. */
  113187. addPointers(): ArcRotateCameraInputsManager;
  113188. /**
  113189. * Add keyboard input support to the input manager.
  113190. * @returns the current input manager
  113191. */
  113192. addKeyboard(): ArcRotateCameraInputsManager;
  113193. }
  113194. }
  113195. declare module BABYLON {
  113196. /**
  113197. * This represents an orbital type of camera.
  113198. *
  113199. * 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.
  113200. * 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.
  113201. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  113202. */
  113203. export class ArcRotateCamera extends TargetCamera {
  113204. /**
  113205. * Defines the rotation angle of the camera along the longitudinal axis.
  113206. */
  113207. alpha: number;
  113208. /**
  113209. * Defines the rotation angle of the camera along the latitudinal axis.
  113210. */
  113211. beta: number;
  113212. /**
  113213. * Defines the radius of the camera from it s target point.
  113214. */
  113215. radius: number;
  113216. protected _target: Vector3;
  113217. protected _targetHost: Nullable<AbstractMesh>;
  113218. /**
  113219. * Defines the target point of the camera.
  113220. * The camera looks towards it form the radius distance.
  113221. */
  113222. get target(): Vector3;
  113223. set target(value: Vector3);
  113224. /**
  113225. * Define the current local position of the camera in the scene
  113226. */
  113227. get position(): Vector3;
  113228. set position(newPosition: Vector3);
  113229. protected _upVector: Vector3;
  113230. protected _upToYMatrix: Matrix;
  113231. protected _YToUpMatrix: Matrix;
  113232. /**
  113233. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  113234. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  113235. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  113236. */
  113237. set upVector(vec: Vector3);
  113238. get upVector(): Vector3;
  113239. /**
  113240. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  113241. */
  113242. setMatUp(): void;
  113243. /**
  113244. * Current inertia value on the longitudinal axis.
  113245. * The bigger this number the longer it will take for the camera to stop.
  113246. */
  113247. inertialAlphaOffset: number;
  113248. /**
  113249. * Current inertia value on the latitudinal axis.
  113250. * The bigger this number the longer it will take for the camera to stop.
  113251. */
  113252. inertialBetaOffset: number;
  113253. /**
  113254. * Current inertia value on the radius axis.
  113255. * The bigger this number the longer it will take for the camera to stop.
  113256. */
  113257. inertialRadiusOffset: number;
  113258. /**
  113259. * Minimum allowed angle on the longitudinal axis.
  113260. * This can help limiting how the Camera is able to move in the scene.
  113261. */
  113262. lowerAlphaLimit: Nullable<number>;
  113263. /**
  113264. * Maximum allowed angle on the longitudinal axis.
  113265. * This can help limiting how the Camera is able to move in the scene.
  113266. */
  113267. upperAlphaLimit: Nullable<number>;
  113268. /**
  113269. * Minimum allowed angle on the latitudinal axis.
  113270. * This can help limiting how the Camera is able to move in the scene.
  113271. */
  113272. lowerBetaLimit: number;
  113273. /**
  113274. * Maximum allowed angle on the latitudinal axis.
  113275. * This can help limiting how the Camera is able to move in the scene.
  113276. */
  113277. upperBetaLimit: number;
  113278. /**
  113279. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  113280. * This can help limiting how the Camera is able to move in the scene.
  113281. */
  113282. lowerRadiusLimit: Nullable<number>;
  113283. /**
  113284. * Maximum allowed distance of the camera to the target (The camera can not get further).
  113285. * This can help limiting how the Camera is able to move in the scene.
  113286. */
  113287. upperRadiusLimit: Nullable<number>;
  113288. /**
  113289. * Defines the current inertia value used during panning of the camera along the X axis.
  113290. */
  113291. inertialPanningX: number;
  113292. /**
  113293. * Defines the current inertia value used during panning of the camera along the Y axis.
  113294. */
  113295. inertialPanningY: number;
  113296. /**
  113297. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  113298. * Basically if your fingers moves away from more than this distance you will be considered
  113299. * in pinch mode.
  113300. */
  113301. pinchToPanMaxDistance: number;
  113302. /**
  113303. * Defines the maximum distance the camera can pan.
  113304. * This could help keeping the cammera always in your scene.
  113305. */
  113306. panningDistanceLimit: Nullable<number>;
  113307. /**
  113308. * Defines the target of the camera before paning.
  113309. */
  113310. panningOriginTarget: Vector3;
  113311. /**
  113312. * Defines the value of the inertia used during panning.
  113313. * 0 would mean stop inertia and one would mean no decelleration at all.
  113314. */
  113315. panningInertia: number;
  113316. /**
  113317. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  113318. */
  113319. get angularSensibilityX(): number;
  113320. set angularSensibilityX(value: number);
  113321. /**
  113322. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  113323. */
  113324. get angularSensibilityY(): number;
  113325. set angularSensibilityY(value: number);
  113326. /**
  113327. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  113328. */
  113329. get pinchPrecision(): number;
  113330. set pinchPrecision(value: number);
  113331. /**
  113332. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  113333. * It will be used instead of pinchDeltaPrecision if different from 0.
  113334. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113335. */
  113336. get pinchDeltaPercentage(): number;
  113337. set pinchDeltaPercentage(value: number);
  113338. /**
  113339. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  113340. * and pinch delta percentage.
  113341. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  113342. * that any object in the plane at the camera's target point will scale
  113343. * perfectly with finger motion.
  113344. */
  113345. get useNaturalPinchZoom(): boolean;
  113346. set useNaturalPinchZoom(value: boolean);
  113347. /**
  113348. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  113349. */
  113350. get panningSensibility(): number;
  113351. set panningSensibility(value: number);
  113352. /**
  113353. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  113354. */
  113355. get keysUp(): number[];
  113356. set keysUp(value: number[]);
  113357. /**
  113358. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  113359. */
  113360. get keysDown(): number[];
  113361. set keysDown(value: number[]);
  113362. /**
  113363. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  113364. */
  113365. get keysLeft(): number[];
  113366. set keysLeft(value: number[]);
  113367. /**
  113368. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  113369. */
  113370. get keysRight(): number[];
  113371. set keysRight(value: number[]);
  113372. /**
  113373. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  113374. */
  113375. get wheelPrecision(): number;
  113376. set wheelPrecision(value: number);
  113377. /**
  113378. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  113379. * It will be used instead of pinchDeltaPrecision if different from 0.
  113380. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  113381. */
  113382. get wheelDeltaPercentage(): number;
  113383. set wheelDeltaPercentage(value: number);
  113384. /**
  113385. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  113386. */
  113387. zoomOnFactor: number;
  113388. /**
  113389. * Defines a screen offset for the camera position.
  113390. */
  113391. targetScreenOffset: Vector2;
  113392. /**
  113393. * Allows the camera to be completely reversed.
  113394. * If false the camera can not arrive upside down.
  113395. */
  113396. allowUpsideDown: boolean;
  113397. /**
  113398. * Define if double tap/click is used to restore the previously saved state of the camera.
  113399. */
  113400. useInputToRestoreState: boolean;
  113401. /** @hidden */
  113402. _viewMatrix: Matrix;
  113403. /** @hidden */
  113404. _useCtrlForPanning: boolean;
  113405. /** @hidden */
  113406. _panningMouseButton: number;
  113407. /**
  113408. * Defines the input associated to the camera.
  113409. */
  113410. inputs: ArcRotateCameraInputsManager;
  113411. /** @hidden */
  113412. _reset: () => void;
  113413. /**
  113414. * Defines the allowed panning axis.
  113415. */
  113416. panningAxis: Vector3;
  113417. protected _localDirection: Vector3;
  113418. protected _transformedDirection: Vector3;
  113419. private _bouncingBehavior;
  113420. /**
  113421. * Gets the bouncing behavior of the camera if it has been enabled.
  113422. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113423. */
  113424. get bouncingBehavior(): Nullable<BouncingBehavior>;
  113425. /**
  113426. * Defines if the bouncing behavior of the camera is enabled on the camera.
  113427. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  113428. */
  113429. get useBouncingBehavior(): boolean;
  113430. set useBouncingBehavior(value: boolean);
  113431. private _framingBehavior;
  113432. /**
  113433. * Gets the framing behavior of the camera if it has been enabled.
  113434. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113435. */
  113436. get framingBehavior(): Nullable<FramingBehavior>;
  113437. /**
  113438. * Defines if the framing behavior of the camera is enabled on the camera.
  113439. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  113440. */
  113441. get useFramingBehavior(): boolean;
  113442. set useFramingBehavior(value: boolean);
  113443. private _autoRotationBehavior;
  113444. /**
  113445. * Gets the auto rotation behavior of the camera if it has been enabled.
  113446. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113447. */
  113448. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  113449. /**
  113450. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  113451. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113452. */
  113453. get useAutoRotationBehavior(): boolean;
  113454. set useAutoRotationBehavior(value: boolean);
  113455. /**
  113456. * Observable triggered when the mesh target has been changed on the camera.
  113457. */
  113458. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  113459. /**
  113460. * Event raised when the camera is colliding with a mesh.
  113461. */
  113462. onCollide: (collidedMesh: AbstractMesh) => void;
  113463. /**
  113464. * Defines whether the camera should check collision with the objects oh the scene.
  113465. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  113466. */
  113467. checkCollisions: boolean;
  113468. /**
  113469. * Defines the collision radius of the camera.
  113470. * This simulates a sphere around the camera.
  113471. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  113472. */
  113473. collisionRadius: Vector3;
  113474. protected _collider: Collider;
  113475. protected _previousPosition: Vector3;
  113476. protected _collisionVelocity: Vector3;
  113477. protected _newPosition: Vector3;
  113478. protected _previousAlpha: number;
  113479. protected _previousBeta: number;
  113480. protected _previousRadius: number;
  113481. protected _collisionTriggered: boolean;
  113482. protected _targetBoundingCenter: Nullable<Vector3>;
  113483. private _computationVector;
  113484. /**
  113485. * Instantiates a new ArcRotateCamera in a given scene
  113486. * @param name Defines the name of the camera
  113487. * @param alpha Defines the camera rotation along the logitudinal axis
  113488. * @param beta Defines the camera rotation along the latitudinal axis
  113489. * @param radius Defines the camera distance from its target
  113490. * @param target Defines the camera target
  113491. * @param scene Defines the scene the camera belongs to
  113492. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  113493. */
  113494. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  113495. /** @hidden */
  113496. _initCache(): void;
  113497. /** @hidden */
  113498. _updateCache(ignoreParentClass?: boolean): void;
  113499. protected _getTargetPosition(): Vector3;
  113500. private _storedAlpha;
  113501. private _storedBeta;
  113502. private _storedRadius;
  113503. private _storedTarget;
  113504. private _storedTargetScreenOffset;
  113505. /**
  113506. * Stores the current state of the camera (alpha, beta, radius and target)
  113507. * @returns the camera itself
  113508. */
  113509. storeState(): Camera;
  113510. /**
  113511. * @hidden
  113512. * Restored camera state. You must call storeState() first
  113513. */
  113514. _restoreStateValues(): boolean;
  113515. /** @hidden */
  113516. _isSynchronizedViewMatrix(): boolean;
  113517. /**
  113518. * Attached controls to the current camera.
  113519. * @param element Defines the element the controls should be listened from
  113520. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  113521. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  113522. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  113523. */
  113524. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  113525. /**
  113526. * Detach the current controls from the camera.
  113527. * The camera will stop reacting to inputs.
  113528. * @param element Defines the element to stop listening the inputs from
  113529. */
  113530. detachControl(element: HTMLElement): void;
  113531. /** @hidden */
  113532. _checkInputs(): void;
  113533. protected _checkLimits(): void;
  113534. /**
  113535. * Rebuilds angles (alpha, beta) and radius from the give position and target
  113536. */
  113537. rebuildAnglesAndRadius(): void;
  113538. /**
  113539. * Use a position to define the current camera related information like alpha, beta and radius
  113540. * @param position Defines the position to set the camera at
  113541. */
  113542. setPosition(position: Vector3): void;
  113543. /**
  113544. * Defines the target the camera should look at.
  113545. * This will automatically adapt alpha beta and radius to fit within the new target.
  113546. * @param target Defines the new target as a Vector or a mesh
  113547. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  113548. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  113549. */
  113550. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  113551. /** @hidden */
  113552. _getViewMatrix(): Matrix;
  113553. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  113554. /**
  113555. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  113556. * @param meshes Defines the mesh to zoom on
  113557. * @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)
  113558. */
  113559. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  113560. /**
  113561. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  113562. * The target will be changed but the radius
  113563. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  113564. * @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)
  113565. */
  113566. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  113567. min: Vector3;
  113568. max: Vector3;
  113569. distance: number;
  113570. }, doNotUpdateMaxZ?: boolean): void;
  113571. /**
  113572. * @override
  113573. * Override Camera.createRigCamera
  113574. */
  113575. createRigCamera(name: string, cameraIndex: number): Camera;
  113576. /**
  113577. * @hidden
  113578. * @override
  113579. * Override Camera._updateRigCameras
  113580. */
  113581. _updateRigCameras(): void;
  113582. /**
  113583. * Destroy the camera and release the current resources hold by it.
  113584. */
  113585. dispose(): void;
  113586. /**
  113587. * Gets the current object class name.
  113588. * @return the class name
  113589. */
  113590. getClassName(): string;
  113591. }
  113592. }
  113593. declare module BABYLON {
  113594. /**
  113595. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  113596. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  113597. */
  113598. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  113599. /**
  113600. * Gets the name of the behavior.
  113601. */
  113602. get name(): string;
  113603. private _zoomStopsAnimation;
  113604. private _idleRotationSpeed;
  113605. private _idleRotationWaitTime;
  113606. private _idleRotationSpinupTime;
  113607. /**
  113608. * Sets the flag that indicates if user zooming should stop animation.
  113609. */
  113610. set zoomStopsAnimation(flag: boolean);
  113611. /**
  113612. * Gets the flag that indicates if user zooming should stop animation.
  113613. */
  113614. get zoomStopsAnimation(): boolean;
  113615. /**
  113616. * Sets the default speed at which the camera rotates around the model.
  113617. */
  113618. set idleRotationSpeed(speed: number);
  113619. /**
  113620. * Gets the default speed at which the camera rotates around the model.
  113621. */
  113622. get idleRotationSpeed(): number;
  113623. /**
  113624. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  113625. */
  113626. set idleRotationWaitTime(time: number);
  113627. /**
  113628. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  113629. */
  113630. get idleRotationWaitTime(): number;
  113631. /**
  113632. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113633. */
  113634. set idleRotationSpinupTime(time: number);
  113635. /**
  113636. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  113637. */
  113638. get idleRotationSpinupTime(): number;
  113639. /**
  113640. * Gets a value indicating if the camera is currently rotating because of this behavior
  113641. */
  113642. get rotationInProgress(): boolean;
  113643. private _onPrePointerObservableObserver;
  113644. private _onAfterCheckInputsObserver;
  113645. private _attachedCamera;
  113646. private _isPointerDown;
  113647. private _lastFrameTime;
  113648. private _lastInteractionTime;
  113649. private _cameraRotationSpeed;
  113650. /**
  113651. * Initializes the behavior.
  113652. */
  113653. init(): void;
  113654. /**
  113655. * Attaches the behavior to its arc rotate camera.
  113656. * @param camera Defines the camera to attach the behavior to
  113657. */
  113658. attach(camera: ArcRotateCamera): void;
  113659. /**
  113660. * Detaches the behavior from its current arc rotate camera.
  113661. */
  113662. detach(): void;
  113663. /**
  113664. * Returns true if user is scrolling.
  113665. * @return true if user is scrolling.
  113666. */
  113667. private _userIsZooming;
  113668. private _lastFrameRadius;
  113669. private _shouldAnimationStopForInteraction;
  113670. /**
  113671. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  113672. */
  113673. private _applyUserInteraction;
  113674. private _userIsMoving;
  113675. }
  113676. }
  113677. declare module BABYLON {
  113678. /**
  113679. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  113680. */
  113681. export class AttachToBoxBehavior implements Behavior<Mesh> {
  113682. private ui;
  113683. /**
  113684. * The name of the behavior
  113685. */
  113686. name: string;
  113687. /**
  113688. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  113689. */
  113690. distanceAwayFromFace: number;
  113691. /**
  113692. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  113693. */
  113694. distanceAwayFromBottomOfFace: number;
  113695. private _faceVectors;
  113696. private _target;
  113697. private _scene;
  113698. private _onRenderObserver;
  113699. private _tmpMatrix;
  113700. private _tmpVector;
  113701. /**
  113702. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  113703. * @param ui The transform node that should be attched to the mesh
  113704. */
  113705. constructor(ui: TransformNode);
  113706. /**
  113707. * Initializes the behavior
  113708. */
  113709. init(): void;
  113710. private _closestFace;
  113711. private _zeroVector;
  113712. private _lookAtTmpMatrix;
  113713. private _lookAtToRef;
  113714. /**
  113715. * Attaches the AttachToBoxBehavior to the passed in mesh
  113716. * @param target The mesh that the specified node will be attached to
  113717. */
  113718. attach(target: Mesh): void;
  113719. /**
  113720. * Detaches the behavior from the mesh
  113721. */
  113722. detach(): void;
  113723. }
  113724. }
  113725. declare module BABYLON {
  113726. /**
  113727. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  113728. */
  113729. export class FadeInOutBehavior implements Behavior<Mesh> {
  113730. /**
  113731. * Time in milliseconds to delay before fading in (Default: 0)
  113732. */
  113733. delay: number;
  113734. /**
  113735. * Time in milliseconds for the mesh to fade in (Default: 300)
  113736. */
  113737. fadeInTime: number;
  113738. private _millisecondsPerFrame;
  113739. private _hovered;
  113740. private _hoverValue;
  113741. private _ownerNode;
  113742. /**
  113743. * Instatiates the FadeInOutBehavior
  113744. */
  113745. constructor();
  113746. /**
  113747. * The name of the behavior
  113748. */
  113749. get name(): string;
  113750. /**
  113751. * Initializes the behavior
  113752. */
  113753. init(): void;
  113754. /**
  113755. * Attaches the fade behavior on the passed in mesh
  113756. * @param ownerNode The mesh that will be faded in/out once attached
  113757. */
  113758. attach(ownerNode: Mesh): void;
  113759. /**
  113760. * Detaches the behavior from the mesh
  113761. */
  113762. detach(): void;
  113763. /**
  113764. * Triggers the mesh to begin fading in or out
  113765. * @param value if the object should fade in or out (true to fade in)
  113766. */
  113767. fadeIn(value: boolean): void;
  113768. private _update;
  113769. private _setAllVisibility;
  113770. }
  113771. }
  113772. declare module BABYLON {
  113773. /**
  113774. * Class containing a set of static utilities functions for managing Pivots
  113775. * @hidden
  113776. */
  113777. export class PivotTools {
  113778. private static _PivotCached;
  113779. private static _OldPivotPoint;
  113780. private static _PivotTranslation;
  113781. private static _PivotTmpVector;
  113782. /** @hidden */
  113783. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  113784. /** @hidden */
  113785. static _RestorePivotPoint(mesh: AbstractMesh): void;
  113786. }
  113787. }
  113788. declare module BABYLON {
  113789. /**
  113790. * Class containing static functions to help procedurally build meshes
  113791. */
  113792. export class PlaneBuilder {
  113793. /**
  113794. * Creates a plane mesh
  113795. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  113796. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  113797. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  113798. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  113799. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  113800. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  113801. * @param name defines the name of the mesh
  113802. * @param options defines the options used to create the mesh
  113803. * @param scene defines the hosting scene
  113804. * @returns the plane mesh
  113805. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  113806. */
  113807. static CreatePlane(name: string, options: {
  113808. size?: number;
  113809. width?: number;
  113810. height?: number;
  113811. sideOrientation?: number;
  113812. frontUVs?: Vector4;
  113813. backUVs?: Vector4;
  113814. updatable?: boolean;
  113815. sourcePlane?: Plane;
  113816. }, scene?: Nullable<Scene>): Mesh;
  113817. }
  113818. }
  113819. declare module BABYLON {
  113820. /**
  113821. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  113822. */
  113823. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  113824. private static _AnyMouseID;
  113825. /**
  113826. * Abstract mesh the behavior is set on
  113827. */
  113828. attachedNode: AbstractMesh;
  113829. private _dragPlane;
  113830. private _scene;
  113831. private _pointerObserver;
  113832. private _beforeRenderObserver;
  113833. private static _planeScene;
  113834. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  113835. /**
  113836. * 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)
  113837. */
  113838. maxDragAngle: number;
  113839. /**
  113840. * @hidden
  113841. */
  113842. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  113843. /**
  113844. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  113845. */
  113846. currentDraggingPointerID: number;
  113847. /**
  113848. * The last position where the pointer hit the drag plane in world space
  113849. */
  113850. lastDragPosition: Vector3;
  113851. /**
  113852. * If the behavior is currently in a dragging state
  113853. */
  113854. dragging: boolean;
  113855. /**
  113856. * 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)
  113857. */
  113858. dragDeltaRatio: number;
  113859. /**
  113860. * If the drag plane orientation should be updated during the dragging (Default: true)
  113861. */
  113862. updateDragPlane: boolean;
  113863. private _debugMode;
  113864. private _moving;
  113865. /**
  113866. * Fires each time the attached mesh is dragged with the pointer
  113867. * * delta between last drag position and current drag position in world space
  113868. * * dragDistance along the drag axis
  113869. * * dragPlaneNormal normal of the current drag plane used during the drag
  113870. * * dragPlanePoint in world space where the drag intersects the drag plane
  113871. */
  113872. onDragObservable: Observable<{
  113873. delta: Vector3;
  113874. dragPlanePoint: Vector3;
  113875. dragPlaneNormal: Vector3;
  113876. dragDistance: number;
  113877. pointerId: number;
  113878. }>;
  113879. /**
  113880. * Fires each time a drag begins (eg. mouse down on mesh)
  113881. */
  113882. onDragStartObservable: Observable<{
  113883. dragPlanePoint: Vector3;
  113884. pointerId: number;
  113885. }>;
  113886. /**
  113887. * Fires each time a drag ends (eg. mouse release after drag)
  113888. */
  113889. onDragEndObservable: Observable<{
  113890. dragPlanePoint: Vector3;
  113891. pointerId: number;
  113892. }>;
  113893. /**
  113894. * If the attached mesh should be moved when dragged
  113895. */
  113896. moveAttached: boolean;
  113897. /**
  113898. * If the drag behavior will react to drag events (Default: true)
  113899. */
  113900. enabled: boolean;
  113901. /**
  113902. * If pointer events should start and release the drag (Default: true)
  113903. */
  113904. startAndReleaseDragOnPointerEvents: boolean;
  113905. /**
  113906. * If camera controls should be detached during the drag
  113907. */
  113908. detachCameraControls: boolean;
  113909. /**
  113910. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  113911. */
  113912. useObjectOrientationForDragging: boolean;
  113913. private _options;
  113914. /**
  113915. * Gets the options used by the behavior
  113916. */
  113917. get options(): {
  113918. dragAxis?: Vector3;
  113919. dragPlaneNormal?: Vector3;
  113920. };
  113921. /**
  113922. * Sets the options used by the behavior
  113923. */
  113924. set options(options: {
  113925. dragAxis?: Vector3;
  113926. dragPlaneNormal?: Vector3;
  113927. });
  113928. /**
  113929. * Creates a pointer drag behavior that can be attached to a mesh
  113930. * @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)
  113931. */
  113932. constructor(options?: {
  113933. dragAxis?: Vector3;
  113934. dragPlaneNormal?: Vector3;
  113935. });
  113936. /**
  113937. * Predicate to determine if it is valid to move the object to a new position when it is moved
  113938. */
  113939. validateDrag: (targetPosition: Vector3) => boolean;
  113940. /**
  113941. * The name of the behavior
  113942. */
  113943. get name(): string;
  113944. /**
  113945. * Initializes the behavior
  113946. */
  113947. init(): void;
  113948. private _tmpVector;
  113949. private _alternatePickedPoint;
  113950. private _worldDragAxis;
  113951. private _targetPosition;
  113952. private _attachedElement;
  113953. /**
  113954. * Attaches the drag behavior the passed in mesh
  113955. * @param ownerNode The mesh that will be dragged around once attached
  113956. * @param predicate Predicate to use for pick filtering
  113957. */
  113958. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  113959. /**
  113960. * Force relase the drag action by code.
  113961. */
  113962. releaseDrag(): void;
  113963. private _startDragRay;
  113964. private _lastPointerRay;
  113965. /**
  113966. * Simulates the start of a pointer drag event on the behavior
  113967. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  113968. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  113969. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  113970. */
  113971. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  113972. private _startDrag;
  113973. private _dragDelta;
  113974. private _moveDrag;
  113975. private _pickWithRayOnDragPlane;
  113976. private _pointA;
  113977. private _pointB;
  113978. private _pointC;
  113979. private _lineA;
  113980. private _lineB;
  113981. private _localAxis;
  113982. private _lookAt;
  113983. private _updateDragPlanePosition;
  113984. /**
  113985. * Detaches the behavior from the mesh
  113986. */
  113987. detach(): void;
  113988. }
  113989. }
  113990. declare module BABYLON {
  113991. /**
  113992. * A behavior that when attached to a mesh will allow the mesh to be scaled
  113993. */
  113994. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  113995. private _dragBehaviorA;
  113996. private _dragBehaviorB;
  113997. private _startDistance;
  113998. private _initialScale;
  113999. private _targetScale;
  114000. private _ownerNode;
  114001. private _sceneRenderObserver;
  114002. /**
  114003. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  114004. */
  114005. constructor();
  114006. /**
  114007. * The name of the behavior
  114008. */
  114009. get name(): string;
  114010. /**
  114011. * Initializes the behavior
  114012. */
  114013. init(): void;
  114014. private _getCurrentDistance;
  114015. /**
  114016. * Attaches the scale behavior the passed in mesh
  114017. * @param ownerNode The mesh that will be scaled around once attached
  114018. */
  114019. attach(ownerNode: Mesh): void;
  114020. /**
  114021. * Detaches the behavior from the mesh
  114022. */
  114023. detach(): void;
  114024. }
  114025. }
  114026. declare module BABYLON {
  114027. /**
  114028. * 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
  114029. */
  114030. export class SixDofDragBehavior implements Behavior<Mesh> {
  114031. private static _virtualScene;
  114032. private _ownerNode;
  114033. private _sceneRenderObserver;
  114034. private _scene;
  114035. private _targetPosition;
  114036. private _virtualOriginMesh;
  114037. private _virtualDragMesh;
  114038. private _pointerObserver;
  114039. private _moving;
  114040. private _startingOrientation;
  114041. private _attachedElement;
  114042. /**
  114043. * 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)
  114044. */
  114045. private zDragFactor;
  114046. /**
  114047. * If the object should rotate to face the drag origin
  114048. */
  114049. rotateDraggedObject: boolean;
  114050. /**
  114051. * If the behavior is currently in a dragging state
  114052. */
  114053. dragging: boolean;
  114054. /**
  114055. * 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)
  114056. */
  114057. dragDeltaRatio: number;
  114058. /**
  114059. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  114060. */
  114061. currentDraggingPointerID: number;
  114062. /**
  114063. * If camera controls should be detached during the drag
  114064. */
  114065. detachCameraControls: boolean;
  114066. /**
  114067. * Fires each time a drag starts
  114068. */
  114069. onDragStartObservable: Observable<{}>;
  114070. /**
  114071. * Fires each time a drag ends (eg. mouse release after drag)
  114072. */
  114073. onDragEndObservable: Observable<{}>;
  114074. /**
  114075. * 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
  114076. */
  114077. constructor();
  114078. /**
  114079. * The name of the behavior
  114080. */
  114081. get name(): string;
  114082. /**
  114083. * Initializes the behavior
  114084. */
  114085. init(): void;
  114086. /**
  114087. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  114088. */
  114089. private get _pointerCamera();
  114090. /**
  114091. * Attaches the scale behavior the passed in mesh
  114092. * @param ownerNode The mesh that will be scaled around once attached
  114093. */
  114094. attach(ownerNode: Mesh): void;
  114095. /**
  114096. * Detaches the behavior from the mesh
  114097. */
  114098. detach(): void;
  114099. }
  114100. }
  114101. declare module BABYLON {
  114102. /**
  114103. * Class used to apply inverse kinematics to bones
  114104. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  114105. */
  114106. export class BoneIKController {
  114107. private static _tmpVecs;
  114108. private static _tmpQuat;
  114109. private static _tmpMats;
  114110. /**
  114111. * Gets or sets the target mesh
  114112. */
  114113. targetMesh: AbstractMesh;
  114114. /** Gets or sets the mesh used as pole */
  114115. poleTargetMesh: AbstractMesh;
  114116. /**
  114117. * Gets or sets the bone used as pole
  114118. */
  114119. poleTargetBone: Nullable<Bone>;
  114120. /**
  114121. * Gets or sets the target position
  114122. */
  114123. targetPosition: Vector3;
  114124. /**
  114125. * Gets or sets the pole target position
  114126. */
  114127. poleTargetPosition: Vector3;
  114128. /**
  114129. * Gets or sets the pole target local offset
  114130. */
  114131. poleTargetLocalOffset: Vector3;
  114132. /**
  114133. * Gets or sets the pole angle
  114134. */
  114135. poleAngle: number;
  114136. /**
  114137. * Gets or sets the mesh associated with the controller
  114138. */
  114139. mesh: AbstractMesh;
  114140. /**
  114141. * 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)
  114142. */
  114143. slerpAmount: number;
  114144. private _bone1Quat;
  114145. private _bone1Mat;
  114146. private _bone2Ang;
  114147. private _bone1;
  114148. private _bone2;
  114149. private _bone1Length;
  114150. private _bone2Length;
  114151. private _maxAngle;
  114152. private _maxReach;
  114153. private _rightHandedSystem;
  114154. private _bendAxis;
  114155. private _slerping;
  114156. private _adjustRoll;
  114157. /**
  114158. * Gets or sets maximum allowed angle
  114159. */
  114160. get maxAngle(): number;
  114161. set maxAngle(value: number);
  114162. /**
  114163. * Creates a new BoneIKController
  114164. * @param mesh defines the mesh to control
  114165. * @param bone defines the bone to control
  114166. * @param options defines options to set up the controller
  114167. */
  114168. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  114169. targetMesh?: AbstractMesh;
  114170. poleTargetMesh?: AbstractMesh;
  114171. poleTargetBone?: Bone;
  114172. poleTargetLocalOffset?: Vector3;
  114173. poleAngle?: number;
  114174. bendAxis?: Vector3;
  114175. maxAngle?: number;
  114176. slerpAmount?: number;
  114177. });
  114178. private _setMaxAngle;
  114179. /**
  114180. * Force the controller to update the bones
  114181. */
  114182. update(): void;
  114183. }
  114184. }
  114185. declare module BABYLON {
  114186. /**
  114187. * Class used to make a bone look toward a point in space
  114188. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  114189. */
  114190. export class BoneLookController {
  114191. private static _tmpVecs;
  114192. private static _tmpQuat;
  114193. private static _tmpMats;
  114194. /**
  114195. * The target Vector3 that the bone will look at
  114196. */
  114197. target: Vector3;
  114198. /**
  114199. * The mesh that the bone is attached to
  114200. */
  114201. mesh: AbstractMesh;
  114202. /**
  114203. * The bone that will be looking to the target
  114204. */
  114205. bone: Bone;
  114206. /**
  114207. * The up axis of the coordinate system that is used when the bone is rotated
  114208. */
  114209. upAxis: Vector3;
  114210. /**
  114211. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  114212. */
  114213. upAxisSpace: Space;
  114214. /**
  114215. * Used to make an adjustment to the yaw of the bone
  114216. */
  114217. adjustYaw: number;
  114218. /**
  114219. * Used to make an adjustment to the pitch of the bone
  114220. */
  114221. adjustPitch: number;
  114222. /**
  114223. * Used to make an adjustment to the roll of the bone
  114224. */
  114225. adjustRoll: number;
  114226. /**
  114227. * 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)
  114228. */
  114229. slerpAmount: number;
  114230. private _minYaw;
  114231. private _maxYaw;
  114232. private _minPitch;
  114233. private _maxPitch;
  114234. private _minYawSin;
  114235. private _minYawCos;
  114236. private _maxYawSin;
  114237. private _maxYawCos;
  114238. private _midYawConstraint;
  114239. private _minPitchTan;
  114240. private _maxPitchTan;
  114241. private _boneQuat;
  114242. private _slerping;
  114243. private _transformYawPitch;
  114244. private _transformYawPitchInv;
  114245. private _firstFrameSkipped;
  114246. private _yawRange;
  114247. private _fowardAxis;
  114248. /**
  114249. * Gets or sets the minimum yaw angle that the bone can look to
  114250. */
  114251. get minYaw(): number;
  114252. set minYaw(value: number);
  114253. /**
  114254. * Gets or sets the maximum yaw angle that the bone can look to
  114255. */
  114256. get maxYaw(): number;
  114257. set maxYaw(value: number);
  114258. /**
  114259. * Gets or sets the minimum pitch angle that the bone can look to
  114260. */
  114261. get minPitch(): number;
  114262. set minPitch(value: number);
  114263. /**
  114264. * Gets or sets the maximum pitch angle that the bone can look to
  114265. */
  114266. get maxPitch(): number;
  114267. set maxPitch(value: number);
  114268. /**
  114269. * Create a BoneLookController
  114270. * @param mesh the mesh that the bone belongs to
  114271. * @param bone the bone that will be looking to the target
  114272. * @param target the target Vector3 to look at
  114273. * @param options optional settings:
  114274. * * maxYaw: the maximum angle the bone will yaw to
  114275. * * minYaw: the minimum angle the bone will yaw to
  114276. * * maxPitch: the maximum angle the bone will pitch to
  114277. * * minPitch: the minimum angle the bone will yaw to
  114278. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  114279. * * upAxis: the up axis of the coordinate system
  114280. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  114281. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  114282. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  114283. * * adjustYaw: used to make an adjustment to the yaw of the bone
  114284. * * adjustPitch: used to make an adjustment to the pitch of the bone
  114285. * * adjustRoll: used to make an adjustment to the roll of the bone
  114286. **/
  114287. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  114288. maxYaw?: number;
  114289. minYaw?: number;
  114290. maxPitch?: number;
  114291. minPitch?: number;
  114292. slerpAmount?: number;
  114293. upAxis?: Vector3;
  114294. upAxisSpace?: Space;
  114295. yawAxis?: Vector3;
  114296. pitchAxis?: Vector3;
  114297. adjustYaw?: number;
  114298. adjustPitch?: number;
  114299. adjustRoll?: number;
  114300. });
  114301. /**
  114302. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  114303. */
  114304. update(): void;
  114305. private _getAngleDiff;
  114306. private _getAngleBetween;
  114307. private _isAngleBetween;
  114308. }
  114309. }
  114310. declare module BABYLON {
  114311. /**
  114312. * Manage the gamepad inputs to control an arc rotate camera.
  114313. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114314. */
  114315. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  114316. /**
  114317. * Defines the camera the input is attached to.
  114318. */
  114319. camera: ArcRotateCamera;
  114320. /**
  114321. * Defines the gamepad the input is gathering event from.
  114322. */
  114323. gamepad: Nullable<Gamepad>;
  114324. /**
  114325. * Defines the gamepad rotation sensiblity.
  114326. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  114327. */
  114328. gamepadRotationSensibility: number;
  114329. /**
  114330. * Defines the gamepad move sensiblity.
  114331. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  114332. */
  114333. gamepadMoveSensibility: number;
  114334. private _yAxisScale;
  114335. /**
  114336. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  114337. */
  114338. get invertYAxis(): boolean;
  114339. set invertYAxis(value: boolean);
  114340. private _onGamepadConnectedObserver;
  114341. private _onGamepadDisconnectedObserver;
  114342. /**
  114343. * Attach the input controls to a specific dom element to get the input from.
  114344. * @param element Defines the element the controls should be listened from
  114345. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114346. */
  114347. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114348. /**
  114349. * Detach the current controls from the specified dom element.
  114350. * @param element Defines the element to stop listening the inputs from
  114351. */
  114352. detachControl(element: Nullable<HTMLElement>): void;
  114353. /**
  114354. * Update the current camera state depending on the inputs that have been used this frame.
  114355. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114356. */
  114357. checkInputs(): void;
  114358. /**
  114359. * Gets the class name of the current intput.
  114360. * @returns the class name
  114361. */
  114362. getClassName(): string;
  114363. /**
  114364. * Get the friendly name associated with the input class.
  114365. * @returns the input friendly name
  114366. */
  114367. getSimpleName(): string;
  114368. }
  114369. }
  114370. declare module BABYLON {
  114371. interface ArcRotateCameraInputsManager {
  114372. /**
  114373. * Add orientation input support to the input manager.
  114374. * @returns the current input manager
  114375. */
  114376. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  114377. }
  114378. /**
  114379. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  114380. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114381. */
  114382. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  114383. /**
  114384. * Defines the camera the input is attached to.
  114385. */
  114386. camera: ArcRotateCamera;
  114387. /**
  114388. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  114389. */
  114390. alphaCorrection: number;
  114391. /**
  114392. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  114393. */
  114394. gammaCorrection: number;
  114395. private _alpha;
  114396. private _gamma;
  114397. private _dirty;
  114398. private _deviceOrientationHandler;
  114399. /**
  114400. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  114401. */
  114402. constructor();
  114403. /**
  114404. * Attach the input controls to a specific dom element to get the input from.
  114405. * @param element Defines the element the controls should be listened from
  114406. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114407. */
  114408. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114409. /** @hidden */
  114410. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  114411. /**
  114412. * Update the current camera state depending on the inputs that have been used this frame.
  114413. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114414. */
  114415. checkInputs(): void;
  114416. /**
  114417. * Detach the current controls from the specified dom element.
  114418. * @param element Defines the element to stop listening the inputs from
  114419. */
  114420. detachControl(element: Nullable<HTMLElement>): void;
  114421. /**
  114422. * Gets the class name of the current intput.
  114423. * @returns the class name
  114424. */
  114425. getClassName(): string;
  114426. /**
  114427. * Get the friendly name associated with the input class.
  114428. * @returns the input friendly name
  114429. */
  114430. getSimpleName(): string;
  114431. }
  114432. }
  114433. declare module BABYLON {
  114434. /**
  114435. * Listen to mouse events to control the camera.
  114436. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114437. */
  114438. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  114439. /**
  114440. * Defines the camera the input is attached to.
  114441. */
  114442. camera: FlyCamera;
  114443. /**
  114444. * Defines if touch is enabled. (Default is true.)
  114445. */
  114446. touchEnabled: boolean;
  114447. /**
  114448. * Defines the buttons associated with the input to handle camera rotation.
  114449. */
  114450. buttons: number[];
  114451. /**
  114452. * Assign buttons for Yaw control.
  114453. */
  114454. buttonsYaw: number[];
  114455. /**
  114456. * Assign buttons for Pitch control.
  114457. */
  114458. buttonsPitch: number[];
  114459. /**
  114460. * Assign buttons for Roll control.
  114461. */
  114462. buttonsRoll: number[];
  114463. /**
  114464. * Detect if any button is being pressed while mouse is moved.
  114465. * -1 = Mouse locked.
  114466. * 0 = Left button.
  114467. * 1 = Middle Button.
  114468. * 2 = Right Button.
  114469. */
  114470. activeButton: number;
  114471. /**
  114472. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  114473. * Higher values reduce its sensitivity.
  114474. */
  114475. angularSensibility: number;
  114476. private _mousemoveCallback;
  114477. private _observer;
  114478. private _rollObserver;
  114479. private previousPosition;
  114480. private noPreventDefault;
  114481. private element;
  114482. /**
  114483. * Listen to mouse events to control the camera.
  114484. * @param touchEnabled Define if touch is enabled. (Default is true.)
  114485. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114486. */
  114487. constructor(touchEnabled?: boolean);
  114488. /**
  114489. * Attach the mouse control to the HTML DOM element.
  114490. * @param element Defines the element that listens to the input events.
  114491. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  114492. */
  114493. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114494. /**
  114495. * Detach the current controls from the specified dom element.
  114496. * @param element Defines the element to stop listening the inputs from
  114497. */
  114498. detachControl(element: Nullable<HTMLElement>): void;
  114499. /**
  114500. * Gets the class name of the current input.
  114501. * @returns the class name.
  114502. */
  114503. getClassName(): string;
  114504. /**
  114505. * Get the friendly name associated with the input class.
  114506. * @returns the input's friendly name.
  114507. */
  114508. getSimpleName(): string;
  114509. private _pointerInput;
  114510. private _onMouseMove;
  114511. /**
  114512. * Rotate camera by mouse offset.
  114513. */
  114514. private rotateCamera;
  114515. }
  114516. }
  114517. declare module BABYLON {
  114518. /**
  114519. * Default Inputs manager for the FlyCamera.
  114520. * It groups all the default supported inputs for ease of use.
  114521. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114522. */
  114523. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  114524. /**
  114525. * Instantiates a new FlyCameraInputsManager.
  114526. * @param camera Defines the camera the inputs belong to.
  114527. */
  114528. constructor(camera: FlyCamera);
  114529. /**
  114530. * Add keyboard input support to the input manager.
  114531. * @returns the new FlyCameraKeyboardMoveInput().
  114532. */
  114533. addKeyboard(): FlyCameraInputsManager;
  114534. /**
  114535. * Add mouse input support to the input manager.
  114536. * @param touchEnabled Enable touch screen support.
  114537. * @returns the new FlyCameraMouseInput().
  114538. */
  114539. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  114540. }
  114541. }
  114542. declare module BABYLON {
  114543. /**
  114544. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114545. * such as in a 3D Space Shooter or a Flight Simulator.
  114546. */
  114547. export class FlyCamera extends TargetCamera {
  114548. /**
  114549. * Define the collision ellipsoid of the camera.
  114550. * This is helpful for simulating a camera body, like a player's body.
  114551. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  114552. */
  114553. ellipsoid: Vector3;
  114554. /**
  114555. * Define an offset for the position of the ellipsoid around the camera.
  114556. * This can be helpful if the camera is attached away from the player's body center,
  114557. * such as at its head.
  114558. */
  114559. ellipsoidOffset: Vector3;
  114560. /**
  114561. * Enable or disable collisions of the camera with the rest of the scene objects.
  114562. */
  114563. checkCollisions: boolean;
  114564. /**
  114565. * Enable or disable gravity on the camera.
  114566. */
  114567. applyGravity: boolean;
  114568. /**
  114569. * Define the current direction the camera is moving to.
  114570. */
  114571. cameraDirection: Vector3;
  114572. /**
  114573. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  114574. * This overrides and empties cameraRotation.
  114575. */
  114576. rotationQuaternion: Quaternion;
  114577. /**
  114578. * Track Roll to maintain the wanted Rolling when looking around.
  114579. */
  114580. _trackRoll: number;
  114581. /**
  114582. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  114583. */
  114584. rollCorrect: number;
  114585. /**
  114586. * Mimic a banked turn, Rolling the camera when Yawing.
  114587. * It's recommended to use rollCorrect = 10 for faster banking correction.
  114588. */
  114589. bankedTurn: boolean;
  114590. /**
  114591. * Limit in radians for how much Roll banking will add. (Default: 90°)
  114592. */
  114593. bankedTurnLimit: number;
  114594. /**
  114595. * Value of 0 disables the banked Roll.
  114596. * Value of 1 is equal to the Yaw angle in radians.
  114597. */
  114598. bankedTurnMultiplier: number;
  114599. /**
  114600. * The inputs manager loads all the input sources, such as keyboard and mouse.
  114601. */
  114602. inputs: FlyCameraInputsManager;
  114603. /**
  114604. * Gets the input sensibility for mouse input.
  114605. * Higher values reduce sensitivity.
  114606. */
  114607. get angularSensibility(): number;
  114608. /**
  114609. * Sets the input sensibility for a mouse input.
  114610. * Higher values reduce sensitivity.
  114611. */
  114612. set angularSensibility(value: number);
  114613. /**
  114614. * Get the keys for camera movement forward.
  114615. */
  114616. get keysForward(): number[];
  114617. /**
  114618. * Set the keys for camera movement forward.
  114619. */
  114620. set keysForward(value: number[]);
  114621. /**
  114622. * Get the keys for camera movement backward.
  114623. */
  114624. get keysBackward(): number[];
  114625. set keysBackward(value: number[]);
  114626. /**
  114627. * Get the keys for camera movement up.
  114628. */
  114629. get keysUp(): number[];
  114630. /**
  114631. * Set the keys for camera movement up.
  114632. */
  114633. set keysUp(value: number[]);
  114634. /**
  114635. * Get the keys for camera movement down.
  114636. */
  114637. get keysDown(): number[];
  114638. /**
  114639. * Set the keys for camera movement down.
  114640. */
  114641. set keysDown(value: number[]);
  114642. /**
  114643. * Get the keys for camera movement left.
  114644. */
  114645. get keysLeft(): number[];
  114646. /**
  114647. * Set the keys for camera movement left.
  114648. */
  114649. set keysLeft(value: number[]);
  114650. /**
  114651. * Set the keys for camera movement right.
  114652. */
  114653. get keysRight(): number[];
  114654. /**
  114655. * Set the keys for camera movement right.
  114656. */
  114657. set keysRight(value: number[]);
  114658. /**
  114659. * Event raised when the camera collides with a mesh in the scene.
  114660. */
  114661. onCollide: (collidedMesh: AbstractMesh) => void;
  114662. private _collider;
  114663. private _needMoveForGravity;
  114664. private _oldPosition;
  114665. private _diffPosition;
  114666. private _newPosition;
  114667. /** @hidden */
  114668. _localDirection: Vector3;
  114669. /** @hidden */
  114670. _transformedDirection: Vector3;
  114671. /**
  114672. * Instantiates a FlyCamera.
  114673. * This is a flying camera, designed for 3D movement and rotation in all directions,
  114674. * such as in a 3D Space Shooter or a Flight Simulator.
  114675. * @param name Define the name of the camera in the scene.
  114676. * @param position Define the starting position of the camera in the scene.
  114677. * @param scene Define the scene the camera belongs to.
  114678. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  114679. */
  114680. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  114681. /**
  114682. * Attach a control to the HTML DOM element.
  114683. * @param element Defines the element that listens to the input events.
  114684. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  114685. */
  114686. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114687. /**
  114688. * Detach a control from the HTML DOM element.
  114689. * The camera will stop reacting to that input.
  114690. * @param element Defines the element that listens to the input events.
  114691. */
  114692. detachControl(element: HTMLElement): void;
  114693. private _collisionMask;
  114694. /**
  114695. * Get the mask that the camera ignores in collision events.
  114696. */
  114697. get collisionMask(): number;
  114698. /**
  114699. * Set the mask that the camera ignores in collision events.
  114700. */
  114701. set collisionMask(mask: number);
  114702. /** @hidden */
  114703. _collideWithWorld(displacement: Vector3): void;
  114704. /** @hidden */
  114705. private _onCollisionPositionChange;
  114706. /** @hidden */
  114707. _checkInputs(): void;
  114708. /** @hidden */
  114709. _decideIfNeedsToMove(): boolean;
  114710. /** @hidden */
  114711. _updatePosition(): void;
  114712. /**
  114713. * Restore the Roll to its target value at the rate specified.
  114714. * @param rate - Higher means slower restoring.
  114715. * @hidden
  114716. */
  114717. restoreRoll(rate: number): void;
  114718. /**
  114719. * Destroy the camera and release the current resources held by it.
  114720. */
  114721. dispose(): void;
  114722. /**
  114723. * Get the current object class name.
  114724. * @returns the class name.
  114725. */
  114726. getClassName(): string;
  114727. }
  114728. }
  114729. declare module BABYLON {
  114730. /**
  114731. * Listen to keyboard events to control the camera.
  114732. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114733. */
  114734. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  114735. /**
  114736. * Defines the camera the input is attached to.
  114737. */
  114738. camera: FlyCamera;
  114739. /**
  114740. * The list of keyboard keys used to control the forward move of the camera.
  114741. */
  114742. keysForward: number[];
  114743. /**
  114744. * The list of keyboard keys used to control the backward move of the camera.
  114745. */
  114746. keysBackward: number[];
  114747. /**
  114748. * The list of keyboard keys used to control the forward move of the camera.
  114749. */
  114750. keysUp: number[];
  114751. /**
  114752. * The list of keyboard keys used to control the backward move of the camera.
  114753. */
  114754. keysDown: number[];
  114755. /**
  114756. * The list of keyboard keys used to control the right strafe move of the camera.
  114757. */
  114758. keysRight: number[];
  114759. /**
  114760. * The list of keyboard keys used to control the left strafe move of the camera.
  114761. */
  114762. keysLeft: number[];
  114763. private _keys;
  114764. private _onCanvasBlurObserver;
  114765. private _onKeyboardObserver;
  114766. private _engine;
  114767. private _scene;
  114768. /**
  114769. * Attach the input controls to a specific dom element to get the input from.
  114770. * @param element Defines the element the controls should be listened from
  114771. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114772. */
  114773. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114774. /**
  114775. * Detach the current controls from the specified dom element.
  114776. * @param element Defines the element to stop listening the inputs from
  114777. */
  114778. detachControl(element: Nullable<HTMLElement>): void;
  114779. /**
  114780. * Gets the class name of the current intput.
  114781. * @returns the class name
  114782. */
  114783. getClassName(): string;
  114784. /** @hidden */
  114785. _onLostFocus(e: FocusEvent): void;
  114786. /**
  114787. * Get the friendly name associated with the input class.
  114788. * @returns the input friendly name
  114789. */
  114790. getSimpleName(): string;
  114791. /**
  114792. * Update the current camera state depending on the inputs that have been used this frame.
  114793. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  114794. */
  114795. checkInputs(): void;
  114796. }
  114797. }
  114798. declare module BABYLON {
  114799. /**
  114800. * Manage the mouse wheel inputs to control a follow camera.
  114801. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114802. */
  114803. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  114804. /**
  114805. * Defines the camera the input is attached to.
  114806. */
  114807. camera: FollowCamera;
  114808. /**
  114809. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  114810. */
  114811. axisControlRadius: boolean;
  114812. /**
  114813. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  114814. */
  114815. axisControlHeight: boolean;
  114816. /**
  114817. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  114818. */
  114819. axisControlRotation: boolean;
  114820. /**
  114821. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  114822. * relation to mouseWheel events.
  114823. */
  114824. wheelPrecision: number;
  114825. /**
  114826. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  114827. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  114828. */
  114829. wheelDeltaPercentage: number;
  114830. private _wheel;
  114831. private _observer;
  114832. /**
  114833. * Attach the input controls to a specific dom element to get the input from.
  114834. * @param element Defines the element the controls should be listened from
  114835. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  114836. */
  114837. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  114838. /**
  114839. * Detach the current controls from the specified dom element.
  114840. * @param element Defines the element to stop listening the inputs from
  114841. */
  114842. detachControl(element: Nullable<HTMLElement>): void;
  114843. /**
  114844. * Gets the class name of the current intput.
  114845. * @returns the class name
  114846. */
  114847. getClassName(): string;
  114848. /**
  114849. * Get the friendly name associated with the input class.
  114850. * @returns the input friendly name
  114851. */
  114852. getSimpleName(): string;
  114853. }
  114854. }
  114855. declare module BABYLON {
  114856. /**
  114857. * Manage the pointers inputs to control an follow camera.
  114858. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114859. */
  114860. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  114861. /**
  114862. * Defines the camera the input is attached to.
  114863. */
  114864. camera: FollowCamera;
  114865. /**
  114866. * Gets the class name of the current input.
  114867. * @returns the class name
  114868. */
  114869. getClassName(): string;
  114870. /**
  114871. * Defines the pointer angular sensibility along the X axis or how fast is
  114872. * the camera rotating.
  114873. * A negative number will reverse the axis direction.
  114874. */
  114875. angularSensibilityX: number;
  114876. /**
  114877. * Defines the pointer angular sensibility along the Y axis or how fast is
  114878. * the camera rotating.
  114879. * A negative number will reverse the axis direction.
  114880. */
  114881. angularSensibilityY: number;
  114882. /**
  114883. * Defines the pointer pinch precision or how fast is the camera zooming.
  114884. * A negative number will reverse the axis direction.
  114885. */
  114886. pinchPrecision: number;
  114887. /**
  114888. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  114889. * from 0.
  114890. * It defines the percentage of current camera.radius to use as delta when
  114891. * pinch zoom is used.
  114892. */
  114893. pinchDeltaPercentage: number;
  114894. /**
  114895. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  114896. */
  114897. axisXControlRadius: boolean;
  114898. /**
  114899. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  114900. */
  114901. axisXControlHeight: boolean;
  114902. /**
  114903. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  114904. */
  114905. axisXControlRotation: boolean;
  114906. /**
  114907. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  114908. */
  114909. axisYControlRadius: boolean;
  114910. /**
  114911. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  114912. */
  114913. axisYControlHeight: boolean;
  114914. /**
  114915. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  114916. */
  114917. axisYControlRotation: boolean;
  114918. /**
  114919. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  114920. */
  114921. axisPinchControlRadius: boolean;
  114922. /**
  114923. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  114924. */
  114925. axisPinchControlHeight: boolean;
  114926. /**
  114927. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  114928. */
  114929. axisPinchControlRotation: boolean;
  114930. /**
  114931. * Log error messages if basic misconfiguration has occurred.
  114932. */
  114933. warningEnable: boolean;
  114934. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  114935. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  114936. private _warningCounter;
  114937. private _warning;
  114938. }
  114939. }
  114940. declare module BABYLON {
  114941. /**
  114942. * Default Inputs manager for the FollowCamera.
  114943. * It groups all the default supported inputs for ease of use.
  114944. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  114945. */
  114946. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  114947. /**
  114948. * Instantiates a new FollowCameraInputsManager.
  114949. * @param camera Defines the camera the inputs belong to
  114950. */
  114951. constructor(camera: FollowCamera);
  114952. /**
  114953. * Add keyboard input support to the input manager.
  114954. * @returns the current input manager
  114955. */
  114956. addKeyboard(): FollowCameraInputsManager;
  114957. /**
  114958. * Add mouse wheel input support to the input manager.
  114959. * @returns the current input manager
  114960. */
  114961. addMouseWheel(): FollowCameraInputsManager;
  114962. /**
  114963. * Add pointers input support to the input manager.
  114964. * @returns the current input manager
  114965. */
  114966. addPointers(): FollowCameraInputsManager;
  114967. /**
  114968. * Add orientation input support to the input manager.
  114969. * @returns the current input manager
  114970. */
  114971. addVRDeviceOrientation(): FollowCameraInputsManager;
  114972. }
  114973. }
  114974. declare module BABYLON {
  114975. /**
  114976. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  114977. * an arc rotate version arcFollowCamera are available.
  114978. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  114979. */
  114980. export class FollowCamera extends TargetCamera {
  114981. /**
  114982. * Distance the follow camera should follow an object at
  114983. */
  114984. radius: number;
  114985. /**
  114986. * Minimum allowed distance of the camera to the axis of rotation
  114987. * (The camera can not get closer).
  114988. * This can help limiting how the Camera is able to move in the scene.
  114989. */
  114990. lowerRadiusLimit: Nullable<number>;
  114991. /**
  114992. * Maximum allowed distance of the camera to the axis of rotation
  114993. * (The camera can not get further).
  114994. * This can help limiting how the Camera is able to move in the scene.
  114995. */
  114996. upperRadiusLimit: Nullable<number>;
  114997. /**
  114998. * Define a rotation offset between the camera and the object it follows
  114999. */
  115000. rotationOffset: number;
  115001. /**
  115002. * Minimum allowed angle to camera position relative to target object.
  115003. * This can help limiting how the Camera is able to move in the scene.
  115004. */
  115005. lowerRotationOffsetLimit: Nullable<number>;
  115006. /**
  115007. * Maximum allowed angle to camera position relative to target object.
  115008. * This can help limiting how the Camera is able to move in the scene.
  115009. */
  115010. upperRotationOffsetLimit: Nullable<number>;
  115011. /**
  115012. * Define a height offset between the camera and the object it follows.
  115013. * It can help following an object from the top (like a car chaing a plane)
  115014. */
  115015. heightOffset: number;
  115016. /**
  115017. * Minimum allowed height of camera position relative to target object.
  115018. * This can help limiting how the Camera is able to move in the scene.
  115019. */
  115020. lowerHeightOffsetLimit: Nullable<number>;
  115021. /**
  115022. * Maximum allowed height of camera position relative to target object.
  115023. * This can help limiting how the Camera is able to move in the scene.
  115024. */
  115025. upperHeightOffsetLimit: Nullable<number>;
  115026. /**
  115027. * Define how fast the camera can accelerate to follow it s target.
  115028. */
  115029. cameraAcceleration: number;
  115030. /**
  115031. * Define the speed limit of the camera following an object.
  115032. */
  115033. maxCameraSpeed: number;
  115034. /**
  115035. * Define the target of the camera.
  115036. */
  115037. lockedTarget: Nullable<AbstractMesh>;
  115038. /**
  115039. * Defines the input associated with the camera.
  115040. */
  115041. inputs: FollowCameraInputsManager;
  115042. /**
  115043. * Instantiates the follow camera.
  115044. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115045. * @param name Define the name of the camera in the scene
  115046. * @param position Define the position of the camera
  115047. * @param scene Define the scene the camera belong to
  115048. * @param lockedTarget Define the target of the camera
  115049. */
  115050. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  115051. private _follow;
  115052. /**
  115053. * Attached controls to the current camera.
  115054. * @param element Defines the element the controls should be listened from
  115055. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115056. */
  115057. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115058. /**
  115059. * Detach the current controls from the camera.
  115060. * The camera will stop reacting to inputs.
  115061. * @param element Defines the element to stop listening the inputs from
  115062. */
  115063. detachControl(element: HTMLElement): void;
  115064. /** @hidden */
  115065. _checkInputs(): void;
  115066. private _checkLimits;
  115067. /**
  115068. * Gets the camera class name.
  115069. * @returns the class name
  115070. */
  115071. getClassName(): string;
  115072. }
  115073. /**
  115074. * Arc Rotate version of the follow camera.
  115075. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  115076. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115077. */
  115078. export class ArcFollowCamera extends TargetCamera {
  115079. /** The longitudinal angle of the camera */
  115080. alpha: number;
  115081. /** The latitudinal angle of the camera */
  115082. beta: number;
  115083. /** The radius of the camera from its target */
  115084. radius: number;
  115085. /** Define the camera target (the messh it should follow) */
  115086. target: Nullable<AbstractMesh>;
  115087. private _cartesianCoordinates;
  115088. /**
  115089. * Instantiates a new ArcFollowCamera
  115090. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  115091. * @param name Define the name of the camera
  115092. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  115093. * @param beta Define the rotation angle of the camera around the elevation axis
  115094. * @param radius Define the radius of the camera from its target point
  115095. * @param target Define the target of the camera
  115096. * @param scene Define the scene the camera belongs to
  115097. */
  115098. constructor(name: string,
  115099. /** The longitudinal angle of the camera */
  115100. alpha: number,
  115101. /** The latitudinal angle of the camera */
  115102. beta: number,
  115103. /** The radius of the camera from its target */
  115104. radius: number,
  115105. /** Define the camera target (the messh it should follow) */
  115106. target: Nullable<AbstractMesh>, scene: Scene);
  115107. private _follow;
  115108. /** @hidden */
  115109. _checkInputs(): void;
  115110. /**
  115111. * Returns the class name of the object.
  115112. * It is mostly used internally for serialization purposes.
  115113. */
  115114. getClassName(): string;
  115115. }
  115116. }
  115117. declare module BABYLON {
  115118. /**
  115119. * Manage the keyboard inputs to control the movement of a follow camera.
  115120. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115121. */
  115122. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  115123. /**
  115124. * Defines the camera the input is attached to.
  115125. */
  115126. camera: FollowCamera;
  115127. /**
  115128. * Defines the list of key codes associated with the up action (increase heightOffset)
  115129. */
  115130. keysHeightOffsetIncr: number[];
  115131. /**
  115132. * Defines the list of key codes associated with the down action (decrease heightOffset)
  115133. */
  115134. keysHeightOffsetDecr: number[];
  115135. /**
  115136. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  115137. */
  115138. keysHeightOffsetModifierAlt: boolean;
  115139. /**
  115140. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  115141. */
  115142. keysHeightOffsetModifierCtrl: boolean;
  115143. /**
  115144. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  115145. */
  115146. keysHeightOffsetModifierShift: boolean;
  115147. /**
  115148. * Defines the list of key codes associated with the left action (increase rotationOffset)
  115149. */
  115150. keysRotationOffsetIncr: number[];
  115151. /**
  115152. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  115153. */
  115154. keysRotationOffsetDecr: number[];
  115155. /**
  115156. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  115157. */
  115158. keysRotationOffsetModifierAlt: boolean;
  115159. /**
  115160. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  115161. */
  115162. keysRotationOffsetModifierCtrl: boolean;
  115163. /**
  115164. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  115165. */
  115166. keysRotationOffsetModifierShift: boolean;
  115167. /**
  115168. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  115169. */
  115170. keysRadiusIncr: number[];
  115171. /**
  115172. * Defines the list of key codes associated with the zoom-out action (increase radius)
  115173. */
  115174. keysRadiusDecr: number[];
  115175. /**
  115176. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  115177. */
  115178. keysRadiusModifierAlt: boolean;
  115179. /**
  115180. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  115181. */
  115182. keysRadiusModifierCtrl: boolean;
  115183. /**
  115184. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  115185. */
  115186. keysRadiusModifierShift: boolean;
  115187. /**
  115188. * Defines the rate of change of heightOffset.
  115189. */
  115190. heightSensibility: number;
  115191. /**
  115192. * Defines the rate of change of rotationOffset.
  115193. */
  115194. rotationSensibility: number;
  115195. /**
  115196. * Defines the rate of change of radius.
  115197. */
  115198. radiusSensibility: number;
  115199. private _keys;
  115200. private _ctrlPressed;
  115201. private _altPressed;
  115202. private _shiftPressed;
  115203. private _onCanvasBlurObserver;
  115204. private _onKeyboardObserver;
  115205. private _engine;
  115206. private _scene;
  115207. /**
  115208. * Attach the input controls to a specific dom element to get the input from.
  115209. * @param element Defines the element the controls should be listened from
  115210. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115211. */
  115212. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115213. /**
  115214. * Detach the current controls from the specified dom element.
  115215. * @param element Defines the element to stop listening the inputs from
  115216. */
  115217. detachControl(element: Nullable<HTMLElement>): void;
  115218. /**
  115219. * Update the current camera state depending on the inputs that have been used this frame.
  115220. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115221. */
  115222. checkInputs(): void;
  115223. /**
  115224. * Gets the class name of the current input.
  115225. * @returns the class name
  115226. */
  115227. getClassName(): string;
  115228. /**
  115229. * Get the friendly name associated with the input class.
  115230. * @returns the input friendly name
  115231. */
  115232. getSimpleName(): string;
  115233. /**
  115234. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115235. * allow modification of the heightOffset value.
  115236. */
  115237. private _modifierHeightOffset;
  115238. /**
  115239. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115240. * allow modification of the rotationOffset value.
  115241. */
  115242. private _modifierRotationOffset;
  115243. /**
  115244. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  115245. * allow modification of the radius value.
  115246. */
  115247. private _modifierRadius;
  115248. }
  115249. }
  115250. declare module BABYLON {
  115251. interface FreeCameraInputsManager {
  115252. /**
  115253. * @hidden
  115254. */
  115255. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  115256. /**
  115257. * Add orientation input support to the input manager.
  115258. * @returns the current input manager
  115259. */
  115260. addDeviceOrientation(): FreeCameraInputsManager;
  115261. }
  115262. /**
  115263. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  115264. * Screen rotation is taken into account.
  115265. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115266. */
  115267. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  115268. private _camera;
  115269. private _screenOrientationAngle;
  115270. private _constantTranform;
  115271. private _screenQuaternion;
  115272. private _alpha;
  115273. private _beta;
  115274. private _gamma;
  115275. /**
  115276. * Can be used to detect if a device orientation sensor is available on a device
  115277. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  115278. * @returns a promise that will resolve on orientation change
  115279. */
  115280. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  115281. /**
  115282. * @hidden
  115283. */
  115284. _onDeviceOrientationChangedObservable: Observable<void>;
  115285. /**
  115286. * Instantiates a new input
  115287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115288. */
  115289. constructor();
  115290. /**
  115291. * Define the camera controlled by the input.
  115292. */
  115293. get camera(): FreeCamera;
  115294. set camera(camera: FreeCamera);
  115295. /**
  115296. * Attach the input controls to a specific dom element to get the input from.
  115297. * @param element Defines the element the controls should be listened from
  115298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115299. */
  115300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115301. private _orientationChanged;
  115302. private _deviceOrientation;
  115303. /**
  115304. * Detach the current controls from the specified dom element.
  115305. * @param element Defines the element to stop listening the inputs from
  115306. */
  115307. detachControl(element: Nullable<HTMLElement>): void;
  115308. /**
  115309. * Update the current camera state depending on the inputs that have been used this frame.
  115310. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115311. */
  115312. checkInputs(): void;
  115313. /**
  115314. * Gets the class name of the current intput.
  115315. * @returns the class name
  115316. */
  115317. getClassName(): string;
  115318. /**
  115319. * Get the friendly name associated with the input class.
  115320. * @returns the input friendly name
  115321. */
  115322. getSimpleName(): string;
  115323. }
  115324. }
  115325. declare module BABYLON {
  115326. /**
  115327. * Manage the gamepad inputs to control a free camera.
  115328. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115329. */
  115330. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  115331. /**
  115332. * Define the camera the input is attached to.
  115333. */
  115334. camera: FreeCamera;
  115335. /**
  115336. * Define the Gamepad controlling the input
  115337. */
  115338. gamepad: Nullable<Gamepad>;
  115339. /**
  115340. * Defines the gamepad rotation sensiblity.
  115341. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  115342. */
  115343. gamepadAngularSensibility: number;
  115344. /**
  115345. * Defines the gamepad move sensiblity.
  115346. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  115347. */
  115348. gamepadMoveSensibility: number;
  115349. private _yAxisScale;
  115350. /**
  115351. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  115352. */
  115353. get invertYAxis(): boolean;
  115354. set invertYAxis(value: boolean);
  115355. private _onGamepadConnectedObserver;
  115356. private _onGamepadDisconnectedObserver;
  115357. private _cameraTransform;
  115358. private _deltaTransform;
  115359. private _vector3;
  115360. private _vector2;
  115361. /**
  115362. * Attach the input controls to a specific dom element to get the input from.
  115363. * @param element Defines the element the controls should be listened from
  115364. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115365. */
  115366. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115367. /**
  115368. * Detach the current controls from the specified dom element.
  115369. * @param element Defines the element to stop listening the inputs from
  115370. */
  115371. detachControl(element: Nullable<HTMLElement>): void;
  115372. /**
  115373. * Update the current camera state depending on the inputs that have been used this frame.
  115374. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115375. */
  115376. checkInputs(): void;
  115377. /**
  115378. * Gets the class name of the current intput.
  115379. * @returns the class name
  115380. */
  115381. getClassName(): string;
  115382. /**
  115383. * Get the friendly name associated with the input class.
  115384. * @returns the input friendly name
  115385. */
  115386. getSimpleName(): string;
  115387. }
  115388. }
  115389. declare module BABYLON {
  115390. /**
  115391. * Defines the potential axis of a Joystick
  115392. */
  115393. export enum JoystickAxis {
  115394. /** X axis */
  115395. X = 0,
  115396. /** Y axis */
  115397. Y = 1,
  115398. /** Z axis */
  115399. Z = 2
  115400. }
  115401. /**
  115402. * Class used to define virtual joystick (used in touch mode)
  115403. */
  115404. export class VirtualJoystick {
  115405. /**
  115406. * Gets or sets a boolean indicating that left and right values must be inverted
  115407. */
  115408. reverseLeftRight: boolean;
  115409. /**
  115410. * Gets or sets a boolean indicating that up and down values must be inverted
  115411. */
  115412. reverseUpDown: boolean;
  115413. /**
  115414. * Gets the offset value for the position (ie. the change of the position value)
  115415. */
  115416. deltaPosition: Vector3;
  115417. /**
  115418. * Gets a boolean indicating if the virtual joystick was pressed
  115419. */
  115420. pressed: boolean;
  115421. /**
  115422. * Canvas the virtual joystick will render onto, default z-index of this is 5
  115423. */
  115424. static Canvas: Nullable<HTMLCanvasElement>;
  115425. private static _globalJoystickIndex;
  115426. private static vjCanvasContext;
  115427. private static vjCanvasWidth;
  115428. private static vjCanvasHeight;
  115429. private static halfWidth;
  115430. private _action;
  115431. private _axisTargetedByLeftAndRight;
  115432. private _axisTargetedByUpAndDown;
  115433. private _joystickSensibility;
  115434. private _inversedSensibility;
  115435. private _joystickPointerID;
  115436. private _joystickColor;
  115437. private _joystickPointerPos;
  115438. private _joystickPreviousPointerPos;
  115439. private _joystickPointerStartPos;
  115440. private _deltaJoystickVector;
  115441. private _leftJoystick;
  115442. private _touches;
  115443. private _onPointerDownHandlerRef;
  115444. private _onPointerMoveHandlerRef;
  115445. private _onPointerUpHandlerRef;
  115446. private _onResize;
  115447. /**
  115448. * Creates a new virtual joystick
  115449. * @param leftJoystick defines that the joystick is for left hand (false by default)
  115450. */
  115451. constructor(leftJoystick?: boolean);
  115452. /**
  115453. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  115454. * @param newJoystickSensibility defines the new sensibility
  115455. */
  115456. setJoystickSensibility(newJoystickSensibility: number): void;
  115457. private _onPointerDown;
  115458. private _onPointerMove;
  115459. private _onPointerUp;
  115460. /**
  115461. * Change the color of the virtual joystick
  115462. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  115463. */
  115464. setJoystickColor(newColor: string): void;
  115465. /**
  115466. * Defines a callback to call when the joystick is touched
  115467. * @param action defines the callback
  115468. */
  115469. setActionOnTouch(action: () => any): void;
  115470. /**
  115471. * Defines which axis you'd like to control for left & right
  115472. * @param axis defines the axis to use
  115473. */
  115474. setAxisForLeftRight(axis: JoystickAxis): void;
  115475. /**
  115476. * Defines which axis you'd like to control for up & down
  115477. * @param axis defines the axis to use
  115478. */
  115479. setAxisForUpDown(axis: JoystickAxis): void;
  115480. private _drawVirtualJoystick;
  115481. /**
  115482. * Release internal HTML canvas
  115483. */
  115484. releaseCanvas(): void;
  115485. }
  115486. }
  115487. declare module BABYLON {
  115488. interface FreeCameraInputsManager {
  115489. /**
  115490. * Add virtual joystick input support to the input manager.
  115491. * @returns the current input manager
  115492. */
  115493. addVirtualJoystick(): FreeCameraInputsManager;
  115494. }
  115495. /**
  115496. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  115497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  115498. */
  115499. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  115500. /**
  115501. * Defines the camera the input is attached to.
  115502. */
  115503. camera: FreeCamera;
  115504. private _leftjoystick;
  115505. private _rightjoystick;
  115506. /**
  115507. * Gets the left stick of the virtual joystick.
  115508. * @returns The virtual Joystick
  115509. */
  115510. getLeftJoystick(): VirtualJoystick;
  115511. /**
  115512. * Gets the right stick of the virtual joystick.
  115513. * @returns The virtual Joystick
  115514. */
  115515. getRightJoystick(): VirtualJoystick;
  115516. /**
  115517. * Update the current camera state depending on the inputs that have been used this frame.
  115518. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  115519. */
  115520. checkInputs(): void;
  115521. /**
  115522. * Attach the input controls to a specific dom element to get the input from.
  115523. * @param element Defines the element the controls should be listened from
  115524. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  115525. */
  115526. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  115527. /**
  115528. * Detach the current controls from the specified dom element.
  115529. * @param element Defines the element to stop listening the inputs from
  115530. */
  115531. detachControl(element: Nullable<HTMLElement>): void;
  115532. /**
  115533. * Gets the class name of the current intput.
  115534. * @returns the class name
  115535. */
  115536. getClassName(): string;
  115537. /**
  115538. * Get the friendly name associated with the input class.
  115539. * @returns the input friendly name
  115540. */
  115541. getSimpleName(): string;
  115542. }
  115543. }
  115544. declare module BABYLON {
  115545. /**
  115546. * This represents a FPS type of camera controlled by touch.
  115547. * This is like a universal camera minus the Gamepad controls.
  115548. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115549. */
  115550. export class TouchCamera extends FreeCamera {
  115551. /**
  115552. * Defines the touch sensibility for rotation.
  115553. * The higher the faster.
  115554. */
  115555. get touchAngularSensibility(): number;
  115556. set touchAngularSensibility(value: number);
  115557. /**
  115558. * Defines the touch sensibility for move.
  115559. * The higher the faster.
  115560. */
  115561. get touchMoveSensibility(): number;
  115562. set touchMoveSensibility(value: number);
  115563. /**
  115564. * Instantiates a new touch camera.
  115565. * This represents a FPS type of camera controlled by touch.
  115566. * This is like a universal camera minus the Gamepad controls.
  115567. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  115568. * @param name Define the name of the camera in the scene
  115569. * @param position Define the start position of the camera in the scene
  115570. * @param scene Define the scene the camera belongs to
  115571. */
  115572. constructor(name: string, position: Vector3, scene: Scene);
  115573. /**
  115574. * Gets the current object class name.
  115575. * @return the class name
  115576. */
  115577. getClassName(): string;
  115578. /** @hidden */
  115579. _setupInputs(): void;
  115580. }
  115581. }
  115582. declare module BABYLON {
  115583. /**
  115584. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  115585. * being tilted forward or back and left or right.
  115586. */
  115587. export class DeviceOrientationCamera extends FreeCamera {
  115588. private _initialQuaternion;
  115589. private _quaternionCache;
  115590. private _tmpDragQuaternion;
  115591. private _disablePointerInputWhenUsingDeviceOrientation;
  115592. /**
  115593. * Creates a new device orientation camera
  115594. * @param name The name of the camera
  115595. * @param position The start position camera
  115596. * @param scene The scene the camera belongs to
  115597. */
  115598. constructor(name: string, position: Vector3, scene: Scene);
  115599. /**
  115600. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  115601. */
  115602. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  115603. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  115604. private _dragFactor;
  115605. /**
  115606. * Enabled turning on the y axis when the orientation sensor is active
  115607. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  115608. */
  115609. enableHorizontalDragging(dragFactor?: number): void;
  115610. /**
  115611. * Gets the current instance class name ("DeviceOrientationCamera").
  115612. * This helps avoiding instanceof at run time.
  115613. * @returns the class name
  115614. */
  115615. getClassName(): string;
  115616. /**
  115617. * @hidden
  115618. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  115619. */
  115620. _checkInputs(): void;
  115621. /**
  115622. * Reset the camera to its default orientation on the specified axis only.
  115623. * @param axis The axis to reset
  115624. */
  115625. resetToCurrentRotation(axis?: Axis): void;
  115626. }
  115627. }
  115628. declare module BABYLON {
  115629. /**
  115630. * Defines supported buttons for XBox360 compatible gamepads
  115631. */
  115632. export enum Xbox360Button {
  115633. /** A */
  115634. A = 0,
  115635. /** B */
  115636. B = 1,
  115637. /** X */
  115638. X = 2,
  115639. /** Y */
  115640. Y = 3,
  115641. /** Left button */
  115642. LB = 4,
  115643. /** Right button */
  115644. RB = 5,
  115645. /** Back */
  115646. Back = 8,
  115647. /** Start */
  115648. Start = 9,
  115649. /** Left stick */
  115650. LeftStick = 10,
  115651. /** Right stick */
  115652. RightStick = 11
  115653. }
  115654. /** Defines values for XBox360 DPad */
  115655. export enum Xbox360Dpad {
  115656. /** Up */
  115657. Up = 12,
  115658. /** Down */
  115659. Down = 13,
  115660. /** Left */
  115661. Left = 14,
  115662. /** Right */
  115663. Right = 15
  115664. }
  115665. /**
  115666. * Defines a XBox360 gamepad
  115667. */
  115668. export class Xbox360Pad extends Gamepad {
  115669. private _leftTrigger;
  115670. private _rightTrigger;
  115671. private _onlefttriggerchanged;
  115672. private _onrighttriggerchanged;
  115673. private _onbuttondown;
  115674. private _onbuttonup;
  115675. private _ondpaddown;
  115676. private _ondpadup;
  115677. /** Observable raised when a button is pressed */
  115678. onButtonDownObservable: Observable<Xbox360Button>;
  115679. /** Observable raised when a button is released */
  115680. onButtonUpObservable: Observable<Xbox360Button>;
  115681. /** Observable raised when a pad is pressed */
  115682. onPadDownObservable: Observable<Xbox360Dpad>;
  115683. /** Observable raised when a pad is released */
  115684. onPadUpObservable: Observable<Xbox360Dpad>;
  115685. private _buttonA;
  115686. private _buttonB;
  115687. private _buttonX;
  115688. private _buttonY;
  115689. private _buttonBack;
  115690. private _buttonStart;
  115691. private _buttonLB;
  115692. private _buttonRB;
  115693. private _buttonLeftStick;
  115694. private _buttonRightStick;
  115695. private _dPadUp;
  115696. private _dPadDown;
  115697. private _dPadLeft;
  115698. private _dPadRight;
  115699. private _isXboxOnePad;
  115700. /**
  115701. * Creates a new XBox360 gamepad object
  115702. * @param id defines the id of this gamepad
  115703. * @param index defines its index
  115704. * @param gamepad defines the internal HTML gamepad object
  115705. * @param xboxOne defines if it is a XBox One gamepad
  115706. */
  115707. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  115708. /**
  115709. * Defines the callback to call when left trigger is pressed
  115710. * @param callback defines the callback to use
  115711. */
  115712. onlefttriggerchanged(callback: (value: number) => void): void;
  115713. /**
  115714. * Defines the callback to call when right trigger is pressed
  115715. * @param callback defines the callback to use
  115716. */
  115717. onrighttriggerchanged(callback: (value: number) => void): void;
  115718. /**
  115719. * Gets the left trigger value
  115720. */
  115721. get leftTrigger(): number;
  115722. /**
  115723. * Sets the left trigger value
  115724. */
  115725. set leftTrigger(newValue: number);
  115726. /**
  115727. * Gets the right trigger value
  115728. */
  115729. get rightTrigger(): number;
  115730. /**
  115731. * Sets the right trigger value
  115732. */
  115733. set rightTrigger(newValue: number);
  115734. /**
  115735. * Defines the callback to call when a button is pressed
  115736. * @param callback defines the callback to use
  115737. */
  115738. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  115739. /**
  115740. * Defines the callback to call when a button is released
  115741. * @param callback defines the callback to use
  115742. */
  115743. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  115744. /**
  115745. * Defines the callback to call when a pad is pressed
  115746. * @param callback defines the callback to use
  115747. */
  115748. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  115749. /**
  115750. * Defines the callback to call when a pad is released
  115751. * @param callback defines the callback to use
  115752. */
  115753. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  115754. private _setButtonValue;
  115755. private _setDPadValue;
  115756. /**
  115757. * Gets the value of the `A` button
  115758. */
  115759. get buttonA(): number;
  115760. /**
  115761. * Sets the value of the `A` button
  115762. */
  115763. set buttonA(value: number);
  115764. /**
  115765. * Gets the value of the `B` button
  115766. */
  115767. get buttonB(): number;
  115768. /**
  115769. * Sets the value of the `B` button
  115770. */
  115771. set buttonB(value: number);
  115772. /**
  115773. * Gets the value of the `X` button
  115774. */
  115775. get buttonX(): number;
  115776. /**
  115777. * Sets the value of the `X` button
  115778. */
  115779. set buttonX(value: number);
  115780. /**
  115781. * Gets the value of the `Y` button
  115782. */
  115783. get buttonY(): number;
  115784. /**
  115785. * Sets the value of the `Y` button
  115786. */
  115787. set buttonY(value: number);
  115788. /**
  115789. * Gets the value of the `Start` button
  115790. */
  115791. get buttonStart(): number;
  115792. /**
  115793. * Sets the value of the `Start` button
  115794. */
  115795. set buttonStart(value: number);
  115796. /**
  115797. * Gets the value of the `Back` button
  115798. */
  115799. get buttonBack(): number;
  115800. /**
  115801. * Sets the value of the `Back` button
  115802. */
  115803. set buttonBack(value: number);
  115804. /**
  115805. * Gets the value of the `Left` button
  115806. */
  115807. get buttonLB(): number;
  115808. /**
  115809. * Sets the value of the `Left` button
  115810. */
  115811. set buttonLB(value: number);
  115812. /**
  115813. * Gets the value of the `Right` button
  115814. */
  115815. get buttonRB(): number;
  115816. /**
  115817. * Sets the value of the `Right` button
  115818. */
  115819. set buttonRB(value: number);
  115820. /**
  115821. * Gets the value of the Left joystick
  115822. */
  115823. get buttonLeftStick(): number;
  115824. /**
  115825. * Sets the value of the Left joystick
  115826. */
  115827. set buttonLeftStick(value: number);
  115828. /**
  115829. * Gets the value of the Right joystick
  115830. */
  115831. get buttonRightStick(): number;
  115832. /**
  115833. * Sets the value of the Right joystick
  115834. */
  115835. set buttonRightStick(value: number);
  115836. /**
  115837. * Gets the value of D-pad up
  115838. */
  115839. get dPadUp(): number;
  115840. /**
  115841. * Sets the value of D-pad up
  115842. */
  115843. set dPadUp(value: number);
  115844. /**
  115845. * Gets the value of D-pad down
  115846. */
  115847. get dPadDown(): number;
  115848. /**
  115849. * Sets the value of D-pad down
  115850. */
  115851. set dPadDown(value: number);
  115852. /**
  115853. * Gets the value of D-pad left
  115854. */
  115855. get dPadLeft(): number;
  115856. /**
  115857. * Sets the value of D-pad left
  115858. */
  115859. set dPadLeft(value: number);
  115860. /**
  115861. * Gets the value of D-pad right
  115862. */
  115863. get dPadRight(): number;
  115864. /**
  115865. * Sets the value of D-pad right
  115866. */
  115867. set dPadRight(value: number);
  115868. /**
  115869. * Force the gamepad to synchronize with device values
  115870. */
  115871. update(): void;
  115872. /**
  115873. * Disposes the gamepad
  115874. */
  115875. dispose(): void;
  115876. }
  115877. }
  115878. declare module BABYLON {
  115879. /**
  115880. * Defines supported buttons for DualShock compatible gamepads
  115881. */
  115882. export enum DualShockButton {
  115883. /** Cross */
  115884. Cross = 0,
  115885. /** Circle */
  115886. Circle = 1,
  115887. /** Square */
  115888. Square = 2,
  115889. /** Triangle */
  115890. Triangle = 3,
  115891. /** L1 */
  115892. L1 = 4,
  115893. /** R1 */
  115894. R1 = 5,
  115895. /** Share */
  115896. Share = 8,
  115897. /** Options */
  115898. Options = 9,
  115899. /** Left stick */
  115900. LeftStick = 10,
  115901. /** Right stick */
  115902. RightStick = 11
  115903. }
  115904. /** Defines values for DualShock DPad */
  115905. export enum DualShockDpad {
  115906. /** Up */
  115907. Up = 12,
  115908. /** Down */
  115909. Down = 13,
  115910. /** Left */
  115911. Left = 14,
  115912. /** Right */
  115913. Right = 15
  115914. }
  115915. /**
  115916. * Defines a DualShock gamepad
  115917. */
  115918. export class DualShockPad extends Gamepad {
  115919. private _leftTrigger;
  115920. private _rightTrigger;
  115921. private _onlefttriggerchanged;
  115922. private _onrighttriggerchanged;
  115923. private _onbuttondown;
  115924. private _onbuttonup;
  115925. private _ondpaddown;
  115926. private _ondpadup;
  115927. /** Observable raised when a button is pressed */
  115928. onButtonDownObservable: Observable<DualShockButton>;
  115929. /** Observable raised when a button is released */
  115930. onButtonUpObservable: Observable<DualShockButton>;
  115931. /** Observable raised when a pad is pressed */
  115932. onPadDownObservable: Observable<DualShockDpad>;
  115933. /** Observable raised when a pad is released */
  115934. onPadUpObservable: Observable<DualShockDpad>;
  115935. private _buttonCross;
  115936. private _buttonCircle;
  115937. private _buttonSquare;
  115938. private _buttonTriangle;
  115939. private _buttonShare;
  115940. private _buttonOptions;
  115941. private _buttonL1;
  115942. private _buttonR1;
  115943. private _buttonLeftStick;
  115944. private _buttonRightStick;
  115945. private _dPadUp;
  115946. private _dPadDown;
  115947. private _dPadLeft;
  115948. private _dPadRight;
  115949. /**
  115950. * Creates a new DualShock gamepad object
  115951. * @param id defines the id of this gamepad
  115952. * @param index defines its index
  115953. * @param gamepad defines the internal HTML gamepad object
  115954. */
  115955. constructor(id: string, index: number, gamepad: any);
  115956. /**
  115957. * Defines the callback to call when left trigger is pressed
  115958. * @param callback defines the callback to use
  115959. */
  115960. onlefttriggerchanged(callback: (value: number) => void): void;
  115961. /**
  115962. * Defines the callback to call when right trigger is pressed
  115963. * @param callback defines the callback to use
  115964. */
  115965. onrighttriggerchanged(callback: (value: number) => void): void;
  115966. /**
  115967. * Gets the left trigger value
  115968. */
  115969. get leftTrigger(): number;
  115970. /**
  115971. * Sets the left trigger value
  115972. */
  115973. set leftTrigger(newValue: number);
  115974. /**
  115975. * Gets the right trigger value
  115976. */
  115977. get rightTrigger(): number;
  115978. /**
  115979. * Sets the right trigger value
  115980. */
  115981. set rightTrigger(newValue: number);
  115982. /**
  115983. * Defines the callback to call when a button is pressed
  115984. * @param callback defines the callback to use
  115985. */
  115986. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  115987. /**
  115988. * Defines the callback to call when a button is released
  115989. * @param callback defines the callback to use
  115990. */
  115991. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  115992. /**
  115993. * Defines the callback to call when a pad is pressed
  115994. * @param callback defines the callback to use
  115995. */
  115996. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  115997. /**
  115998. * Defines the callback to call when a pad is released
  115999. * @param callback defines the callback to use
  116000. */
  116001. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  116002. private _setButtonValue;
  116003. private _setDPadValue;
  116004. /**
  116005. * Gets the value of the `Cross` button
  116006. */
  116007. get buttonCross(): number;
  116008. /**
  116009. * Sets the value of the `Cross` button
  116010. */
  116011. set buttonCross(value: number);
  116012. /**
  116013. * Gets the value of the `Circle` button
  116014. */
  116015. get buttonCircle(): number;
  116016. /**
  116017. * Sets the value of the `Circle` button
  116018. */
  116019. set buttonCircle(value: number);
  116020. /**
  116021. * Gets the value of the `Square` button
  116022. */
  116023. get buttonSquare(): number;
  116024. /**
  116025. * Sets the value of the `Square` button
  116026. */
  116027. set buttonSquare(value: number);
  116028. /**
  116029. * Gets the value of the `Triangle` button
  116030. */
  116031. get buttonTriangle(): number;
  116032. /**
  116033. * Sets the value of the `Triangle` button
  116034. */
  116035. set buttonTriangle(value: number);
  116036. /**
  116037. * Gets the value of the `Options` button
  116038. */
  116039. get buttonOptions(): number;
  116040. /**
  116041. * Sets the value of the `Options` button
  116042. */
  116043. set buttonOptions(value: number);
  116044. /**
  116045. * Gets the value of the `Share` button
  116046. */
  116047. get buttonShare(): number;
  116048. /**
  116049. * Sets the value of the `Share` button
  116050. */
  116051. set buttonShare(value: number);
  116052. /**
  116053. * Gets the value of the `L1` button
  116054. */
  116055. get buttonL1(): number;
  116056. /**
  116057. * Sets the value of the `L1` button
  116058. */
  116059. set buttonL1(value: number);
  116060. /**
  116061. * Gets the value of the `R1` button
  116062. */
  116063. get buttonR1(): number;
  116064. /**
  116065. * Sets the value of the `R1` button
  116066. */
  116067. set buttonR1(value: number);
  116068. /**
  116069. * Gets the value of the Left joystick
  116070. */
  116071. get buttonLeftStick(): number;
  116072. /**
  116073. * Sets the value of the Left joystick
  116074. */
  116075. set buttonLeftStick(value: number);
  116076. /**
  116077. * Gets the value of the Right joystick
  116078. */
  116079. get buttonRightStick(): number;
  116080. /**
  116081. * Sets the value of the Right joystick
  116082. */
  116083. set buttonRightStick(value: number);
  116084. /**
  116085. * Gets the value of D-pad up
  116086. */
  116087. get dPadUp(): number;
  116088. /**
  116089. * Sets the value of D-pad up
  116090. */
  116091. set dPadUp(value: number);
  116092. /**
  116093. * Gets the value of D-pad down
  116094. */
  116095. get dPadDown(): number;
  116096. /**
  116097. * Sets the value of D-pad down
  116098. */
  116099. set dPadDown(value: number);
  116100. /**
  116101. * Gets the value of D-pad left
  116102. */
  116103. get dPadLeft(): number;
  116104. /**
  116105. * Sets the value of D-pad left
  116106. */
  116107. set dPadLeft(value: number);
  116108. /**
  116109. * Gets the value of D-pad right
  116110. */
  116111. get dPadRight(): number;
  116112. /**
  116113. * Sets the value of D-pad right
  116114. */
  116115. set dPadRight(value: number);
  116116. /**
  116117. * Force the gamepad to synchronize with device values
  116118. */
  116119. update(): void;
  116120. /**
  116121. * Disposes the gamepad
  116122. */
  116123. dispose(): void;
  116124. }
  116125. }
  116126. declare module BABYLON {
  116127. /**
  116128. * Manager for handling gamepads
  116129. */
  116130. export class GamepadManager {
  116131. private _scene?;
  116132. private _babylonGamepads;
  116133. private _oneGamepadConnected;
  116134. /** @hidden */
  116135. _isMonitoring: boolean;
  116136. private _gamepadEventSupported;
  116137. private _gamepadSupport?;
  116138. /**
  116139. * observable to be triggered when the gamepad controller has been connected
  116140. */
  116141. onGamepadConnectedObservable: Observable<Gamepad>;
  116142. /**
  116143. * observable to be triggered when the gamepad controller has been disconnected
  116144. */
  116145. onGamepadDisconnectedObservable: Observable<Gamepad>;
  116146. private _onGamepadConnectedEvent;
  116147. private _onGamepadDisconnectedEvent;
  116148. /**
  116149. * Initializes the gamepad manager
  116150. * @param _scene BabylonJS scene
  116151. */
  116152. constructor(_scene?: Scene | undefined);
  116153. /**
  116154. * The gamepads in the game pad manager
  116155. */
  116156. get gamepads(): Gamepad[];
  116157. /**
  116158. * Get the gamepad controllers based on type
  116159. * @param type The type of gamepad controller
  116160. * @returns Nullable gamepad
  116161. */
  116162. getGamepadByType(type?: number): Nullable<Gamepad>;
  116163. /**
  116164. * Disposes the gamepad manager
  116165. */
  116166. dispose(): void;
  116167. private _addNewGamepad;
  116168. private _startMonitoringGamepads;
  116169. private _stopMonitoringGamepads;
  116170. /** @hidden */
  116171. _checkGamepadsStatus(): void;
  116172. private _updateGamepadObjects;
  116173. }
  116174. }
  116175. declare module BABYLON {
  116176. interface Scene {
  116177. /** @hidden */
  116178. _gamepadManager: Nullable<GamepadManager>;
  116179. /**
  116180. * Gets the gamepad manager associated with the scene
  116181. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  116182. */
  116183. gamepadManager: GamepadManager;
  116184. }
  116185. /**
  116186. * Interface representing a free camera inputs manager
  116187. */
  116188. interface FreeCameraInputsManager {
  116189. /**
  116190. * Adds gamepad input support to the FreeCameraInputsManager.
  116191. * @returns the FreeCameraInputsManager
  116192. */
  116193. addGamepad(): FreeCameraInputsManager;
  116194. }
  116195. /**
  116196. * Interface representing an arc rotate camera inputs manager
  116197. */
  116198. interface ArcRotateCameraInputsManager {
  116199. /**
  116200. * Adds gamepad input support to the ArcRotateCamera InputManager.
  116201. * @returns the camera inputs manager
  116202. */
  116203. addGamepad(): ArcRotateCameraInputsManager;
  116204. }
  116205. /**
  116206. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  116207. */
  116208. export class GamepadSystemSceneComponent implements ISceneComponent {
  116209. /**
  116210. * The component name helpfull to identify the component in the list of scene components.
  116211. */
  116212. readonly name: string;
  116213. /**
  116214. * The scene the component belongs to.
  116215. */
  116216. scene: Scene;
  116217. /**
  116218. * Creates a new instance of the component for the given scene
  116219. * @param scene Defines the scene to register the component in
  116220. */
  116221. constructor(scene: Scene);
  116222. /**
  116223. * Registers the component in a given scene
  116224. */
  116225. register(): void;
  116226. /**
  116227. * Rebuilds the elements related to this component in case of
  116228. * context lost for instance.
  116229. */
  116230. rebuild(): void;
  116231. /**
  116232. * Disposes the component and the associated ressources
  116233. */
  116234. dispose(): void;
  116235. private _beforeCameraUpdate;
  116236. }
  116237. }
  116238. declare module BABYLON {
  116239. /**
  116240. * 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,
  116241. * which still works and will still be found in many Playgrounds.
  116242. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116243. */
  116244. export class UniversalCamera extends TouchCamera {
  116245. /**
  116246. * Defines the gamepad rotation sensiblity.
  116247. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  116248. */
  116249. get gamepadAngularSensibility(): number;
  116250. set gamepadAngularSensibility(value: number);
  116251. /**
  116252. * Defines the gamepad move sensiblity.
  116253. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  116254. */
  116255. get gamepadMoveSensibility(): number;
  116256. set gamepadMoveSensibility(value: number);
  116257. /**
  116258. * 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,
  116259. * which still works and will still be found in many Playgrounds.
  116260. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116261. * @param name Define the name of the camera in the scene
  116262. * @param position Define the start position of the camera in the scene
  116263. * @param scene Define the scene the camera belongs to
  116264. */
  116265. constructor(name: string, position: Vector3, scene: Scene);
  116266. /**
  116267. * Gets the current object class name.
  116268. * @return the class name
  116269. */
  116270. getClassName(): string;
  116271. }
  116272. }
  116273. declare module BABYLON {
  116274. /**
  116275. * This represents a FPS type of camera. This is only here for back compat purpose.
  116276. * Please use the UniversalCamera instead as both are identical.
  116277. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116278. */
  116279. export class GamepadCamera extends UniversalCamera {
  116280. /**
  116281. * Instantiates a new Gamepad Camera
  116282. * This represents a FPS type of camera. This is only here for back compat purpose.
  116283. * Please use the UniversalCamera instead as both are identical.
  116284. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  116285. * @param name Define the name of the camera in the scene
  116286. * @param position Define the start position of the camera in the scene
  116287. * @param scene Define the scene the camera belongs to
  116288. */
  116289. constructor(name: string, position: Vector3, scene: Scene);
  116290. /**
  116291. * Gets the current object class name.
  116292. * @return the class name
  116293. */
  116294. getClassName(): string;
  116295. }
  116296. }
  116297. declare module BABYLON {
  116298. /** @hidden */
  116299. export var passPixelShader: {
  116300. name: string;
  116301. shader: string;
  116302. };
  116303. }
  116304. declare module BABYLON {
  116305. /** @hidden */
  116306. export var passCubePixelShader: {
  116307. name: string;
  116308. shader: string;
  116309. };
  116310. }
  116311. declare module BABYLON {
  116312. /**
  116313. * PassPostProcess which produces an output the same as it's input
  116314. */
  116315. export class PassPostProcess extends PostProcess {
  116316. /**
  116317. * Creates the PassPostProcess
  116318. * @param name The name of the effect.
  116319. * @param options The required width/height ratio to downsize to before computing the render pass.
  116320. * @param camera The camera to apply the render pass to.
  116321. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116322. * @param engine The engine which the post process will be applied. (default: current engine)
  116323. * @param reusable If the post process can be reused on the same frame. (default: false)
  116324. * @param textureType The type of texture to be used when performing the post processing.
  116325. * @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)
  116326. */
  116327. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116328. }
  116329. /**
  116330. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  116331. */
  116332. export class PassCubePostProcess extends PostProcess {
  116333. private _face;
  116334. /**
  116335. * Gets or sets the cube face to display.
  116336. * * 0 is +X
  116337. * * 1 is -X
  116338. * * 2 is +Y
  116339. * * 3 is -Y
  116340. * * 4 is +Z
  116341. * * 5 is -Z
  116342. */
  116343. get face(): number;
  116344. set face(value: number);
  116345. /**
  116346. * Creates the PassCubePostProcess
  116347. * @param name The name of the effect.
  116348. * @param options The required width/height ratio to downsize to before computing the render pass.
  116349. * @param camera The camera to apply the render pass to.
  116350. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116351. * @param engine The engine which the post process will be applied. (default: current engine)
  116352. * @param reusable If the post process can be reused on the same frame. (default: false)
  116353. * @param textureType The type of texture to be used when performing the post processing.
  116354. * @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)
  116355. */
  116356. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  116357. }
  116358. }
  116359. declare module BABYLON {
  116360. /** @hidden */
  116361. export var anaglyphPixelShader: {
  116362. name: string;
  116363. shader: string;
  116364. };
  116365. }
  116366. declare module BABYLON {
  116367. /**
  116368. * Postprocess used to generate anaglyphic rendering
  116369. */
  116370. export class AnaglyphPostProcess extends PostProcess {
  116371. private _passedProcess;
  116372. /**
  116373. * Creates a new AnaglyphPostProcess
  116374. * @param name defines postprocess name
  116375. * @param options defines creation options or target ratio scale
  116376. * @param rigCameras defines cameras using this postprocess
  116377. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  116378. * @param engine defines hosting engine
  116379. * @param reusable defines if the postprocess will be reused multiple times per frame
  116380. */
  116381. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  116382. }
  116383. }
  116384. declare module BABYLON {
  116385. /**
  116386. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  116387. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116388. */
  116389. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  116390. /**
  116391. * Creates a new AnaglyphArcRotateCamera
  116392. * @param name defines camera name
  116393. * @param alpha defines alpha angle (in radians)
  116394. * @param beta defines beta angle (in radians)
  116395. * @param radius defines radius
  116396. * @param target defines camera target
  116397. * @param interaxialDistance defines distance between each color axis
  116398. * @param scene defines the hosting scene
  116399. */
  116400. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  116401. /**
  116402. * Gets camera class name
  116403. * @returns AnaglyphArcRotateCamera
  116404. */
  116405. getClassName(): string;
  116406. }
  116407. }
  116408. declare module BABYLON {
  116409. /**
  116410. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  116411. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116412. */
  116413. export class AnaglyphFreeCamera extends FreeCamera {
  116414. /**
  116415. * Creates a new AnaglyphFreeCamera
  116416. * @param name defines camera name
  116417. * @param position defines initial position
  116418. * @param interaxialDistance defines distance between each color axis
  116419. * @param scene defines the hosting scene
  116420. */
  116421. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116422. /**
  116423. * Gets camera class name
  116424. * @returns AnaglyphFreeCamera
  116425. */
  116426. getClassName(): string;
  116427. }
  116428. }
  116429. declare module BABYLON {
  116430. /**
  116431. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  116432. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116433. */
  116434. export class AnaglyphGamepadCamera extends GamepadCamera {
  116435. /**
  116436. * Creates a new AnaglyphGamepadCamera
  116437. * @param name defines camera name
  116438. * @param position defines initial position
  116439. * @param interaxialDistance defines distance between each color axis
  116440. * @param scene defines the hosting scene
  116441. */
  116442. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116443. /**
  116444. * Gets camera class name
  116445. * @returns AnaglyphGamepadCamera
  116446. */
  116447. getClassName(): string;
  116448. }
  116449. }
  116450. declare module BABYLON {
  116451. /**
  116452. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  116453. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  116454. */
  116455. export class AnaglyphUniversalCamera extends UniversalCamera {
  116456. /**
  116457. * Creates a new AnaglyphUniversalCamera
  116458. * @param name defines camera name
  116459. * @param position defines initial position
  116460. * @param interaxialDistance defines distance between each color axis
  116461. * @param scene defines the hosting scene
  116462. */
  116463. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  116464. /**
  116465. * Gets camera class name
  116466. * @returns AnaglyphUniversalCamera
  116467. */
  116468. getClassName(): string;
  116469. }
  116470. }
  116471. declare module BABYLON {
  116472. /** @hidden */
  116473. export var stereoscopicInterlacePixelShader: {
  116474. name: string;
  116475. shader: string;
  116476. };
  116477. }
  116478. declare module BABYLON {
  116479. /**
  116480. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  116481. */
  116482. export class StereoscopicInterlacePostProcessI extends PostProcess {
  116483. private _stepSize;
  116484. private _passedProcess;
  116485. /**
  116486. * Initializes a StereoscopicInterlacePostProcessI
  116487. * @param name The name of the effect.
  116488. * @param rigCameras The rig cameras to be appled to the post process
  116489. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  116490. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  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, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116496. }
  116497. /**
  116498. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  116499. */
  116500. export class StereoscopicInterlacePostProcess extends PostProcess {
  116501. private _stepSize;
  116502. private _passedProcess;
  116503. /**
  116504. * Initializes a StereoscopicInterlacePostProcess
  116505. * @param name The name of the effect.
  116506. * @param rigCameras The rig cameras to be appled to the post process
  116507. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  116508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  116509. * @param engine The engine which the post process will be applied. (default: current engine)
  116510. * @param reusable If the post process can be reused on the same frame. (default: false)
  116511. */
  116512. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  116513. }
  116514. }
  116515. declare module BABYLON {
  116516. /**
  116517. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  116518. * @see http://doc.babylonjs.com/features/cameras
  116519. */
  116520. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  116521. /**
  116522. * Creates a new StereoscopicArcRotateCamera
  116523. * @param name defines camera name
  116524. * @param alpha defines alpha angle (in radians)
  116525. * @param beta defines beta angle (in radians)
  116526. * @param radius defines radius
  116527. * @param target defines camera target
  116528. * @param interaxialDistance defines distance between each color axis
  116529. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116530. * @param scene defines the hosting scene
  116531. */
  116532. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116533. /**
  116534. * Gets camera class name
  116535. * @returns StereoscopicArcRotateCamera
  116536. */
  116537. getClassName(): string;
  116538. }
  116539. }
  116540. declare module BABYLON {
  116541. /**
  116542. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  116543. * @see http://doc.babylonjs.com/features/cameras
  116544. */
  116545. export class StereoscopicFreeCamera extends FreeCamera {
  116546. /**
  116547. * Creates a new StereoscopicFreeCamera
  116548. * @param name defines camera name
  116549. * @param position defines initial position
  116550. * @param interaxialDistance defines distance between each color axis
  116551. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116552. * @param scene defines the hosting scene
  116553. */
  116554. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116555. /**
  116556. * Gets camera class name
  116557. * @returns StereoscopicFreeCamera
  116558. */
  116559. getClassName(): string;
  116560. }
  116561. }
  116562. declare module BABYLON {
  116563. /**
  116564. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  116565. * @see http://doc.babylonjs.com/features/cameras
  116566. */
  116567. export class StereoscopicGamepadCamera extends GamepadCamera {
  116568. /**
  116569. * Creates a new StereoscopicGamepadCamera
  116570. * @param name defines camera name
  116571. * @param position defines initial position
  116572. * @param interaxialDistance defines distance between each color axis
  116573. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116574. * @param scene defines the hosting scene
  116575. */
  116576. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116577. /**
  116578. * Gets camera class name
  116579. * @returns StereoscopicGamepadCamera
  116580. */
  116581. getClassName(): string;
  116582. }
  116583. }
  116584. declare module BABYLON {
  116585. /**
  116586. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  116587. * @see http://doc.babylonjs.com/features/cameras
  116588. */
  116589. export class StereoscopicUniversalCamera extends UniversalCamera {
  116590. /**
  116591. * Creates a new StereoscopicUniversalCamera
  116592. * @param name defines camera name
  116593. * @param position defines initial position
  116594. * @param interaxialDistance defines distance between each color axis
  116595. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  116596. * @param scene defines the hosting scene
  116597. */
  116598. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  116599. /**
  116600. * Gets camera class name
  116601. * @returns StereoscopicUniversalCamera
  116602. */
  116603. getClassName(): string;
  116604. }
  116605. }
  116606. declare module BABYLON {
  116607. /**
  116608. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  116609. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116610. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116611. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116612. */
  116613. export class VirtualJoysticksCamera extends FreeCamera {
  116614. /**
  116615. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  116616. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  116617. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  116618. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  116619. * @param name Define the name of the camera in the scene
  116620. * @param position Define the start position of the camera in the scene
  116621. * @param scene Define the scene the camera belongs to
  116622. */
  116623. constructor(name: string, position: Vector3, scene: Scene);
  116624. /**
  116625. * Gets the current object class name.
  116626. * @return the class name
  116627. */
  116628. getClassName(): string;
  116629. }
  116630. }
  116631. declare module BABYLON {
  116632. /**
  116633. * This represents all the required metrics to create a VR camera.
  116634. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  116635. */
  116636. export class VRCameraMetrics {
  116637. /**
  116638. * Define the horizontal resolution off the screen.
  116639. */
  116640. hResolution: number;
  116641. /**
  116642. * Define the vertical resolution off the screen.
  116643. */
  116644. vResolution: number;
  116645. /**
  116646. * Define the horizontal screen size.
  116647. */
  116648. hScreenSize: number;
  116649. /**
  116650. * Define the vertical screen size.
  116651. */
  116652. vScreenSize: number;
  116653. /**
  116654. * Define the vertical screen center position.
  116655. */
  116656. vScreenCenter: number;
  116657. /**
  116658. * Define the distance of the eyes to the screen.
  116659. */
  116660. eyeToScreenDistance: number;
  116661. /**
  116662. * Define the distance between both lenses
  116663. */
  116664. lensSeparationDistance: number;
  116665. /**
  116666. * Define the distance between both viewer's eyes.
  116667. */
  116668. interpupillaryDistance: number;
  116669. /**
  116670. * Define the distortion factor of the VR postprocess.
  116671. * Please, touch with care.
  116672. */
  116673. distortionK: number[];
  116674. /**
  116675. * Define the chromatic aberration correction factors for the VR post process.
  116676. */
  116677. chromaAbCorrection: number[];
  116678. /**
  116679. * Define the scale factor of the post process.
  116680. * The smaller the better but the slower.
  116681. */
  116682. postProcessScaleFactor: number;
  116683. /**
  116684. * Define an offset for the lens center.
  116685. */
  116686. lensCenterOffset: number;
  116687. /**
  116688. * Define if the current vr camera should compensate the distortion of the lense or not.
  116689. */
  116690. compensateDistortion: boolean;
  116691. /**
  116692. * Defines if multiview should be enabled when rendering (Default: false)
  116693. */
  116694. multiviewEnabled: boolean;
  116695. /**
  116696. * Gets the rendering aspect ratio based on the provided resolutions.
  116697. */
  116698. get aspectRatio(): number;
  116699. /**
  116700. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  116701. */
  116702. get aspectRatioFov(): number;
  116703. /**
  116704. * @hidden
  116705. */
  116706. get leftHMatrix(): Matrix;
  116707. /**
  116708. * @hidden
  116709. */
  116710. get rightHMatrix(): Matrix;
  116711. /**
  116712. * @hidden
  116713. */
  116714. get leftPreViewMatrix(): Matrix;
  116715. /**
  116716. * @hidden
  116717. */
  116718. get rightPreViewMatrix(): Matrix;
  116719. /**
  116720. * Get the default VRMetrics based on the most generic setup.
  116721. * @returns the default vr metrics
  116722. */
  116723. static GetDefault(): VRCameraMetrics;
  116724. }
  116725. }
  116726. declare module BABYLON {
  116727. /** @hidden */
  116728. export var vrDistortionCorrectionPixelShader: {
  116729. name: string;
  116730. shader: string;
  116731. };
  116732. }
  116733. declare module BABYLON {
  116734. /**
  116735. * VRDistortionCorrectionPostProcess used for mobile VR
  116736. */
  116737. export class VRDistortionCorrectionPostProcess extends PostProcess {
  116738. private _isRightEye;
  116739. private _distortionFactors;
  116740. private _postProcessScaleFactor;
  116741. private _lensCenterOffset;
  116742. private _scaleIn;
  116743. private _scaleFactor;
  116744. private _lensCenter;
  116745. /**
  116746. * Initializes the VRDistortionCorrectionPostProcess
  116747. * @param name The name of the effect.
  116748. * @param camera The camera to apply the render pass to.
  116749. * @param isRightEye If this is for the right eye distortion
  116750. * @param vrMetrics All the required metrics for the VR camera
  116751. */
  116752. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  116753. }
  116754. }
  116755. declare module BABYLON {
  116756. /**
  116757. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  116758. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116759. */
  116760. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  116761. /**
  116762. * Creates a new VRDeviceOrientationArcRotateCamera
  116763. * @param name defines camera name
  116764. * @param alpha defines the camera rotation along the logitudinal axis
  116765. * @param beta defines the camera rotation along the latitudinal axis
  116766. * @param radius defines the camera distance from its target
  116767. * @param target defines the camera target
  116768. * @param scene defines the scene the camera belongs to
  116769. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116770. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116771. */
  116772. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116773. /**
  116774. * Gets camera class name
  116775. * @returns VRDeviceOrientationArcRotateCamera
  116776. */
  116777. getClassName(): string;
  116778. }
  116779. }
  116780. declare module BABYLON {
  116781. /**
  116782. * Camera used to simulate VR rendering (based on FreeCamera)
  116783. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116784. */
  116785. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  116786. /**
  116787. * Creates a new VRDeviceOrientationFreeCamera
  116788. * @param name defines camera name
  116789. * @param position defines the start position of the camera
  116790. * @param scene defines the scene the camera belongs to
  116791. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116792. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116793. */
  116794. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116795. /**
  116796. * Gets camera class name
  116797. * @returns VRDeviceOrientationFreeCamera
  116798. */
  116799. getClassName(): string;
  116800. }
  116801. }
  116802. declare module BABYLON {
  116803. /**
  116804. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  116805. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  116806. */
  116807. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  116808. /**
  116809. * Creates a new VRDeviceOrientationGamepadCamera
  116810. * @param name defines camera name
  116811. * @param position defines the start position of the camera
  116812. * @param scene defines the scene the camera belongs to
  116813. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  116814. * @param vrCameraMetrics defines the vr metrics associated to the camera
  116815. */
  116816. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  116817. /**
  116818. * Gets camera class name
  116819. * @returns VRDeviceOrientationGamepadCamera
  116820. */
  116821. getClassName(): string;
  116822. }
  116823. }
  116824. declare module BABYLON {
  116825. /** @hidden */
  116826. export var imageProcessingPixelShader: {
  116827. name: string;
  116828. shader: string;
  116829. };
  116830. }
  116831. declare module BABYLON {
  116832. /**
  116833. * ImageProcessingPostProcess
  116834. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  116835. */
  116836. export class ImageProcessingPostProcess extends PostProcess {
  116837. /**
  116838. * Default configuration related to image processing available in the PBR Material.
  116839. */
  116840. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  116841. /**
  116842. * Gets the image processing configuration used either in this material.
  116843. */
  116844. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  116845. /**
  116846. * Sets the Default image processing configuration used either in the this material.
  116847. *
  116848. * If sets to null, the scene one is in use.
  116849. */
  116850. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  116851. /**
  116852. * Keep track of the image processing observer to allow dispose and replace.
  116853. */
  116854. private _imageProcessingObserver;
  116855. /**
  116856. * Attaches a new image processing configuration to the PBR Material.
  116857. * @param configuration
  116858. */
  116859. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  116860. /**
  116861. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116862. */
  116863. get colorCurves(): Nullable<ColorCurves>;
  116864. /**
  116865. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  116866. */
  116867. set colorCurves(value: Nullable<ColorCurves>);
  116868. /**
  116869. * Gets wether the color curves effect is enabled.
  116870. */
  116871. get colorCurvesEnabled(): boolean;
  116872. /**
  116873. * Sets wether the color curves effect is enabled.
  116874. */
  116875. set colorCurvesEnabled(value: boolean);
  116876. /**
  116877. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116878. */
  116879. get colorGradingTexture(): Nullable<BaseTexture>;
  116880. /**
  116881. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  116882. */
  116883. set colorGradingTexture(value: Nullable<BaseTexture>);
  116884. /**
  116885. * Gets wether the color grading effect is enabled.
  116886. */
  116887. get colorGradingEnabled(): boolean;
  116888. /**
  116889. * Gets wether the color grading effect is enabled.
  116890. */
  116891. set colorGradingEnabled(value: boolean);
  116892. /**
  116893. * Gets exposure used in the effect.
  116894. */
  116895. get exposure(): number;
  116896. /**
  116897. * Sets exposure used in the effect.
  116898. */
  116899. set exposure(value: number);
  116900. /**
  116901. * Gets wether tonemapping is enabled or not.
  116902. */
  116903. get toneMappingEnabled(): boolean;
  116904. /**
  116905. * Sets wether tonemapping is enabled or not
  116906. */
  116907. set toneMappingEnabled(value: boolean);
  116908. /**
  116909. * Gets the type of tone mapping effect.
  116910. */
  116911. get toneMappingType(): number;
  116912. /**
  116913. * Sets the type of tone mapping effect.
  116914. */
  116915. set toneMappingType(value: number);
  116916. /**
  116917. * Gets contrast used in the effect.
  116918. */
  116919. get contrast(): number;
  116920. /**
  116921. * Sets contrast used in the effect.
  116922. */
  116923. set contrast(value: number);
  116924. /**
  116925. * Gets Vignette stretch size.
  116926. */
  116927. get vignetteStretch(): number;
  116928. /**
  116929. * Sets Vignette stretch size.
  116930. */
  116931. set vignetteStretch(value: number);
  116932. /**
  116933. * Gets Vignette centre X Offset.
  116934. */
  116935. get vignetteCentreX(): number;
  116936. /**
  116937. * Sets Vignette centre X Offset.
  116938. */
  116939. set vignetteCentreX(value: number);
  116940. /**
  116941. * Gets Vignette centre Y Offset.
  116942. */
  116943. get vignetteCentreY(): number;
  116944. /**
  116945. * Sets Vignette centre Y Offset.
  116946. */
  116947. set vignetteCentreY(value: number);
  116948. /**
  116949. * Gets Vignette weight or intensity of the vignette effect.
  116950. */
  116951. get vignetteWeight(): number;
  116952. /**
  116953. * Sets Vignette weight or intensity of the vignette effect.
  116954. */
  116955. set vignetteWeight(value: number);
  116956. /**
  116957. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116958. * if vignetteEnabled is set to true.
  116959. */
  116960. get vignetteColor(): Color4;
  116961. /**
  116962. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  116963. * if vignetteEnabled is set to true.
  116964. */
  116965. set vignetteColor(value: Color4);
  116966. /**
  116967. * Gets Camera field of view used by the Vignette effect.
  116968. */
  116969. get vignetteCameraFov(): number;
  116970. /**
  116971. * Sets Camera field of view used by the Vignette effect.
  116972. */
  116973. set vignetteCameraFov(value: number);
  116974. /**
  116975. * Gets the vignette blend mode allowing different kind of effect.
  116976. */
  116977. get vignetteBlendMode(): number;
  116978. /**
  116979. * Sets the vignette blend mode allowing different kind of effect.
  116980. */
  116981. set vignetteBlendMode(value: number);
  116982. /**
  116983. * Gets wether the vignette effect is enabled.
  116984. */
  116985. get vignetteEnabled(): boolean;
  116986. /**
  116987. * Sets wether the vignette effect is enabled.
  116988. */
  116989. set vignetteEnabled(value: boolean);
  116990. private _fromLinearSpace;
  116991. /**
  116992. * Gets wether the input of the processing is in Gamma or Linear Space.
  116993. */
  116994. get fromLinearSpace(): boolean;
  116995. /**
  116996. * Sets wether the input of the processing is in Gamma or Linear Space.
  116997. */
  116998. set fromLinearSpace(value: boolean);
  116999. /**
  117000. * Defines cache preventing GC.
  117001. */
  117002. private _defines;
  117003. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  117004. /**
  117005. * "ImageProcessingPostProcess"
  117006. * @returns "ImageProcessingPostProcess"
  117007. */
  117008. getClassName(): string;
  117009. protected _updateParameters(): void;
  117010. dispose(camera?: Camera): void;
  117011. }
  117012. }
  117013. declare module BABYLON {
  117014. /**
  117015. * Class containing static functions to help procedurally build meshes
  117016. */
  117017. export class GroundBuilder {
  117018. /**
  117019. * Creates a ground mesh
  117020. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  117021. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  117022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  117023. * @param name defines the name of the mesh
  117024. * @param options defines the options used to create the mesh
  117025. * @param scene defines the hosting scene
  117026. * @returns the ground mesh
  117027. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  117028. */
  117029. static CreateGround(name: string, options: {
  117030. width?: number;
  117031. height?: number;
  117032. subdivisions?: number;
  117033. subdivisionsX?: number;
  117034. subdivisionsY?: number;
  117035. updatable?: boolean;
  117036. }, scene: any): Mesh;
  117037. /**
  117038. * Creates a tiled ground mesh
  117039. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  117040. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  117041. * * 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
  117042. * * 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
  117043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117044. * @param name defines the name of the mesh
  117045. * @param options defines the options used to create the mesh
  117046. * @param scene defines the hosting scene
  117047. * @returns the tiled ground mesh
  117048. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  117049. */
  117050. static CreateTiledGround(name: string, options: {
  117051. xmin: number;
  117052. zmin: number;
  117053. xmax: number;
  117054. zmax: number;
  117055. subdivisions?: {
  117056. w: number;
  117057. h: number;
  117058. };
  117059. precision?: {
  117060. w: number;
  117061. h: number;
  117062. };
  117063. updatable?: boolean;
  117064. }, scene?: Nullable<Scene>): Mesh;
  117065. /**
  117066. * Creates a ground mesh from a height map
  117067. * * The parameter `url` sets the URL of the height map image resource.
  117068. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  117069. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  117070. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  117071. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  117072. * * 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.
  117073. * * 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).
  117074. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  117075. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117076. * @param name defines the name of the mesh
  117077. * @param url defines the url to the height map
  117078. * @param options defines the options used to create the mesh
  117079. * @param scene defines the hosting scene
  117080. * @returns the ground mesh
  117081. * @see https://doc.babylonjs.com/babylon101/height_map
  117082. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  117083. */
  117084. static CreateGroundFromHeightMap(name: string, url: string, options: {
  117085. width?: number;
  117086. height?: number;
  117087. subdivisions?: number;
  117088. minHeight?: number;
  117089. maxHeight?: number;
  117090. colorFilter?: Color3;
  117091. alphaFilter?: number;
  117092. updatable?: boolean;
  117093. onReady?: (mesh: GroundMesh) => void;
  117094. }, scene?: Nullable<Scene>): GroundMesh;
  117095. }
  117096. }
  117097. declare module BABYLON {
  117098. /**
  117099. * Class containing static functions to help procedurally build meshes
  117100. */
  117101. export class TorusBuilder {
  117102. /**
  117103. * Creates a torus mesh
  117104. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  117105. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  117106. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  117107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117108. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117110. * @param name defines the name of the mesh
  117111. * @param options defines the options used to create the mesh
  117112. * @param scene defines the hosting scene
  117113. * @returns the torus mesh
  117114. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  117115. */
  117116. static CreateTorus(name: string, options: {
  117117. diameter?: number;
  117118. thickness?: number;
  117119. tessellation?: number;
  117120. updatable?: boolean;
  117121. sideOrientation?: number;
  117122. frontUVs?: Vector4;
  117123. backUVs?: Vector4;
  117124. }, scene: any): Mesh;
  117125. }
  117126. }
  117127. declare module BABYLON {
  117128. /**
  117129. * Class containing static functions to help procedurally build meshes
  117130. */
  117131. export class CylinderBuilder {
  117132. /**
  117133. * Creates a cylinder or a cone mesh
  117134. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  117135. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  117136. * * 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.
  117137. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  117138. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  117139. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  117140. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  117141. * * 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).
  117142. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  117143. * * 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).
  117144. * * 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
  117145. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  117146. * * 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
  117147. * * 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.
  117148. * * If `enclose` is false, a ring surface is one element.
  117149. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  117150. * * 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
  117151. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  117152. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  117153. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  117154. * @param name defines the name of the mesh
  117155. * @param options defines the options used to create the mesh
  117156. * @param scene defines the hosting scene
  117157. * @returns the cylinder mesh
  117158. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  117159. */
  117160. static CreateCylinder(name: string, options: {
  117161. height?: number;
  117162. diameterTop?: number;
  117163. diameterBottom?: number;
  117164. diameter?: number;
  117165. tessellation?: number;
  117166. subdivisions?: number;
  117167. arc?: number;
  117168. faceColors?: Color4[];
  117169. faceUV?: Vector4[];
  117170. updatable?: boolean;
  117171. hasRings?: boolean;
  117172. enclose?: boolean;
  117173. cap?: number;
  117174. sideOrientation?: number;
  117175. frontUVs?: Vector4;
  117176. backUVs?: Vector4;
  117177. }, scene: any): Mesh;
  117178. }
  117179. }
  117180. declare module BABYLON {
  117181. /**
  117182. * States of the webXR experience
  117183. */
  117184. export enum WebXRState {
  117185. /**
  117186. * Transitioning to being in XR mode
  117187. */
  117188. ENTERING_XR = 0,
  117189. /**
  117190. * Transitioning to non XR mode
  117191. */
  117192. EXITING_XR = 1,
  117193. /**
  117194. * In XR mode and presenting
  117195. */
  117196. IN_XR = 2,
  117197. /**
  117198. * Not entered XR mode
  117199. */
  117200. NOT_IN_XR = 3
  117201. }
  117202. /**
  117203. * Abstraction of the XR render target
  117204. */
  117205. export interface WebXRRenderTarget extends IDisposable {
  117206. /**
  117207. * xrpresent context of the canvas which can be used to display/mirror xr content
  117208. */
  117209. canvasContext: WebGLRenderingContext;
  117210. /**
  117211. * xr layer for the canvas
  117212. */
  117213. xrLayer: Nullable<XRWebGLLayer>;
  117214. /**
  117215. * Initializes the xr layer for the session
  117216. * @param xrSession xr session
  117217. * @returns a promise that will resolve once the XR Layer has been created
  117218. */
  117219. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117220. }
  117221. }
  117222. declare module BABYLON {
  117223. /**
  117224. * COnfiguration object for WebXR output canvas
  117225. */
  117226. export class WebXRManagedOutputCanvasOptions {
  117227. /**
  117228. * An optional canvas in case you wish to create it yourself and provide it here.
  117229. * If not provided, a new canvas will be created
  117230. */
  117231. canvasElement?: HTMLCanvasElement;
  117232. /**
  117233. * Options for this XR Layer output
  117234. */
  117235. canvasOptions?: XRWebGLLayerOptions;
  117236. /**
  117237. * CSS styling for a newly created canvas (if not provided)
  117238. */
  117239. newCanvasCssStyle?: string;
  117240. /**
  117241. * Get the default values of the configuration object
  117242. * @returns default values of this configuration object
  117243. */
  117244. static GetDefaults(): WebXRManagedOutputCanvasOptions;
  117245. }
  117246. /**
  117247. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  117248. */
  117249. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  117250. private _options;
  117251. private _canvas;
  117252. private _engine;
  117253. /**
  117254. * Rendering context of the canvas which can be used to display/mirror xr content
  117255. */
  117256. canvasContext: WebGLRenderingContext;
  117257. /**
  117258. * xr layer for the canvas
  117259. */
  117260. xrLayer: Nullable<XRWebGLLayer>;
  117261. /**
  117262. * Initializes the canvas to be added/removed upon entering/exiting xr
  117263. * @param _xrSessionManager The XR Session manager
  117264. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  117265. */
  117266. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  117267. /**
  117268. * Disposes of the object
  117269. */
  117270. dispose(): void;
  117271. /**
  117272. * Initializes the xr layer for the session
  117273. * @param xrSession xr session
  117274. * @returns a promise that will resolve once the XR Layer has been created
  117275. */
  117276. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  117277. private _addCanvas;
  117278. private _removeCanvas;
  117279. private _setManagedOutputCanvas;
  117280. }
  117281. }
  117282. declare module BABYLON {
  117283. /**
  117284. * Manages an XRSession to work with Babylon's engine
  117285. * @see https://doc.babylonjs.com/how_to/webxr
  117286. */
  117287. export class WebXRSessionManager implements IDisposable {
  117288. /** The scene which the session should be created for */
  117289. scene: Scene;
  117290. private _referenceSpace;
  117291. private _rttProvider;
  117292. private _sessionEnded;
  117293. private _xrNavigator;
  117294. private baseLayer;
  117295. /**
  117296. * The base reference space from which the session started. good if you want to reset your
  117297. * reference space
  117298. */
  117299. baseReferenceSpace: XRReferenceSpace;
  117300. /**
  117301. * Current XR frame
  117302. */
  117303. currentFrame: Nullable<XRFrame>;
  117304. /** WebXR timestamp updated every frame */
  117305. currentTimestamp: number;
  117306. /**
  117307. * Used just in case of a failure to initialize an immersive session.
  117308. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  117309. */
  117310. defaultHeightCompensation: number;
  117311. /**
  117312. * Fires every time a new xrFrame arrives which can be used to update the camera
  117313. */
  117314. onXRFrameObservable: Observable<XRFrame>;
  117315. /**
  117316. * Fires when the reference space changed
  117317. */
  117318. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  117319. /**
  117320. * Fires when the xr session is ended either by the device or manually done
  117321. */
  117322. onXRSessionEnded: Observable<any>;
  117323. /**
  117324. * Fires when the xr session is ended either by the device or manually done
  117325. */
  117326. onXRSessionInit: Observable<XRSession>;
  117327. /**
  117328. * Underlying xr session
  117329. */
  117330. session: XRSession;
  117331. /**
  117332. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  117333. * or get the offset the player is currently at.
  117334. */
  117335. viewerReferenceSpace: XRReferenceSpace;
  117336. /**
  117337. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  117338. * @param scene The scene which the session should be created for
  117339. */
  117340. constructor(
  117341. /** The scene which the session should be created for */
  117342. scene: Scene);
  117343. /**
  117344. * The current reference space used in this session. This reference space can constantly change!
  117345. * It is mainly used to offset the camera's position.
  117346. */
  117347. get referenceSpace(): XRReferenceSpace;
  117348. /**
  117349. * Set a new reference space and triggers the observable
  117350. */
  117351. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  117352. /**
  117353. * Disposes of the session manager
  117354. */
  117355. dispose(): void;
  117356. /**
  117357. * Stops the xrSession and restores the render loop
  117358. * @returns Promise which resolves after it exits XR
  117359. */
  117360. exitXRAsync(): Promise<void>;
  117361. /**
  117362. * Gets the correct render target texture to be rendered this frame for this eye
  117363. * @param eye the eye for which to get the render target
  117364. * @returns the render target for the specified eye
  117365. */
  117366. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  117367. /**
  117368. * Creates a WebXRRenderTarget object for the XR session
  117369. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  117370. * @param options optional options to provide when creating a new render target
  117371. * @returns a WebXR render target to which the session can render
  117372. */
  117373. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  117374. /**
  117375. * Initializes the manager
  117376. * After initialization enterXR can be called to start an XR session
  117377. * @returns Promise which resolves after it is initialized
  117378. */
  117379. initializeAsync(): Promise<void>;
  117380. /**
  117381. * Initializes an xr session
  117382. * @param xrSessionMode mode to initialize
  117383. * @param xrSessionInit defines optional and required values to pass to the session builder
  117384. * @returns a promise which will resolve once the session has been initialized
  117385. */
  117386. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  117387. /**
  117388. * Checks if a session would be supported for the creation options specified
  117389. * @param sessionMode session mode to check if supported eg. immersive-vr
  117390. * @returns A Promise that resolves to true if supported and false if not
  117391. */
  117392. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117393. /**
  117394. * Resets the reference space to the one started the session
  117395. */
  117396. resetReferenceSpace(): void;
  117397. /**
  117398. * Starts rendering to the xr layer
  117399. */
  117400. runXRRenderLoop(): void;
  117401. /**
  117402. * Sets the reference space on the xr session
  117403. * @param referenceSpaceType space to set
  117404. * @returns a promise that will resolve once the reference space has been set
  117405. */
  117406. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  117407. /**
  117408. * Updates the render state of the session
  117409. * @param state state to set
  117410. * @returns a promise that resolves once the render state has been updated
  117411. */
  117412. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  117413. /**
  117414. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  117415. * @param sessionMode defines the session to test
  117416. * @returns a promise with boolean as final value
  117417. */
  117418. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  117419. private _createRenderTargetTexture;
  117420. }
  117421. }
  117422. declare module BABYLON {
  117423. /**
  117424. * WebXR Camera which holds the views for the xrSession
  117425. * @see https://doc.babylonjs.com/how_to/webxr_camera
  117426. */
  117427. export class WebXRCamera extends FreeCamera {
  117428. private _xrSessionManager;
  117429. private _firstFrame;
  117430. private _referenceQuaternion;
  117431. private _referencedPosition;
  117432. private _xrInvPositionCache;
  117433. private _xrInvQuaternionCache;
  117434. /**
  117435. * Should position compensation execute on first frame.
  117436. * This is used when copying the position from a native (non XR) camera
  117437. */
  117438. compensateOnFirstFrame: boolean;
  117439. /**
  117440. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  117441. * @param name the name of the camera
  117442. * @param scene the scene to add the camera to
  117443. * @param _xrSessionManager a constructed xr session manager
  117444. */
  117445. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  117446. /**
  117447. * Return the user's height, unrelated to the current ground.
  117448. * This will be the y position of this camera, when ground level is 0.
  117449. */
  117450. get realWorldHeight(): number;
  117451. /** @hidden */
  117452. _updateForDualEyeDebugging(): void;
  117453. /**
  117454. * Sets this camera's transformation based on a non-vr camera
  117455. * @param otherCamera the non-vr camera to copy the transformation from
  117456. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  117457. */
  117458. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  117459. /**
  117460. * Gets the current instance class name ("WebXRCamera").
  117461. * @returns the class name
  117462. */
  117463. getClassName(): string;
  117464. private _updateFromXRSession;
  117465. private _updateNumberOfRigCameras;
  117466. private _updateReferenceSpace;
  117467. private _updateReferenceSpaceOffset;
  117468. }
  117469. }
  117470. declare module BABYLON {
  117471. /**
  117472. * Defining the interface required for a (webxr) feature
  117473. */
  117474. export interface IWebXRFeature extends IDisposable {
  117475. /**
  117476. * Is this feature attached
  117477. */
  117478. attached: boolean;
  117479. /**
  117480. * Should auto-attach be disabled?
  117481. */
  117482. disableAutoAttach: boolean;
  117483. /**
  117484. * Attach the feature to the session
  117485. * Will usually be called by the features manager
  117486. *
  117487. * @param force should attachment be forced (even when already attached)
  117488. * @returns true if successful.
  117489. */
  117490. attach(force?: boolean): boolean;
  117491. /**
  117492. * Detach the feature from the session
  117493. * Will usually be called by the features manager
  117494. *
  117495. * @returns true if successful.
  117496. */
  117497. detach(): boolean;
  117498. }
  117499. /**
  117500. * A list of the currently available features without referencing them
  117501. */
  117502. export class WebXRFeatureName {
  117503. /**
  117504. * The name of the anchor system feature
  117505. */
  117506. static ANCHOR_SYSTEM: string;
  117507. /**
  117508. * The name of the background remover feature
  117509. */
  117510. static BACKGROUND_REMOVER: string;
  117511. /**
  117512. * The name of the hit test feature
  117513. */
  117514. static HIT_TEST: string;
  117515. /**
  117516. * physics impostors for xr controllers feature
  117517. */
  117518. static PHYSICS_CONTROLLERS: string;
  117519. /**
  117520. * The name of the plane detection feature
  117521. */
  117522. static PLANE_DETECTION: string;
  117523. /**
  117524. * The name of the pointer selection feature
  117525. */
  117526. static POINTER_SELECTION: string;
  117527. /**
  117528. * The name of the teleportation feature
  117529. */
  117530. static TELEPORTATION: string;
  117531. }
  117532. /**
  117533. * Defining the constructor of a feature. Used to register the modules.
  117534. */
  117535. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => (() => IWebXRFeature);
  117536. /**
  117537. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  117538. * It is mainly used in AR sessions.
  117539. *
  117540. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  117541. */
  117542. export class WebXRFeaturesManager implements IDisposable {
  117543. private _xrSessionManager;
  117544. private static readonly _AvailableFeatures;
  117545. private _features;
  117546. /**
  117547. * constructs a new features manages.
  117548. *
  117549. * @param _xrSessionManager an instance of WebXRSessionManager
  117550. */
  117551. constructor(_xrSessionManager: WebXRSessionManager);
  117552. /**
  117553. * Used to register a module. After calling this function a developer can use this feature in the scene.
  117554. * Mainly used internally.
  117555. *
  117556. * @param featureName the name of the feature to register
  117557. * @param constructorFunction the function used to construct the module
  117558. * @param version the (babylon) version of the module
  117559. * @param stable is that a stable version of this module
  117560. */
  117561. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  117562. /**
  117563. * Returns a constructor of a specific feature.
  117564. *
  117565. * @param featureName the name of the feature to construct
  117566. * @param version the version of the feature to load
  117567. * @param xrSessionManager the xrSessionManager. Used to construct the module
  117568. * @param options optional options provided to the module.
  117569. * @returns a function that, when called, will return a new instance of this feature
  117570. */
  117571. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): (() => IWebXRFeature);
  117572. /**
  117573. * Can be used to return the list of features currently registered
  117574. *
  117575. * @returns an Array of available features
  117576. */
  117577. static GetAvailableFeatures(): string[];
  117578. /**
  117579. * Gets the versions available for a specific feature
  117580. * @param featureName the name of the feature
  117581. * @returns an array with the available versions
  117582. */
  117583. static GetAvailableVersions(featureName: string): string[];
  117584. /**
  117585. * Return the latest unstable version of this feature
  117586. * @param featureName the name of the feature to search
  117587. * @returns the version number. if not found will return -1
  117588. */
  117589. static GetLatestVersionOfFeature(featureName: string): number;
  117590. /**
  117591. * Return the latest stable version of this feature
  117592. * @param featureName the name of the feature to search
  117593. * @returns the version number. if not found will return -1
  117594. */
  117595. static GetStableVersionOfFeature(featureName: string): number;
  117596. /**
  117597. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  117598. * Can be used during a session to start a feature
  117599. * @param featureName the name of feature to attach
  117600. */
  117601. attachFeature(featureName: string): void;
  117602. /**
  117603. * Can be used inside a session or when the session ends to detach a specific feature
  117604. * @param featureName the name of the feature to detach
  117605. */
  117606. detachFeature(featureName: string): void;
  117607. /**
  117608. * Used to disable an already-enabled feature
  117609. * The feature will be disposed and will be recreated once enabled.
  117610. * @param featureName the feature to disable
  117611. * @returns true if disable was successful
  117612. */
  117613. disableFeature(featureName: string | {
  117614. Name: string;
  117615. }): boolean;
  117616. /**
  117617. * dispose this features manager
  117618. */
  117619. dispose(): void;
  117620. /**
  117621. * 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.
  117622. * 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.
  117623. *
  117624. * @param featureName the name of the feature to load or the class of the feature
  117625. * @param version optional version to load. if not provided the latest version will be enabled
  117626. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  117627. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  117628. * @returns a new constructed feature or throws an error if feature not found.
  117629. */
  117630. enableFeature(featureName: string | {
  117631. Name: string;
  117632. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean): IWebXRFeature;
  117633. /**
  117634. * get the implementation of an enabled feature.
  117635. * @param featureName the name of the feature to load
  117636. * @returns the feature class, if found
  117637. */
  117638. getEnabledFeature(featureName: string): IWebXRFeature;
  117639. /**
  117640. * Get the list of enabled features
  117641. * @returns an array of enabled features
  117642. */
  117643. getEnabledFeatures(): string[];
  117644. }
  117645. }
  117646. declare module BABYLON {
  117647. /**
  117648. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  117649. * @see https://doc.babylonjs.com/how_to/webxr
  117650. */
  117651. export class WebXRExperienceHelper implements IDisposable {
  117652. private scene;
  117653. private _nonVRCamera;
  117654. private _originalSceneAutoClear;
  117655. private _supported;
  117656. /**
  117657. * Camera used to render xr content
  117658. */
  117659. camera: WebXRCamera;
  117660. /** A features manager for this xr session */
  117661. featuresManager: WebXRFeaturesManager;
  117662. /**
  117663. * Observers registered here will be triggered after the camera's initial transformation is set
  117664. * This can be used to set a different ground level or an extra rotation.
  117665. *
  117666. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  117667. * to the position set after this observable is done executing.
  117668. */
  117669. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  117670. /**
  117671. * Fires when the state of the experience helper has changed
  117672. */
  117673. onStateChangedObservable: Observable<WebXRState>;
  117674. /** Session manager used to keep track of xr session */
  117675. sessionManager: WebXRSessionManager;
  117676. /**
  117677. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  117678. */
  117679. state: WebXRState;
  117680. /**
  117681. * Creates a WebXRExperienceHelper
  117682. * @param scene The scene the helper should be created in
  117683. */
  117684. private constructor();
  117685. /**
  117686. * Creates the experience helper
  117687. * @param scene the scene to attach the experience helper to
  117688. * @returns a promise for the experience helper
  117689. */
  117690. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  117691. /**
  117692. * Disposes of the experience helper
  117693. */
  117694. dispose(): void;
  117695. /**
  117696. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  117697. * @param sessionMode options for the XR session
  117698. * @param referenceSpaceType frame of reference of the XR session
  117699. * @param renderTarget the output canvas that will be used to enter XR mode
  117700. * @returns promise that resolves after xr mode has entered
  117701. */
  117702. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget): Promise<WebXRSessionManager>;
  117703. /**
  117704. * Exits XR mode and returns the scene to its original state
  117705. * @returns promise that resolves after xr mode has exited
  117706. */
  117707. exitXRAsync(): Promise<void>;
  117708. private _nonXRToXRCamera;
  117709. private _setState;
  117710. }
  117711. }
  117712. declare module BABYLON {
  117713. /**
  117714. * X-Y values for axes in WebXR
  117715. */
  117716. export interface IWebXRMotionControllerAxesValue {
  117717. /**
  117718. * The value of the x axis
  117719. */
  117720. x: number;
  117721. /**
  117722. * The value of the y-axis
  117723. */
  117724. y: number;
  117725. }
  117726. /**
  117727. * changed / previous values for the values of this component
  117728. */
  117729. export interface IWebXRMotionControllerComponentChangesValues<T> {
  117730. /**
  117731. * current (this frame) value
  117732. */
  117733. current: T;
  117734. /**
  117735. * previous (last change) value
  117736. */
  117737. previous: T;
  117738. }
  117739. /**
  117740. * Represents changes in the component between current frame and last values recorded
  117741. */
  117742. export interface IWebXRMotionControllerComponentChanges {
  117743. /**
  117744. * will be populated with previous and current values if axes changed
  117745. */
  117746. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  117747. /**
  117748. * will be populated with previous and current values if pressed changed
  117749. */
  117750. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117751. /**
  117752. * will be populated with previous and current values if touched changed
  117753. */
  117754. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  117755. /**
  117756. * will be populated with previous and current values if value changed
  117757. */
  117758. value?: IWebXRMotionControllerComponentChangesValues<number>;
  117759. }
  117760. /**
  117761. * This class represents a single component (for example button or thumbstick) of a motion controller
  117762. */
  117763. export class WebXRControllerComponent implements IDisposable {
  117764. /**
  117765. * the id of this component
  117766. */
  117767. id: string;
  117768. /**
  117769. * the type of the component
  117770. */
  117771. type: MotionControllerComponentType;
  117772. private _buttonIndex;
  117773. private _axesIndices;
  117774. private _axes;
  117775. private _changes;
  117776. private _currentValue;
  117777. private _hasChanges;
  117778. private _pressed;
  117779. private _touched;
  117780. /**
  117781. * button component type
  117782. */
  117783. static BUTTON_TYPE: MotionControllerComponentType;
  117784. /**
  117785. * squeeze component type
  117786. */
  117787. static SQUEEZE_TYPE: MotionControllerComponentType;
  117788. /**
  117789. * Thumbstick component type
  117790. */
  117791. static THUMBSTICK_TYPE: MotionControllerComponentType;
  117792. /**
  117793. * Touchpad component type
  117794. */
  117795. static TOUCHPAD_TYPE: MotionControllerComponentType;
  117796. /**
  117797. * trigger component type
  117798. */
  117799. static TRIGGER_TYPE: MotionControllerComponentType;
  117800. /**
  117801. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  117802. * the axes data changes
  117803. */
  117804. onAxisValueChangedObservable: Observable<{
  117805. x: number;
  117806. y: number;
  117807. }>;
  117808. /**
  117809. * Observers registered here will be triggered when the state of a button changes
  117810. * State change is either pressed / touched / value
  117811. */
  117812. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  117813. /**
  117814. * Creates a new component for a motion controller.
  117815. * It is created by the motion controller itself
  117816. *
  117817. * @param id the id of this component
  117818. * @param type the type of the component
  117819. * @param _buttonIndex index in the buttons array of the gamepad
  117820. * @param _axesIndices indices of the values in the axes array of the gamepad
  117821. */
  117822. constructor(
  117823. /**
  117824. * the id of this component
  117825. */
  117826. id: string,
  117827. /**
  117828. * the type of the component
  117829. */
  117830. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  117831. /**
  117832. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  117833. */
  117834. get axes(): IWebXRMotionControllerAxesValue;
  117835. /**
  117836. * Get the changes. Elements will be populated only if they changed with their previous and current value
  117837. */
  117838. get changes(): IWebXRMotionControllerComponentChanges;
  117839. /**
  117840. * Return whether or not the component changed the last frame
  117841. */
  117842. get hasChanges(): boolean;
  117843. /**
  117844. * is the button currently pressed
  117845. */
  117846. get pressed(): boolean;
  117847. /**
  117848. * is the button currently touched
  117849. */
  117850. get touched(): boolean;
  117851. /**
  117852. * Get the current value of this component
  117853. */
  117854. get value(): number;
  117855. /**
  117856. * Dispose this component
  117857. */
  117858. dispose(): void;
  117859. /**
  117860. * Are there axes correlating to this component
  117861. * @return true is axes data is available
  117862. */
  117863. isAxes(): boolean;
  117864. /**
  117865. * Is this component a button (hence - pressable)
  117866. * @returns true if can be pressed
  117867. */
  117868. isButton(): boolean;
  117869. /**
  117870. * update this component using the gamepad object it is in. Called on every frame
  117871. * @param nativeController the native gamepad controller object
  117872. */
  117873. update(nativeController: IMinimalMotionControllerObject): void;
  117874. }
  117875. }
  117876. declare module BABYLON {
  117877. /**
  117878. * Class used to represent data loading progression
  117879. */
  117880. export class SceneLoaderProgressEvent {
  117881. /** defines if data length to load can be evaluated */
  117882. readonly lengthComputable: boolean;
  117883. /** defines the loaded data length */
  117884. readonly loaded: number;
  117885. /** defines the data length to load */
  117886. readonly total: number;
  117887. /**
  117888. * Create a new progress event
  117889. * @param lengthComputable defines if data length to load can be evaluated
  117890. * @param loaded defines the loaded data length
  117891. * @param total defines the data length to load
  117892. */
  117893. constructor(
  117894. /** defines if data length to load can be evaluated */
  117895. lengthComputable: boolean,
  117896. /** defines the loaded data length */
  117897. loaded: number,
  117898. /** defines the data length to load */
  117899. total: number);
  117900. /**
  117901. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  117902. * @param event defines the source event
  117903. * @returns a new SceneLoaderProgressEvent
  117904. */
  117905. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  117906. }
  117907. /**
  117908. * Interface used by SceneLoader plugins to define supported file extensions
  117909. */
  117910. export interface ISceneLoaderPluginExtensions {
  117911. /**
  117912. * Defines the list of supported extensions
  117913. */
  117914. [extension: string]: {
  117915. isBinary: boolean;
  117916. };
  117917. }
  117918. /**
  117919. * Interface used by SceneLoader plugin factory
  117920. */
  117921. export interface ISceneLoaderPluginFactory {
  117922. /**
  117923. * Defines the name of the factory
  117924. */
  117925. name: string;
  117926. /**
  117927. * Function called to create a new plugin
  117928. * @return the new plugin
  117929. */
  117930. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  117931. /**
  117932. * The callback that returns true if the data can be directly loaded.
  117933. * @param data string containing the file data
  117934. * @returns if the data can be loaded directly
  117935. */
  117936. canDirectLoad?(data: string): boolean;
  117937. }
  117938. /**
  117939. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  117940. */
  117941. export interface ISceneLoaderPluginBase {
  117942. /**
  117943. * The friendly name of this plugin.
  117944. */
  117945. name: string;
  117946. /**
  117947. * The file extensions supported by this plugin.
  117948. */
  117949. extensions: string | ISceneLoaderPluginExtensions;
  117950. /**
  117951. * The callback called when loading from a url.
  117952. * @param scene scene loading this url
  117953. * @param url url to load
  117954. * @param onSuccess callback called when the file successfully loads
  117955. * @param onProgress callback called while file is loading (if the server supports this mode)
  117956. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  117957. * @param onError callback called when the file fails to load
  117958. * @returns a file request object
  117959. */
  117960. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117961. /**
  117962. * The callback called when loading from a file object.
  117963. * @param scene scene loading this file
  117964. * @param file defines the file to load
  117965. * @param onSuccess defines the callback to call when data is loaded
  117966. * @param onProgress defines the callback to call during loading process
  117967. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  117968. * @param onError defines the callback to call when an error occurs
  117969. * @returns a file request object
  117970. */
  117971. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  117972. /**
  117973. * The callback that returns true if the data can be directly loaded.
  117974. * @param data string containing the file data
  117975. * @returns if the data can be loaded directly
  117976. */
  117977. canDirectLoad?(data: string): boolean;
  117978. /**
  117979. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  117980. * @param scene scene loading this data
  117981. * @param data string containing the data
  117982. * @returns data to pass to the plugin
  117983. */
  117984. directLoad?(scene: Scene, data: string): any;
  117985. /**
  117986. * The callback that allows custom handling of the root url based on the response url.
  117987. * @param rootUrl the original root url
  117988. * @param responseURL the response url if available
  117989. * @returns the new root url
  117990. */
  117991. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  117992. }
  117993. /**
  117994. * Interface used to define a SceneLoader plugin
  117995. */
  117996. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  117997. /**
  117998. * Import meshes into a scene.
  117999. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118000. * @param scene The scene to import into
  118001. * @param data The data to import
  118002. * @param rootUrl The root url for scene and resources
  118003. * @param meshes The meshes array to import into
  118004. * @param particleSystems The particle systems array to import into
  118005. * @param skeletons The skeletons array to import into
  118006. * @param onError The callback when import fails
  118007. * @returns True if successful or false otherwise
  118008. */
  118009. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  118010. /**
  118011. * Load into a scene.
  118012. * @param scene The scene to load into
  118013. * @param data The data to import
  118014. * @param rootUrl The root url for scene and resources
  118015. * @param onError The callback when import fails
  118016. * @returns True if successful or false otherwise
  118017. */
  118018. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  118019. /**
  118020. * Load into an asset container.
  118021. * @param scene The scene to load into
  118022. * @param data The data to import
  118023. * @param rootUrl The root url for scene and resources
  118024. * @param onError The callback when import fails
  118025. * @returns The loaded asset container
  118026. */
  118027. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  118028. }
  118029. /**
  118030. * Interface used to define an async SceneLoader plugin
  118031. */
  118032. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  118033. /**
  118034. * Import meshes into a scene.
  118035. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118036. * @param scene The scene to import into
  118037. * @param data The data to import
  118038. * @param rootUrl The root url for scene and resources
  118039. * @param onProgress The callback when the load progresses
  118040. * @param fileName Defines the name of the file to load
  118041. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  118042. */
  118043. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  118044. meshes: AbstractMesh[];
  118045. particleSystems: IParticleSystem[];
  118046. skeletons: Skeleton[];
  118047. animationGroups: AnimationGroup[];
  118048. }>;
  118049. /**
  118050. * Load into a scene.
  118051. * @param scene The scene to load into
  118052. * @param data The data to import
  118053. * @param rootUrl The root url for scene and resources
  118054. * @param onProgress The callback when the load progresses
  118055. * @param fileName Defines the name of the file to load
  118056. * @returns Nothing
  118057. */
  118058. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  118059. /**
  118060. * Load into an asset container.
  118061. * @param scene The scene to load into
  118062. * @param data The data to import
  118063. * @param rootUrl The root url for scene and resources
  118064. * @param onProgress The callback when the load progresses
  118065. * @param fileName Defines the name of the file to load
  118066. * @returns The loaded asset container
  118067. */
  118068. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  118069. }
  118070. /**
  118071. * Mode that determines how to handle old animation groups before loading new ones.
  118072. */
  118073. export enum SceneLoaderAnimationGroupLoadingMode {
  118074. /**
  118075. * Reset all old animations to initial state then dispose them.
  118076. */
  118077. Clean = 0,
  118078. /**
  118079. * Stop all old animations.
  118080. */
  118081. Stop = 1,
  118082. /**
  118083. * Restart old animations from first frame.
  118084. */
  118085. Sync = 2,
  118086. /**
  118087. * Old animations remains untouched.
  118088. */
  118089. NoSync = 3
  118090. }
  118091. /**
  118092. * Class used to load scene from various file formats using registered plugins
  118093. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  118094. */
  118095. export class SceneLoader {
  118096. /**
  118097. * No logging while loading
  118098. */
  118099. static readonly NO_LOGGING: number;
  118100. /**
  118101. * Minimal logging while loading
  118102. */
  118103. static readonly MINIMAL_LOGGING: number;
  118104. /**
  118105. * Summary logging while loading
  118106. */
  118107. static readonly SUMMARY_LOGGING: number;
  118108. /**
  118109. * Detailled logging while loading
  118110. */
  118111. static readonly DETAILED_LOGGING: number;
  118112. /**
  118113. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  118114. */
  118115. static get ForceFullSceneLoadingForIncremental(): boolean;
  118116. static set ForceFullSceneLoadingForIncremental(value: boolean);
  118117. /**
  118118. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  118119. */
  118120. static get ShowLoadingScreen(): boolean;
  118121. static set ShowLoadingScreen(value: boolean);
  118122. /**
  118123. * Defines the current logging level (while loading the scene)
  118124. * @ignorenaming
  118125. */
  118126. static get loggingLevel(): number;
  118127. static set loggingLevel(value: number);
  118128. /**
  118129. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  118130. */
  118131. static get CleanBoneMatrixWeights(): boolean;
  118132. static set CleanBoneMatrixWeights(value: boolean);
  118133. /**
  118134. * Event raised when a plugin is used to load a scene
  118135. */
  118136. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  118137. private static _registeredPlugins;
  118138. private static _getDefaultPlugin;
  118139. private static _getPluginForExtension;
  118140. private static _getPluginForDirectLoad;
  118141. private static _getPluginForFilename;
  118142. private static _getDirectLoad;
  118143. private static _loadData;
  118144. private static _getFileInfo;
  118145. /**
  118146. * Gets a plugin that can load the given extension
  118147. * @param extension defines the extension to load
  118148. * @returns a plugin or null if none works
  118149. */
  118150. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  118151. /**
  118152. * Gets a boolean indicating that the given extension can be loaded
  118153. * @param extension defines the extension to load
  118154. * @returns true if the extension is supported
  118155. */
  118156. static IsPluginForExtensionAvailable(extension: string): boolean;
  118157. /**
  118158. * Adds a new plugin to the list of registered plugins
  118159. * @param plugin defines the plugin to add
  118160. */
  118161. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  118162. /**
  118163. * Import meshes into a scene
  118164. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118165. * @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)
  118166. * @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)
  118167. * @param scene the instance of BABYLON.Scene to append to
  118168. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  118169. * @param onProgress a callback with a progress event for each file being loaded
  118170. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118171. * @param pluginExtension the extension used to determine the plugin
  118172. * @returns The loaded plugin
  118173. */
  118174. 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>;
  118175. /**
  118176. * Import meshes into a scene
  118177. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  118178. * @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)
  118179. * @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)
  118180. * @param scene the instance of BABYLON.Scene to append to
  118181. * @param onProgress a callback with a progress event for each file being loaded
  118182. * @param pluginExtension the extension used to determine the plugin
  118183. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  118184. */
  118185. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  118186. meshes: AbstractMesh[];
  118187. particleSystems: IParticleSystem[];
  118188. skeletons: Skeleton[];
  118189. animationGroups: AnimationGroup[];
  118190. }>;
  118191. /**
  118192. * Load a scene
  118193. * @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)
  118194. * @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)
  118195. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118196. * @param onSuccess a callback with the scene when import succeeds
  118197. * @param onProgress a callback with a progress event for each file being loaded
  118198. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118199. * @param pluginExtension the extension used to determine the plugin
  118200. * @returns The loaded plugin
  118201. */
  118202. 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>;
  118203. /**
  118204. * Load a scene
  118205. * @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)
  118206. * @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)
  118207. * @param engine is the instance of BABYLON.Engine to use to create the scene
  118208. * @param onProgress a callback with a progress event for each file being loaded
  118209. * @param pluginExtension the extension used to determine the plugin
  118210. * @returns The loaded scene
  118211. */
  118212. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118213. /**
  118214. * Append a scene
  118215. * @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)
  118216. * @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)
  118217. * @param scene is the instance of BABYLON.Scene to append to
  118218. * @param onSuccess a callback with the scene when import succeeds
  118219. * @param onProgress a callback with a progress event for each file being loaded
  118220. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118221. * @param pluginExtension the extension used to determine the plugin
  118222. * @returns The loaded plugin
  118223. */
  118224. 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>;
  118225. /**
  118226. * Append a scene
  118227. * @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)
  118228. * @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)
  118229. * @param scene is the instance of BABYLON.Scene to append to
  118230. * @param onProgress a callback with a progress event for each file being loaded
  118231. * @param pluginExtension the extension used to determine the plugin
  118232. * @returns The given scene
  118233. */
  118234. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  118235. /**
  118236. * Load a scene into an asset container
  118237. * @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)
  118238. * @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)
  118239. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118240. * @param onSuccess a callback with the scene when import succeeds
  118241. * @param onProgress a callback with a progress event for each file being loaded
  118242. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118243. * @param pluginExtension the extension used to determine the plugin
  118244. * @returns The loaded plugin
  118245. */
  118246. 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>;
  118247. /**
  118248. * Load a scene into an asset container
  118249. * @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)
  118250. * @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)
  118251. * @param scene is the instance of Scene to append to
  118252. * @param onProgress a callback with a progress event for each file being loaded
  118253. * @param pluginExtension the extension used to determine the plugin
  118254. * @returns The loaded asset container
  118255. */
  118256. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  118257. /**
  118258. * Import animations from a file into a scene
  118259. * @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)
  118260. * @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)
  118261. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118262. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118263. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118264. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118265. * @param onSuccess a callback with the scene when import succeeds
  118266. * @param onProgress a callback with a progress event for each file being loaded
  118267. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118268. */
  118269. 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;
  118270. /**
  118271. * Import animations from a file into a scene
  118272. * @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)
  118273. * @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)
  118274. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  118275. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  118276. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  118277. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  118278. * @param onSuccess a callback with the scene when import succeeds
  118279. * @param onProgress a callback with a progress event for each file being loaded
  118280. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  118281. * @returns the updated scene with imported animations
  118282. */
  118283. 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>;
  118284. }
  118285. }
  118286. declare module BABYLON {
  118287. /**
  118288. * Handness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  118289. */
  118290. export type MotionControllerHandness = "none" | "left" | "right";
  118291. /**
  118292. * The type of components available in motion controllers.
  118293. * This is not the name of the component.
  118294. */
  118295. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  118296. /**
  118297. * The state of a controller component
  118298. */
  118299. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  118300. /**
  118301. * The schema of motion controller layout.
  118302. * No object will be initialized using this interface
  118303. * This is used just to define the profile.
  118304. */
  118305. export interface IMotionControllerLayout {
  118306. /**
  118307. * Path to load the assets. Usually relative to the base path
  118308. */
  118309. assetPath: string;
  118310. /**
  118311. * Available components (unsorted)
  118312. */
  118313. components: {
  118314. /**
  118315. * A map of component Ids
  118316. */
  118317. [componentId: string]: {
  118318. /**
  118319. * The type of input the component outputs
  118320. */
  118321. type: MotionControllerComponentType;
  118322. /**
  118323. * The indices of this component in the gamepad object
  118324. */
  118325. gamepadIndices: {
  118326. /**
  118327. * Index of button
  118328. */
  118329. button?: number;
  118330. /**
  118331. * If available, index of x-axis
  118332. */
  118333. xAxis?: number;
  118334. /**
  118335. * If available, index of y-axis
  118336. */
  118337. yAxis?: number;
  118338. };
  118339. /**
  118340. * The mesh's root node name
  118341. */
  118342. rootNodeName: string;
  118343. /**
  118344. * Animation definitions for this model
  118345. */
  118346. visualResponses: {
  118347. [stateKey: string]: {
  118348. /**
  118349. * What property will be animated
  118350. */
  118351. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  118352. /**
  118353. * What states influence this visual response
  118354. */
  118355. states: MotionControllerComponentStateType[];
  118356. /**
  118357. * Type of animation - movement or visibility
  118358. */
  118359. valueNodeProperty: "transform" | "visibility";
  118360. /**
  118361. * Base node name to move. Its position will be calculated according to the min and max nodes
  118362. */
  118363. valueNodeName?: string;
  118364. /**
  118365. * Minimum movement node
  118366. */
  118367. minNodeName?: string;
  118368. /**
  118369. * Max movement node
  118370. */
  118371. maxNodeName?: string;
  118372. };
  118373. };
  118374. /**
  118375. * If touch enabled, what is the name of node to display user feedback
  118376. */
  118377. touchPointNodeName?: string;
  118378. };
  118379. };
  118380. /**
  118381. * Is it xr standard mapping or not
  118382. */
  118383. gamepadMapping: "" | "xr-standard";
  118384. /**
  118385. * Base root node of this entire model
  118386. */
  118387. rootNodeName: string;
  118388. /**
  118389. * Defines the main button component id
  118390. */
  118391. selectComponentId: string;
  118392. }
  118393. /**
  118394. * A definition for the layout map in the input profile
  118395. */
  118396. export interface IMotionControllerLayoutMap {
  118397. /**
  118398. * Layouts with handness type as a key
  118399. */
  118400. [handness: string]: IMotionControllerLayout;
  118401. }
  118402. /**
  118403. * The XR Input profile schema
  118404. * Profiles can be found here:
  118405. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  118406. */
  118407. export interface IMotionControllerProfile {
  118408. /**
  118409. * fallback profiles for this profileId
  118410. */
  118411. fallbackProfileIds: string[];
  118412. /**
  118413. * The layout map, with handness as key
  118414. */
  118415. layouts: IMotionControllerLayoutMap;
  118416. /**
  118417. * The id of this profile
  118418. * correlates to the profile(s) in the xrInput.profiles array
  118419. */
  118420. profileId: string;
  118421. }
  118422. /**
  118423. * A helper-interface for the 3 meshes needed for controller button animation
  118424. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  118425. */
  118426. export interface IMotionControllerButtonMeshMap {
  118427. /**
  118428. * the mesh that defines the pressed value mesh position.
  118429. * This is used to find the max-position of this button
  118430. */
  118431. pressedMesh: AbstractMesh;
  118432. /**
  118433. * the mesh that defines the unpressed value mesh position.
  118434. * This is used to find the min (or initial) position of this button
  118435. */
  118436. unpressedMesh: AbstractMesh;
  118437. /**
  118438. * The mesh that will be changed when value changes
  118439. */
  118440. valueMesh: AbstractMesh;
  118441. }
  118442. /**
  118443. * A helper-interface for the 3 meshes needed for controller axis animation.
  118444. * This will be expanded when touchpad animations are fully supported
  118445. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  118446. */
  118447. export interface IMotionControllerMeshMap {
  118448. /**
  118449. * the mesh that defines the maximum value mesh position.
  118450. */
  118451. maxMesh?: AbstractMesh;
  118452. /**
  118453. * the mesh that defines the minimum value mesh position.
  118454. */
  118455. minMesh?: AbstractMesh;
  118456. /**
  118457. * The mesh that will be changed when axis value changes
  118458. */
  118459. valueMesh: AbstractMesh;
  118460. }
  118461. /**
  118462. * The elements needed for change-detection of the gamepad objects in motion controllers
  118463. */
  118464. export interface IMinimalMotionControllerObject {
  118465. /**
  118466. * Available axes of this controller
  118467. */
  118468. axes: number[];
  118469. /**
  118470. * An array of available buttons
  118471. */
  118472. buttons: Array<{
  118473. /**
  118474. * Value of the button/trigger
  118475. */
  118476. value: number;
  118477. /**
  118478. * If the button/trigger is currently touched
  118479. */
  118480. touched: boolean;
  118481. /**
  118482. * If the button/trigger is currently pressed
  118483. */
  118484. pressed: boolean;
  118485. }>;
  118486. }
  118487. /**
  118488. * An Abstract Motion controller
  118489. * This class receives an xrInput and a profile layout and uses those to initialize the components
  118490. * Each component has an observable to check for changes in value and state
  118491. */
  118492. export abstract class WebXRAbstractMotionController implements IDisposable {
  118493. protected scene: Scene;
  118494. protected layout: IMotionControllerLayout;
  118495. /**
  118496. * The gamepad object correlating to this controller
  118497. */
  118498. gamepadObject: IMinimalMotionControllerObject;
  118499. /**
  118500. * handness (left/right/none) of this controller
  118501. */
  118502. handness: MotionControllerHandness;
  118503. private _initComponent;
  118504. private _modelReady;
  118505. /**
  118506. * A map of components (WebXRControllerComponent) in this motion controller
  118507. * Components have a ComponentType and can also have both button and axis definitions
  118508. */
  118509. readonly components: {
  118510. [id: string]: WebXRControllerComponent;
  118511. };
  118512. /**
  118513. * Disable the model's animation. Can be set at any time.
  118514. */
  118515. disableAnimation: boolean;
  118516. /**
  118517. * Observers registered here will be triggered when the model of this controller is done loading
  118518. */
  118519. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  118520. /**
  118521. * The profile id of this motion controller
  118522. */
  118523. abstract profileId: string;
  118524. /**
  118525. * The root mesh of the model. It is null if the model was not yet initialized
  118526. */
  118527. rootMesh: Nullable<AbstractMesh>;
  118528. /**
  118529. * constructs a new abstract motion controller
  118530. * @param scene the scene to which the model of the controller will be added
  118531. * @param layout The profile layout to load
  118532. * @param gamepadObject The gamepad object correlating to this controller
  118533. * @param handness handness (left/right/none) of this controller
  118534. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  118535. */
  118536. constructor(scene: Scene, layout: IMotionControllerLayout,
  118537. /**
  118538. * The gamepad object correlating to this controller
  118539. */
  118540. gamepadObject: IMinimalMotionControllerObject,
  118541. /**
  118542. * handness (left/right/none) of this controller
  118543. */
  118544. handness: MotionControllerHandness, _doNotLoadControllerMesh?: boolean);
  118545. /**
  118546. * Dispose this controller, the model mesh and all its components
  118547. */
  118548. dispose(): void;
  118549. /**
  118550. * Returns all components of specific type
  118551. * @param type the type to search for
  118552. * @return an array of components with this type
  118553. */
  118554. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  118555. /**
  118556. * get a component based an its component id as defined in layout.components
  118557. * @param id the id of the component
  118558. * @returns the component correlates to the id or undefined if not found
  118559. */
  118560. getComponent(id: string): WebXRControllerComponent;
  118561. /**
  118562. * Get the list of components available in this motion controller
  118563. * @returns an array of strings correlating to available components
  118564. */
  118565. getComponentIds(): string[];
  118566. /**
  118567. * Get the first component of specific type
  118568. * @param type type of component to find
  118569. * @return a controller component or null if not found
  118570. */
  118571. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  118572. /**
  118573. * Get the main (Select) component of this controller as defined in the layout
  118574. * @returns the main component of this controller
  118575. */
  118576. getMainComponent(): WebXRControllerComponent;
  118577. /**
  118578. * Loads the model correlating to this controller
  118579. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  118580. * @returns A promise fulfilled with the result of the model loading
  118581. */
  118582. loadModel(): Promise<boolean>;
  118583. /**
  118584. * Update this model using the current XRFrame
  118585. * @param xrFrame the current xr frame to use and update the model
  118586. */
  118587. updateFromXRFrame(xrFrame: XRFrame): void;
  118588. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118589. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh;
  118590. /**
  118591. * Moves the axis on the controller mesh based on its current state
  118592. * @param axis the index of the axis
  118593. * @param axisValue the value of the axis which determines the meshes new position
  118594. * @hidden
  118595. */
  118596. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  118597. /**
  118598. * Update the model itself with the current frame data
  118599. * @param xrFrame the frame to use for updating the model mesh
  118600. */
  118601. protected updateModel(xrFrame: XRFrame): void;
  118602. /**
  118603. * Get the filename and path for this controller's model
  118604. * @returns a map of filename and path
  118605. */
  118606. protected abstract _getFilenameAndPath(): {
  118607. filename: string;
  118608. path: string;
  118609. };
  118610. /**
  118611. * This function is called before the mesh is loaded. It checks for loading constraints.
  118612. * For example, this function can check if the GLB loader is available
  118613. * If this function returns false, the generic controller will be loaded instead
  118614. * @returns Is the client ready to load the mesh
  118615. */
  118616. protected abstract _getModelLoadingConstraints(): boolean;
  118617. /**
  118618. * This function will be called after the model was successfully loaded and can be used
  118619. * for mesh transformations before it is available for the user
  118620. * @param meshes the loaded meshes
  118621. */
  118622. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  118623. /**
  118624. * Set the root mesh for this controller. Important for the WebXR controller class
  118625. * @param meshes the loaded meshes
  118626. */
  118627. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  118628. /**
  118629. * A function executed each frame that updates the mesh (if needed)
  118630. * @param xrFrame the current xrFrame
  118631. */
  118632. protected abstract _updateModel(xrFrame: XRFrame): void;
  118633. private _getGenericFilenameAndPath;
  118634. private _getGenericParentMesh;
  118635. }
  118636. }
  118637. declare module BABYLON {
  118638. /**
  118639. * A generic trigger-only motion controller for WebXR
  118640. */
  118641. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  118642. /**
  118643. * Static version of the profile id of this controller
  118644. */
  118645. static ProfileId: string;
  118646. profileId: string;
  118647. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  118648. protected _getFilenameAndPath(): {
  118649. filename: string;
  118650. path: string;
  118651. };
  118652. protected _getModelLoadingConstraints(): boolean;
  118653. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  118654. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118655. protected _updateModel(): void;
  118656. }
  118657. }
  118658. declare module BABYLON {
  118659. /**
  118660. * Class containing static functions to help procedurally build meshes
  118661. */
  118662. export class SphereBuilder {
  118663. /**
  118664. * Creates a sphere mesh
  118665. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  118666. * * 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`)
  118667. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  118668. * * 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
  118669. * * 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)
  118670. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  118671. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  118672. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  118673. * @param name defines the name of the mesh
  118674. * @param options defines the options used to create the mesh
  118675. * @param scene defines the hosting scene
  118676. * @returns the sphere mesh
  118677. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  118678. */
  118679. static CreateSphere(name: string, options: {
  118680. segments?: number;
  118681. diameter?: number;
  118682. diameterX?: number;
  118683. diameterY?: number;
  118684. diameterZ?: number;
  118685. arc?: number;
  118686. slice?: number;
  118687. sideOrientation?: number;
  118688. frontUVs?: Vector4;
  118689. backUVs?: Vector4;
  118690. updatable?: boolean;
  118691. }, scene?: Nullable<Scene>): Mesh;
  118692. }
  118693. }
  118694. declare module BABYLON {
  118695. /**
  118696. * A profiled motion controller has its profile loaded from an online repository.
  118697. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  118698. */
  118699. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  118700. private _repositoryUrl;
  118701. private _buttonMeshMapping;
  118702. private _touchDots;
  118703. /**
  118704. * The profile ID of this controller. Will be populated when the controller initializes.
  118705. */
  118706. profileId: string;
  118707. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  118708. dispose(): void;
  118709. protected _getFilenameAndPath(): {
  118710. filename: string;
  118711. path: string;
  118712. };
  118713. protected _getModelLoadingConstraints(): boolean;
  118714. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  118715. protected _setRootMesh(meshes: AbstractMesh[]): void;
  118716. protected _updateModel(_xrFrame: XRFrame): void;
  118717. }
  118718. }
  118719. declare module BABYLON {
  118720. /**
  118721. * A construction function type to create a new controller based on an xrInput object
  118722. */
  118723. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  118724. /**
  118725. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  118726. *
  118727. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  118728. * it should be replaced with auto-loaded controllers.
  118729. *
  118730. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  118731. */
  118732. export class WebXRMotionControllerManager {
  118733. private static _AvailableControllers;
  118734. private static _Fallbacks;
  118735. private static _ProfileLoadingPromises;
  118736. private static _ProfilesList;
  118737. /**
  118738. * The base URL of the online controller repository. Can be changed at any time.
  118739. */
  118740. static BaseRepositoryUrl: string;
  118741. /**
  118742. * Which repository gets priority - local or online
  118743. */
  118744. static PrioritizeOnlineRepository: boolean;
  118745. /**
  118746. * Use the online repository, or use only locally-defined controllers
  118747. */
  118748. static UseOnlineRepository: boolean;
  118749. /**
  118750. * Clear the cache used for profile loading and reload when requested again
  118751. */
  118752. static ClearProfilesCache(): void;
  118753. /**
  118754. * Register the default fallbacks.
  118755. * This function is called automatically when this file is imported.
  118756. */
  118757. static DefaultFallbacks(): void;
  118758. /**
  118759. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  118760. * @param profileId the profile to which a fallback needs to be found
  118761. * @return an array with corresponding fallback profiles
  118762. */
  118763. static FindFallbackWithProfileId(profileId: string): string[];
  118764. /**
  118765. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  118766. * The order of search:
  118767. *
  118768. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  118769. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  118770. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  118771. * 4) return the generic trigger controller if none were found
  118772. *
  118773. * @param xrInput the xrInput to which a new controller is initialized
  118774. * @param scene the scene to which the model will be added
  118775. * @param forceProfile force a certain profile for this controller
  118776. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  118777. */
  118778. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  118779. /**
  118780. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  118781. *
  118782. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  118783. *
  118784. * @param type the profile type to register
  118785. * @param constructFunction the function to be called when loading this profile
  118786. */
  118787. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  118788. /**
  118789. * Register a fallback to a specific profile.
  118790. * @param profileId the profileId that will receive the fallbacks
  118791. * @param fallbacks A list of fallback profiles
  118792. */
  118793. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  118794. /**
  118795. * Will update the list of profiles available in the repository
  118796. * @return a promise that resolves to a map of profiles available online
  118797. */
  118798. static UpdateProfilesList(): Promise<{
  118799. [profile: string]: string;
  118800. }>;
  118801. private static _LoadProfileFromRepository;
  118802. private static _LoadProfilesFromAvailableControllers;
  118803. }
  118804. }
  118805. declare module BABYLON {
  118806. /**
  118807. * Configuration options for the WebXR controller creation
  118808. */
  118809. export interface IWebXRControllerOptions {
  118810. /**
  118811. * Should the controller mesh be animated when a user interacts with it
  118812. * The pressed buttons / thumbstick and touchpad animations will be disabled
  118813. */
  118814. disableMotionControllerAnimation?: boolean;
  118815. /**
  118816. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  118817. */
  118818. doNotLoadControllerMesh?: boolean;
  118819. /**
  118820. * Force a specific controller type for this controller.
  118821. * This can be used when creating your own profile or when testing different controllers
  118822. */
  118823. forceControllerProfile?: string;
  118824. }
  118825. /**
  118826. * Represents an XR controller
  118827. */
  118828. export class WebXRInputSource {
  118829. private _scene;
  118830. /** The underlying input source for the controller */
  118831. inputSource: XRInputSource;
  118832. private _options;
  118833. private _tmpQuaternion;
  118834. private _tmpVector;
  118835. private _uniqueId;
  118836. /**
  118837. * 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
  118838. */
  118839. grip?: AbstractMesh;
  118840. /**
  118841. * If available, this is the gamepad object related to this controller.
  118842. * Using this object it is possible to get click events and trackpad changes of the
  118843. * webxr controller that is currently being used.
  118844. */
  118845. motionController?: WebXRAbstractMotionController;
  118846. /**
  118847. * Event that fires when the controller is removed/disposed.
  118848. * The object provided as event data is this controller, after associated assets were disposed.
  118849. * uniqueId is still available.
  118850. */
  118851. onDisposeObservable: Observable<WebXRInputSource>;
  118852. /**
  118853. * Will be triggered when the mesh associated with the motion controller is done loading.
  118854. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  118855. * A shortened version of controller -> motion controller -> on mesh loaded.
  118856. */
  118857. onMeshLoadedObservable: Observable<AbstractMesh>;
  118858. /**
  118859. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  118860. */
  118861. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  118862. /**
  118863. * Pointer which can be used to select objects or attach a visible laser to
  118864. */
  118865. pointer: AbstractMesh;
  118866. /**
  118867. * Creates the controller
  118868. * @see https://doc.babylonjs.com/how_to/webxr
  118869. * @param _scene the scene which the controller should be associated to
  118870. * @param inputSource the underlying input source for the controller
  118871. * @param _options options for this controller creation
  118872. */
  118873. constructor(_scene: Scene,
  118874. /** The underlying input source for the controller */
  118875. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  118876. /**
  118877. * Get this controllers unique id
  118878. */
  118879. get uniqueId(): string;
  118880. /**
  118881. * Disposes of the object
  118882. */
  118883. dispose(): void;
  118884. /**
  118885. * Gets a world space ray coming from the pointer or grip
  118886. * @param result the resulting ray
  118887. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  118888. */
  118889. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  118890. /**
  118891. * Updates the controller pose based on the given XRFrame
  118892. * @param xrFrame xr frame to update the pose with
  118893. * @param referenceSpace reference space to use
  118894. */
  118895. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  118896. }
  118897. }
  118898. declare module BABYLON {
  118899. /**
  118900. * The schema for initialization options of the XR Input class
  118901. */
  118902. export interface IWebXRInputOptions {
  118903. /**
  118904. * If set to true no model will be automatically loaded
  118905. */
  118906. doNotLoadControllerMeshes?: boolean;
  118907. /**
  118908. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  118909. * If not found, the xr input profile data will be used.
  118910. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  118911. */
  118912. forceInputProfile?: string;
  118913. /**
  118914. * Do not send a request to the controller repository to load the profile.
  118915. *
  118916. * Instead, use the controllers available in babylon itself.
  118917. */
  118918. disableOnlineControllerRepository?: boolean;
  118919. /**
  118920. * A custom URL for the controllers repository
  118921. */
  118922. customControllersRepositoryURL?: string;
  118923. /**
  118924. * Should the controller model's components not move according to the user input
  118925. */
  118926. disableControllerAnimation?: boolean;
  118927. }
  118928. /**
  118929. * XR input used to track XR inputs such as controllers/rays
  118930. */
  118931. export class WebXRInput implements IDisposable {
  118932. /**
  118933. * the xr session manager for this session
  118934. */
  118935. xrSessionManager: WebXRSessionManager;
  118936. /**
  118937. * the WebXR camera for this session. Mainly used for teleportation
  118938. */
  118939. xrCamera: WebXRCamera;
  118940. private readonly options;
  118941. /**
  118942. * XR controllers being tracked
  118943. */
  118944. controllers: Array<WebXRInputSource>;
  118945. private _frameObserver;
  118946. private _sessionEndedObserver;
  118947. private _sessionInitObserver;
  118948. /**
  118949. * Event when a controller has been connected/added
  118950. */
  118951. onControllerAddedObservable: Observable<WebXRInputSource>;
  118952. /**
  118953. * Event when a controller has been removed/disconnected
  118954. */
  118955. onControllerRemovedObservable: Observable<WebXRInputSource>;
  118956. /**
  118957. * Initializes the WebXRInput
  118958. * @param xrSessionManager the xr session manager for this session
  118959. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  118960. * @param options = initialization options for this xr input
  118961. */
  118962. constructor(
  118963. /**
  118964. * the xr session manager for this session
  118965. */
  118966. xrSessionManager: WebXRSessionManager,
  118967. /**
  118968. * the WebXR camera for this session. Mainly used for teleportation
  118969. */
  118970. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  118971. private _onInputSourcesChange;
  118972. private _addAndRemoveControllers;
  118973. /**
  118974. * Disposes of the object
  118975. */
  118976. dispose(): void;
  118977. }
  118978. }
  118979. declare module BABYLON {
  118980. /**
  118981. * This is the base class for all WebXR features.
  118982. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  118983. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  118984. */
  118985. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  118986. protected _xrSessionManager: WebXRSessionManager;
  118987. private _attached;
  118988. private _removeOnDetach;
  118989. /**
  118990. * Should auto-attach be disabled?
  118991. */
  118992. disableAutoAttach: boolean;
  118993. /**
  118994. * Construct a new (abstract) WebXR feature
  118995. * @param _xrSessionManager the xr session manager for this feature
  118996. */
  118997. constructor(_xrSessionManager: WebXRSessionManager);
  118998. /**
  118999. * Is this feature attached
  119000. */
  119001. get attached(): boolean;
  119002. /**
  119003. * attach this feature
  119004. *
  119005. * @param force should attachment be forced (even when already attached)
  119006. * @returns true if successful, false is failed or already attached
  119007. */
  119008. attach(force?: boolean): boolean;
  119009. /**
  119010. * detach this feature.
  119011. *
  119012. * @returns true if successful, false if failed or already detached
  119013. */
  119014. detach(): boolean;
  119015. /**
  119016. * Dispose this feature and all of the resources attached
  119017. */
  119018. dispose(): void;
  119019. /**
  119020. * This is used to register callbacks that will automatically be removed when detach is called.
  119021. * @param observable the observable to which the observer will be attached
  119022. * @param callback the callback to register
  119023. */
  119024. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  119025. /**
  119026. * Code in this function will be executed on each xrFrame received from the browser.
  119027. * This function will not execute after the feature is detached.
  119028. * @param _xrFrame the current frame
  119029. */
  119030. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  119031. }
  119032. }
  119033. declare module BABYLON {
  119034. /**
  119035. * Renders a layer on top of an existing scene
  119036. */
  119037. export class UtilityLayerRenderer implements IDisposable {
  119038. /** the original scene that will be rendered on top of */
  119039. originalScene: Scene;
  119040. private _pointerCaptures;
  119041. private _lastPointerEvents;
  119042. private static _DefaultUtilityLayer;
  119043. private static _DefaultKeepDepthUtilityLayer;
  119044. private _sharedGizmoLight;
  119045. private _renderCamera;
  119046. /**
  119047. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  119048. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  119049. * @returns the camera that is used when rendering the utility layer
  119050. */
  119051. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  119052. /**
  119053. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  119054. * @param cam the camera that should be used when rendering the utility layer
  119055. */
  119056. setRenderCamera(cam: Nullable<Camera>): void;
  119057. /**
  119058. * @hidden
  119059. * Light which used by gizmos to get light shading
  119060. */
  119061. _getSharedGizmoLight(): HemisphericLight;
  119062. /**
  119063. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  119064. */
  119065. pickUtilitySceneFirst: boolean;
  119066. /**
  119067. * 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)
  119068. */
  119069. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  119070. /**
  119071. * 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)
  119072. */
  119073. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  119074. /**
  119075. * The scene that is rendered on top of the original scene
  119076. */
  119077. utilityLayerScene: Scene;
  119078. /**
  119079. * If the utility layer should automatically be rendered on top of existing scene
  119080. */
  119081. shouldRender: boolean;
  119082. /**
  119083. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  119084. */
  119085. onlyCheckPointerDownEvents: boolean;
  119086. /**
  119087. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  119088. */
  119089. processAllEvents: boolean;
  119090. /**
  119091. * Observable raised when the pointer move from the utility layer scene to the main scene
  119092. */
  119093. onPointerOutObservable: Observable<number>;
  119094. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  119095. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  119096. private _afterRenderObserver;
  119097. private _sceneDisposeObserver;
  119098. private _originalPointerObserver;
  119099. /**
  119100. * Instantiates a UtilityLayerRenderer
  119101. * @param originalScene the original scene that will be rendered on top of
  119102. * @param handleEvents boolean indicating if the utility layer should handle events
  119103. */
  119104. constructor(
  119105. /** the original scene that will be rendered on top of */
  119106. originalScene: Scene, handleEvents?: boolean);
  119107. private _notifyObservers;
  119108. /**
  119109. * Renders the utility layers scene on top of the original scene
  119110. */
  119111. render(): void;
  119112. /**
  119113. * Disposes of the renderer
  119114. */
  119115. dispose(): void;
  119116. private _updateCamera;
  119117. }
  119118. }
  119119. declare module BABYLON {
  119120. /**
  119121. * Options interface for the pointer selection module
  119122. */
  119123. export interface IWebXRControllerPointerSelectionOptions {
  119124. /**
  119125. * if provided, this scene will be used to render meshes.
  119126. */
  119127. customUtilityLayerScene?: Scene;
  119128. /**
  119129. * 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)
  119130. * If not disabled, the last picked point will be used to execute a pointer up event
  119131. * If disabled, pointer up event will be triggered right after the pointer down event.
  119132. * Used in screen and gaze target ray mode only
  119133. */
  119134. disablePointerUpOnTouchOut: boolean;
  119135. /**
  119136. * For gaze mode (time to select instead of press)
  119137. */
  119138. forceGazeMode: boolean;
  119139. /**
  119140. * 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
  119141. * to start a new countdown to the pointer down event.
  119142. * Defaults to 1.
  119143. */
  119144. gazeModePointerMovedFactor?: number;
  119145. /**
  119146. * Different button type to use instead of the main component
  119147. */
  119148. overrideButtonId?: string;
  119149. /**
  119150. * use this rendering group id for the meshes (optional)
  119151. */
  119152. renderingGroupId?: number;
  119153. /**
  119154. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  119155. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  119156. * 3000 means 3 seconds between pointing at something and selecting it
  119157. */
  119158. timeToSelect?: number;
  119159. /**
  119160. * Should meshes created here be added to a utility layer or the main scene
  119161. */
  119162. useUtilityLayer?: boolean;
  119163. /**
  119164. * the xr input to use with this pointer selection
  119165. */
  119166. xrInput: WebXRInput;
  119167. }
  119168. /**
  119169. * A module that will enable pointer selection for motion controllers of XR Input Sources
  119170. */
  119171. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  119172. private readonly _options;
  119173. private static _idCounter;
  119174. private _attachController;
  119175. private _controllers;
  119176. private _scene;
  119177. private _tmpVectorForPickCompare;
  119178. /**
  119179. * The module's name
  119180. */
  119181. static readonly Name: string;
  119182. /**
  119183. * The (Babylon) version of this module.
  119184. * This is an integer representing the implementation version.
  119185. * This number does not correspond to the WebXR specs version
  119186. */
  119187. static readonly Version: number;
  119188. /**
  119189. * Disable lighting on the laser pointer (so it will always be visible)
  119190. */
  119191. disablePointerLighting: boolean;
  119192. /**
  119193. * Disable lighting on the selection mesh (so it will always be visible)
  119194. */
  119195. disableSelectionMeshLighting: boolean;
  119196. /**
  119197. * Should the laser pointer be displayed
  119198. */
  119199. displayLaserPointer: boolean;
  119200. /**
  119201. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  119202. */
  119203. displaySelectionMesh: boolean;
  119204. /**
  119205. * This color will be set to the laser pointer when selection is triggered
  119206. */
  119207. laserPointerPickedColor: Color3;
  119208. /**
  119209. * Default color of the laser pointer
  119210. */
  119211. lasterPointerDefaultColor: Color3;
  119212. /**
  119213. * default color of the selection ring
  119214. */
  119215. selectionMeshDefaultColor: Color3;
  119216. /**
  119217. * This color will be applied to the selection ring when selection is triggered
  119218. */
  119219. selectionMeshPickedColor: Color3;
  119220. /**
  119221. * Optional filter to be used for ray selection. This predicate shares behavior with
  119222. * scene.pointerMovePredicate which takes priority if it is also assigned.
  119223. */
  119224. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119225. /**
  119226. * constructs a new background remover module
  119227. * @param _xrSessionManager the session manager for this module
  119228. * @param _options read-only options to be used in this module
  119229. */
  119230. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  119231. /**
  119232. * attach this feature
  119233. * Will usually be called by the features manager
  119234. *
  119235. * @returns true if successful.
  119236. */
  119237. attach(): boolean;
  119238. /**
  119239. * detach this feature.
  119240. * Will usually be called by the features manager
  119241. *
  119242. * @returns true if successful.
  119243. */
  119244. detach(): boolean;
  119245. /**
  119246. * Will get the mesh under a specific pointer.
  119247. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  119248. * @param controllerId the controllerId to check
  119249. * @returns The mesh under pointer or null if no mesh is under the pointer
  119250. */
  119251. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  119252. /**
  119253. * Get the xr controller that correlates to the pointer id in the pointer event
  119254. *
  119255. * @param id the pointer id to search for
  119256. * @returns the controller that correlates to this id or null if not found
  119257. */
  119258. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  119259. protected _onXRFrame(_xrFrame: XRFrame): void;
  119260. private _attachGazeMode;
  119261. private _attachScreenRayMode;
  119262. private _attachTrackedPointerRayMode;
  119263. private _convertNormalToDirectionOfRay;
  119264. private _detachController;
  119265. private _generateNewMeshPair;
  119266. private _pickingMoved;
  119267. private _updatePointerDistance;
  119268. }
  119269. }
  119270. declare module BABYLON {
  119271. /**
  119272. * Button which can be used to enter a different mode of XR
  119273. */
  119274. export class WebXREnterExitUIButton {
  119275. /** button element */
  119276. element: HTMLElement;
  119277. /** XR initialization options for the button */
  119278. sessionMode: XRSessionMode;
  119279. /** Reference space type */
  119280. referenceSpaceType: XRReferenceSpaceType;
  119281. /**
  119282. * Creates a WebXREnterExitUIButton
  119283. * @param element button element
  119284. * @param sessionMode XR initialization session mode
  119285. * @param referenceSpaceType the type of reference space to be used
  119286. */
  119287. constructor(
  119288. /** button element */
  119289. element: HTMLElement,
  119290. /** XR initialization options for the button */
  119291. sessionMode: XRSessionMode,
  119292. /** Reference space type */
  119293. referenceSpaceType: XRReferenceSpaceType);
  119294. /**
  119295. * Extendable function which can be used to update the button's visuals when the state changes
  119296. * @param activeButton the current active button in the UI
  119297. */
  119298. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  119299. }
  119300. /**
  119301. * Options to create the webXR UI
  119302. */
  119303. export class WebXREnterExitUIOptions {
  119304. /**
  119305. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  119306. */
  119307. customButtons?: Array<WebXREnterExitUIButton>;
  119308. /**
  119309. * A reference space type to use when creating the default button.
  119310. * Default is local-floor
  119311. */
  119312. referenceSpaceType?: XRReferenceSpaceType;
  119313. /**
  119314. * Context to enter xr with
  119315. */
  119316. renderTarget?: Nullable<WebXRRenderTarget>;
  119317. /**
  119318. * A session mode to use when creating the default button.
  119319. * Default is immersive-vr
  119320. */
  119321. sessionMode?: XRSessionMode;
  119322. }
  119323. /**
  119324. * UI to allow the user to enter/exit XR mode
  119325. */
  119326. export class WebXREnterExitUI implements IDisposable {
  119327. private scene;
  119328. /** version of the options passed to this UI */
  119329. options: WebXREnterExitUIOptions;
  119330. private _activeButton;
  119331. private _buttons;
  119332. private _overlay;
  119333. /**
  119334. * Fired every time the active button is changed.
  119335. *
  119336. * When xr is entered via a button that launches xr that button will be the callback parameter
  119337. *
  119338. * When exiting xr the callback parameter will be null)
  119339. */
  119340. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  119341. /**
  119342. *
  119343. * @param scene babylon scene object to use
  119344. * @param options (read-only) version of the options passed to this UI
  119345. */
  119346. private constructor();
  119347. /**
  119348. * Creates UI to allow the user to enter/exit XR mode
  119349. * @param scene the scene to add the ui to
  119350. * @param helper the xr experience helper to enter/exit xr with
  119351. * @param options options to configure the UI
  119352. * @returns the created ui
  119353. */
  119354. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  119355. /**
  119356. * Disposes of the XR UI component
  119357. */
  119358. dispose(): void;
  119359. private _updateButtons;
  119360. }
  119361. }
  119362. declare module BABYLON {
  119363. /**
  119364. * Class containing static functions to help procedurally build meshes
  119365. */
  119366. export class LinesBuilder {
  119367. /**
  119368. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  119369. * * 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
  119370. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  119371. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  119372. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  119373. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  119374. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119375. * * 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
  119376. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  119377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119378. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  119379. * @param name defines the name of the new line system
  119380. * @param options defines the options used to create the line system
  119381. * @param scene defines the hosting scene
  119382. * @returns a new line system mesh
  119383. */
  119384. static CreateLineSystem(name: string, options: {
  119385. lines: Vector3[][];
  119386. updatable?: boolean;
  119387. instance?: Nullable<LinesMesh>;
  119388. colors?: Nullable<Color4[][]>;
  119389. useVertexAlpha?: boolean;
  119390. }, scene: Nullable<Scene>): LinesMesh;
  119391. /**
  119392. * Creates a line mesh
  119393. * 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
  119394. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119395. * * The parameter `points` is an array successive Vector3
  119396. * * 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
  119397. * * The optional parameter `colors` is an array of successive Color4, one per line point
  119398. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  119399. * * When updating an instance, remember that only point positions can change, not the number of points
  119400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119401. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  119402. * @param name defines the name of the new line system
  119403. * @param options defines the options used to create the line system
  119404. * @param scene defines the hosting scene
  119405. * @returns a new line mesh
  119406. */
  119407. static CreateLines(name: string, options: {
  119408. points: Vector3[];
  119409. updatable?: boolean;
  119410. instance?: Nullable<LinesMesh>;
  119411. colors?: Color4[];
  119412. useVertexAlpha?: boolean;
  119413. }, scene?: Nullable<Scene>): LinesMesh;
  119414. /**
  119415. * Creates a dashed line mesh
  119416. * * 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
  119417. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  119418. * * The parameter `points` is an array successive Vector3
  119419. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  119420. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  119421. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  119422. * * 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
  119423. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  119424. * * When updating an instance, remember that only point positions can change, not the number of points
  119425. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  119426. * @param name defines the name of the mesh
  119427. * @param options defines the options used to create the mesh
  119428. * @param scene defines the hosting scene
  119429. * @returns the dashed line mesh
  119430. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  119431. */
  119432. static CreateDashedLines(name: string, options: {
  119433. points: Vector3[];
  119434. dashSize?: number;
  119435. gapSize?: number;
  119436. dashNb?: number;
  119437. updatable?: boolean;
  119438. instance?: LinesMesh;
  119439. useVertexAlpha?: boolean;
  119440. }, scene?: Nullable<Scene>): LinesMesh;
  119441. }
  119442. }
  119443. declare module BABYLON {
  119444. /**
  119445. * The options container for the teleportation module
  119446. */
  119447. export interface IWebXRTeleportationOptions {
  119448. /**
  119449. * if provided, this scene will be used to render meshes.
  119450. */
  119451. customUtilityLayerScene?: Scene;
  119452. /**
  119453. * Values to configure the default target mesh
  119454. */
  119455. defaultTargetMeshOptions?: {
  119456. /**
  119457. * Fill color of the teleportation area
  119458. */
  119459. teleportationFillColor?: string;
  119460. /**
  119461. * Border color for the teleportation area
  119462. */
  119463. teleportationBorderColor?: string;
  119464. /**
  119465. * Disable the mesh's animation sequence
  119466. */
  119467. disableAnimation?: boolean;
  119468. /**
  119469. * Disable lighting on the material or the ring and arrow
  119470. */
  119471. disableLighting?: boolean;
  119472. /**
  119473. * Override the default material of the torus and arrow
  119474. */
  119475. torusArrowMaterial?: Material;
  119476. };
  119477. /**
  119478. * A list of meshes to use as floor meshes.
  119479. * Meshes can be added and removed after initializing the feature using the
  119480. * addFloorMesh and removeFloorMesh functions
  119481. * If empty, rotation will still work
  119482. */
  119483. floorMeshes?: AbstractMesh[];
  119484. /**
  119485. * use this rendering group id for the meshes (optional)
  119486. */
  119487. renderingGroupId?: number;
  119488. /**
  119489. * Should teleportation move only to snap points
  119490. */
  119491. snapPointsOnly?: boolean;
  119492. /**
  119493. * An array of points to which the teleportation will snap to.
  119494. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  119495. */
  119496. snapPositions?: Vector3[];
  119497. /**
  119498. * How close should the teleportation ray be in order to snap to position.
  119499. * Default to 0.8 units (meters)
  119500. */
  119501. snapToPositionRadius?: number;
  119502. /**
  119503. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  119504. * If you want to support rotation, make sure your mesh has a direction indicator.
  119505. *
  119506. * When left untouched, the default mesh will be initialized.
  119507. */
  119508. teleportationTargetMesh?: AbstractMesh;
  119509. /**
  119510. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  119511. */
  119512. timeToTeleport?: number;
  119513. /**
  119514. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  119515. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  119516. */
  119517. useMainComponentOnly?: boolean;
  119518. /**
  119519. * Should meshes created here be added to a utility layer or the main scene
  119520. */
  119521. useUtilityLayer?: boolean;
  119522. /**
  119523. * Babylon XR Input class for controller
  119524. */
  119525. xrInput: WebXRInput;
  119526. }
  119527. /**
  119528. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  119529. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  119530. * the input of the attached controllers.
  119531. */
  119532. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  119533. private _options;
  119534. private _controllers;
  119535. private _currentTeleportationControllerId;
  119536. private _floorMeshes;
  119537. private _quadraticBezierCurve;
  119538. private _selectionFeature;
  119539. private _snapToPositions;
  119540. private _snappedToPoint;
  119541. private _teleportationRingMaterial?;
  119542. private _tmpRay;
  119543. private _tmpVector;
  119544. /**
  119545. * The module's name
  119546. */
  119547. static readonly Name: string;
  119548. /**
  119549. * The (Babylon) version of this module.
  119550. * This is an integer representing the implementation version.
  119551. * This number does not correspond to the webxr specs version
  119552. */
  119553. static readonly Version: number;
  119554. /**
  119555. * Is movement backwards enabled
  119556. */
  119557. backwardsMovementEnabled: boolean;
  119558. /**
  119559. * Distance to travel when moving backwards
  119560. */
  119561. backwardsTeleportationDistance: number;
  119562. /**
  119563. * The distance from the user to the inspection point in the direction of the controller
  119564. * A higher number will allow the user to move further
  119565. * defaults to 5 (meters, in xr units)
  119566. */
  119567. parabolicCheckRadius: number;
  119568. /**
  119569. * Should the module support parabolic ray on top of direct ray
  119570. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  119571. * Very helpful when moving between floors / different heights
  119572. */
  119573. parabolicRayEnabled: boolean;
  119574. /**
  119575. * How much rotation should be applied when rotating right and left
  119576. */
  119577. rotationAngle: number;
  119578. /**
  119579. * Is rotation enabled when moving forward?
  119580. * Disabling this feature will prevent the user from deciding the direction when teleporting
  119581. */
  119582. rotationEnabled: boolean;
  119583. /**
  119584. * constructs a new anchor system
  119585. * @param _xrSessionManager an instance of WebXRSessionManager
  119586. * @param _options configuration object for this feature
  119587. */
  119588. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  119589. /**
  119590. * Get the snapPointsOnly flag
  119591. */
  119592. get snapPointsOnly(): boolean;
  119593. /**
  119594. * Sets the snapPointsOnly flag
  119595. * @param snapToPoints should teleportation be exclusively to snap points
  119596. */
  119597. set snapPointsOnly(snapToPoints: boolean);
  119598. /**
  119599. * Add a new mesh to the floor meshes array
  119600. * @param mesh the mesh to use as floor mesh
  119601. */
  119602. addFloorMesh(mesh: AbstractMesh): void;
  119603. /**
  119604. * Add a new snap-to point to fix teleportation to this position
  119605. * @param newSnapPoint The new Snap-To point
  119606. */
  119607. addSnapPoint(newSnapPoint: Vector3): void;
  119608. attach(): boolean;
  119609. detach(): boolean;
  119610. dispose(): void;
  119611. /**
  119612. * Remove a mesh from the floor meshes array
  119613. * @param mesh the mesh to remove
  119614. */
  119615. removeFloorMesh(mesh: AbstractMesh): void;
  119616. /**
  119617. * Remove a mesh from the floor meshes array using its name
  119618. * @param name the mesh name to remove
  119619. */
  119620. removeFloorMeshByName(name: string): void;
  119621. /**
  119622. * 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
  119623. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  119624. * @returns was the point found and removed or not
  119625. */
  119626. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  119627. /**
  119628. * This function sets a selection feature that will be disabled when
  119629. * the forward ray is shown and will be reattached when hidden.
  119630. * This is used to remove the selection rays when moving.
  119631. * @param selectionFeature the feature to disable when forward movement is enabled
  119632. */
  119633. setSelectionFeature(selectionFeature: IWebXRFeature): void;
  119634. protected _onXRFrame(_xrFrame: XRFrame): void;
  119635. private _attachController;
  119636. private _createDefaultTargetMesh;
  119637. private _detachController;
  119638. private _findClosestSnapPointWithRadius;
  119639. private _setTargetMeshPosition;
  119640. private _setTargetMeshVisibility;
  119641. private _showParabolicPath;
  119642. private _teleportForward;
  119643. }
  119644. }
  119645. declare module BABYLON {
  119646. /**
  119647. * Options for the default xr helper
  119648. */
  119649. export class WebXRDefaultExperienceOptions {
  119650. /**
  119651. * Enable or disable default UI to enter XR
  119652. */
  119653. disableDefaultUI?: boolean;
  119654. /**
  119655. * Should teleportation not initialize. defaults to false.
  119656. */
  119657. disableTeleportation?: boolean;
  119658. /**
  119659. * Floor meshes that will be used for teleport
  119660. */
  119661. floorMeshes?: Array<AbstractMesh>;
  119662. /**
  119663. * If set to true, the first frame will not be used to reset position
  119664. * The first frame is mainly used when copying transformation from the old camera
  119665. * Mainly used in AR
  119666. */
  119667. ignoreNativeCameraTransformation?: boolean;
  119668. /**
  119669. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  119670. */
  119671. inputOptions?: IWebXRInputOptions;
  119672. /**
  119673. * optional configuration for the output canvas
  119674. */
  119675. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  119676. /**
  119677. * optional UI options. This can be used among other to change session mode and reference space type
  119678. */
  119679. uiOptions?: WebXREnterExitUIOptions;
  119680. /**
  119681. * When loading teleportation and pointer select, use stable versions instead of latest.
  119682. */
  119683. useStablePlugins?: boolean;
  119684. }
  119685. /**
  119686. * Default experience which provides a similar setup to the previous webVRExperience
  119687. */
  119688. export class WebXRDefaultExperience {
  119689. /**
  119690. * Base experience
  119691. */
  119692. baseExperience: WebXRExperienceHelper;
  119693. /**
  119694. * Enables ui for entering/exiting xr
  119695. */
  119696. enterExitUI: WebXREnterExitUI;
  119697. /**
  119698. * Input experience extension
  119699. */
  119700. input: WebXRInput;
  119701. /**
  119702. * Enables laser pointer and selection
  119703. */
  119704. pointerSelection: WebXRControllerPointerSelection;
  119705. /**
  119706. * Default target xr should render to
  119707. */
  119708. renderTarget: WebXRRenderTarget;
  119709. /**
  119710. * Enables teleportation
  119711. */
  119712. teleportation: WebXRMotionControllerTeleportation;
  119713. private constructor();
  119714. /**
  119715. * Creates the default xr experience
  119716. * @param scene scene
  119717. * @param options options for basic configuration
  119718. * @returns resulting WebXRDefaultExperience
  119719. */
  119720. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  119721. /**
  119722. * DIsposes of the experience helper
  119723. */
  119724. dispose(): void;
  119725. }
  119726. }
  119727. declare module BABYLON {
  119728. /**
  119729. * Options to modify the vr teleportation behavior.
  119730. */
  119731. export interface VRTeleportationOptions {
  119732. /**
  119733. * The name of the mesh which should be used as the teleportation floor. (default: null)
  119734. */
  119735. floorMeshName?: string;
  119736. /**
  119737. * A list of meshes to be used as the teleportation floor. (default: empty)
  119738. */
  119739. floorMeshes?: Mesh[];
  119740. /**
  119741. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  119742. */
  119743. teleportationMode?: number;
  119744. /**
  119745. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  119746. */
  119747. teleportationTime?: number;
  119748. /**
  119749. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  119750. */
  119751. teleportationSpeed?: number;
  119752. /**
  119753. * The easing function used in the animation or null for Linear. (default CircleEase)
  119754. */
  119755. easingFunction?: EasingFunction;
  119756. }
  119757. /**
  119758. * Options to modify the vr experience helper's behavior.
  119759. */
  119760. export interface VRExperienceHelperOptions extends WebVROptions {
  119761. /**
  119762. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  119763. */
  119764. createDeviceOrientationCamera?: boolean;
  119765. /**
  119766. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  119767. */
  119768. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  119769. /**
  119770. * Uses the main button on the controller to toggle the laser casted. (default: true)
  119771. */
  119772. laserToggle?: boolean;
  119773. /**
  119774. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  119775. */
  119776. floorMeshes?: Mesh[];
  119777. /**
  119778. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  119779. */
  119780. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  119781. /**
  119782. * Defines if WebXR should be used instead of WebVR (if available)
  119783. */
  119784. useXR?: boolean;
  119785. }
  119786. /**
  119787. * Event containing information after VR has been entered
  119788. */
  119789. export class OnAfterEnteringVRObservableEvent {
  119790. /**
  119791. * If entering vr was successful
  119792. */
  119793. success: boolean;
  119794. }
  119795. /**
  119796. * Helps to quickly add VR support to an existing scene.
  119797. * See http://doc.babylonjs.com/how_to/webvr_helper
  119798. */
  119799. export class VRExperienceHelper {
  119800. /** Options to modify the vr experience helper's behavior. */
  119801. webVROptions: VRExperienceHelperOptions;
  119802. private _scene;
  119803. private _position;
  119804. private _btnVR;
  119805. private _btnVRDisplayed;
  119806. private _webVRsupported;
  119807. private _webVRready;
  119808. private _webVRrequesting;
  119809. private _webVRpresenting;
  119810. private _hasEnteredVR;
  119811. private _fullscreenVRpresenting;
  119812. private _inputElement;
  119813. private _webVRCamera;
  119814. private _vrDeviceOrientationCamera;
  119815. private _deviceOrientationCamera;
  119816. private _existingCamera;
  119817. private _onKeyDown;
  119818. private _onVrDisplayPresentChange;
  119819. private _onVRDisplayChanged;
  119820. private _onVRRequestPresentStart;
  119821. private _onVRRequestPresentComplete;
  119822. /**
  119823. * 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)
  119824. */
  119825. enableGazeEvenWhenNoPointerLock: boolean;
  119826. /**
  119827. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  119828. */
  119829. exitVROnDoubleTap: boolean;
  119830. /**
  119831. * Observable raised right before entering VR.
  119832. */
  119833. onEnteringVRObservable: Observable<VRExperienceHelper>;
  119834. /**
  119835. * Observable raised when entering VR has completed.
  119836. */
  119837. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  119838. /**
  119839. * Observable raised when exiting VR.
  119840. */
  119841. onExitingVRObservable: Observable<VRExperienceHelper>;
  119842. /**
  119843. * Observable raised when controller mesh is loaded.
  119844. */
  119845. onControllerMeshLoadedObservable: Observable<WebVRController>;
  119846. /** Return this.onEnteringVRObservable
  119847. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  119848. */
  119849. get onEnteringVR(): Observable<VRExperienceHelper>;
  119850. /** Return this.onExitingVRObservable
  119851. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  119852. */
  119853. get onExitingVR(): Observable<VRExperienceHelper>;
  119854. /** Return this.onControllerMeshLoadedObservable
  119855. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  119856. */
  119857. get onControllerMeshLoaded(): Observable<WebVRController>;
  119858. private _rayLength;
  119859. private _useCustomVRButton;
  119860. private _teleportationRequested;
  119861. private _teleportActive;
  119862. private _floorMeshName;
  119863. private _floorMeshesCollection;
  119864. private _teleportationMode;
  119865. private _teleportationTime;
  119866. private _teleportationSpeed;
  119867. private _teleportationEasing;
  119868. private _rotationAllowed;
  119869. private _teleportBackwardsVector;
  119870. private _teleportationTarget;
  119871. private _isDefaultTeleportationTarget;
  119872. private _postProcessMove;
  119873. private _teleportationFillColor;
  119874. private _teleportationBorderColor;
  119875. private _rotationAngle;
  119876. private _haloCenter;
  119877. private _cameraGazer;
  119878. private _padSensibilityUp;
  119879. private _padSensibilityDown;
  119880. private _leftController;
  119881. private _rightController;
  119882. private _gazeColor;
  119883. private _laserColor;
  119884. private _pickedLaserColor;
  119885. private _pickedGazeColor;
  119886. /**
  119887. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  119888. */
  119889. onNewMeshSelected: Observable<AbstractMesh>;
  119890. /**
  119891. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  119892. * This observable will provide the mesh and the controller used to select the mesh
  119893. */
  119894. onMeshSelectedWithController: Observable<{
  119895. mesh: AbstractMesh;
  119896. controller: WebVRController;
  119897. }>;
  119898. /**
  119899. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  119900. */
  119901. onNewMeshPicked: Observable<PickingInfo>;
  119902. private _circleEase;
  119903. /**
  119904. * Observable raised before camera teleportation
  119905. */
  119906. onBeforeCameraTeleport: Observable<Vector3>;
  119907. /**
  119908. * Observable raised after camera teleportation
  119909. */
  119910. onAfterCameraTeleport: Observable<Vector3>;
  119911. /**
  119912. * Observable raised when current selected mesh gets unselected
  119913. */
  119914. onSelectedMeshUnselected: Observable<AbstractMesh>;
  119915. private _raySelectionPredicate;
  119916. /**
  119917. * To be optionaly changed by user to define custom ray selection
  119918. */
  119919. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  119920. /**
  119921. * To be optionaly changed by user to define custom selection logic (after ray selection)
  119922. */
  119923. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  119924. /**
  119925. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  119926. */
  119927. teleportationEnabled: boolean;
  119928. private _defaultHeight;
  119929. private _teleportationInitialized;
  119930. private _interactionsEnabled;
  119931. private _interactionsRequested;
  119932. private _displayGaze;
  119933. private _displayLaserPointer;
  119934. /**
  119935. * The mesh used to display where the user is going to teleport.
  119936. */
  119937. get teleportationTarget(): Mesh;
  119938. /**
  119939. * Sets the mesh to be used to display where the user is going to teleport.
  119940. */
  119941. set teleportationTarget(value: Mesh);
  119942. /**
  119943. * 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
  119944. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  119945. * See http://doc.babylonjs.com/resources/baking_transformations
  119946. */
  119947. get gazeTrackerMesh(): Mesh;
  119948. set gazeTrackerMesh(value: Mesh);
  119949. /**
  119950. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  119951. */
  119952. updateGazeTrackerScale: boolean;
  119953. /**
  119954. * If the gaze trackers color should be updated when selecting meshes
  119955. */
  119956. updateGazeTrackerColor: boolean;
  119957. /**
  119958. * If the controller laser color should be updated when selecting meshes
  119959. */
  119960. updateControllerLaserColor: boolean;
  119961. /**
  119962. * The gaze tracking mesh corresponding to the left controller
  119963. */
  119964. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  119965. /**
  119966. * The gaze tracking mesh corresponding to the right controller
  119967. */
  119968. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  119969. /**
  119970. * If the ray of the gaze should be displayed.
  119971. */
  119972. get displayGaze(): boolean;
  119973. /**
  119974. * Sets if the ray of the gaze should be displayed.
  119975. */
  119976. set displayGaze(value: boolean);
  119977. /**
  119978. * If the ray of the LaserPointer should be displayed.
  119979. */
  119980. get displayLaserPointer(): boolean;
  119981. /**
  119982. * Sets if the ray of the LaserPointer should be displayed.
  119983. */
  119984. set displayLaserPointer(value: boolean);
  119985. /**
  119986. * The deviceOrientationCamera used as the camera when not in VR.
  119987. */
  119988. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  119989. /**
  119990. * Based on the current WebVR support, returns the current VR camera used.
  119991. */
  119992. get currentVRCamera(): Nullable<Camera>;
  119993. /**
  119994. * The webVRCamera which is used when in VR.
  119995. */
  119996. get webVRCamera(): WebVRFreeCamera;
  119997. /**
  119998. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  119999. */
  120000. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  120001. /**
  120002. * The html button that is used to trigger entering into VR.
  120003. */
  120004. get vrButton(): Nullable<HTMLButtonElement>;
  120005. private get _teleportationRequestInitiated();
  120006. /**
  120007. * Defines whether or not Pointer lock should be requested when switching to
  120008. * full screen.
  120009. */
  120010. requestPointerLockOnFullScreen: boolean;
  120011. /**
  120012. * If asking to force XR, this will be populated with the default xr experience
  120013. */
  120014. xr: WebXRDefaultExperience;
  120015. /**
  120016. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  120017. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  120018. */
  120019. xrTestDone: boolean;
  120020. /**
  120021. * Instantiates a VRExperienceHelper.
  120022. * Helps to quickly add VR support to an existing scene.
  120023. * @param scene The scene the VRExperienceHelper belongs to.
  120024. * @param webVROptions Options to modify the vr experience helper's behavior.
  120025. */
  120026. constructor(scene: Scene,
  120027. /** Options to modify the vr experience helper's behavior. */
  120028. webVROptions?: VRExperienceHelperOptions);
  120029. private completeVRInit;
  120030. private _onDefaultMeshLoaded;
  120031. private _onResize;
  120032. private _onFullscreenChange;
  120033. /**
  120034. * Gets a value indicating if we are currently in VR mode.
  120035. */
  120036. get isInVRMode(): boolean;
  120037. private onVrDisplayPresentChange;
  120038. private onVRDisplayChanged;
  120039. private moveButtonToBottomRight;
  120040. private displayVRButton;
  120041. private updateButtonVisibility;
  120042. private _cachedAngularSensibility;
  120043. /**
  120044. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  120045. * Otherwise, will use the fullscreen API.
  120046. */
  120047. enterVR(): void;
  120048. /**
  120049. * Attempt to exit VR, or fullscreen.
  120050. */
  120051. exitVR(): void;
  120052. /**
  120053. * The position of the vr experience helper.
  120054. */
  120055. get position(): Vector3;
  120056. /**
  120057. * Sets the position of the vr experience helper.
  120058. */
  120059. set position(value: Vector3);
  120060. /**
  120061. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  120062. */
  120063. enableInteractions(): void;
  120064. private get _noControllerIsActive();
  120065. private beforeRender;
  120066. private _isTeleportationFloor;
  120067. /**
  120068. * Adds a floor mesh to be used for teleportation.
  120069. * @param floorMesh the mesh to be used for teleportation.
  120070. */
  120071. addFloorMesh(floorMesh: Mesh): void;
  120072. /**
  120073. * Removes a floor mesh from being used for teleportation.
  120074. * @param floorMesh the mesh to be removed.
  120075. */
  120076. removeFloorMesh(floorMesh: Mesh): void;
  120077. /**
  120078. * Enables interactions and teleportation using the VR controllers and gaze.
  120079. * @param vrTeleportationOptions options to modify teleportation behavior.
  120080. */
  120081. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  120082. private _onNewGamepadConnected;
  120083. private _tryEnableInteractionOnController;
  120084. private _onNewGamepadDisconnected;
  120085. private _enableInteractionOnController;
  120086. private _checkTeleportWithRay;
  120087. private _checkRotate;
  120088. private _checkTeleportBackwards;
  120089. private _enableTeleportationOnController;
  120090. private _createTeleportationCircles;
  120091. private _displayTeleportationTarget;
  120092. private _hideTeleportationTarget;
  120093. private _rotateCamera;
  120094. private _moveTeleportationSelectorTo;
  120095. private _workingVector;
  120096. private _workingQuaternion;
  120097. private _workingMatrix;
  120098. /**
  120099. * Time Constant Teleportation Mode
  120100. */
  120101. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  120102. /**
  120103. * Speed Constant Teleportation Mode
  120104. */
  120105. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  120106. /**
  120107. * Teleports the users feet to the desired location
  120108. * @param location The location where the user's feet should be placed
  120109. */
  120110. teleportCamera(location: Vector3): void;
  120111. private _convertNormalToDirectionOfRay;
  120112. private _castRayAndSelectObject;
  120113. private _notifySelectedMeshUnselected;
  120114. /**
  120115. * Permanently set new colors for the laser pointer
  120116. * @param color the new laser color
  120117. * @param pickedColor the new laser color when picked mesh detected
  120118. */
  120119. setLaserColor(color: Color3, pickedColor?: Color3): void;
  120120. /**
  120121. * Set lighting enabled / disabled on the laser pointer of both controllers
  120122. * @param enabled should the lighting be enabled on the laser pointer
  120123. */
  120124. setLaserLightingState(enabled?: boolean): void;
  120125. /**
  120126. * Permanently set new colors for the gaze pointer
  120127. * @param color the new gaze color
  120128. * @param pickedColor the new gaze color when picked mesh detected
  120129. */
  120130. setGazeColor(color: Color3, pickedColor?: Color3): void;
  120131. /**
  120132. * Sets the color of the laser ray from the vr controllers.
  120133. * @param color new color for the ray.
  120134. */
  120135. changeLaserColor(color: Color3): void;
  120136. /**
  120137. * Sets the color of the ray from the vr headsets gaze.
  120138. * @param color new color for the ray.
  120139. */
  120140. changeGazeColor(color: Color3): void;
  120141. /**
  120142. * Exits VR and disposes of the vr experience helper
  120143. */
  120144. dispose(): void;
  120145. /**
  120146. * Gets the name of the VRExperienceHelper class
  120147. * @returns "VRExperienceHelper"
  120148. */
  120149. getClassName(): string;
  120150. }
  120151. }
  120152. declare module BABYLON {
  120153. /**
  120154. * Contains an array of blocks representing the octree
  120155. */
  120156. export interface IOctreeContainer<T> {
  120157. /**
  120158. * Blocks within the octree
  120159. */
  120160. blocks: Array<OctreeBlock<T>>;
  120161. }
  120162. /**
  120163. * Class used to store a cell in an octree
  120164. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120165. */
  120166. export class OctreeBlock<T> {
  120167. /**
  120168. * Gets the content of the current block
  120169. */
  120170. entries: T[];
  120171. /**
  120172. * Gets the list of block children
  120173. */
  120174. blocks: Array<OctreeBlock<T>>;
  120175. private _depth;
  120176. private _maxDepth;
  120177. private _capacity;
  120178. private _minPoint;
  120179. private _maxPoint;
  120180. private _boundingVectors;
  120181. private _creationFunc;
  120182. /**
  120183. * Creates a new block
  120184. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  120185. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  120186. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120187. * @param depth defines the current depth of this block in the octree
  120188. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  120189. * @param creationFunc defines a callback to call when an element is added to the block
  120190. */
  120191. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  120192. /**
  120193. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  120194. */
  120195. get capacity(): number;
  120196. /**
  120197. * Gets the minimum vector (in world space) of the block's bounding box
  120198. */
  120199. get minPoint(): Vector3;
  120200. /**
  120201. * Gets the maximum vector (in world space) of the block's bounding box
  120202. */
  120203. get maxPoint(): Vector3;
  120204. /**
  120205. * Add a new element to this block
  120206. * @param entry defines the element to add
  120207. */
  120208. addEntry(entry: T): void;
  120209. /**
  120210. * Remove an element from this block
  120211. * @param entry defines the element to remove
  120212. */
  120213. removeEntry(entry: T): void;
  120214. /**
  120215. * Add an array of elements to this block
  120216. * @param entries defines the array of elements to add
  120217. */
  120218. addEntries(entries: T[]): void;
  120219. /**
  120220. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  120221. * @param frustumPlanes defines the frustum planes to test
  120222. * @param selection defines the array to store current content if selection is positive
  120223. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120224. */
  120225. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120226. /**
  120227. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  120228. * @param sphereCenter defines the bounding sphere center
  120229. * @param sphereRadius defines the bounding sphere radius
  120230. * @param selection defines the array to store current content if selection is positive
  120231. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120232. */
  120233. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  120234. /**
  120235. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  120236. * @param ray defines the ray to test with
  120237. * @param selection defines the array to store current content if selection is positive
  120238. */
  120239. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  120240. /**
  120241. * Subdivide the content into child blocks (this block will then be empty)
  120242. */
  120243. createInnerBlocks(): void;
  120244. /**
  120245. * @hidden
  120246. */
  120247. 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;
  120248. }
  120249. }
  120250. declare module BABYLON {
  120251. /**
  120252. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  120253. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120254. */
  120255. export class Octree<T> {
  120256. /** 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.) */
  120257. maxDepth: number;
  120258. /**
  120259. * Blocks within the octree containing objects
  120260. */
  120261. blocks: Array<OctreeBlock<T>>;
  120262. /**
  120263. * Content stored in the octree
  120264. */
  120265. dynamicContent: T[];
  120266. private _maxBlockCapacity;
  120267. private _selectionContent;
  120268. private _creationFunc;
  120269. /**
  120270. * Creates a octree
  120271. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120272. * @param creationFunc function to be used to instatiate the octree
  120273. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  120274. * @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.)
  120275. */
  120276. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  120277. /** 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.) */
  120278. maxDepth?: number);
  120279. /**
  120280. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  120281. * @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);
  120282. * @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);
  120283. * @param entries meshes to be added to the octree blocks
  120284. */
  120285. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  120286. /**
  120287. * Adds a mesh to the octree
  120288. * @param entry Mesh to add to the octree
  120289. */
  120290. addMesh(entry: T): void;
  120291. /**
  120292. * Remove an element from the octree
  120293. * @param entry defines the element to remove
  120294. */
  120295. removeMesh(entry: T): void;
  120296. /**
  120297. * Selects an array of meshes within the frustum
  120298. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  120299. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  120300. * @returns array of meshes within the frustum
  120301. */
  120302. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  120303. /**
  120304. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  120305. * @param sphereCenter defines the bounding sphere center
  120306. * @param sphereRadius defines the bounding sphere radius
  120307. * @param allowDuplicate defines if the selection array can contains duplicated entries
  120308. * @returns an array of objects that intersect the sphere
  120309. */
  120310. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  120311. /**
  120312. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  120313. * @param ray defines the ray to test with
  120314. * @returns array of intersected objects
  120315. */
  120316. intersectsRay(ray: Ray): SmartArray<T>;
  120317. /**
  120318. * Adds a mesh into the octree block if it intersects the block
  120319. */
  120320. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  120321. /**
  120322. * Adds a submesh into the octree block if it intersects the block
  120323. */
  120324. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  120325. }
  120326. }
  120327. declare module BABYLON {
  120328. interface Scene {
  120329. /**
  120330. * @hidden
  120331. * Backing Filed
  120332. */
  120333. _selectionOctree: Octree<AbstractMesh>;
  120334. /**
  120335. * Gets the octree used to boost mesh selection (picking)
  120336. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120337. */
  120338. selectionOctree: Octree<AbstractMesh>;
  120339. /**
  120340. * Creates or updates the octree used to boost selection (picking)
  120341. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120342. * @param maxCapacity defines the maximum capacity per leaf
  120343. * @param maxDepth defines the maximum depth of the octree
  120344. * @returns an octree of AbstractMesh
  120345. */
  120346. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  120347. }
  120348. interface AbstractMesh {
  120349. /**
  120350. * @hidden
  120351. * Backing Field
  120352. */
  120353. _submeshesOctree: Octree<SubMesh>;
  120354. /**
  120355. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  120356. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  120357. * @param maxCapacity defines the maximum size of each block (64 by default)
  120358. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  120359. * @returns the new octree
  120360. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  120361. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  120362. */
  120363. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  120364. }
  120365. /**
  120366. * Defines the octree scene component responsible to manage any octrees
  120367. * in a given scene.
  120368. */
  120369. export class OctreeSceneComponent {
  120370. /**
  120371. * The component name help to identify the component in the list of scene components.
  120372. */
  120373. readonly name: string;
  120374. /**
  120375. * The scene the component belongs to.
  120376. */
  120377. scene: Scene;
  120378. /**
  120379. * Indicates if the meshes have been checked to make sure they are isEnabled()
  120380. */
  120381. readonly checksIsEnabled: boolean;
  120382. /**
  120383. * Creates a new instance of the component for the given scene
  120384. * @param scene Defines the scene to register the component in
  120385. */
  120386. constructor(scene: Scene);
  120387. /**
  120388. * Registers the component in a given scene
  120389. */
  120390. register(): void;
  120391. /**
  120392. * Return the list of active meshes
  120393. * @returns the list of active meshes
  120394. */
  120395. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120396. /**
  120397. * Return the list of active sub meshes
  120398. * @param mesh The mesh to get the candidates sub meshes from
  120399. * @returns the list of active sub meshes
  120400. */
  120401. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120402. private _tempRay;
  120403. /**
  120404. * Return the list of sub meshes intersecting with a given local ray
  120405. * @param mesh defines the mesh to find the submesh for
  120406. * @param localRay defines the ray in local space
  120407. * @returns the list of intersecting sub meshes
  120408. */
  120409. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  120410. /**
  120411. * Return the list of sub meshes colliding with a collider
  120412. * @param mesh defines the mesh to find the submesh for
  120413. * @param collider defines the collider to evaluate the collision against
  120414. * @returns the list of colliding sub meshes
  120415. */
  120416. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  120417. /**
  120418. * Rebuilds the elements related to this component in case of
  120419. * context lost for instance.
  120420. */
  120421. rebuild(): void;
  120422. /**
  120423. * Disposes the component and the associated ressources.
  120424. */
  120425. dispose(): void;
  120426. }
  120427. }
  120428. declare module BABYLON {
  120429. /**
  120430. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  120431. */
  120432. export class Gizmo implements IDisposable {
  120433. /** The utility layer the gizmo will be added to */
  120434. gizmoLayer: UtilityLayerRenderer;
  120435. /**
  120436. * The root mesh of the gizmo
  120437. */
  120438. _rootMesh: Mesh;
  120439. private _attachedMesh;
  120440. /**
  120441. * Ratio for the scale of the gizmo (Default: 1)
  120442. */
  120443. scaleRatio: number;
  120444. /**
  120445. * If a custom mesh has been set (Default: false)
  120446. */
  120447. protected _customMeshSet: boolean;
  120448. /**
  120449. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  120450. * * When set, interactions will be enabled
  120451. */
  120452. get attachedMesh(): Nullable<AbstractMesh>;
  120453. set attachedMesh(value: Nullable<AbstractMesh>);
  120454. /**
  120455. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  120456. * @param mesh The mesh to replace the default mesh of the gizmo
  120457. */
  120458. setCustomMesh(mesh: Mesh): void;
  120459. /**
  120460. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  120461. */
  120462. updateGizmoRotationToMatchAttachedMesh: boolean;
  120463. /**
  120464. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  120465. */
  120466. updateGizmoPositionToMatchAttachedMesh: boolean;
  120467. /**
  120468. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  120469. */
  120470. updateScale: boolean;
  120471. protected _interactionsEnabled: boolean;
  120472. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120473. private _beforeRenderObserver;
  120474. private _tempVector;
  120475. /**
  120476. * Creates a gizmo
  120477. * @param gizmoLayer The utility layer the gizmo will be added to
  120478. */
  120479. constructor(
  120480. /** The utility layer the gizmo will be added to */
  120481. gizmoLayer?: UtilityLayerRenderer);
  120482. /**
  120483. * Updates the gizmo to match the attached mesh's position/rotation
  120484. */
  120485. protected _update(): void;
  120486. /**
  120487. * Disposes of the gizmo
  120488. */
  120489. dispose(): void;
  120490. }
  120491. }
  120492. declare module BABYLON {
  120493. /**
  120494. * Single plane drag gizmo
  120495. */
  120496. export class PlaneDragGizmo extends Gizmo {
  120497. /**
  120498. * Drag behavior responsible for the gizmos dragging interactions
  120499. */
  120500. dragBehavior: PointerDragBehavior;
  120501. private _pointerObserver;
  120502. /**
  120503. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120504. */
  120505. snapDistance: number;
  120506. /**
  120507. * Event that fires each time the gizmo snaps to a new location.
  120508. * * snapDistance is the the change in distance
  120509. */
  120510. onSnapObservable: Observable<{
  120511. snapDistance: number;
  120512. }>;
  120513. private _plane;
  120514. private _coloredMaterial;
  120515. private _hoverMaterial;
  120516. private _isEnabled;
  120517. private _parent;
  120518. /** @hidden */
  120519. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  120520. /** @hidden */
  120521. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120522. /**
  120523. * Creates a PlaneDragGizmo
  120524. * @param gizmoLayer The utility layer the gizmo will be added to
  120525. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  120526. * @param color The color of the gizmo
  120527. */
  120528. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120529. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120530. /**
  120531. * If the gizmo is enabled
  120532. */
  120533. set isEnabled(value: boolean);
  120534. get isEnabled(): boolean;
  120535. /**
  120536. * Disposes of the gizmo
  120537. */
  120538. dispose(): void;
  120539. }
  120540. }
  120541. declare module BABYLON {
  120542. /**
  120543. * Gizmo that enables dragging a mesh along 3 axis
  120544. */
  120545. export class PositionGizmo extends Gizmo {
  120546. /**
  120547. * Internal gizmo used for interactions on the x axis
  120548. */
  120549. xGizmo: AxisDragGizmo;
  120550. /**
  120551. * Internal gizmo used for interactions on the y axis
  120552. */
  120553. yGizmo: AxisDragGizmo;
  120554. /**
  120555. * Internal gizmo used for interactions on the z axis
  120556. */
  120557. zGizmo: AxisDragGizmo;
  120558. /**
  120559. * Internal gizmo used for interactions on the yz plane
  120560. */
  120561. xPlaneGizmo: PlaneDragGizmo;
  120562. /**
  120563. * Internal gizmo used for interactions on the xz plane
  120564. */
  120565. yPlaneGizmo: PlaneDragGizmo;
  120566. /**
  120567. * Internal gizmo used for interactions on the xy plane
  120568. */
  120569. zPlaneGizmo: PlaneDragGizmo;
  120570. /**
  120571. * private variables
  120572. */
  120573. private _meshAttached;
  120574. private _updateGizmoRotationToMatchAttachedMesh;
  120575. private _snapDistance;
  120576. private _scaleRatio;
  120577. /** Fires an event when any of it's sub gizmos are dragged */
  120578. onDragStartObservable: Observable<unknown>;
  120579. /** Fires an event when any of it's sub gizmos are released from dragging */
  120580. onDragEndObservable: Observable<unknown>;
  120581. /**
  120582. * If set to true, planar drag is enabled
  120583. */
  120584. private _planarGizmoEnabled;
  120585. get attachedMesh(): Nullable<AbstractMesh>;
  120586. set attachedMesh(mesh: Nullable<AbstractMesh>);
  120587. /**
  120588. * Creates a PositionGizmo
  120589. * @param gizmoLayer The utility layer the gizmo will be added to
  120590. */
  120591. constructor(gizmoLayer?: UtilityLayerRenderer);
  120592. /**
  120593. * If the planar drag gizmo is enabled
  120594. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  120595. */
  120596. set planarGizmoEnabled(value: boolean);
  120597. get planarGizmoEnabled(): boolean;
  120598. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  120599. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  120600. /**
  120601. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120602. */
  120603. set snapDistance(value: number);
  120604. get snapDistance(): number;
  120605. /**
  120606. * Ratio for the scale of the gizmo (Default: 1)
  120607. */
  120608. set scaleRatio(value: number);
  120609. get scaleRatio(): number;
  120610. /**
  120611. * Disposes of the gizmo
  120612. */
  120613. dispose(): void;
  120614. /**
  120615. * CustomMeshes are not supported by this gizmo
  120616. * @param mesh The mesh to replace the default mesh of the gizmo
  120617. */
  120618. setCustomMesh(mesh: Mesh): void;
  120619. }
  120620. }
  120621. declare module BABYLON {
  120622. /**
  120623. * Single axis drag gizmo
  120624. */
  120625. export class AxisDragGizmo extends Gizmo {
  120626. /**
  120627. * Drag behavior responsible for the gizmos dragging interactions
  120628. */
  120629. dragBehavior: PointerDragBehavior;
  120630. private _pointerObserver;
  120631. /**
  120632. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  120633. */
  120634. snapDistance: number;
  120635. /**
  120636. * Event that fires each time the gizmo snaps to a new location.
  120637. * * snapDistance is the the change in distance
  120638. */
  120639. onSnapObservable: Observable<{
  120640. snapDistance: number;
  120641. }>;
  120642. private _isEnabled;
  120643. private _parent;
  120644. private _arrow;
  120645. private _coloredMaterial;
  120646. private _hoverMaterial;
  120647. /** @hidden */
  120648. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  120649. /** @hidden */
  120650. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  120651. /**
  120652. * Creates an AxisDragGizmo
  120653. * @param gizmoLayer The utility layer the gizmo will be added to
  120654. * @param dragAxis The axis which the gizmo will be able to drag on
  120655. * @param color The color of the gizmo
  120656. */
  120657. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  120658. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  120659. /**
  120660. * If the gizmo is enabled
  120661. */
  120662. set isEnabled(value: boolean);
  120663. get isEnabled(): boolean;
  120664. /**
  120665. * Disposes of the gizmo
  120666. */
  120667. dispose(): void;
  120668. }
  120669. }
  120670. declare module BABYLON.Debug {
  120671. /**
  120672. * The Axes viewer will show 3 axes in a specific point in space
  120673. */
  120674. export class AxesViewer {
  120675. private _xAxis;
  120676. private _yAxis;
  120677. private _zAxis;
  120678. private _scaleLinesFactor;
  120679. private _instanced;
  120680. /**
  120681. * Gets the hosting scene
  120682. */
  120683. scene: Scene;
  120684. /**
  120685. * Gets or sets a number used to scale line length
  120686. */
  120687. scaleLines: number;
  120688. /** Gets the node hierarchy used to render x-axis */
  120689. get xAxis(): TransformNode;
  120690. /** Gets the node hierarchy used to render y-axis */
  120691. get yAxis(): TransformNode;
  120692. /** Gets the node hierarchy used to render z-axis */
  120693. get zAxis(): TransformNode;
  120694. /**
  120695. * Creates a new AxesViewer
  120696. * @param scene defines the hosting scene
  120697. * @param scaleLines defines a number used to scale line length (1 by default)
  120698. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  120699. * @param xAxis defines the node hierarchy used to render the x-axis
  120700. * @param yAxis defines the node hierarchy used to render the y-axis
  120701. * @param zAxis defines the node hierarchy used to render the z-axis
  120702. */
  120703. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  120704. /**
  120705. * Force the viewer to update
  120706. * @param position defines the position of the viewer
  120707. * @param xaxis defines the x axis of the viewer
  120708. * @param yaxis defines the y axis of the viewer
  120709. * @param zaxis defines the z axis of the viewer
  120710. */
  120711. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  120712. /**
  120713. * Creates an instance of this axes viewer.
  120714. * @returns a new axes viewer with instanced meshes
  120715. */
  120716. createInstance(): AxesViewer;
  120717. /** Releases resources */
  120718. dispose(): void;
  120719. private static _SetRenderingGroupId;
  120720. }
  120721. }
  120722. declare module BABYLON.Debug {
  120723. /**
  120724. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  120725. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  120726. */
  120727. export class BoneAxesViewer extends AxesViewer {
  120728. /**
  120729. * Gets or sets the target mesh where to display the axes viewer
  120730. */
  120731. mesh: Nullable<Mesh>;
  120732. /**
  120733. * Gets or sets the target bone where to display the axes viewer
  120734. */
  120735. bone: Nullable<Bone>;
  120736. /** Gets current position */
  120737. pos: Vector3;
  120738. /** Gets direction of X axis */
  120739. xaxis: Vector3;
  120740. /** Gets direction of Y axis */
  120741. yaxis: Vector3;
  120742. /** Gets direction of Z axis */
  120743. zaxis: Vector3;
  120744. /**
  120745. * Creates a new BoneAxesViewer
  120746. * @param scene defines the hosting scene
  120747. * @param bone defines the target bone
  120748. * @param mesh defines the target mesh
  120749. * @param scaleLines defines a scaling factor for line length (1 by default)
  120750. */
  120751. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  120752. /**
  120753. * Force the viewer to update
  120754. */
  120755. update(): void;
  120756. /** Releases resources */
  120757. dispose(): void;
  120758. }
  120759. }
  120760. declare module BABYLON {
  120761. /**
  120762. * Interface used to define scene explorer extensibility option
  120763. */
  120764. export interface IExplorerExtensibilityOption {
  120765. /**
  120766. * Define the option label
  120767. */
  120768. label: string;
  120769. /**
  120770. * Defines the action to execute on click
  120771. */
  120772. action: (entity: any) => void;
  120773. }
  120774. /**
  120775. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  120776. */
  120777. export interface IExplorerExtensibilityGroup {
  120778. /**
  120779. * Defines a predicate to test if a given type mut be extended
  120780. */
  120781. predicate: (entity: any) => boolean;
  120782. /**
  120783. * Gets the list of options added to a type
  120784. */
  120785. entries: IExplorerExtensibilityOption[];
  120786. }
  120787. /**
  120788. * Interface used to define the options to use to create the Inspector
  120789. */
  120790. export interface IInspectorOptions {
  120791. /**
  120792. * Display in overlay mode (default: false)
  120793. */
  120794. overlay?: boolean;
  120795. /**
  120796. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  120797. */
  120798. globalRoot?: HTMLElement;
  120799. /**
  120800. * Display the Scene explorer
  120801. */
  120802. showExplorer?: boolean;
  120803. /**
  120804. * Display the property inspector
  120805. */
  120806. showInspector?: boolean;
  120807. /**
  120808. * Display in embed mode (both panes on the right)
  120809. */
  120810. embedMode?: boolean;
  120811. /**
  120812. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  120813. */
  120814. handleResize?: boolean;
  120815. /**
  120816. * Allow the panes to popup (default: true)
  120817. */
  120818. enablePopup?: boolean;
  120819. /**
  120820. * Allow the panes to be closed by users (default: true)
  120821. */
  120822. enableClose?: boolean;
  120823. /**
  120824. * Optional list of extensibility entries
  120825. */
  120826. explorerExtensibility?: IExplorerExtensibilityGroup[];
  120827. /**
  120828. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  120829. */
  120830. inspectorURL?: string;
  120831. /**
  120832. * Optional initial tab (default to DebugLayerTab.Properties)
  120833. */
  120834. initialTab?: DebugLayerTab;
  120835. }
  120836. interface Scene {
  120837. /**
  120838. * @hidden
  120839. * Backing field
  120840. */
  120841. _debugLayer: DebugLayer;
  120842. /**
  120843. * Gets the debug layer (aka Inspector) associated with the scene
  120844. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120845. */
  120846. debugLayer: DebugLayer;
  120847. }
  120848. /**
  120849. * Enum of inspector action tab
  120850. */
  120851. export enum DebugLayerTab {
  120852. /**
  120853. * Properties tag (default)
  120854. */
  120855. Properties = 0,
  120856. /**
  120857. * Debug tab
  120858. */
  120859. Debug = 1,
  120860. /**
  120861. * Statistics tab
  120862. */
  120863. Statistics = 2,
  120864. /**
  120865. * Tools tab
  120866. */
  120867. Tools = 3,
  120868. /**
  120869. * Settings tab
  120870. */
  120871. Settings = 4
  120872. }
  120873. /**
  120874. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120875. * what is happening in your scene
  120876. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120877. */
  120878. export class DebugLayer {
  120879. /**
  120880. * Define the url to get the inspector script from.
  120881. * By default it uses the babylonjs CDN.
  120882. * @ignoreNaming
  120883. */
  120884. static InspectorURL: string;
  120885. private _scene;
  120886. private BJSINSPECTOR;
  120887. private _onPropertyChangedObservable?;
  120888. /**
  120889. * Observable triggered when a property is changed through the inspector.
  120890. */
  120891. get onPropertyChangedObservable(): any;
  120892. /**
  120893. * Instantiates a new debug layer.
  120894. * The debug layer (aka Inspector) is the go to tool in order to better understand
  120895. * what is happening in your scene
  120896. * @see http://doc.babylonjs.com/features/playground_debuglayer
  120897. * @param scene Defines the scene to inspect
  120898. */
  120899. constructor(scene: Scene);
  120900. /** Creates the inspector window. */
  120901. private _createInspector;
  120902. /**
  120903. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  120904. * @param entity defines the entity to select
  120905. * @param lineContainerTitle defines the specific block to highlight
  120906. */
  120907. select(entity: any, lineContainerTitle?: string): void;
  120908. /** Get the inspector from bundle or global */
  120909. private _getGlobalInspector;
  120910. /**
  120911. * Get if the inspector is visible or not.
  120912. * @returns true if visible otherwise, false
  120913. */
  120914. isVisible(): boolean;
  120915. /**
  120916. * Hide the inspector and close its window.
  120917. */
  120918. hide(): void;
  120919. /**
  120920. * Launch the debugLayer.
  120921. * @param config Define the configuration of the inspector
  120922. * @return a promise fulfilled when the debug layer is visible
  120923. */
  120924. show(config?: IInspectorOptions): Promise<DebugLayer>;
  120925. }
  120926. }
  120927. declare module BABYLON {
  120928. /**
  120929. * Class containing static functions to help procedurally build meshes
  120930. */
  120931. export class BoxBuilder {
  120932. /**
  120933. * Creates a box mesh
  120934. * * The parameter `size` sets the size (float) of each box side (default 1)
  120935. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  120936. * * 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)
  120937. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  120938. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  120939. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  120940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  120941. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  120942. * @param name defines the name of the mesh
  120943. * @param options defines the options used to create the mesh
  120944. * @param scene defines the hosting scene
  120945. * @returns the box mesh
  120946. */
  120947. static CreateBox(name: string, options: {
  120948. size?: number;
  120949. width?: number;
  120950. height?: number;
  120951. depth?: number;
  120952. faceUV?: Vector4[];
  120953. faceColors?: Color4[];
  120954. sideOrientation?: number;
  120955. frontUVs?: Vector4;
  120956. backUVs?: Vector4;
  120957. wrap?: boolean;
  120958. topBaseAt?: number;
  120959. bottomBaseAt?: number;
  120960. updatable?: boolean;
  120961. }, scene?: Nullable<Scene>): Mesh;
  120962. }
  120963. }
  120964. declare module BABYLON.Debug {
  120965. /**
  120966. * Used to show the physics impostor around the specific mesh
  120967. */
  120968. export class PhysicsViewer {
  120969. /** @hidden */
  120970. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  120971. /** @hidden */
  120972. protected _meshes: Array<Nullable<AbstractMesh>>;
  120973. /** @hidden */
  120974. protected _scene: Nullable<Scene>;
  120975. /** @hidden */
  120976. protected _numMeshes: number;
  120977. /** @hidden */
  120978. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  120979. private _renderFunction;
  120980. private _utilityLayer;
  120981. private _debugBoxMesh;
  120982. private _debugSphereMesh;
  120983. private _debugCylinderMesh;
  120984. private _debugMaterial;
  120985. private _debugMeshMeshes;
  120986. /**
  120987. * Creates a new PhysicsViewer
  120988. * @param scene defines the hosting scene
  120989. */
  120990. constructor(scene: Scene);
  120991. /** @hidden */
  120992. protected _updateDebugMeshes(): void;
  120993. /**
  120994. * Renders a specified physic impostor
  120995. * @param impostor defines the impostor to render
  120996. * @param targetMesh defines the mesh represented by the impostor
  120997. * @returns the new debug mesh used to render the impostor
  120998. */
  120999. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  121000. /**
  121001. * Hides a specified physic impostor
  121002. * @param impostor defines the impostor to hide
  121003. */
  121004. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  121005. private _getDebugMaterial;
  121006. private _getDebugBoxMesh;
  121007. private _getDebugSphereMesh;
  121008. private _getDebugCylinderMesh;
  121009. private _getDebugMeshMesh;
  121010. private _getDebugMesh;
  121011. /** Releases all resources */
  121012. dispose(): void;
  121013. }
  121014. }
  121015. declare module BABYLON {
  121016. /**
  121017. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121018. * in order to better appreciate the issue one might have.
  121019. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121020. */
  121021. export class RayHelper {
  121022. /**
  121023. * Defines the ray we are currently tryin to visualize.
  121024. */
  121025. ray: Nullable<Ray>;
  121026. private _renderPoints;
  121027. private _renderLine;
  121028. private _renderFunction;
  121029. private _scene;
  121030. private _updateToMeshFunction;
  121031. private _attachedToMesh;
  121032. private _meshSpaceDirection;
  121033. private _meshSpaceOrigin;
  121034. /**
  121035. * Helper function to create a colored helper in a scene in one line.
  121036. * @param ray Defines the ray we are currently tryin to visualize
  121037. * @param scene Defines the scene the ray is used in
  121038. * @param color Defines the color we want to see the ray in
  121039. * @returns The newly created ray helper.
  121040. */
  121041. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  121042. /**
  121043. * Instantiate a new ray helper.
  121044. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  121045. * in order to better appreciate the issue one might have.
  121046. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  121047. * @param ray Defines the ray we are currently tryin to visualize
  121048. */
  121049. constructor(ray: Ray);
  121050. /**
  121051. * Shows the ray we are willing to debug.
  121052. * @param scene Defines the scene the ray needs to be rendered in
  121053. * @param color Defines the color the ray needs to be rendered in
  121054. */
  121055. show(scene: Scene, color?: Color3): void;
  121056. /**
  121057. * Hides the ray we are debugging.
  121058. */
  121059. hide(): void;
  121060. private _render;
  121061. /**
  121062. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  121063. * @param mesh Defines the mesh we want the helper attached to
  121064. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  121065. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  121066. * @param length Defines the length of the ray
  121067. */
  121068. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  121069. /**
  121070. * Detach the ray helper from the mesh it has previously been attached to.
  121071. */
  121072. detachFromMesh(): void;
  121073. private _updateToMesh;
  121074. /**
  121075. * Dispose the helper and release its associated resources.
  121076. */
  121077. dispose(): void;
  121078. }
  121079. }
  121080. declare module BABYLON.Debug {
  121081. /**
  121082. * Class used to render a debug view of a given skeleton
  121083. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  121084. */
  121085. export class SkeletonViewer {
  121086. /** defines the skeleton to render */
  121087. skeleton: Skeleton;
  121088. /** defines the mesh attached to the skeleton */
  121089. mesh: AbstractMesh;
  121090. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121091. autoUpdateBonesMatrices: boolean;
  121092. /** defines the rendering group id to use with the viewer */
  121093. renderingGroupId: number;
  121094. /** Gets or sets the color used to render the skeleton */
  121095. color: Color3;
  121096. private _scene;
  121097. private _debugLines;
  121098. private _debugMesh;
  121099. private _isEnabled;
  121100. private _renderFunction;
  121101. private _utilityLayer;
  121102. /**
  121103. * Returns the mesh used to render the bones
  121104. */
  121105. get debugMesh(): Nullable<LinesMesh>;
  121106. /**
  121107. * Creates a new SkeletonViewer
  121108. * @param skeleton defines the skeleton to render
  121109. * @param mesh defines the mesh attached to the skeleton
  121110. * @param scene defines the hosting scene
  121111. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  121112. * @param renderingGroupId defines the rendering group id to use with the viewer
  121113. */
  121114. constructor(
  121115. /** defines the skeleton to render */
  121116. skeleton: Skeleton,
  121117. /** defines the mesh attached to the skeleton */
  121118. mesh: AbstractMesh, scene: Scene,
  121119. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  121120. autoUpdateBonesMatrices?: boolean,
  121121. /** defines the rendering group id to use with the viewer */
  121122. renderingGroupId?: number);
  121123. /** Gets or sets a boolean indicating if the viewer is enabled */
  121124. set isEnabled(value: boolean);
  121125. get isEnabled(): boolean;
  121126. private _getBonePosition;
  121127. private _getLinesForBonesWithLength;
  121128. private _getLinesForBonesNoLength;
  121129. /** Update the viewer to sync with current skeleton state */
  121130. update(): void;
  121131. /** Release associated resources */
  121132. dispose(): void;
  121133. }
  121134. }
  121135. declare module BABYLON {
  121136. /**
  121137. * Options to create the null engine
  121138. */
  121139. export class NullEngineOptions {
  121140. /**
  121141. * Render width (Default: 512)
  121142. */
  121143. renderWidth: number;
  121144. /**
  121145. * Render height (Default: 256)
  121146. */
  121147. renderHeight: number;
  121148. /**
  121149. * Texture size (Default: 512)
  121150. */
  121151. textureSize: number;
  121152. /**
  121153. * If delta time between frames should be constant
  121154. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121155. */
  121156. deterministicLockstep: boolean;
  121157. /**
  121158. * Maximum about of steps between frames (Default: 4)
  121159. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121160. */
  121161. lockstepMaxSteps: number;
  121162. }
  121163. /**
  121164. * The null engine class provides support for headless version of babylon.js.
  121165. * This can be used in server side scenario or for testing purposes
  121166. */
  121167. export class NullEngine extends Engine {
  121168. private _options;
  121169. /**
  121170. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  121171. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121172. * @returns true if engine is in deterministic lock step mode
  121173. */
  121174. isDeterministicLockStep(): boolean;
  121175. /**
  121176. * Gets the max steps when engine is running in deterministic lock step
  121177. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  121178. * @returns the max steps
  121179. */
  121180. getLockstepMaxSteps(): number;
  121181. /**
  121182. * Gets the current hardware scaling level.
  121183. * By default the hardware scaling level is computed from the window device ratio.
  121184. * 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.
  121185. * @returns a number indicating the current hardware scaling level
  121186. */
  121187. getHardwareScalingLevel(): number;
  121188. constructor(options?: NullEngineOptions);
  121189. /**
  121190. * Creates a vertex buffer
  121191. * @param vertices the data for the vertex buffer
  121192. * @returns the new WebGL static buffer
  121193. */
  121194. createVertexBuffer(vertices: FloatArray): DataBuffer;
  121195. /**
  121196. * Creates a new index buffer
  121197. * @param indices defines the content of the index buffer
  121198. * @param updatable defines if the index buffer must be updatable
  121199. * @returns a new webGL buffer
  121200. */
  121201. createIndexBuffer(indices: IndicesArray): DataBuffer;
  121202. /**
  121203. * Clear the current render buffer or the current render target (if any is set up)
  121204. * @param color defines the color to use
  121205. * @param backBuffer defines if the back buffer must be cleared
  121206. * @param depth defines if the depth buffer must be cleared
  121207. * @param stencil defines if the stencil buffer must be cleared
  121208. */
  121209. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  121210. /**
  121211. * Gets the current render width
  121212. * @param useScreen defines if screen size must be used (or the current render target if any)
  121213. * @returns a number defining the current render width
  121214. */
  121215. getRenderWidth(useScreen?: boolean): number;
  121216. /**
  121217. * Gets the current render height
  121218. * @param useScreen defines if screen size must be used (or the current render target if any)
  121219. * @returns a number defining the current render height
  121220. */
  121221. getRenderHeight(useScreen?: boolean): number;
  121222. /**
  121223. * Set the WebGL's viewport
  121224. * @param viewport defines the viewport element to be used
  121225. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  121226. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  121227. */
  121228. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  121229. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  121230. /**
  121231. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  121232. * @param pipelineContext defines the pipeline context to use
  121233. * @param uniformsNames defines the list of uniform names
  121234. * @returns an array of webGL uniform locations
  121235. */
  121236. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  121237. /**
  121238. * Gets the lsit of active attributes for a given webGL program
  121239. * @param pipelineContext defines the pipeline context to use
  121240. * @param attributesNames defines the list of attribute names to get
  121241. * @returns an array of indices indicating the offset of each attribute
  121242. */
  121243. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  121244. /**
  121245. * Binds an effect to the webGL context
  121246. * @param effect defines the effect to bind
  121247. */
  121248. bindSamplers(effect: Effect): void;
  121249. /**
  121250. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  121251. * @param effect defines the effect to activate
  121252. */
  121253. enableEffect(effect: Effect): void;
  121254. /**
  121255. * Set various states to the webGL context
  121256. * @param culling defines backface culling state
  121257. * @param zOffset defines the value to apply to zOffset (0 by default)
  121258. * @param force defines if states must be applied even if cache is up to date
  121259. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  121260. */
  121261. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  121262. /**
  121263. * Set the value of an uniform to an array of int32
  121264. * @param uniform defines the webGL uniform location where to store the value
  121265. * @param array defines the array of int32 to store
  121266. */
  121267. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  121268. /**
  121269. * Set the value of an uniform to an array of int32 (stored as vec2)
  121270. * @param uniform defines the webGL uniform location where to store the value
  121271. * @param array defines the array of int32 to store
  121272. */
  121273. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  121274. /**
  121275. * Set the value of an uniform to an array of int32 (stored as vec3)
  121276. * @param uniform defines the webGL uniform location where to store the value
  121277. * @param array defines the array of int32 to store
  121278. */
  121279. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  121280. /**
  121281. * Set the value of an uniform to an array of int32 (stored as vec4)
  121282. * @param uniform defines the webGL uniform location where to store the value
  121283. * @param array defines the array of int32 to store
  121284. */
  121285. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  121286. /**
  121287. * Set the value of an uniform to an array of float32
  121288. * @param uniform defines the webGL uniform location where to store the value
  121289. * @param array defines the array of float32 to store
  121290. */
  121291. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  121292. /**
  121293. * Set the value of an uniform to an array of float32 (stored as vec2)
  121294. * @param uniform defines the webGL uniform location where to store the value
  121295. * @param array defines the array of float32 to store
  121296. */
  121297. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  121298. /**
  121299. * Set the value of an uniform to an array of float32 (stored as vec3)
  121300. * @param uniform defines the webGL uniform location where to store the value
  121301. * @param array defines the array of float32 to store
  121302. */
  121303. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  121304. /**
  121305. * Set the value of an uniform to an array of float32 (stored as vec4)
  121306. * @param uniform defines the webGL uniform location where to store the value
  121307. * @param array defines the array of float32 to store
  121308. */
  121309. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  121310. /**
  121311. * Set the value of an uniform to an array of number
  121312. * @param uniform defines the webGL uniform location where to store the value
  121313. * @param array defines the array of number to store
  121314. */
  121315. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  121316. /**
  121317. * Set the value of an uniform to an array of number (stored as vec2)
  121318. * @param uniform defines the webGL uniform location where to store the value
  121319. * @param array defines the array of number to store
  121320. */
  121321. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  121322. /**
  121323. * Set the value of an uniform to an array of number (stored as vec3)
  121324. * @param uniform defines the webGL uniform location where to store the value
  121325. * @param array defines the array of number to store
  121326. */
  121327. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  121328. /**
  121329. * Set the value of an uniform to an array of number (stored as vec4)
  121330. * @param uniform defines the webGL uniform location where to store the value
  121331. * @param array defines the array of number to store
  121332. */
  121333. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  121334. /**
  121335. * Set the value of an uniform to an array of float32 (stored as matrices)
  121336. * @param uniform defines the webGL uniform location where to store the value
  121337. * @param matrices defines the array of float32 to store
  121338. */
  121339. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  121340. /**
  121341. * Set the value of an uniform to a matrix (3x3)
  121342. * @param uniform defines the webGL uniform location where to store the value
  121343. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  121344. */
  121345. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121346. /**
  121347. * Set the value of an uniform to a matrix (2x2)
  121348. * @param uniform defines the webGL uniform location where to store the value
  121349. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  121350. */
  121351. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  121352. /**
  121353. * Set the value of an uniform to a number (float)
  121354. * @param uniform defines the webGL uniform location where to store the value
  121355. * @param value defines the float number to store
  121356. */
  121357. setFloat(uniform: WebGLUniformLocation, value: number): void;
  121358. /**
  121359. * Set the value of an uniform to a vec2
  121360. * @param uniform defines the webGL uniform location where to store the value
  121361. * @param x defines the 1st component of the value
  121362. * @param y defines the 2nd component of the value
  121363. */
  121364. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  121365. /**
  121366. * Set the value of an uniform to a vec3
  121367. * @param uniform defines the webGL uniform location where to store the value
  121368. * @param x defines the 1st component of the value
  121369. * @param y defines the 2nd component of the value
  121370. * @param z defines the 3rd component of the value
  121371. */
  121372. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  121373. /**
  121374. * Set the value of an uniform to a boolean
  121375. * @param uniform defines the webGL uniform location where to store the value
  121376. * @param bool defines the boolean to store
  121377. */
  121378. setBool(uniform: WebGLUniformLocation, bool: number): void;
  121379. /**
  121380. * Set the value of an uniform to a vec4
  121381. * @param uniform defines the webGL uniform location where to store the value
  121382. * @param x defines the 1st component of the value
  121383. * @param y defines the 2nd component of the value
  121384. * @param z defines the 3rd component of the value
  121385. * @param w defines the 4th component of the value
  121386. */
  121387. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  121388. /**
  121389. * Sets the current alpha mode
  121390. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  121391. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  121392. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  121393. */
  121394. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  121395. /**
  121396. * Bind webGl buffers directly to the webGL context
  121397. * @param vertexBuffers defines the vertex buffer to bind
  121398. * @param indexBuffer defines the index buffer to bind
  121399. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  121400. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  121401. * @param effect defines the effect associated with the vertex buffer
  121402. */
  121403. bindBuffers(vertexBuffers: {
  121404. [key: string]: VertexBuffer;
  121405. }, indexBuffer: DataBuffer, effect: Effect): void;
  121406. /**
  121407. * Force the entire cache to be cleared
  121408. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  121409. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  121410. */
  121411. wipeCaches(bruteForce?: boolean): void;
  121412. /**
  121413. * Send a draw order
  121414. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  121415. * @param indexStart defines the starting index
  121416. * @param indexCount defines the number of index to draw
  121417. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121418. */
  121419. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  121420. /**
  121421. * Draw a list of indexed primitives
  121422. * @param fillMode defines the primitive to use
  121423. * @param indexStart defines the starting index
  121424. * @param indexCount defines the number of index to draw
  121425. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121426. */
  121427. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  121428. /**
  121429. * Draw a list of unindexed primitives
  121430. * @param fillMode defines the primitive to use
  121431. * @param verticesStart defines the index of first vertex to draw
  121432. * @param verticesCount defines the count of vertices to draw
  121433. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  121434. */
  121435. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  121436. /** @hidden */
  121437. _createTexture(): WebGLTexture;
  121438. /** @hidden */
  121439. _releaseTexture(texture: InternalTexture): void;
  121440. /**
  121441. * Usually called from Texture.ts.
  121442. * Passed information to create a WebGLTexture
  121443. * @param urlArg defines a value which contains one of the following:
  121444. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  121445. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  121446. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  121447. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  121448. * @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)
  121449. * @param scene needed for loading to the correct scene
  121450. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  121451. * @param onLoad optional callback to be called upon successful completion
  121452. * @param onError optional callback to be called upon failure
  121453. * @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
  121454. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  121455. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  121456. * @param forcedExtension defines the extension to use to pick the right loader
  121457. * @param mimeType defines an optional mime type
  121458. * @returns a InternalTexture for assignment back into BABYLON.Texture
  121459. */
  121460. 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;
  121461. /**
  121462. * Creates a new render target texture
  121463. * @param size defines the size of the texture
  121464. * @param options defines the options used to create the texture
  121465. * @returns a new render target texture stored in an InternalTexture
  121466. */
  121467. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  121468. /**
  121469. * Update the sampling mode of a given texture
  121470. * @param samplingMode defines the required sampling mode
  121471. * @param texture defines the texture to update
  121472. */
  121473. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  121474. /**
  121475. * Binds the frame buffer to the specified texture.
  121476. * @param texture The texture to render to or null for the default canvas
  121477. * @param faceIndex The face of the texture to render to in case of cube texture
  121478. * @param requiredWidth The width of the target to render to
  121479. * @param requiredHeight The height of the target to render to
  121480. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  121481. * @param lodLevel defines le lod level to bind to the frame buffer
  121482. */
  121483. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  121484. /**
  121485. * Unbind the current render target texture from the webGL context
  121486. * @param texture defines the render target texture to unbind
  121487. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121488. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121489. */
  121490. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  121491. /**
  121492. * Creates a dynamic vertex buffer
  121493. * @param vertices the data for the dynamic vertex buffer
  121494. * @returns the new WebGL dynamic buffer
  121495. */
  121496. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  121497. /**
  121498. * Update the content of a dynamic texture
  121499. * @param texture defines the texture to update
  121500. * @param canvas defines the canvas containing the source
  121501. * @param invertY defines if data must be stored with Y axis inverted
  121502. * @param premulAlpha defines if alpha is stored as premultiplied
  121503. * @param format defines the format of the data
  121504. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  121505. */
  121506. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  121507. /**
  121508. * Gets a boolean indicating if all created effects are ready
  121509. * @returns true if all effects are ready
  121510. */
  121511. areAllEffectsReady(): boolean;
  121512. /**
  121513. * @hidden
  121514. * Get the current error code of the webGL context
  121515. * @returns the error code
  121516. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  121517. */
  121518. getError(): number;
  121519. /** @hidden */
  121520. _getUnpackAlignement(): number;
  121521. /** @hidden */
  121522. _unpackFlipY(value: boolean): void;
  121523. /**
  121524. * Update a dynamic index buffer
  121525. * @param indexBuffer defines the target index buffer
  121526. * @param indices defines the data to update
  121527. * @param offset defines the offset in the target index buffer where update should start
  121528. */
  121529. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  121530. /**
  121531. * Updates a dynamic vertex buffer.
  121532. * @param vertexBuffer the vertex buffer to update
  121533. * @param vertices the data used to update the vertex buffer
  121534. * @param byteOffset the byte offset of the data (optional)
  121535. * @param byteLength the byte length of the data (optional)
  121536. */
  121537. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  121538. /** @hidden */
  121539. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  121540. /** @hidden */
  121541. _bindTexture(channel: number, texture: InternalTexture): void;
  121542. protected _deleteBuffer(buffer: WebGLBuffer): void;
  121543. /**
  121544. * 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
  121545. */
  121546. releaseEffects(): void;
  121547. displayLoadingUI(): void;
  121548. hideLoadingUI(): void;
  121549. /** @hidden */
  121550. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121551. /** @hidden */
  121552. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121553. /** @hidden */
  121554. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  121555. /** @hidden */
  121556. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  121557. }
  121558. }
  121559. declare module BABYLON {
  121560. /**
  121561. * @hidden
  121562. **/
  121563. export class _TimeToken {
  121564. _startTimeQuery: Nullable<WebGLQuery>;
  121565. _endTimeQuery: Nullable<WebGLQuery>;
  121566. _timeElapsedQuery: Nullable<WebGLQuery>;
  121567. _timeElapsedQueryEnded: boolean;
  121568. }
  121569. }
  121570. declare module BABYLON {
  121571. /** @hidden */
  121572. export class _OcclusionDataStorage {
  121573. /** @hidden */
  121574. occlusionInternalRetryCounter: number;
  121575. /** @hidden */
  121576. isOcclusionQueryInProgress: boolean;
  121577. /** @hidden */
  121578. isOccluded: boolean;
  121579. /** @hidden */
  121580. occlusionRetryCount: number;
  121581. /** @hidden */
  121582. occlusionType: number;
  121583. /** @hidden */
  121584. occlusionQueryAlgorithmType: number;
  121585. }
  121586. interface Engine {
  121587. /**
  121588. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  121589. * @return the new query
  121590. */
  121591. createQuery(): WebGLQuery;
  121592. /**
  121593. * Delete and release a webGL query
  121594. * @param query defines the query to delete
  121595. * @return the current engine
  121596. */
  121597. deleteQuery(query: WebGLQuery): Engine;
  121598. /**
  121599. * Check if a given query has resolved and got its value
  121600. * @param query defines the query to check
  121601. * @returns true if the query got its value
  121602. */
  121603. isQueryResultAvailable(query: WebGLQuery): boolean;
  121604. /**
  121605. * Gets the value of a given query
  121606. * @param query defines the query to check
  121607. * @returns the value of the query
  121608. */
  121609. getQueryResult(query: WebGLQuery): number;
  121610. /**
  121611. * Initiates an occlusion query
  121612. * @param algorithmType defines the algorithm to use
  121613. * @param query defines the query to use
  121614. * @returns the current engine
  121615. * @see http://doc.babylonjs.com/features/occlusionquery
  121616. */
  121617. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  121618. /**
  121619. * Ends an occlusion query
  121620. * @see http://doc.babylonjs.com/features/occlusionquery
  121621. * @param algorithmType defines the algorithm to use
  121622. * @returns the current engine
  121623. */
  121624. endOcclusionQuery(algorithmType: number): Engine;
  121625. /**
  121626. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  121627. * Please note that only one query can be issued at a time
  121628. * @returns a time token used to track the time span
  121629. */
  121630. startTimeQuery(): Nullable<_TimeToken>;
  121631. /**
  121632. * Ends a time query
  121633. * @param token defines the token used to measure the time span
  121634. * @returns the time spent (in ns)
  121635. */
  121636. endTimeQuery(token: _TimeToken): int;
  121637. /** @hidden */
  121638. _currentNonTimestampToken: Nullable<_TimeToken>;
  121639. /** @hidden */
  121640. _createTimeQuery(): WebGLQuery;
  121641. /** @hidden */
  121642. _deleteTimeQuery(query: WebGLQuery): void;
  121643. /** @hidden */
  121644. _getGlAlgorithmType(algorithmType: number): number;
  121645. /** @hidden */
  121646. _getTimeQueryResult(query: WebGLQuery): any;
  121647. /** @hidden */
  121648. _getTimeQueryAvailability(query: WebGLQuery): any;
  121649. }
  121650. interface AbstractMesh {
  121651. /**
  121652. * Backing filed
  121653. * @hidden
  121654. */
  121655. __occlusionDataStorage: _OcclusionDataStorage;
  121656. /**
  121657. * Access property
  121658. * @hidden
  121659. */
  121660. _occlusionDataStorage: _OcclusionDataStorage;
  121661. /**
  121662. * 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.
  121663. * The default value is -1 which means don't break the query and wait till the result
  121664. * @see http://doc.babylonjs.com/features/occlusionquery
  121665. */
  121666. occlusionRetryCount: number;
  121667. /**
  121668. * 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:
  121669. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  121670. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  121671. * * 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.
  121672. * @see http://doc.babylonjs.com/features/occlusionquery
  121673. */
  121674. occlusionType: number;
  121675. /**
  121676. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  121677. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  121678. * * 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.
  121679. * @see http://doc.babylonjs.com/features/occlusionquery
  121680. */
  121681. occlusionQueryAlgorithmType: number;
  121682. /**
  121683. * 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
  121684. * @see http://doc.babylonjs.com/features/occlusionquery
  121685. */
  121686. isOccluded: boolean;
  121687. /**
  121688. * Flag to check the progress status of the query
  121689. * @see http://doc.babylonjs.com/features/occlusionquery
  121690. */
  121691. isOcclusionQueryInProgress: boolean;
  121692. }
  121693. }
  121694. declare module BABYLON {
  121695. /** @hidden */
  121696. export var _forceTransformFeedbackToBundle: boolean;
  121697. interface Engine {
  121698. /**
  121699. * Creates a webGL transform feedback object
  121700. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  121701. * @returns the webGL transform feedback object
  121702. */
  121703. createTransformFeedback(): WebGLTransformFeedback;
  121704. /**
  121705. * Delete a webGL transform feedback object
  121706. * @param value defines the webGL transform feedback object to delete
  121707. */
  121708. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  121709. /**
  121710. * Bind a webGL transform feedback object to the webgl context
  121711. * @param value defines the webGL transform feedback object to bind
  121712. */
  121713. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  121714. /**
  121715. * Begins a transform feedback operation
  121716. * @param usePoints defines if points or triangles must be used
  121717. */
  121718. beginTransformFeedback(usePoints: boolean): void;
  121719. /**
  121720. * Ends a transform feedback operation
  121721. */
  121722. endTransformFeedback(): void;
  121723. /**
  121724. * Specify the varyings to use with transform feedback
  121725. * @param program defines the associated webGL program
  121726. * @param value defines the list of strings representing the varying names
  121727. */
  121728. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  121729. /**
  121730. * Bind a webGL buffer for a transform feedback operation
  121731. * @param value defines the webGL buffer to bind
  121732. */
  121733. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  121734. }
  121735. }
  121736. declare module BABYLON {
  121737. /**
  121738. * Creation options of the multi render target texture.
  121739. */
  121740. export interface IMultiRenderTargetOptions {
  121741. /**
  121742. * Define if the texture needs to create mip maps after render.
  121743. */
  121744. generateMipMaps?: boolean;
  121745. /**
  121746. * Define the types of all the draw buffers we want to create
  121747. */
  121748. types?: number[];
  121749. /**
  121750. * Define the sampling modes of all the draw buffers we want to create
  121751. */
  121752. samplingModes?: number[];
  121753. /**
  121754. * Define if a depth buffer is required
  121755. */
  121756. generateDepthBuffer?: boolean;
  121757. /**
  121758. * Define if a stencil buffer is required
  121759. */
  121760. generateStencilBuffer?: boolean;
  121761. /**
  121762. * Define if a depth texture is required instead of a depth buffer
  121763. */
  121764. generateDepthTexture?: boolean;
  121765. /**
  121766. * Define the number of desired draw buffers
  121767. */
  121768. textureCount?: number;
  121769. /**
  121770. * Define if aspect ratio should be adapted to the texture or stay the scene one
  121771. */
  121772. doNotChangeAspectRatio?: boolean;
  121773. /**
  121774. * Define the default type of the buffers we are creating
  121775. */
  121776. defaultType?: number;
  121777. }
  121778. /**
  121779. * A multi render target, like a render target provides the ability to render to a texture.
  121780. * Unlike the render target, it can render to several draw buffers in one draw.
  121781. * This is specially interesting in deferred rendering or for any effects requiring more than
  121782. * just one color from a single pass.
  121783. */
  121784. export class MultiRenderTarget extends RenderTargetTexture {
  121785. private _internalTextures;
  121786. private _textures;
  121787. private _multiRenderTargetOptions;
  121788. /**
  121789. * Get if draw buffers are currently supported by the used hardware and browser.
  121790. */
  121791. get isSupported(): boolean;
  121792. /**
  121793. * Get the list of textures generated by the multi render target.
  121794. */
  121795. get textures(): Texture[];
  121796. /**
  121797. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  121798. */
  121799. get depthTexture(): Texture;
  121800. /**
  121801. * Set the wrapping mode on U of all the textures we are rendering to.
  121802. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121803. */
  121804. set wrapU(wrap: number);
  121805. /**
  121806. * Set the wrapping mode on V of all the textures we are rendering to.
  121807. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  121808. */
  121809. set wrapV(wrap: number);
  121810. /**
  121811. * Instantiate a new multi render target texture.
  121812. * A multi render target, like a render target provides the ability to render to a texture.
  121813. * Unlike the render target, it can render to several draw buffers in one draw.
  121814. * This is specially interesting in deferred rendering or for any effects requiring more than
  121815. * just one color from a single pass.
  121816. * @param name Define the name of the texture
  121817. * @param size Define the size of the buffers to render to
  121818. * @param count Define the number of target we are rendering into
  121819. * @param scene Define the scene the texture belongs to
  121820. * @param options Define the options used to create the multi render target
  121821. */
  121822. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  121823. /** @hidden */
  121824. _rebuild(): void;
  121825. private _createInternalTextures;
  121826. private _createTextures;
  121827. /**
  121828. * Define the number of samples used if MSAA is enabled.
  121829. */
  121830. get samples(): number;
  121831. set samples(value: number);
  121832. /**
  121833. * Resize all the textures in the multi render target.
  121834. * Be carrefull as it will recreate all the data in the new texture.
  121835. * @param size Define the new size
  121836. */
  121837. resize(size: any): void;
  121838. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  121839. /**
  121840. * Dispose the render targets and their associated resources
  121841. */
  121842. dispose(): void;
  121843. /**
  121844. * Release all the underlying texture used as draw buffers.
  121845. */
  121846. releaseInternalTextures(): void;
  121847. }
  121848. }
  121849. declare module BABYLON {
  121850. interface ThinEngine {
  121851. /**
  121852. * Unbind a list of render target textures from the webGL context
  121853. * This is used only when drawBuffer extension or webGL2 are active
  121854. * @param textures defines the render target textures to unbind
  121855. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  121856. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  121857. */
  121858. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  121859. /**
  121860. * Create a multi render target texture
  121861. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  121862. * @param size defines the size of the texture
  121863. * @param options defines the creation options
  121864. * @returns the cube texture as an InternalTexture
  121865. */
  121866. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  121867. /**
  121868. * Update the sample count for a given multiple render target texture
  121869. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  121870. * @param textures defines the textures to update
  121871. * @param samples defines the sample count to set
  121872. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  121873. */
  121874. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  121875. }
  121876. }
  121877. declare module BABYLON {
  121878. /**
  121879. * Class used to define an additional view for the engine
  121880. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121881. */
  121882. export class EngineView {
  121883. /** Defines the canvas where to render the view */
  121884. target: HTMLCanvasElement;
  121885. /** Defines an optional camera used to render the view (will use active camera else) */
  121886. camera?: Camera;
  121887. }
  121888. interface Engine {
  121889. /**
  121890. * Gets or sets the HTML element to use for attaching events
  121891. */
  121892. inputElement: Nullable<HTMLElement>;
  121893. /**
  121894. * Gets the current engine view
  121895. * @see https://doc.babylonjs.com/how_to/multi_canvases
  121896. */
  121897. activeView: Nullable<EngineView>;
  121898. /** Gets or sets the list of views */
  121899. views: EngineView[];
  121900. /**
  121901. * Register a new child canvas
  121902. * @param canvas defines the canvas to register
  121903. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  121904. * @returns the associated view
  121905. */
  121906. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  121907. /**
  121908. * Remove a registered child canvas
  121909. * @param canvas defines the canvas to remove
  121910. * @returns the current engine
  121911. */
  121912. unRegisterView(canvas: HTMLCanvasElement): Engine;
  121913. }
  121914. }
  121915. declare module BABYLON {
  121916. interface Engine {
  121917. /** @hidden */
  121918. _excludedCompressedTextures: string[];
  121919. /** @hidden */
  121920. _textureFormatInUse: string;
  121921. /**
  121922. * Gets the list of texture formats supported
  121923. */
  121924. readonly texturesSupported: Array<string>;
  121925. /**
  121926. * Gets the texture format in use
  121927. */
  121928. readonly textureFormatInUse: Nullable<string>;
  121929. /**
  121930. * Set the compressed texture extensions or file names to skip.
  121931. *
  121932. * @param skippedFiles defines the list of those texture files you want to skip
  121933. * Example: [".dds", ".env", "myfile.png"]
  121934. */
  121935. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  121936. /**
  121937. * Set the compressed texture format to use, based on the formats you have, and the formats
  121938. * supported by the hardware / browser.
  121939. *
  121940. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  121941. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  121942. * to API arguments needed to compressed textures. This puts the burden on the container
  121943. * generator to house the arcane code for determining these for current & future formats.
  121944. *
  121945. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  121946. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  121947. *
  121948. * Note: The result of this call is not taken into account when a texture is base64.
  121949. *
  121950. * @param formatsAvailable defines the list of those format families you have created
  121951. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  121952. *
  121953. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  121954. * @returns The extension selected.
  121955. */
  121956. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  121957. }
  121958. }
  121959. declare module BABYLON {
  121960. /**
  121961. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  121962. */
  121963. export interface CubeMapInfo {
  121964. /**
  121965. * The pixel array for the front face.
  121966. * This is stored in format, left to right, up to down format.
  121967. */
  121968. front: Nullable<ArrayBufferView>;
  121969. /**
  121970. * The pixel array for the back face.
  121971. * This is stored in format, left to right, up to down format.
  121972. */
  121973. back: Nullable<ArrayBufferView>;
  121974. /**
  121975. * The pixel array for the left face.
  121976. * This is stored in format, left to right, up to down format.
  121977. */
  121978. left: Nullable<ArrayBufferView>;
  121979. /**
  121980. * The pixel array for the right face.
  121981. * This is stored in format, left to right, up to down format.
  121982. */
  121983. right: Nullable<ArrayBufferView>;
  121984. /**
  121985. * The pixel array for the up face.
  121986. * This is stored in format, left to right, up to down format.
  121987. */
  121988. up: Nullable<ArrayBufferView>;
  121989. /**
  121990. * The pixel array for the down face.
  121991. * This is stored in format, left to right, up to down format.
  121992. */
  121993. down: Nullable<ArrayBufferView>;
  121994. /**
  121995. * The size of the cubemap stored.
  121996. *
  121997. * Each faces will be size * size pixels.
  121998. */
  121999. size: number;
  122000. /**
  122001. * The format of the texture.
  122002. *
  122003. * RGBA, RGB.
  122004. */
  122005. format: number;
  122006. /**
  122007. * The type of the texture data.
  122008. *
  122009. * UNSIGNED_INT, FLOAT.
  122010. */
  122011. type: number;
  122012. /**
  122013. * Specifies whether the texture is in gamma space.
  122014. */
  122015. gammaSpace: boolean;
  122016. }
  122017. /**
  122018. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  122019. */
  122020. export class PanoramaToCubeMapTools {
  122021. private static FACE_FRONT;
  122022. private static FACE_BACK;
  122023. private static FACE_RIGHT;
  122024. private static FACE_LEFT;
  122025. private static FACE_DOWN;
  122026. private static FACE_UP;
  122027. /**
  122028. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  122029. *
  122030. * @param float32Array The source data.
  122031. * @param inputWidth The width of the input panorama.
  122032. * @param inputHeight The height of the input panorama.
  122033. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  122034. * @return The cubemap data
  122035. */
  122036. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  122037. private static CreateCubemapTexture;
  122038. private static CalcProjectionSpherical;
  122039. }
  122040. }
  122041. declare module BABYLON {
  122042. /**
  122043. * Helper class dealing with the extraction of spherical polynomial dataArray
  122044. * from a cube map.
  122045. */
  122046. export class CubeMapToSphericalPolynomialTools {
  122047. private static FileFaces;
  122048. /**
  122049. * Converts a texture to the according Spherical Polynomial data.
  122050. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122051. *
  122052. * @param texture The texture to extract the information from.
  122053. * @return The Spherical Polynomial data.
  122054. */
  122055. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  122056. /**
  122057. * Converts a cubemap to the according Spherical Polynomial data.
  122058. * This extracts the first 3 orders only as they are the only one used in the lighting.
  122059. *
  122060. * @param cubeInfo The Cube map to extract the information from.
  122061. * @return The Spherical Polynomial data.
  122062. */
  122063. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  122064. }
  122065. }
  122066. declare module BABYLON {
  122067. interface BaseTexture {
  122068. /**
  122069. * Get the polynomial representation of the texture data.
  122070. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  122071. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  122072. */
  122073. sphericalPolynomial: Nullable<SphericalPolynomial>;
  122074. }
  122075. }
  122076. declare module BABYLON {
  122077. /** @hidden */
  122078. export var rgbdEncodePixelShader: {
  122079. name: string;
  122080. shader: string;
  122081. };
  122082. }
  122083. declare module BABYLON {
  122084. /** @hidden */
  122085. export var rgbdDecodePixelShader: {
  122086. name: string;
  122087. shader: string;
  122088. };
  122089. }
  122090. declare module BABYLON {
  122091. /**
  122092. * Raw texture data and descriptor sufficient for WebGL texture upload
  122093. */
  122094. export interface EnvironmentTextureInfo {
  122095. /**
  122096. * Version of the environment map
  122097. */
  122098. version: number;
  122099. /**
  122100. * Width of image
  122101. */
  122102. width: number;
  122103. /**
  122104. * Irradiance information stored in the file.
  122105. */
  122106. irradiance: any;
  122107. /**
  122108. * Specular information stored in the file.
  122109. */
  122110. specular: any;
  122111. }
  122112. /**
  122113. * Defines One Image in the file. It requires only the position in the file
  122114. * as well as the length.
  122115. */
  122116. interface BufferImageData {
  122117. /**
  122118. * Length of the image data.
  122119. */
  122120. length: number;
  122121. /**
  122122. * Position of the data from the null terminator delimiting the end of the JSON.
  122123. */
  122124. position: number;
  122125. }
  122126. /**
  122127. * Defines the specular data enclosed in the file.
  122128. * This corresponds to the version 1 of the data.
  122129. */
  122130. export interface EnvironmentTextureSpecularInfoV1 {
  122131. /**
  122132. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  122133. */
  122134. specularDataPosition?: number;
  122135. /**
  122136. * This contains all the images data needed to reconstruct the cubemap.
  122137. */
  122138. mipmaps: Array<BufferImageData>;
  122139. /**
  122140. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  122141. */
  122142. lodGenerationScale: number;
  122143. }
  122144. /**
  122145. * Sets of helpers addressing the serialization and deserialization of environment texture
  122146. * stored in a BabylonJS env file.
  122147. * Those files are usually stored as .env files.
  122148. */
  122149. export class EnvironmentTextureTools {
  122150. /**
  122151. * Magic number identifying the env file.
  122152. */
  122153. private static _MagicBytes;
  122154. /**
  122155. * Gets the environment info from an env file.
  122156. * @param data The array buffer containing the .env bytes.
  122157. * @returns the environment file info (the json header) if successfully parsed.
  122158. */
  122159. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  122160. /**
  122161. * Creates an environment texture from a loaded cube texture.
  122162. * @param texture defines the cube texture to convert in env file
  122163. * @return a promise containing the environment data if succesfull.
  122164. */
  122165. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  122166. /**
  122167. * Creates a JSON representation of the spherical data.
  122168. * @param texture defines the texture containing the polynomials
  122169. * @return the JSON representation of the spherical info
  122170. */
  122171. private static _CreateEnvTextureIrradiance;
  122172. /**
  122173. * Creates the ArrayBufferViews used for initializing environment texture image data.
  122174. * @param data the image data
  122175. * @param info parameters that determine what views will be created for accessing the underlying buffer
  122176. * @return the views described by info providing access to the underlying buffer
  122177. */
  122178. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  122179. /**
  122180. * Uploads the texture info contained in the env file to the GPU.
  122181. * @param texture defines the internal texture to upload to
  122182. * @param data defines the data to load
  122183. * @param info defines the texture info retrieved through the GetEnvInfo method
  122184. * @returns a promise
  122185. */
  122186. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  122187. private static _OnImageReadyAsync;
  122188. /**
  122189. * Uploads the levels of image data to the GPU.
  122190. * @param texture defines the internal texture to upload to
  122191. * @param imageData defines the array buffer views of image data [mipmap][face]
  122192. * @returns a promise
  122193. */
  122194. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  122195. /**
  122196. * Uploads spherical polynomials information to the texture.
  122197. * @param texture defines the texture we are trying to upload the information to
  122198. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  122199. */
  122200. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  122201. /** @hidden */
  122202. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  122203. }
  122204. }
  122205. declare module BABYLON {
  122206. /**
  122207. * Contains position and normal vectors for a vertex
  122208. */
  122209. export class PositionNormalVertex {
  122210. /** the position of the vertex (defaut: 0,0,0) */
  122211. position: Vector3;
  122212. /** the normal of the vertex (defaut: 0,1,0) */
  122213. normal: Vector3;
  122214. /**
  122215. * Creates a PositionNormalVertex
  122216. * @param position the position of the vertex (defaut: 0,0,0)
  122217. * @param normal the normal of the vertex (defaut: 0,1,0)
  122218. */
  122219. constructor(
  122220. /** the position of the vertex (defaut: 0,0,0) */
  122221. position?: Vector3,
  122222. /** the normal of the vertex (defaut: 0,1,0) */
  122223. normal?: Vector3);
  122224. /**
  122225. * Clones the PositionNormalVertex
  122226. * @returns the cloned PositionNormalVertex
  122227. */
  122228. clone(): PositionNormalVertex;
  122229. }
  122230. /**
  122231. * Contains position, normal and uv vectors for a vertex
  122232. */
  122233. export class PositionNormalTextureVertex {
  122234. /** the position of the vertex (defaut: 0,0,0) */
  122235. position: Vector3;
  122236. /** the normal of the vertex (defaut: 0,1,0) */
  122237. normal: Vector3;
  122238. /** the uv of the vertex (default: 0,0) */
  122239. uv: Vector2;
  122240. /**
  122241. * Creates a PositionNormalTextureVertex
  122242. * @param position the position of the vertex (defaut: 0,0,0)
  122243. * @param normal the normal of the vertex (defaut: 0,1,0)
  122244. * @param uv the uv of the vertex (default: 0,0)
  122245. */
  122246. constructor(
  122247. /** the position of the vertex (defaut: 0,0,0) */
  122248. position?: Vector3,
  122249. /** the normal of the vertex (defaut: 0,1,0) */
  122250. normal?: Vector3,
  122251. /** the uv of the vertex (default: 0,0) */
  122252. uv?: Vector2);
  122253. /**
  122254. * Clones the PositionNormalTextureVertex
  122255. * @returns the cloned PositionNormalTextureVertex
  122256. */
  122257. clone(): PositionNormalTextureVertex;
  122258. }
  122259. }
  122260. declare module BABYLON {
  122261. /** @hidden */
  122262. export class NativeShaderProcessor extends WebGL2ShaderProcessor {
  122263. private _genericAttributeLocation;
  122264. private _varyingLocationCount;
  122265. private _varyingLocationMap;
  122266. private _replacements;
  122267. private _textureCount;
  122268. private _uniforms;
  122269. lineProcessor(line: string): string;
  122270. attributeProcessor(attribute: string): string;
  122271. varyingProcessor(varying: string, isFragment: boolean): string;
  122272. uniformProcessor(uniform: string): string;
  122273. preProcessor(code: string, defines: string[], isFragment: boolean): string;
  122274. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  122275. }
  122276. }
  122277. declare module BABYLON {
  122278. /**
  122279. * Container for accessors for natively-stored mesh data buffers.
  122280. */
  122281. class NativeDataBuffer extends DataBuffer {
  122282. /**
  122283. * Accessor value used to identify/retrieve a natively-stored index buffer.
  122284. */
  122285. nativeIndexBuffer?: any;
  122286. /**
  122287. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  122288. */
  122289. nativeVertexBuffer?: any;
  122290. }
  122291. /** @hidden */
  122292. class NativeTexture extends InternalTexture {
  122293. getInternalTexture(): InternalTexture;
  122294. getViewCount(): number;
  122295. }
  122296. /** @hidden */
  122297. export class NativeEngine extends Engine {
  122298. private readonly _native;
  122299. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  122300. private readonly INVALID_HANDLE;
  122301. getHardwareScalingLevel(): number;
  122302. constructor();
  122303. dispose(): void;
  122304. /**
  122305. * Can be used to override the current requestAnimationFrame requester.
  122306. * @hidden
  122307. */
  122308. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  122309. /**
  122310. * Override default engine behavior.
  122311. * @param color
  122312. * @param backBuffer
  122313. * @param depth
  122314. * @param stencil
  122315. */
  122316. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  122317. /**
  122318. * Gets host document
  122319. * @returns the host document object
  122320. */
  122321. getHostDocument(): Nullable<Document>;
  122322. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  122323. createIndexBuffer(indices: IndicesArray): NativeDataBuffer;
  122324. createVertexBuffer(data: DataArray): NativeDataBuffer;
  122325. recordVertexArrayObject(vertexBuffers: {
  122326. [key: string]: VertexBuffer;
  122327. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  122328. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122329. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  122330. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  122331. /**
  122332. * Draw a list of indexed primitives
  122333. * @param fillMode defines the primitive to use
  122334. * @param indexStart defines the starting index
  122335. * @param indexCount defines the number of index to draw
  122336. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122337. */
  122338. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  122339. /**
  122340. * Draw a list of unindexed primitives
  122341. * @param fillMode defines the primitive to use
  122342. * @param verticesStart defines the index of first vertex to draw
  122343. * @param verticesCount defines the count of vertices to draw
  122344. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  122345. */
  122346. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  122347. createPipelineContext(): IPipelineContext;
  122348. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  122349. /** @hidden */
  122350. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  122351. /** @hidden */
  122352. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  122353. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122354. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  122355. protected _setProgram(program: WebGLProgram): void;
  122356. _releaseEffect(effect: Effect): void;
  122357. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  122358. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  122359. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  122360. bindSamplers(effect: Effect): void;
  122361. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  122362. getRenderWidth(useScreen?: boolean): number;
  122363. getRenderHeight(useScreen?: boolean): number;
  122364. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  122365. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  122366. /**
  122367. * Set the z offset to apply to current rendering
  122368. * @param value defines the offset to apply
  122369. */
  122370. setZOffset(value: number): void;
  122371. /**
  122372. * Gets the current value of the zOffset
  122373. * @returns the current zOffset state
  122374. */
  122375. getZOffset(): number;
  122376. /**
  122377. * Enable or disable depth buffering
  122378. * @param enable defines the state to set
  122379. */
  122380. setDepthBuffer(enable: boolean): void;
  122381. /**
  122382. * Gets a boolean indicating if depth writing is enabled
  122383. * @returns the current depth writing state
  122384. */
  122385. getDepthWrite(): boolean;
  122386. /**
  122387. * Enable or disable depth writing
  122388. * @param enable defines the state to set
  122389. */
  122390. setDepthWrite(enable: boolean): void;
  122391. /**
  122392. * Enable or disable color writing
  122393. * @param enable defines the state to set
  122394. */
  122395. setColorWrite(enable: boolean): void;
  122396. /**
  122397. * Gets a boolean indicating if color writing is enabled
  122398. * @returns the current color writing state
  122399. */
  122400. getColorWrite(): boolean;
  122401. /**
  122402. * Sets alpha constants used by some alpha blending modes
  122403. * @param r defines the red component
  122404. * @param g defines the green component
  122405. * @param b defines the blue component
  122406. * @param a defines the alpha component
  122407. */
  122408. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  122409. /**
  122410. * Sets the current alpha mode
  122411. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  122412. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  122413. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122414. */
  122415. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  122416. /**
  122417. * Gets the current alpha mode
  122418. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  122419. * @returns the current alpha mode
  122420. */
  122421. getAlphaMode(): number;
  122422. setInt(uniform: WebGLUniformLocation, int: number): void;
  122423. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  122424. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  122425. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  122426. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  122427. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  122428. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  122429. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  122430. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  122431. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  122432. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  122433. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  122434. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  122435. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  122436. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122437. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  122438. setFloat(uniform: WebGLUniformLocation, value: number): void;
  122439. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  122440. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  122441. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  122442. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  122443. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  122444. wipeCaches(bruteForce?: boolean): void;
  122445. _createTexture(): WebGLTexture;
  122446. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  122447. /**
  122448. * Usually called from Texture.ts.
  122449. * Passed information to create a WebGLTexture
  122450. * @param url defines a value which contains one of the following:
  122451. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  122452. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  122453. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  122454. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  122455. * @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)
  122456. * @param scene needed for loading to the correct scene
  122457. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  122458. * @param onLoad optional callback to be called upon successful completion
  122459. * @param onError optional callback to be called upon failure
  122460. * @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
  122461. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  122462. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  122463. * @param forcedExtension defines the extension to use to pick the right loader
  122464. * @param mimeType defines an optional mime type
  122465. * @returns a InternalTexture for assignment back into BABYLON.Texture
  122466. */
  122467. 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;
  122468. /**
  122469. * Creates a cube texture
  122470. * @param rootUrl defines the url where the files to load is located
  122471. * @param scene defines the current scene
  122472. * @param files defines the list of files to load (1 per face)
  122473. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  122474. * @param onLoad defines an optional callback raised when the texture is loaded
  122475. * @param onError defines an optional callback raised if there is an issue to load the texture
  122476. * @param format defines the format of the data
  122477. * @param forcedExtension defines the extension to use to pick the right loader
  122478. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  122479. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  122480. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  122481. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  122482. * @returns the cube texture as an InternalTexture
  122483. */
  122484. 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;
  122485. private _getSamplingFilter;
  122486. private static _GetNativeTextureFormat;
  122487. createRenderTargetTexture(size: number | {
  122488. width: number;
  122489. height: number;
  122490. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  122491. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  122492. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  122493. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  122494. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  122495. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  122496. /**
  122497. * Updates a dynamic vertex buffer.
  122498. * @param vertexBuffer the vertex buffer to update
  122499. * @param data the data used to update the vertex buffer
  122500. * @param byteOffset the byte offset of the data (optional)
  122501. * @param byteLength the byte length of the data (optional)
  122502. */
  122503. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  122504. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  122505. private _updateAnisotropicLevel;
  122506. private _getAddressMode;
  122507. /** @hidden */
  122508. _bindTexture(channel: number, texture: InternalTexture): void;
  122509. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  122510. releaseEffects(): void;
  122511. /** @hidden */
  122512. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122513. /** @hidden */
  122514. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122515. /** @hidden */
  122516. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  122517. /** @hidden */
  122518. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  122519. }
  122520. }
  122521. declare module BABYLON {
  122522. /**
  122523. * Gather the list of clipboard event types as constants.
  122524. */
  122525. export class ClipboardEventTypes {
  122526. /**
  122527. * The clipboard event is fired when a copy command is active (pressed).
  122528. */
  122529. static readonly COPY: number;
  122530. /**
  122531. * The clipboard event is fired when a cut command is active (pressed).
  122532. */
  122533. static readonly CUT: number;
  122534. /**
  122535. * The clipboard event is fired when a paste command is active (pressed).
  122536. */
  122537. static readonly PASTE: number;
  122538. }
  122539. /**
  122540. * This class is used to store clipboard related info for the onClipboardObservable event.
  122541. */
  122542. export class ClipboardInfo {
  122543. /**
  122544. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122545. */
  122546. type: number;
  122547. /**
  122548. * Defines the related dom event
  122549. */
  122550. event: ClipboardEvent;
  122551. /**
  122552. *Creates an instance of ClipboardInfo.
  122553. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  122554. * @param event Defines the related dom event
  122555. */
  122556. constructor(
  122557. /**
  122558. * Defines the type of event (BABYLON.ClipboardEventTypes)
  122559. */
  122560. type: number,
  122561. /**
  122562. * Defines the related dom event
  122563. */
  122564. event: ClipboardEvent);
  122565. /**
  122566. * Get the clipboard event's type from the keycode.
  122567. * @param keyCode Defines the keyCode for the current keyboard event.
  122568. * @return {number}
  122569. */
  122570. static GetTypeFromCharacter(keyCode: number): number;
  122571. }
  122572. }
  122573. declare module BABYLON {
  122574. /**
  122575. * Google Daydream controller
  122576. */
  122577. export class DaydreamController extends WebVRController {
  122578. /**
  122579. * Base Url for the controller model.
  122580. */
  122581. static MODEL_BASE_URL: string;
  122582. /**
  122583. * File name for the controller model.
  122584. */
  122585. static MODEL_FILENAME: string;
  122586. /**
  122587. * Gamepad Id prefix used to identify Daydream Controller.
  122588. */
  122589. static readonly GAMEPAD_ID_PREFIX: string;
  122590. /**
  122591. * Creates a new DaydreamController from a gamepad
  122592. * @param vrGamepad the gamepad that the controller should be created from
  122593. */
  122594. constructor(vrGamepad: any);
  122595. /**
  122596. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122597. * @param scene scene in which to add meshes
  122598. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122599. */
  122600. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122601. /**
  122602. * Called once for each button that changed state since the last frame
  122603. * @param buttonIdx Which button index changed
  122604. * @param state New state of the button
  122605. * @param changes Which properties on the state changed since last frame
  122606. */
  122607. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122608. }
  122609. }
  122610. declare module BABYLON {
  122611. /**
  122612. * Gear VR Controller
  122613. */
  122614. export class GearVRController extends WebVRController {
  122615. /**
  122616. * Base Url for the controller model.
  122617. */
  122618. static MODEL_BASE_URL: string;
  122619. /**
  122620. * File name for the controller model.
  122621. */
  122622. static MODEL_FILENAME: string;
  122623. /**
  122624. * Gamepad Id prefix used to identify this controller.
  122625. */
  122626. static readonly GAMEPAD_ID_PREFIX: string;
  122627. private readonly _buttonIndexToObservableNameMap;
  122628. /**
  122629. * Creates a new GearVRController from a gamepad
  122630. * @param vrGamepad the gamepad that the controller should be created from
  122631. */
  122632. constructor(vrGamepad: any);
  122633. /**
  122634. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122635. * @param scene scene in which to add meshes
  122636. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122637. */
  122638. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122639. /**
  122640. * Called once for each button that changed state since the last frame
  122641. * @param buttonIdx Which button index changed
  122642. * @param state New state of the button
  122643. * @param changes Which properties on the state changed since last frame
  122644. */
  122645. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122646. }
  122647. }
  122648. declare module BABYLON {
  122649. /**
  122650. * Generic Controller
  122651. */
  122652. export class GenericController extends WebVRController {
  122653. /**
  122654. * Base Url for the controller model.
  122655. */
  122656. static readonly MODEL_BASE_URL: string;
  122657. /**
  122658. * File name for the controller model.
  122659. */
  122660. static readonly MODEL_FILENAME: string;
  122661. /**
  122662. * Creates a new GenericController from a gamepad
  122663. * @param vrGamepad the gamepad that the controller should be created from
  122664. */
  122665. constructor(vrGamepad: any);
  122666. /**
  122667. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122668. * @param scene scene in which to add meshes
  122669. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122670. */
  122671. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122672. /**
  122673. * Called once for each button that changed state since the last frame
  122674. * @param buttonIdx Which button index changed
  122675. * @param state New state of the button
  122676. * @param changes Which properties on the state changed since last frame
  122677. */
  122678. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122679. }
  122680. }
  122681. declare module BABYLON {
  122682. /**
  122683. * Oculus Touch Controller
  122684. */
  122685. export class OculusTouchController extends WebVRController {
  122686. /**
  122687. * Base Url for the controller model.
  122688. */
  122689. static MODEL_BASE_URL: string;
  122690. /**
  122691. * File name for the left controller model.
  122692. */
  122693. static MODEL_LEFT_FILENAME: string;
  122694. /**
  122695. * File name for the right controller model.
  122696. */
  122697. static MODEL_RIGHT_FILENAME: string;
  122698. /**
  122699. * Base Url for the Quest controller model.
  122700. */
  122701. static QUEST_MODEL_BASE_URL: string;
  122702. /**
  122703. * @hidden
  122704. * If the controllers are running on a device that needs the updated Quest controller models
  122705. */
  122706. static _IsQuest: boolean;
  122707. /**
  122708. * Fired when the secondary trigger on this controller is modified
  122709. */
  122710. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  122711. /**
  122712. * Fired when the thumb rest on this controller is modified
  122713. */
  122714. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  122715. /**
  122716. * Creates a new OculusTouchController from a gamepad
  122717. * @param vrGamepad the gamepad that the controller should be created from
  122718. */
  122719. constructor(vrGamepad: any);
  122720. /**
  122721. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122722. * @param scene scene in which to add meshes
  122723. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122724. */
  122725. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122726. /**
  122727. * Fired when the A button on this controller is modified
  122728. */
  122729. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122730. /**
  122731. * Fired when the B button on this controller is modified
  122732. */
  122733. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122734. /**
  122735. * Fired when the X button on this controller is modified
  122736. */
  122737. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122738. /**
  122739. * Fired when the Y button on this controller is modified
  122740. */
  122741. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122742. /**
  122743. * Called once for each button that changed state since the last frame
  122744. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  122745. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  122746. * 2) secondary trigger (same)
  122747. * 3) A (right) X (left), touch, pressed = value
  122748. * 4) B / Y
  122749. * 5) thumb rest
  122750. * @param buttonIdx Which button index changed
  122751. * @param state New state of the button
  122752. * @param changes Which properties on the state changed since last frame
  122753. */
  122754. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122755. }
  122756. }
  122757. declare module BABYLON {
  122758. /**
  122759. * Vive Controller
  122760. */
  122761. export class ViveController extends WebVRController {
  122762. /**
  122763. * Base Url for the controller model.
  122764. */
  122765. static MODEL_BASE_URL: string;
  122766. /**
  122767. * File name for the controller model.
  122768. */
  122769. static MODEL_FILENAME: string;
  122770. /**
  122771. * Creates a new ViveController from a gamepad
  122772. * @param vrGamepad the gamepad that the controller should be created from
  122773. */
  122774. constructor(vrGamepad: any);
  122775. /**
  122776. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122777. * @param scene scene in which to add meshes
  122778. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122779. */
  122780. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  122781. /**
  122782. * Fired when the left button on this controller is modified
  122783. */
  122784. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122785. /**
  122786. * Fired when the right button on this controller is modified
  122787. */
  122788. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122789. /**
  122790. * Fired when the menu button on this controller is modified
  122791. */
  122792. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122793. /**
  122794. * Called once for each button that changed state since the last frame
  122795. * Vive mapping:
  122796. * 0: touchpad
  122797. * 1: trigger
  122798. * 2: left AND right buttons
  122799. * 3: menu button
  122800. * @param buttonIdx Which button index changed
  122801. * @param state New state of the button
  122802. * @param changes Which properties on the state changed since last frame
  122803. */
  122804. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122805. }
  122806. }
  122807. declare module BABYLON {
  122808. /**
  122809. * Defines the WindowsMotionController object that the state of the windows motion controller
  122810. */
  122811. export class WindowsMotionController extends WebVRController {
  122812. /**
  122813. * The base url used to load the left and right controller models
  122814. */
  122815. static MODEL_BASE_URL: string;
  122816. /**
  122817. * The name of the left controller model file
  122818. */
  122819. static MODEL_LEFT_FILENAME: string;
  122820. /**
  122821. * The name of the right controller model file
  122822. */
  122823. static MODEL_RIGHT_FILENAME: string;
  122824. /**
  122825. * The controller name prefix for this controller type
  122826. */
  122827. static readonly GAMEPAD_ID_PREFIX: string;
  122828. /**
  122829. * The controller id pattern for this controller type
  122830. */
  122831. private static readonly GAMEPAD_ID_PATTERN;
  122832. private _loadedMeshInfo;
  122833. protected readonly _mapping: {
  122834. buttons: string[];
  122835. buttonMeshNames: {
  122836. trigger: string;
  122837. menu: string;
  122838. grip: string;
  122839. thumbstick: string;
  122840. trackpad: string;
  122841. };
  122842. buttonObservableNames: {
  122843. trigger: string;
  122844. menu: string;
  122845. grip: string;
  122846. thumbstick: string;
  122847. trackpad: string;
  122848. };
  122849. axisMeshNames: string[];
  122850. pointingPoseMeshName: string;
  122851. };
  122852. /**
  122853. * Fired when the trackpad on this controller is clicked
  122854. */
  122855. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122856. /**
  122857. * Fired when the trackpad on this controller is modified
  122858. */
  122859. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122860. /**
  122861. * The current x and y values of this controller's trackpad
  122862. */
  122863. trackpad: StickValues;
  122864. /**
  122865. * Creates a new WindowsMotionController from a gamepad
  122866. * @param vrGamepad the gamepad that the controller should be created from
  122867. */
  122868. constructor(vrGamepad: any);
  122869. /**
  122870. * Fired when the trigger on this controller is modified
  122871. */
  122872. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122873. /**
  122874. * Fired when the menu button on this controller is modified
  122875. */
  122876. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122877. /**
  122878. * Fired when the grip button on this controller is modified
  122879. */
  122880. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122881. /**
  122882. * Fired when the thumbstick button on this controller is modified
  122883. */
  122884. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122885. /**
  122886. * Fired when the touchpad button on this controller is modified
  122887. */
  122888. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  122889. /**
  122890. * Fired when the touchpad values on this controller are modified
  122891. */
  122892. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  122893. protected _updateTrackpad(): void;
  122894. /**
  122895. * Called once per frame by the engine.
  122896. */
  122897. update(): void;
  122898. /**
  122899. * Called once for each button that changed state since the last frame
  122900. * @param buttonIdx Which button index changed
  122901. * @param state New state of the button
  122902. * @param changes Which properties on the state changed since last frame
  122903. */
  122904. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  122905. /**
  122906. * Moves the buttons on the controller mesh based on their current state
  122907. * @param buttonName the name of the button to move
  122908. * @param buttonValue the value of the button which determines the buttons new position
  122909. */
  122910. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  122911. /**
  122912. * Moves the axis on the controller mesh based on its current state
  122913. * @param axis the index of the axis
  122914. * @param axisValue the value of the axis which determines the meshes new position
  122915. * @hidden
  122916. */
  122917. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  122918. /**
  122919. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  122920. * @param scene scene in which to add meshes
  122921. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  122922. */
  122923. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  122924. /**
  122925. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  122926. * can be transformed by button presses and axes values, based on this._mapping.
  122927. *
  122928. * @param scene scene in which the meshes exist
  122929. * @param meshes list of meshes that make up the controller model to process
  122930. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  122931. */
  122932. private processModel;
  122933. private createMeshInfo;
  122934. /**
  122935. * Gets the ray of the controller in the direction the controller is pointing
  122936. * @param length the length the resulting ray should be
  122937. * @returns a ray in the direction the controller is pointing
  122938. */
  122939. getForwardRay(length?: number): Ray;
  122940. /**
  122941. * Disposes of the controller
  122942. */
  122943. dispose(): void;
  122944. }
  122945. /**
  122946. * This class represents a new windows motion controller in XR.
  122947. */
  122948. export class XRWindowsMotionController extends WindowsMotionController {
  122949. /**
  122950. * Changing the original WIndowsMotionController mapping to fir the new mapping
  122951. */
  122952. protected readonly _mapping: {
  122953. buttons: string[];
  122954. buttonMeshNames: {
  122955. trigger: string;
  122956. menu: string;
  122957. grip: string;
  122958. thumbstick: string;
  122959. trackpad: string;
  122960. };
  122961. buttonObservableNames: {
  122962. trigger: string;
  122963. menu: string;
  122964. grip: string;
  122965. thumbstick: string;
  122966. trackpad: string;
  122967. };
  122968. axisMeshNames: string[];
  122969. pointingPoseMeshName: string;
  122970. };
  122971. /**
  122972. * Construct a new XR-Based windows motion controller
  122973. *
  122974. * @param gamepadInfo the gamepad object from the browser
  122975. */
  122976. constructor(gamepadInfo: any);
  122977. /**
  122978. * holds the thumbstick values (X,Y)
  122979. */
  122980. thumbstickValues: StickValues;
  122981. /**
  122982. * Fired when the thumbstick on this controller is clicked
  122983. */
  122984. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  122985. /**
  122986. * Fired when the thumbstick on this controller is modified
  122987. */
  122988. onThumbstickValuesChangedObservable: Observable<StickValues>;
  122989. /**
  122990. * Fired when the touchpad button on this controller is modified
  122991. */
  122992. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  122993. /**
  122994. * Fired when the touchpad values on this controller are modified
  122995. */
  122996. onTrackpadValuesChangedObservable: Observable<StickValues>;
  122997. /**
  122998. * Fired when the thumbstick button on this controller is modified
  122999. * here to prevent breaking changes
  123000. */
  123001. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  123002. /**
  123003. * updating the thumbstick(!) and not the trackpad.
  123004. * This is named this way due to the difference between WebVR and XR and to avoid
  123005. * changing the parent class.
  123006. */
  123007. protected _updateTrackpad(): void;
  123008. /**
  123009. * Disposes the class with joy
  123010. */
  123011. dispose(): void;
  123012. }
  123013. }
  123014. declare module BABYLON {
  123015. /**
  123016. * Class containing static functions to help procedurally build meshes
  123017. */
  123018. export class PolyhedronBuilder {
  123019. /**
  123020. * Creates a polyhedron mesh
  123021. * * 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
  123022. * * The parameter `size` (positive float, default 1) sets the polygon size
  123023. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  123024. * * 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`
  123025. * * 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
  123026. * * 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)`)
  123027. * * 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
  123028. * * 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
  123029. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  123030. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  123031. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  123032. * @param name defines the name of the mesh
  123033. * @param options defines the options used to create the mesh
  123034. * @param scene defines the hosting scene
  123035. * @returns the polyhedron mesh
  123036. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  123037. */
  123038. static CreatePolyhedron(name: string, options: {
  123039. type?: number;
  123040. size?: number;
  123041. sizeX?: number;
  123042. sizeY?: number;
  123043. sizeZ?: number;
  123044. custom?: any;
  123045. faceUV?: Vector4[];
  123046. faceColors?: Color4[];
  123047. flat?: boolean;
  123048. updatable?: boolean;
  123049. sideOrientation?: number;
  123050. frontUVs?: Vector4;
  123051. backUVs?: Vector4;
  123052. }, scene?: Nullable<Scene>): Mesh;
  123053. }
  123054. }
  123055. declare module BABYLON {
  123056. /**
  123057. * Gizmo that enables scaling a mesh along 3 axis
  123058. */
  123059. export class ScaleGizmo extends Gizmo {
  123060. /**
  123061. * Internal gizmo used for interactions on the x axis
  123062. */
  123063. xGizmo: AxisScaleGizmo;
  123064. /**
  123065. * Internal gizmo used for interactions on the y axis
  123066. */
  123067. yGizmo: AxisScaleGizmo;
  123068. /**
  123069. * Internal gizmo used for interactions on the z axis
  123070. */
  123071. zGizmo: AxisScaleGizmo;
  123072. /**
  123073. * Internal gizmo used to scale all axis equally
  123074. */
  123075. uniformScaleGizmo: AxisScaleGizmo;
  123076. private _meshAttached;
  123077. private _updateGizmoRotationToMatchAttachedMesh;
  123078. private _snapDistance;
  123079. private _scaleRatio;
  123080. private _uniformScalingMesh;
  123081. private _octahedron;
  123082. private _sensitivity;
  123083. /** Fires an event when any of it's sub gizmos are dragged */
  123084. onDragStartObservable: Observable<unknown>;
  123085. /** Fires an event when any of it's sub gizmos are released from dragging */
  123086. onDragEndObservable: Observable<unknown>;
  123087. get attachedMesh(): Nullable<AbstractMesh>;
  123088. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123089. /**
  123090. * Creates a ScaleGizmo
  123091. * @param gizmoLayer The utility layer the gizmo will be added to
  123092. */
  123093. constructor(gizmoLayer?: UtilityLayerRenderer);
  123094. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123095. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123096. /**
  123097. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123098. */
  123099. set snapDistance(value: number);
  123100. get snapDistance(): number;
  123101. /**
  123102. * Ratio for the scale of the gizmo (Default: 1)
  123103. */
  123104. set scaleRatio(value: number);
  123105. get scaleRatio(): number;
  123106. /**
  123107. * Sensitivity factor for dragging (Default: 1)
  123108. */
  123109. set sensitivity(value: number);
  123110. get sensitivity(): number;
  123111. /**
  123112. * Disposes of the gizmo
  123113. */
  123114. dispose(): void;
  123115. }
  123116. }
  123117. declare module BABYLON {
  123118. /**
  123119. * Single axis scale gizmo
  123120. */
  123121. export class AxisScaleGizmo extends Gizmo {
  123122. /**
  123123. * Drag behavior responsible for the gizmos dragging interactions
  123124. */
  123125. dragBehavior: PointerDragBehavior;
  123126. private _pointerObserver;
  123127. /**
  123128. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123129. */
  123130. snapDistance: number;
  123131. /**
  123132. * Event that fires each time the gizmo snaps to a new location.
  123133. * * snapDistance is the the change in distance
  123134. */
  123135. onSnapObservable: Observable<{
  123136. snapDistance: number;
  123137. }>;
  123138. /**
  123139. * If the scaling operation should be done on all axis (default: false)
  123140. */
  123141. uniformScaling: boolean;
  123142. /**
  123143. * Custom sensitivity value for the drag strength
  123144. */
  123145. sensitivity: number;
  123146. private _isEnabled;
  123147. private _parent;
  123148. private _arrow;
  123149. private _coloredMaterial;
  123150. private _hoverMaterial;
  123151. /**
  123152. * Creates an AxisScaleGizmo
  123153. * @param gizmoLayer The utility layer the gizmo will be added to
  123154. * @param dragAxis The axis which the gizmo will be able to scale on
  123155. * @param color The color of the gizmo
  123156. */
  123157. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>);
  123158. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123159. /**
  123160. * If the gizmo is enabled
  123161. */
  123162. set isEnabled(value: boolean);
  123163. get isEnabled(): boolean;
  123164. /**
  123165. * Disposes of the gizmo
  123166. */
  123167. dispose(): void;
  123168. /**
  123169. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  123170. * @param mesh The mesh to replace the default mesh of the gizmo
  123171. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  123172. */
  123173. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  123174. }
  123175. }
  123176. declare module BABYLON {
  123177. /**
  123178. * Bounding box gizmo
  123179. */
  123180. export class BoundingBoxGizmo extends Gizmo {
  123181. private _lineBoundingBox;
  123182. private _rotateSpheresParent;
  123183. private _scaleBoxesParent;
  123184. private _boundingDimensions;
  123185. private _renderObserver;
  123186. private _pointerObserver;
  123187. private _scaleDragSpeed;
  123188. private _tmpQuaternion;
  123189. private _tmpVector;
  123190. private _tmpRotationMatrix;
  123191. /**
  123192. * 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)
  123193. */
  123194. ignoreChildren: boolean;
  123195. /**
  123196. * 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)
  123197. */
  123198. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  123199. /**
  123200. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  123201. */
  123202. rotationSphereSize: number;
  123203. /**
  123204. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  123205. */
  123206. scaleBoxSize: number;
  123207. /**
  123208. * 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)
  123209. */
  123210. fixedDragMeshScreenSize: boolean;
  123211. /**
  123212. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  123213. */
  123214. fixedDragMeshScreenSizeDistanceFactor: number;
  123215. /**
  123216. * Fired when a rotation sphere or scale box is dragged
  123217. */
  123218. onDragStartObservable: Observable<{}>;
  123219. /**
  123220. * Fired when a scale box is dragged
  123221. */
  123222. onScaleBoxDragObservable: Observable<{}>;
  123223. /**
  123224. * Fired when a scale box drag is ended
  123225. */
  123226. onScaleBoxDragEndObservable: Observable<{}>;
  123227. /**
  123228. * Fired when a rotation sphere is dragged
  123229. */
  123230. onRotationSphereDragObservable: Observable<{}>;
  123231. /**
  123232. * Fired when a rotation sphere drag is ended
  123233. */
  123234. onRotationSphereDragEndObservable: Observable<{}>;
  123235. /**
  123236. * 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)
  123237. */
  123238. scalePivot: Nullable<Vector3>;
  123239. /**
  123240. * Mesh used as a pivot to rotate the attached mesh
  123241. */
  123242. private _anchorMesh;
  123243. private _existingMeshScale;
  123244. private _dragMesh;
  123245. private pointerDragBehavior;
  123246. private coloredMaterial;
  123247. private hoverColoredMaterial;
  123248. /**
  123249. * Sets the color of the bounding box gizmo
  123250. * @param color the color to set
  123251. */
  123252. setColor(color: Color3): void;
  123253. /**
  123254. * Creates an BoundingBoxGizmo
  123255. * @param gizmoLayer The utility layer the gizmo will be added to
  123256. * @param color The color of the gizmo
  123257. */
  123258. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  123259. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123260. private _selectNode;
  123261. /**
  123262. * Updates the bounding box information for the Gizmo
  123263. */
  123264. updateBoundingBox(): void;
  123265. private _updateRotationSpheres;
  123266. private _updateScaleBoxes;
  123267. /**
  123268. * Enables rotation on the specified axis and disables rotation on the others
  123269. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  123270. */
  123271. setEnabledRotationAxis(axis: string): void;
  123272. /**
  123273. * Enables/disables scaling
  123274. * @param enable if scaling should be enabled
  123275. * @param homogeneousScaling defines if scaling should only be homogeneous
  123276. */
  123277. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  123278. private _updateDummy;
  123279. /**
  123280. * Enables a pointer drag behavior on the bounding box of the gizmo
  123281. */
  123282. enableDragBehavior(): void;
  123283. /**
  123284. * Disposes of the gizmo
  123285. */
  123286. dispose(): void;
  123287. /**
  123288. * 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)
  123289. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  123290. * @returns the bounding box mesh with the passed in mesh as a child
  123291. */
  123292. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  123293. /**
  123294. * CustomMeshes are not supported by this gizmo
  123295. * @param mesh The mesh to replace the default mesh of the gizmo
  123296. */
  123297. setCustomMesh(mesh: Mesh): void;
  123298. }
  123299. }
  123300. declare module BABYLON {
  123301. /**
  123302. * Single plane rotation gizmo
  123303. */
  123304. export class PlaneRotationGizmo extends Gizmo {
  123305. /**
  123306. * Drag behavior responsible for the gizmos dragging interactions
  123307. */
  123308. dragBehavior: PointerDragBehavior;
  123309. private _pointerObserver;
  123310. /**
  123311. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  123312. */
  123313. snapDistance: number;
  123314. /**
  123315. * Event that fires each time the gizmo snaps to a new location.
  123316. * * snapDistance is the the change in distance
  123317. */
  123318. onSnapObservable: Observable<{
  123319. snapDistance: number;
  123320. }>;
  123321. private _isEnabled;
  123322. private _parent;
  123323. /**
  123324. * Creates a PlaneRotationGizmo
  123325. * @param gizmoLayer The utility layer the gizmo will be added to
  123326. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  123327. * @param color The color of the gizmo
  123328. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123329. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123330. */
  123331. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean);
  123332. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  123333. /**
  123334. * If the gizmo is enabled
  123335. */
  123336. set isEnabled(value: boolean);
  123337. get isEnabled(): boolean;
  123338. /**
  123339. * Disposes of the gizmo
  123340. */
  123341. dispose(): void;
  123342. }
  123343. }
  123344. declare module BABYLON {
  123345. /**
  123346. * Gizmo that enables rotating a mesh along 3 axis
  123347. */
  123348. export class RotationGizmo extends Gizmo {
  123349. /**
  123350. * Internal gizmo used for interactions on the x axis
  123351. */
  123352. xGizmo: PlaneRotationGizmo;
  123353. /**
  123354. * Internal gizmo used for interactions on the y axis
  123355. */
  123356. yGizmo: PlaneRotationGizmo;
  123357. /**
  123358. * Internal gizmo used for interactions on the z axis
  123359. */
  123360. zGizmo: PlaneRotationGizmo;
  123361. /** Fires an event when any of it's sub gizmos are dragged */
  123362. onDragStartObservable: Observable<unknown>;
  123363. /** Fires an event when any of it's sub gizmos are released from dragging */
  123364. onDragEndObservable: Observable<unknown>;
  123365. private _meshAttached;
  123366. get attachedMesh(): Nullable<AbstractMesh>;
  123367. set attachedMesh(mesh: Nullable<AbstractMesh>);
  123368. /**
  123369. * Creates a RotationGizmo
  123370. * @param gizmoLayer The utility layer the gizmo will be added to
  123371. * @param tessellation Amount of tessellation to be used when creating rotation circles
  123372. * @param useEulerRotation Use and update Euler angle instead of quaternion
  123373. */
  123374. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean);
  123375. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  123376. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  123377. /**
  123378. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  123379. */
  123380. set snapDistance(value: number);
  123381. get snapDistance(): number;
  123382. /**
  123383. * Ratio for the scale of the gizmo (Default: 1)
  123384. */
  123385. set scaleRatio(value: number);
  123386. get scaleRatio(): number;
  123387. /**
  123388. * Disposes of the gizmo
  123389. */
  123390. dispose(): void;
  123391. /**
  123392. * CustomMeshes are not supported by this gizmo
  123393. * @param mesh The mesh to replace the default mesh of the gizmo
  123394. */
  123395. setCustomMesh(mesh: Mesh): void;
  123396. }
  123397. }
  123398. declare module BABYLON {
  123399. /**
  123400. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  123401. */
  123402. export class GizmoManager implements IDisposable {
  123403. private scene;
  123404. /**
  123405. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  123406. */
  123407. gizmos: {
  123408. positionGizmo: Nullable<PositionGizmo>;
  123409. rotationGizmo: Nullable<RotationGizmo>;
  123410. scaleGizmo: Nullable<ScaleGizmo>;
  123411. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  123412. };
  123413. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  123414. clearGizmoOnEmptyPointerEvent: boolean;
  123415. /** Fires an event when the manager is attached to a mesh */
  123416. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  123417. private _gizmosEnabled;
  123418. private _pointerObserver;
  123419. private _attachedMesh;
  123420. private _boundingBoxColor;
  123421. private _defaultUtilityLayer;
  123422. private _defaultKeepDepthUtilityLayer;
  123423. /**
  123424. * When bounding box gizmo is enabled, this can be used to track drag/end events
  123425. */
  123426. boundingBoxDragBehavior: SixDofDragBehavior;
  123427. /**
  123428. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  123429. */
  123430. attachableMeshes: Nullable<Array<AbstractMesh>>;
  123431. /**
  123432. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  123433. */
  123434. usePointerToAttachGizmos: boolean;
  123435. /**
  123436. * Utility layer that the bounding box gizmo belongs to
  123437. */
  123438. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  123439. /**
  123440. * Utility layer that all gizmos besides bounding box belong to
  123441. */
  123442. get utilityLayer(): UtilityLayerRenderer;
  123443. /**
  123444. * Instatiates a gizmo manager
  123445. * @param scene the scene to overlay the gizmos on top of
  123446. */
  123447. constructor(scene: Scene);
  123448. /**
  123449. * Attaches a set of gizmos to the specified mesh
  123450. * @param mesh The mesh the gizmo's should be attached to
  123451. */
  123452. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  123453. /**
  123454. * If the position gizmo is enabled
  123455. */
  123456. set positionGizmoEnabled(value: boolean);
  123457. get positionGizmoEnabled(): boolean;
  123458. /**
  123459. * If the rotation gizmo is enabled
  123460. */
  123461. set rotationGizmoEnabled(value: boolean);
  123462. get rotationGizmoEnabled(): boolean;
  123463. /**
  123464. * If the scale gizmo is enabled
  123465. */
  123466. set scaleGizmoEnabled(value: boolean);
  123467. get scaleGizmoEnabled(): boolean;
  123468. /**
  123469. * If the boundingBox gizmo is enabled
  123470. */
  123471. set boundingBoxGizmoEnabled(value: boolean);
  123472. get boundingBoxGizmoEnabled(): boolean;
  123473. /**
  123474. * Disposes of the gizmo manager
  123475. */
  123476. dispose(): void;
  123477. }
  123478. }
  123479. declare module BABYLON {
  123480. /**
  123481. * A directional light is defined by a direction (what a surprise!).
  123482. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  123483. * 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.
  123484. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123485. */
  123486. export class DirectionalLight extends ShadowLight {
  123487. private _shadowFrustumSize;
  123488. /**
  123489. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  123490. */
  123491. get shadowFrustumSize(): number;
  123492. /**
  123493. * Specifies a fix frustum size for the shadow generation.
  123494. */
  123495. set shadowFrustumSize(value: number);
  123496. private _shadowOrthoScale;
  123497. /**
  123498. * Gets the shadow projection scale against the optimal computed one.
  123499. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123500. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123501. */
  123502. get shadowOrthoScale(): number;
  123503. /**
  123504. * Sets the shadow projection scale against the optimal computed one.
  123505. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  123506. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  123507. */
  123508. set shadowOrthoScale(value: number);
  123509. /**
  123510. * Automatically compute the projection matrix to best fit (including all the casters)
  123511. * on each frame.
  123512. */
  123513. autoUpdateExtends: boolean;
  123514. /**
  123515. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  123516. * on each frame. autoUpdateExtends must be set to true for this to work
  123517. */
  123518. autoCalcShadowZBounds: boolean;
  123519. private _orthoLeft;
  123520. private _orthoRight;
  123521. private _orthoTop;
  123522. private _orthoBottom;
  123523. /**
  123524. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  123525. * The directional light is emitted from everywhere in the given direction.
  123526. * It can cast shadows.
  123527. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123528. * @param name The friendly name of the light
  123529. * @param direction The direction of the light
  123530. * @param scene The scene the light belongs to
  123531. */
  123532. constructor(name: string, direction: Vector3, scene: Scene);
  123533. /**
  123534. * Returns the string "DirectionalLight".
  123535. * @return The class name
  123536. */
  123537. getClassName(): string;
  123538. /**
  123539. * Returns the integer 1.
  123540. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123541. */
  123542. getTypeID(): number;
  123543. /**
  123544. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  123545. * Returns the DirectionalLight Shadow projection matrix.
  123546. */
  123547. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123548. /**
  123549. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  123550. * Returns the DirectionalLight Shadow projection matrix.
  123551. */
  123552. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  123553. /**
  123554. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  123555. * Returns the DirectionalLight Shadow projection matrix.
  123556. */
  123557. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123558. protected _buildUniformLayout(): void;
  123559. /**
  123560. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  123561. * @param effect The effect to update
  123562. * @param lightIndex The index of the light in the effect to update
  123563. * @returns The directional light
  123564. */
  123565. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  123566. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  123567. /**
  123568. * Gets the minZ used for shadow according to both the scene and the light.
  123569. *
  123570. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123571. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123572. * @param activeCamera The camera we are returning the min for
  123573. * @returns the depth min z
  123574. */
  123575. getDepthMinZ(activeCamera: Camera): number;
  123576. /**
  123577. * Gets the maxZ used for shadow according to both the scene and the light.
  123578. *
  123579. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  123580. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  123581. * @param activeCamera The camera we are returning the max for
  123582. * @returns the depth max z
  123583. */
  123584. getDepthMaxZ(activeCamera: Camera): number;
  123585. /**
  123586. * Prepares the list of defines specific to the light type.
  123587. * @param defines the list of defines
  123588. * @param lightIndex defines the index of the light for the effect
  123589. */
  123590. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123591. }
  123592. }
  123593. declare module BABYLON {
  123594. /**
  123595. * Class containing static functions to help procedurally build meshes
  123596. */
  123597. export class HemisphereBuilder {
  123598. /**
  123599. * Creates a hemisphere mesh
  123600. * @param name defines the name of the mesh
  123601. * @param options defines the options used to create the mesh
  123602. * @param scene defines the hosting scene
  123603. * @returns the hemisphere mesh
  123604. */
  123605. static CreateHemisphere(name: string, options: {
  123606. segments?: number;
  123607. diameter?: number;
  123608. sideOrientation?: number;
  123609. }, scene: any): Mesh;
  123610. }
  123611. }
  123612. declare module BABYLON {
  123613. /**
  123614. * A spot light is defined by a position, a direction, an angle, and an exponent.
  123615. * These values define a cone of light starting from the position, emitting toward the direction.
  123616. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  123617. * and the exponent defines the speed of the decay of the light with distance (reach).
  123618. * Documentation: https://doc.babylonjs.com/babylon101/lights
  123619. */
  123620. export class SpotLight extends ShadowLight {
  123621. private _angle;
  123622. private _innerAngle;
  123623. private _cosHalfAngle;
  123624. private _lightAngleScale;
  123625. private _lightAngleOffset;
  123626. /**
  123627. * Gets the cone angle of the spot light in Radians.
  123628. */
  123629. get angle(): number;
  123630. /**
  123631. * Sets the cone angle of the spot light in Radians.
  123632. */
  123633. set angle(value: number);
  123634. /**
  123635. * Only used in gltf falloff mode, this defines the angle where
  123636. * the directional falloff will start before cutting at angle which could be seen
  123637. * as outer angle.
  123638. */
  123639. get innerAngle(): number;
  123640. /**
  123641. * Only used in gltf falloff mode, this defines the angle where
  123642. * the directional falloff will start before cutting at angle which could be seen
  123643. * as outer angle.
  123644. */
  123645. set innerAngle(value: number);
  123646. private _shadowAngleScale;
  123647. /**
  123648. * Allows scaling the angle of the light for shadow generation only.
  123649. */
  123650. get shadowAngleScale(): number;
  123651. /**
  123652. * Allows scaling the angle of the light for shadow generation only.
  123653. */
  123654. set shadowAngleScale(value: number);
  123655. /**
  123656. * The light decay speed with the distance from the emission spot.
  123657. */
  123658. exponent: number;
  123659. private _projectionTextureMatrix;
  123660. /**
  123661. * Allows reading the projecton texture
  123662. */
  123663. get projectionTextureMatrix(): Matrix;
  123664. protected _projectionTextureLightNear: number;
  123665. /**
  123666. * Gets the near clip of the Spotlight for texture projection.
  123667. */
  123668. get projectionTextureLightNear(): number;
  123669. /**
  123670. * Sets the near clip of the Spotlight for texture projection.
  123671. */
  123672. set projectionTextureLightNear(value: number);
  123673. protected _projectionTextureLightFar: number;
  123674. /**
  123675. * Gets the far clip of the Spotlight for texture projection.
  123676. */
  123677. get projectionTextureLightFar(): number;
  123678. /**
  123679. * Sets the far clip of the Spotlight for texture projection.
  123680. */
  123681. set projectionTextureLightFar(value: number);
  123682. protected _projectionTextureUpDirection: Vector3;
  123683. /**
  123684. * Gets the Up vector of the Spotlight for texture projection.
  123685. */
  123686. get projectionTextureUpDirection(): Vector3;
  123687. /**
  123688. * Sets the Up vector of the Spotlight for texture projection.
  123689. */
  123690. set projectionTextureUpDirection(value: Vector3);
  123691. private _projectionTexture;
  123692. /**
  123693. * Gets the projection texture of the light.
  123694. */
  123695. get projectionTexture(): Nullable<BaseTexture>;
  123696. /**
  123697. * Sets the projection texture of the light.
  123698. */
  123699. set projectionTexture(value: Nullable<BaseTexture>);
  123700. private _projectionTextureViewLightDirty;
  123701. private _projectionTextureProjectionLightDirty;
  123702. private _projectionTextureDirty;
  123703. private _projectionTextureViewTargetVector;
  123704. private _projectionTextureViewLightMatrix;
  123705. private _projectionTextureProjectionLightMatrix;
  123706. private _projectionTextureScalingMatrix;
  123707. /**
  123708. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  123709. * It can cast shadows.
  123710. * Documentation : https://doc.babylonjs.com/babylon101/lights
  123711. * @param name The light friendly name
  123712. * @param position The position of the spot light in the scene
  123713. * @param direction The direction of the light in the scene
  123714. * @param angle The cone angle of the light in Radians
  123715. * @param exponent The light decay speed with the distance from the emission spot
  123716. * @param scene The scene the lights belongs to
  123717. */
  123718. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  123719. /**
  123720. * Returns the string "SpotLight".
  123721. * @returns the class name
  123722. */
  123723. getClassName(): string;
  123724. /**
  123725. * Returns the integer 2.
  123726. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  123727. */
  123728. getTypeID(): number;
  123729. /**
  123730. * Overrides the direction setter to recompute the projection texture view light Matrix.
  123731. */
  123732. protected _setDirection(value: Vector3): void;
  123733. /**
  123734. * Overrides the position setter to recompute the projection texture view light Matrix.
  123735. */
  123736. protected _setPosition(value: Vector3): void;
  123737. /**
  123738. * 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.
  123739. * Returns the SpotLight.
  123740. */
  123741. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  123742. protected _computeProjectionTextureViewLightMatrix(): void;
  123743. protected _computeProjectionTextureProjectionLightMatrix(): void;
  123744. /**
  123745. * Main function for light texture projection matrix computing.
  123746. */
  123747. protected _computeProjectionTextureMatrix(): void;
  123748. protected _buildUniformLayout(): void;
  123749. private _computeAngleValues;
  123750. /**
  123751. * Sets the passed Effect "effect" with the Light textures.
  123752. * @param effect The effect to update
  123753. * @param lightIndex The index of the light in the effect to update
  123754. * @returns The light
  123755. */
  123756. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  123757. /**
  123758. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  123759. * @param effect The effect to update
  123760. * @param lightIndex The index of the light in the effect to update
  123761. * @returns The spot light
  123762. */
  123763. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  123764. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  123765. /**
  123766. * Disposes the light and the associated resources.
  123767. */
  123768. dispose(): void;
  123769. /**
  123770. * Prepares the list of defines specific to the light type.
  123771. * @param defines the list of defines
  123772. * @param lightIndex defines the index of the light for the effect
  123773. */
  123774. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  123775. }
  123776. }
  123777. declare module BABYLON {
  123778. /**
  123779. * Gizmo that enables viewing a light
  123780. */
  123781. export class LightGizmo extends Gizmo {
  123782. private _lightMesh;
  123783. private _material;
  123784. private _cachedPosition;
  123785. private _cachedForward;
  123786. private _attachedMeshParent;
  123787. /**
  123788. * Creates a LightGizmo
  123789. * @param gizmoLayer The utility layer the gizmo will be added to
  123790. */
  123791. constructor(gizmoLayer?: UtilityLayerRenderer);
  123792. private _light;
  123793. /**
  123794. * The light that the gizmo is attached to
  123795. */
  123796. set light(light: Nullable<Light>);
  123797. get light(): Nullable<Light>;
  123798. /**
  123799. * Gets the material used to render the light gizmo
  123800. */
  123801. get material(): StandardMaterial;
  123802. /**
  123803. * @hidden
  123804. * Updates the gizmo to match the attached mesh's position/rotation
  123805. */
  123806. protected _update(): void;
  123807. private static _Scale;
  123808. /**
  123809. * Creates the lines for a light mesh
  123810. */
  123811. private static _CreateLightLines;
  123812. /**
  123813. * Disposes of the light gizmo
  123814. */
  123815. dispose(): void;
  123816. private static _CreateHemisphericLightMesh;
  123817. private static _CreatePointLightMesh;
  123818. private static _CreateSpotLightMesh;
  123819. private static _CreateDirectionalLightMesh;
  123820. }
  123821. }
  123822. declare module BABYLON {
  123823. /** @hidden */
  123824. export var backgroundFragmentDeclaration: {
  123825. name: string;
  123826. shader: string;
  123827. };
  123828. }
  123829. declare module BABYLON {
  123830. /** @hidden */
  123831. export var backgroundUboDeclaration: {
  123832. name: string;
  123833. shader: string;
  123834. };
  123835. }
  123836. declare module BABYLON {
  123837. /** @hidden */
  123838. export var backgroundPixelShader: {
  123839. name: string;
  123840. shader: string;
  123841. };
  123842. }
  123843. declare module BABYLON {
  123844. /** @hidden */
  123845. export var backgroundVertexDeclaration: {
  123846. name: string;
  123847. shader: string;
  123848. };
  123849. }
  123850. declare module BABYLON {
  123851. /** @hidden */
  123852. export var backgroundVertexShader: {
  123853. name: string;
  123854. shader: string;
  123855. };
  123856. }
  123857. declare module BABYLON {
  123858. /**
  123859. * Background material used to create an efficient environement around your scene.
  123860. */
  123861. export class BackgroundMaterial extends PushMaterial {
  123862. /**
  123863. * Standard reflectance value at parallel view angle.
  123864. */
  123865. static StandardReflectance0: number;
  123866. /**
  123867. * Standard reflectance value at grazing angle.
  123868. */
  123869. static StandardReflectance90: number;
  123870. protected _primaryColor: Color3;
  123871. /**
  123872. * Key light Color (multiply against the environement texture)
  123873. */
  123874. primaryColor: Color3;
  123875. protected __perceptualColor: Nullable<Color3>;
  123876. /**
  123877. * Experimental Internal Use Only.
  123878. *
  123879. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  123880. * This acts as a helper to set the primary color to a more "human friendly" value.
  123881. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  123882. * output color as close as possible from the chosen value.
  123883. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  123884. * part of lighting setup.)
  123885. */
  123886. get _perceptualColor(): Nullable<Color3>;
  123887. set _perceptualColor(value: Nullable<Color3>);
  123888. protected _primaryColorShadowLevel: float;
  123889. /**
  123890. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  123891. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  123892. */
  123893. get primaryColorShadowLevel(): float;
  123894. set primaryColorShadowLevel(value: float);
  123895. protected _primaryColorHighlightLevel: float;
  123896. /**
  123897. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  123898. * The primary color is used at the level chosen to define what the white area would look.
  123899. */
  123900. get primaryColorHighlightLevel(): float;
  123901. set primaryColorHighlightLevel(value: float);
  123902. protected _reflectionTexture: Nullable<BaseTexture>;
  123903. /**
  123904. * Reflection Texture used in the material.
  123905. * Should be author in a specific way for the best result (refer to the documentation).
  123906. */
  123907. reflectionTexture: Nullable<BaseTexture>;
  123908. protected _reflectionBlur: float;
  123909. /**
  123910. * Reflection Texture level of blur.
  123911. *
  123912. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  123913. * texture twice.
  123914. */
  123915. reflectionBlur: float;
  123916. protected _diffuseTexture: Nullable<BaseTexture>;
  123917. /**
  123918. * Diffuse Texture used in the material.
  123919. * Should be author in a specific way for the best result (refer to the documentation).
  123920. */
  123921. diffuseTexture: Nullable<BaseTexture>;
  123922. protected _shadowLights: Nullable<IShadowLight[]>;
  123923. /**
  123924. * Specify the list of lights casting shadow on the material.
  123925. * All scene shadow lights will be included if null.
  123926. */
  123927. shadowLights: Nullable<IShadowLight[]>;
  123928. protected _shadowLevel: float;
  123929. /**
  123930. * Helps adjusting the shadow to a softer level if required.
  123931. * 0 means black shadows and 1 means no shadows.
  123932. */
  123933. shadowLevel: float;
  123934. protected _sceneCenter: Vector3;
  123935. /**
  123936. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  123937. * It is usually zero but might be interesting to modify according to your setup.
  123938. */
  123939. sceneCenter: Vector3;
  123940. protected _opacityFresnel: boolean;
  123941. /**
  123942. * This helps specifying that the material is falling off to the sky box at grazing angle.
  123943. * This helps ensuring a nice transition when the camera goes under the ground.
  123944. */
  123945. opacityFresnel: boolean;
  123946. protected _reflectionFresnel: boolean;
  123947. /**
  123948. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  123949. * This helps adding a mirror texture on the ground.
  123950. */
  123951. reflectionFresnel: boolean;
  123952. protected _reflectionFalloffDistance: number;
  123953. /**
  123954. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  123955. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  123956. */
  123957. reflectionFalloffDistance: number;
  123958. protected _reflectionAmount: number;
  123959. /**
  123960. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  123961. */
  123962. reflectionAmount: number;
  123963. protected _reflectionReflectance0: number;
  123964. /**
  123965. * This specifies the weight of the reflection at grazing angle.
  123966. */
  123967. reflectionReflectance0: number;
  123968. protected _reflectionReflectance90: number;
  123969. /**
  123970. * This specifies the weight of the reflection at a perpendicular point of view.
  123971. */
  123972. reflectionReflectance90: number;
  123973. /**
  123974. * Sets the reflection reflectance fresnel values according to the default standard
  123975. * empirically know to work well :-)
  123976. */
  123977. set reflectionStandardFresnelWeight(value: number);
  123978. protected _useRGBColor: boolean;
  123979. /**
  123980. * Helps to directly use the maps channels instead of their level.
  123981. */
  123982. useRGBColor: boolean;
  123983. protected _enableNoise: boolean;
  123984. /**
  123985. * This helps reducing the banding effect that could occur on the background.
  123986. */
  123987. enableNoise: boolean;
  123988. /**
  123989. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  123990. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  123991. * Recommended to be keep at 1.0 except for special cases.
  123992. */
  123993. get fovMultiplier(): number;
  123994. set fovMultiplier(value: number);
  123995. private _fovMultiplier;
  123996. /**
  123997. * Enable the FOV adjustment feature controlled by fovMultiplier.
  123998. */
  123999. useEquirectangularFOV: boolean;
  124000. private _maxSimultaneousLights;
  124001. /**
  124002. * Number of Simultaneous lights allowed on the material.
  124003. */
  124004. maxSimultaneousLights: int;
  124005. /**
  124006. * Default configuration related to image processing available in the Background Material.
  124007. */
  124008. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  124009. /**
  124010. * Keep track of the image processing observer to allow dispose and replace.
  124011. */
  124012. private _imageProcessingObserver;
  124013. /**
  124014. * Attaches a new image processing configuration to the PBR Material.
  124015. * @param configuration (if null the scene configuration will be use)
  124016. */
  124017. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  124018. /**
  124019. * Gets the image processing configuration used either in this material.
  124020. */
  124021. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  124022. /**
  124023. * Sets the Default image processing configuration used either in the this material.
  124024. *
  124025. * If sets to null, the scene one is in use.
  124026. */
  124027. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  124028. /**
  124029. * Gets wether the color curves effect is enabled.
  124030. */
  124031. get cameraColorCurvesEnabled(): boolean;
  124032. /**
  124033. * Sets wether the color curves effect is enabled.
  124034. */
  124035. set cameraColorCurvesEnabled(value: boolean);
  124036. /**
  124037. * Gets wether the color grading effect is enabled.
  124038. */
  124039. get cameraColorGradingEnabled(): boolean;
  124040. /**
  124041. * Gets wether the color grading effect is enabled.
  124042. */
  124043. set cameraColorGradingEnabled(value: boolean);
  124044. /**
  124045. * Gets wether tonemapping is enabled or not.
  124046. */
  124047. get cameraToneMappingEnabled(): boolean;
  124048. /**
  124049. * Sets wether tonemapping is enabled or not
  124050. */
  124051. set cameraToneMappingEnabled(value: boolean);
  124052. /**
  124053. * The camera exposure used on this material.
  124054. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124055. * This corresponds to a photographic exposure.
  124056. */
  124057. get cameraExposure(): float;
  124058. /**
  124059. * The camera exposure used on this material.
  124060. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  124061. * This corresponds to a photographic exposure.
  124062. */
  124063. set cameraExposure(value: float);
  124064. /**
  124065. * Gets The camera contrast used on this material.
  124066. */
  124067. get cameraContrast(): float;
  124068. /**
  124069. * Sets The camera contrast used on this material.
  124070. */
  124071. set cameraContrast(value: float);
  124072. /**
  124073. * Gets the Color Grading 2D Lookup Texture.
  124074. */
  124075. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  124076. /**
  124077. * Sets the Color Grading 2D Lookup Texture.
  124078. */
  124079. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  124080. /**
  124081. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124082. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124083. * 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;
  124084. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124085. */
  124086. get cameraColorCurves(): Nullable<ColorCurves>;
  124087. /**
  124088. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  124089. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  124090. * 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;
  124091. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  124092. */
  124093. set cameraColorCurves(value: Nullable<ColorCurves>);
  124094. /**
  124095. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  124096. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  124097. */
  124098. switchToBGR: boolean;
  124099. private _renderTargets;
  124100. private _reflectionControls;
  124101. private _white;
  124102. private _primaryShadowColor;
  124103. private _primaryHighlightColor;
  124104. /**
  124105. * Instantiates a Background Material in the given scene
  124106. * @param name The friendly name of the material
  124107. * @param scene The scene to add the material to
  124108. */
  124109. constructor(name: string, scene: Scene);
  124110. /**
  124111. * Gets a boolean indicating that current material needs to register RTT
  124112. */
  124113. get hasRenderTargetTextures(): boolean;
  124114. /**
  124115. * The entire material has been created in order to prevent overdraw.
  124116. * @returns false
  124117. */
  124118. needAlphaTesting(): boolean;
  124119. /**
  124120. * The entire material has been created in order to prevent overdraw.
  124121. * @returns true if blending is enable
  124122. */
  124123. needAlphaBlending(): boolean;
  124124. /**
  124125. * Checks wether the material is ready to be rendered for a given mesh.
  124126. * @param mesh The mesh to render
  124127. * @param subMesh The submesh to check against
  124128. * @param useInstances Specify wether or not the material is used with instances
  124129. * @returns true if all the dependencies are ready (Textures, Effects...)
  124130. */
  124131. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  124132. /**
  124133. * Compute the primary color according to the chosen perceptual color.
  124134. */
  124135. private _computePrimaryColorFromPerceptualColor;
  124136. /**
  124137. * Compute the highlights and shadow colors according to their chosen levels.
  124138. */
  124139. private _computePrimaryColors;
  124140. /**
  124141. * Build the uniform buffer used in the material.
  124142. */
  124143. buildUniformLayout(): void;
  124144. /**
  124145. * Unbind the material.
  124146. */
  124147. unbind(): void;
  124148. /**
  124149. * Bind only the world matrix to the material.
  124150. * @param world The world matrix to bind.
  124151. */
  124152. bindOnlyWorldMatrix(world: Matrix): void;
  124153. /**
  124154. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  124155. * @param world The world matrix to bind.
  124156. * @param subMesh The submesh to bind for.
  124157. */
  124158. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  124159. /**
  124160. * Checks to see if a texture is used in the material.
  124161. * @param texture - Base texture to use.
  124162. * @returns - Boolean specifying if a texture is used in the material.
  124163. */
  124164. hasTexture(texture: BaseTexture): boolean;
  124165. /**
  124166. * Dispose the material.
  124167. * @param forceDisposeEffect Force disposal of the associated effect.
  124168. * @param forceDisposeTextures Force disposal of the associated textures.
  124169. */
  124170. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  124171. /**
  124172. * Clones the material.
  124173. * @param name The cloned name.
  124174. * @returns The cloned material.
  124175. */
  124176. clone(name: string): BackgroundMaterial;
  124177. /**
  124178. * Serializes the current material to its JSON representation.
  124179. * @returns The JSON representation.
  124180. */
  124181. serialize(): any;
  124182. /**
  124183. * Gets the class name of the material
  124184. * @returns "BackgroundMaterial"
  124185. */
  124186. getClassName(): string;
  124187. /**
  124188. * Parse a JSON input to create back a background material.
  124189. * @param source The JSON data to parse
  124190. * @param scene The scene to create the parsed material in
  124191. * @param rootUrl The root url of the assets the material depends upon
  124192. * @returns the instantiated BackgroundMaterial.
  124193. */
  124194. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  124195. }
  124196. }
  124197. declare module BABYLON {
  124198. /**
  124199. * Represents the different options available during the creation of
  124200. * a Environment helper.
  124201. *
  124202. * This can control the default ground, skybox and image processing setup of your scene.
  124203. */
  124204. export interface IEnvironmentHelperOptions {
  124205. /**
  124206. * Specifies whether or not to create a ground.
  124207. * True by default.
  124208. */
  124209. createGround: boolean;
  124210. /**
  124211. * Specifies the ground size.
  124212. * 15 by default.
  124213. */
  124214. groundSize: number;
  124215. /**
  124216. * The texture used on the ground for the main color.
  124217. * Comes from the BabylonJS CDN by default.
  124218. *
  124219. * Remarks: Can be either a texture or a url.
  124220. */
  124221. groundTexture: string | BaseTexture;
  124222. /**
  124223. * The color mixed in the ground texture by default.
  124224. * BabylonJS clearColor by default.
  124225. */
  124226. groundColor: Color3;
  124227. /**
  124228. * Specifies the ground opacity.
  124229. * 1 by default.
  124230. */
  124231. groundOpacity: number;
  124232. /**
  124233. * Enables the ground to receive shadows.
  124234. * True by default.
  124235. */
  124236. enableGroundShadow: boolean;
  124237. /**
  124238. * Helps preventing the shadow to be fully black on the ground.
  124239. * 0.5 by default.
  124240. */
  124241. groundShadowLevel: number;
  124242. /**
  124243. * Creates a mirror texture attach to the ground.
  124244. * false by default.
  124245. */
  124246. enableGroundMirror: boolean;
  124247. /**
  124248. * Specifies the ground mirror size ratio.
  124249. * 0.3 by default as the default kernel is 64.
  124250. */
  124251. groundMirrorSizeRatio: number;
  124252. /**
  124253. * Specifies the ground mirror blur kernel size.
  124254. * 64 by default.
  124255. */
  124256. groundMirrorBlurKernel: number;
  124257. /**
  124258. * Specifies the ground mirror visibility amount.
  124259. * 1 by default
  124260. */
  124261. groundMirrorAmount: number;
  124262. /**
  124263. * Specifies the ground mirror reflectance weight.
  124264. * This uses the standard weight of the background material to setup the fresnel effect
  124265. * of the mirror.
  124266. * 1 by default.
  124267. */
  124268. groundMirrorFresnelWeight: number;
  124269. /**
  124270. * Specifies the ground mirror Falloff distance.
  124271. * This can helps reducing the size of the reflection.
  124272. * 0 by Default.
  124273. */
  124274. groundMirrorFallOffDistance: number;
  124275. /**
  124276. * Specifies the ground mirror texture type.
  124277. * Unsigned Int by Default.
  124278. */
  124279. groundMirrorTextureType: number;
  124280. /**
  124281. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  124282. * the shown objects.
  124283. */
  124284. groundYBias: number;
  124285. /**
  124286. * Specifies whether or not to create a skybox.
  124287. * True by default.
  124288. */
  124289. createSkybox: boolean;
  124290. /**
  124291. * Specifies the skybox size.
  124292. * 20 by default.
  124293. */
  124294. skyboxSize: number;
  124295. /**
  124296. * The texture used on the skybox for the main color.
  124297. * Comes from the BabylonJS CDN by default.
  124298. *
  124299. * Remarks: Can be either a texture or a url.
  124300. */
  124301. skyboxTexture: string | BaseTexture;
  124302. /**
  124303. * The color mixed in the skybox texture by default.
  124304. * BabylonJS clearColor by default.
  124305. */
  124306. skyboxColor: Color3;
  124307. /**
  124308. * The background rotation around the Y axis of the scene.
  124309. * This helps aligning the key lights of your scene with the background.
  124310. * 0 by default.
  124311. */
  124312. backgroundYRotation: number;
  124313. /**
  124314. * Compute automatically the size of the elements to best fit with the scene.
  124315. */
  124316. sizeAuto: boolean;
  124317. /**
  124318. * Default position of the rootMesh if autoSize is not true.
  124319. */
  124320. rootPosition: Vector3;
  124321. /**
  124322. * Sets up the image processing in the scene.
  124323. * true by default.
  124324. */
  124325. setupImageProcessing: boolean;
  124326. /**
  124327. * The texture used as your environment texture in the scene.
  124328. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  124329. *
  124330. * Remarks: Can be either a texture or a url.
  124331. */
  124332. environmentTexture: string | BaseTexture;
  124333. /**
  124334. * The value of the exposure to apply to the scene.
  124335. * 0.6 by default if setupImageProcessing is true.
  124336. */
  124337. cameraExposure: number;
  124338. /**
  124339. * The value of the contrast to apply to the scene.
  124340. * 1.6 by default if setupImageProcessing is true.
  124341. */
  124342. cameraContrast: number;
  124343. /**
  124344. * Specifies whether or not tonemapping should be enabled in the scene.
  124345. * true by default if setupImageProcessing is true.
  124346. */
  124347. toneMappingEnabled: boolean;
  124348. }
  124349. /**
  124350. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  124351. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  124352. * It also helps with the default setup of your imageProcessing configuration.
  124353. */
  124354. export class EnvironmentHelper {
  124355. /**
  124356. * Default ground texture URL.
  124357. */
  124358. private static _groundTextureCDNUrl;
  124359. /**
  124360. * Default skybox texture URL.
  124361. */
  124362. private static _skyboxTextureCDNUrl;
  124363. /**
  124364. * Default environment texture URL.
  124365. */
  124366. private static _environmentTextureCDNUrl;
  124367. /**
  124368. * Creates the default options for the helper.
  124369. */
  124370. private static _getDefaultOptions;
  124371. private _rootMesh;
  124372. /**
  124373. * Gets the root mesh created by the helper.
  124374. */
  124375. get rootMesh(): Mesh;
  124376. private _skybox;
  124377. /**
  124378. * Gets the skybox created by the helper.
  124379. */
  124380. get skybox(): Nullable<Mesh>;
  124381. private _skyboxTexture;
  124382. /**
  124383. * Gets the skybox texture created by the helper.
  124384. */
  124385. get skyboxTexture(): Nullable<BaseTexture>;
  124386. private _skyboxMaterial;
  124387. /**
  124388. * Gets the skybox material created by the helper.
  124389. */
  124390. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  124391. private _ground;
  124392. /**
  124393. * Gets the ground mesh created by the helper.
  124394. */
  124395. get ground(): Nullable<Mesh>;
  124396. private _groundTexture;
  124397. /**
  124398. * Gets the ground texture created by the helper.
  124399. */
  124400. get groundTexture(): Nullable<BaseTexture>;
  124401. private _groundMirror;
  124402. /**
  124403. * Gets the ground mirror created by the helper.
  124404. */
  124405. get groundMirror(): Nullable<MirrorTexture>;
  124406. /**
  124407. * Gets the ground mirror render list to helps pushing the meshes
  124408. * you wish in the ground reflection.
  124409. */
  124410. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  124411. private _groundMaterial;
  124412. /**
  124413. * Gets the ground material created by the helper.
  124414. */
  124415. get groundMaterial(): Nullable<BackgroundMaterial>;
  124416. /**
  124417. * Stores the creation options.
  124418. */
  124419. private readonly _scene;
  124420. private _options;
  124421. /**
  124422. * This observable will be notified with any error during the creation of the environment,
  124423. * mainly texture creation errors.
  124424. */
  124425. onErrorObservable: Observable<{
  124426. message?: string;
  124427. exception?: any;
  124428. }>;
  124429. /**
  124430. * constructor
  124431. * @param options Defines the options we want to customize the helper
  124432. * @param scene The scene to add the material to
  124433. */
  124434. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  124435. /**
  124436. * Updates the background according to the new options
  124437. * @param options
  124438. */
  124439. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  124440. /**
  124441. * Sets the primary color of all the available elements.
  124442. * @param color the main color to affect to the ground and the background
  124443. */
  124444. setMainColor(color: Color3): void;
  124445. /**
  124446. * Setup the image processing according to the specified options.
  124447. */
  124448. private _setupImageProcessing;
  124449. /**
  124450. * Setup the environment texture according to the specified options.
  124451. */
  124452. private _setupEnvironmentTexture;
  124453. /**
  124454. * Setup the background according to the specified options.
  124455. */
  124456. private _setupBackground;
  124457. /**
  124458. * Get the scene sizes according to the setup.
  124459. */
  124460. private _getSceneSize;
  124461. /**
  124462. * Setup the ground according to the specified options.
  124463. */
  124464. private _setupGround;
  124465. /**
  124466. * Setup the ground material according to the specified options.
  124467. */
  124468. private _setupGroundMaterial;
  124469. /**
  124470. * Setup the ground diffuse texture according to the specified options.
  124471. */
  124472. private _setupGroundDiffuseTexture;
  124473. /**
  124474. * Setup the ground mirror texture according to the specified options.
  124475. */
  124476. private _setupGroundMirrorTexture;
  124477. /**
  124478. * Setup the ground to receive the mirror texture.
  124479. */
  124480. private _setupMirrorInGroundMaterial;
  124481. /**
  124482. * Setup the skybox according to the specified options.
  124483. */
  124484. private _setupSkybox;
  124485. /**
  124486. * Setup the skybox material according to the specified options.
  124487. */
  124488. private _setupSkyboxMaterial;
  124489. /**
  124490. * Setup the skybox reflection texture according to the specified options.
  124491. */
  124492. private _setupSkyboxReflectionTexture;
  124493. private _errorHandler;
  124494. /**
  124495. * Dispose all the elements created by the Helper.
  124496. */
  124497. dispose(): void;
  124498. }
  124499. }
  124500. declare module BABYLON {
  124501. /**
  124502. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  124503. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  124504. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  124505. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  124506. */
  124507. export class PhotoDome extends TransformNode {
  124508. /**
  124509. * Define the image as a Monoscopic panoramic 360 image.
  124510. */
  124511. static readonly MODE_MONOSCOPIC: number;
  124512. /**
  124513. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124514. */
  124515. static readonly MODE_TOPBOTTOM: number;
  124516. /**
  124517. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124518. */
  124519. static readonly MODE_SIDEBYSIDE: number;
  124520. private _useDirectMapping;
  124521. /**
  124522. * The texture being displayed on the sphere
  124523. */
  124524. protected _photoTexture: Texture;
  124525. /**
  124526. * Gets or sets the texture being displayed on the sphere
  124527. */
  124528. get photoTexture(): Texture;
  124529. set photoTexture(value: Texture);
  124530. /**
  124531. * Observable raised when an error occured while loading the 360 image
  124532. */
  124533. onLoadErrorObservable: Observable<string>;
  124534. /**
  124535. * The skybox material
  124536. */
  124537. protected _material: BackgroundMaterial;
  124538. /**
  124539. * The surface used for the skybox
  124540. */
  124541. protected _mesh: Mesh;
  124542. /**
  124543. * Gets the mesh used for the skybox.
  124544. */
  124545. get mesh(): Mesh;
  124546. /**
  124547. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  124548. * Also see the options.resolution property.
  124549. */
  124550. get fovMultiplier(): number;
  124551. set fovMultiplier(value: number);
  124552. private _imageMode;
  124553. /**
  124554. * Gets or set the current video mode for the video. It can be:
  124555. * * PhotoDome.MODE_MONOSCOPIC : Define the image as a Monoscopic panoramic 360 image.
  124556. * * PhotoDome.MODE_TOPBOTTOM : Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  124557. * * PhotoDome.MODE_SIDEBYSIDE : Define the image as a Stereoscopic Side by Side panoramic 360 image.
  124558. */
  124559. get imageMode(): number;
  124560. set imageMode(value: number);
  124561. /**
  124562. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  124563. * @param name Element's name, child elements will append suffixes for their own names.
  124564. * @param urlsOfPhoto defines the url of the photo to display
  124565. * @param options defines an object containing optional or exposed sub element properties
  124566. * @param onError defines a callback called when an error occured while loading the texture
  124567. */
  124568. constructor(name: string, urlOfPhoto: string, options: {
  124569. resolution?: number;
  124570. size?: number;
  124571. useDirectMapping?: boolean;
  124572. faceForward?: boolean;
  124573. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  124574. private _onBeforeCameraRenderObserver;
  124575. private _changeImageMode;
  124576. /**
  124577. * Releases resources associated with this node.
  124578. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  124579. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  124580. */
  124581. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  124582. }
  124583. }
  124584. declare module BABYLON {
  124585. /**
  124586. * Class used to host RGBD texture specific utilities
  124587. */
  124588. export class RGBDTextureTools {
  124589. /**
  124590. * Expand the RGBD Texture from RGBD to Half Float if possible.
  124591. * @param texture the texture to expand.
  124592. */
  124593. static ExpandRGBDTexture(texture: Texture): void;
  124594. }
  124595. }
  124596. declare module BABYLON {
  124597. /**
  124598. * Class used to host texture specific utilities
  124599. */
  124600. export class BRDFTextureTools {
  124601. /**
  124602. * Prevents texture cache collision
  124603. */
  124604. private static _instanceNumber;
  124605. /**
  124606. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  124607. * @param scene defines the hosting scene
  124608. * @returns the environment BRDF texture
  124609. */
  124610. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  124611. private static _environmentBRDFBase64Texture;
  124612. }
  124613. }
  124614. declare module BABYLON {
  124615. /**
  124616. * @hidden
  124617. */
  124618. export interface IMaterialClearCoatDefines {
  124619. CLEARCOAT: boolean;
  124620. CLEARCOAT_DEFAULTIOR: boolean;
  124621. CLEARCOAT_TEXTURE: boolean;
  124622. CLEARCOAT_TEXTUREDIRECTUV: number;
  124623. CLEARCOAT_BUMP: boolean;
  124624. CLEARCOAT_BUMPDIRECTUV: number;
  124625. CLEARCOAT_TINT: boolean;
  124626. CLEARCOAT_TINT_TEXTURE: boolean;
  124627. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  124628. /** @hidden */
  124629. _areTexturesDirty: boolean;
  124630. }
  124631. /**
  124632. * Define the code related to the clear coat parameters of the pbr material.
  124633. */
  124634. export class PBRClearCoatConfiguration {
  124635. /**
  124636. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124637. * The default fits with a polyurethane material.
  124638. */
  124639. private static readonly _DefaultIndexOfRefraction;
  124640. private _isEnabled;
  124641. /**
  124642. * Defines if the clear coat is enabled in the material.
  124643. */
  124644. isEnabled: boolean;
  124645. /**
  124646. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  124647. */
  124648. intensity: number;
  124649. /**
  124650. * Defines the clear coat layer roughness.
  124651. */
  124652. roughness: number;
  124653. private _indexOfRefraction;
  124654. /**
  124655. * Defines the index of refraction of the clear coat.
  124656. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  124657. * The default fits with a polyurethane material.
  124658. * Changing the default value is more performance intensive.
  124659. */
  124660. indexOfRefraction: number;
  124661. private _texture;
  124662. /**
  124663. * Stores the clear coat values in a texture.
  124664. */
  124665. texture: Nullable<BaseTexture>;
  124666. private _bumpTexture;
  124667. /**
  124668. * Define the clear coat specific bump texture.
  124669. */
  124670. bumpTexture: Nullable<BaseTexture>;
  124671. private _isTintEnabled;
  124672. /**
  124673. * Defines if the clear coat tint is enabled in the material.
  124674. */
  124675. isTintEnabled: boolean;
  124676. /**
  124677. * Defines the clear coat tint of the material.
  124678. * This is only use if tint is enabled
  124679. */
  124680. tintColor: Color3;
  124681. /**
  124682. * Defines the distance at which the tint color should be found in the
  124683. * clear coat media.
  124684. * This is only use if tint is enabled
  124685. */
  124686. tintColorAtDistance: number;
  124687. /**
  124688. * Defines the clear coat layer thickness.
  124689. * This is only use if tint is enabled
  124690. */
  124691. tintThickness: number;
  124692. private _tintTexture;
  124693. /**
  124694. * Stores the clear tint values in a texture.
  124695. * rgb is tint
  124696. * a is a thickness factor
  124697. */
  124698. tintTexture: Nullable<BaseTexture>;
  124699. /** @hidden */
  124700. private _internalMarkAllSubMeshesAsTexturesDirty;
  124701. /** @hidden */
  124702. _markAllSubMeshesAsTexturesDirty(): void;
  124703. /**
  124704. * Instantiate a new istance of clear coat configuration.
  124705. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124706. */
  124707. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124708. /**
  124709. * Gets wehter the submesh is ready to be used or not.
  124710. * @param defines the list of "defines" to update.
  124711. * @param scene defines the scene the material belongs to.
  124712. * @param engine defines the engine the material belongs to.
  124713. * @param disableBumpMap defines wether the material disables bump or not.
  124714. * @returns - boolean indicating that the submesh is ready or not.
  124715. */
  124716. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  124717. /**
  124718. * Checks to see if a texture is used in the material.
  124719. * @param defines the list of "defines" to update.
  124720. * @param scene defines the scene to the material belongs to.
  124721. */
  124722. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  124723. /**
  124724. * Binds the material data.
  124725. * @param uniformBuffer defines the Uniform buffer to fill in.
  124726. * @param scene defines the scene the material belongs to.
  124727. * @param engine defines the engine the material belongs to.
  124728. * @param disableBumpMap defines wether the material disables bump or not.
  124729. * @param isFrozen defines wether the material is frozen or not.
  124730. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  124731. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  124732. */
  124733. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  124734. /**
  124735. * Checks to see if a texture is used in the material.
  124736. * @param texture - Base texture to use.
  124737. * @returns - Boolean specifying if a texture is used in the material.
  124738. */
  124739. hasTexture(texture: BaseTexture): boolean;
  124740. /**
  124741. * Returns an array of the actively used textures.
  124742. * @param activeTextures Array of BaseTextures
  124743. */
  124744. getActiveTextures(activeTextures: BaseTexture[]): void;
  124745. /**
  124746. * Returns the animatable textures.
  124747. * @param animatables Array of animatable textures.
  124748. */
  124749. getAnimatables(animatables: IAnimatable[]): void;
  124750. /**
  124751. * Disposes the resources of the material.
  124752. * @param forceDisposeTextures - Forces the disposal of all textures.
  124753. */
  124754. dispose(forceDisposeTextures?: boolean): void;
  124755. /**
  124756. * Get the current class name of the texture useful for serialization or dynamic coding.
  124757. * @returns "PBRClearCoatConfiguration"
  124758. */
  124759. getClassName(): string;
  124760. /**
  124761. * Add fallbacks to the effect fallbacks list.
  124762. * @param defines defines the Base texture to use.
  124763. * @param fallbacks defines the current fallback list.
  124764. * @param currentRank defines the current fallback rank.
  124765. * @returns the new fallback rank.
  124766. */
  124767. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124768. /**
  124769. * Add the required uniforms to the current list.
  124770. * @param uniforms defines the current uniform list.
  124771. */
  124772. static AddUniforms(uniforms: string[]): void;
  124773. /**
  124774. * Add the required samplers to the current list.
  124775. * @param samplers defines the current sampler list.
  124776. */
  124777. static AddSamplers(samplers: string[]): void;
  124778. /**
  124779. * Add the required uniforms to the current buffer.
  124780. * @param uniformBuffer defines the current uniform buffer.
  124781. */
  124782. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124783. /**
  124784. * Makes a duplicate of the current configuration into another one.
  124785. * @param clearCoatConfiguration define the config where to copy the info
  124786. */
  124787. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  124788. /**
  124789. * Serializes this clear coat configuration.
  124790. * @returns - An object with the serialized config.
  124791. */
  124792. serialize(): any;
  124793. /**
  124794. * Parses a anisotropy Configuration from a serialized object.
  124795. * @param source - Serialized object.
  124796. * @param scene Defines the scene we are parsing for
  124797. * @param rootUrl Defines the rootUrl to load from
  124798. */
  124799. parse(source: any, scene: Scene, rootUrl: string): void;
  124800. }
  124801. }
  124802. declare module BABYLON {
  124803. /**
  124804. * @hidden
  124805. */
  124806. export interface IMaterialAnisotropicDefines {
  124807. ANISOTROPIC: boolean;
  124808. ANISOTROPIC_TEXTURE: boolean;
  124809. ANISOTROPIC_TEXTUREDIRECTUV: number;
  124810. MAINUV1: boolean;
  124811. _areTexturesDirty: boolean;
  124812. _needUVs: boolean;
  124813. }
  124814. /**
  124815. * Define the code related to the anisotropic parameters of the pbr material.
  124816. */
  124817. export class PBRAnisotropicConfiguration {
  124818. private _isEnabled;
  124819. /**
  124820. * Defines if the anisotropy is enabled in the material.
  124821. */
  124822. isEnabled: boolean;
  124823. /**
  124824. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  124825. */
  124826. intensity: number;
  124827. /**
  124828. * Defines if the effect is along the tangents, bitangents or in between.
  124829. * By default, the effect is "strectching" the highlights along the tangents.
  124830. */
  124831. direction: Vector2;
  124832. private _texture;
  124833. /**
  124834. * Stores the anisotropy values in a texture.
  124835. * rg is direction (like normal from -1 to 1)
  124836. * b is a intensity
  124837. */
  124838. texture: Nullable<BaseTexture>;
  124839. /** @hidden */
  124840. private _internalMarkAllSubMeshesAsTexturesDirty;
  124841. /** @hidden */
  124842. _markAllSubMeshesAsTexturesDirty(): void;
  124843. /**
  124844. * Instantiate a new istance of anisotropy configuration.
  124845. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  124846. */
  124847. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  124848. /**
  124849. * Specifies that the submesh is ready to be used.
  124850. * @param defines the list of "defines" to update.
  124851. * @param scene defines the scene the material belongs to.
  124852. * @returns - boolean indicating that the submesh is ready or not.
  124853. */
  124854. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  124855. /**
  124856. * Checks to see if a texture is used in the material.
  124857. * @param defines the list of "defines" to update.
  124858. * @param mesh the mesh we are preparing the defines for.
  124859. * @param scene defines the scene the material belongs to.
  124860. */
  124861. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  124862. /**
  124863. * Binds the material data.
  124864. * @param uniformBuffer defines the Uniform buffer to fill in.
  124865. * @param scene defines the scene the material belongs to.
  124866. * @param isFrozen defines wether the material is frozen or not.
  124867. */
  124868. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  124869. /**
  124870. * Checks to see if a texture is used in the material.
  124871. * @param texture - Base texture to use.
  124872. * @returns - Boolean specifying if a texture is used in the material.
  124873. */
  124874. hasTexture(texture: BaseTexture): boolean;
  124875. /**
  124876. * Returns an array of the actively used textures.
  124877. * @param activeTextures Array of BaseTextures
  124878. */
  124879. getActiveTextures(activeTextures: BaseTexture[]): void;
  124880. /**
  124881. * Returns the animatable textures.
  124882. * @param animatables Array of animatable textures.
  124883. */
  124884. getAnimatables(animatables: IAnimatable[]): void;
  124885. /**
  124886. * Disposes the resources of the material.
  124887. * @param forceDisposeTextures - Forces the disposal of all textures.
  124888. */
  124889. dispose(forceDisposeTextures?: boolean): void;
  124890. /**
  124891. * Get the current class name of the texture useful for serialization or dynamic coding.
  124892. * @returns "PBRAnisotropicConfiguration"
  124893. */
  124894. getClassName(): string;
  124895. /**
  124896. * Add fallbacks to the effect fallbacks list.
  124897. * @param defines defines the Base texture to use.
  124898. * @param fallbacks defines the current fallback list.
  124899. * @param currentRank defines the current fallback rank.
  124900. * @returns the new fallback rank.
  124901. */
  124902. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  124903. /**
  124904. * Add the required uniforms to the current list.
  124905. * @param uniforms defines the current uniform list.
  124906. */
  124907. static AddUniforms(uniforms: string[]): void;
  124908. /**
  124909. * Add the required uniforms to the current buffer.
  124910. * @param uniformBuffer defines the current uniform buffer.
  124911. */
  124912. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  124913. /**
  124914. * Add the required samplers to the current list.
  124915. * @param samplers defines the current sampler list.
  124916. */
  124917. static AddSamplers(samplers: string[]): void;
  124918. /**
  124919. * Makes a duplicate of the current configuration into another one.
  124920. * @param anisotropicConfiguration define the config where to copy the info
  124921. */
  124922. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  124923. /**
  124924. * Serializes this anisotropy configuration.
  124925. * @returns - An object with the serialized config.
  124926. */
  124927. serialize(): any;
  124928. /**
  124929. * Parses a anisotropy Configuration from a serialized object.
  124930. * @param source - Serialized object.
  124931. * @param scene Defines the scene we are parsing for
  124932. * @param rootUrl Defines the rootUrl to load from
  124933. */
  124934. parse(source: any, scene: Scene, rootUrl: string): void;
  124935. }
  124936. }
  124937. declare module BABYLON {
  124938. /**
  124939. * @hidden
  124940. */
  124941. export interface IMaterialBRDFDefines {
  124942. BRDF_V_HEIGHT_CORRELATED: boolean;
  124943. MS_BRDF_ENERGY_CONSERVATION: boolean;
  124944. SPHERICAL_HARMONICS: boolean;
  124945. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  124946. /** @hidden */
  124947. _areMiscDirty: boolean;
  124948. }
  124949. /**
  124950. * Define the code related to the BRDF parameters of the pbr material.
  124951. */
  124952. export class PBRBRDFConfiguration {
  124953. /**
  124954. * Default value used for the energy conservation.
  124955. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124956. */
  124957. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  124958. /**
  124959. * Default value used for the Smith Visibility Height Correlated mode.
  124960. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  124961. */
  124962. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  124963. /**
  124964. * Default value used for the IBL diffuse part.
  124965. * This can help switching back to the polynomials mode globally which is a tiny bit
  124966. * less GPU intensive at the drawback of a lower quality.
  124967. */
  124968. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  124969. /**
  124970. * Default value used for activating energy conservation for the specular workflow.
  124971. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  124972. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  124973. */
  124974. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  124975. private _useEnergyConservation;
  124976. /**
  124977. * Defines if the material uses energy conservation.
  124978. */
  124979. useEnergyConservation: boolean;
  124980. private _useSmithVisibilityHeightCorrelated;
  124981. /**
  124982. * LEGACY Mode set to false
  124983. * Defines if the material uses height smith correlated visibility term.
  124984. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  124985. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  124986. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  124987. * Not relying on height correlated will also disable energy conservation.
  124988. */
  124989. useSmithVisibilityHeightCorrelated: boolean;
  124990. private _useSphericalHarmonics;
  124991. /**
  124992. * LEGACY Mode set to false
  124993. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  124994. * diffuse part of the IBL.
  124995. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  124996. * to the ground truth.
  124997. */
  124998. useSphericalHarmonics: boolean;
  124999. private _useSpecularGlossinessInputEnergyConservation;
  125000. /**
  125001. * Defines if the material uses energy conservation, when the specular workflow is active.
  125002. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  125003. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  125004. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  125005. */
  125006. useSpecularGlossinessInputEnergyConservation: boolean;
  125007. /** @hidden */
  125008. private _internalMarkAllSubMeshesAsMiscDirty;
  125009. /** @hidden */
  125010. _markAllSubMeshesAsMiscDirty(): void;
  125011. /**
  125012. * Instantiate a new istance of clear coat configuration.
  125013. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  125014. */
  125015. constructor(markAllSubMeshesAsMiscDirty: () => void);
  125016. /**
  125017. * Checks to see if a texture is used in the material.
  125018. * @param defines the list of "defines" to update.
  125019. */
  125020. prepareDefines(defines: IMaterialBRDFDefines): void;
  125021. /**
  125022. * Get the current class name of the texture useful for serialization or dynamic coding.
  125023. * @returns "PBRClearCoatConfiguration"
  125024. */
  125025. getClassName(): string;
  125026. /**
  125027. * Makes a duplicate of the current configuration into another one.
  125028. * @param brdfConfiguration define the config where to copy the info
  125029. */
  125030. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  125031. /**
  125032. * Serializes this BRDF configuration.
  125033. * @returns - An object with the serialized config.
  125034. */
  125035. serialize(): any;
  125036. /**
  125037. * Parses a anisotropy Configuration from a serialized object.
  125038. * @param source - Serialized object.
  125039. * @param scene Defines the scene we are parsing for
  125040. * @param rootUrl Defines the rootUrl to load from
  125041. */
  125042. parse(source: any, scene: Scene, rootUrl: string): void;
  125043. }
  125044. }
  125045. declare module BABYLON {
  125046. /**
  125047. * @hidden
  125048. */
  125049. export interface IMaterialSheenDefines {
  125050. SHEEN: boolean;
  125051. SHEEN_TEXTURE: boolean;
  125052. SHEEN_TEXTUREDIRECTUV: number;
  125053. SHEEN_LINKWITHALBEDO: boolean;
  125054. SHEEN_ROUGHNESS: boolean;
  125055. SHEEN_ALBEDOSCALING: boolean;
  125056. /** @hidden */
  125057. _areTexturesDirty: boolean;
  125058. }
  125059. /**
  125060. * Define the code related to the Sheen parameters of the pbr material.
  125061. */
  125062. export class PBRSheenConfiguration {
  125063. private _isEnabled;
  125064. /**
  125065. * Defines if the material uses sheen.
  125066. */
  125067. isEnabled: boolean;
  125068. private _linkSheenWithAlbedo;
  125069. /**
  125070. * Defines if the sheen is linked to the sheen color.
  125071. */
  125072. linkSheenWithAlbedo: boolean;
  125073. /**
  125074. * Defines the sheen intensity.
  125075. */
  125076. intensity: number;
  125077. /**
  125078. * Defines the sheen color.
  125079. */
  125080. color: Color3;
  125081. private _texture;
  125082. /**
  125083. * Stores the sheen tint values in a texture.
  125084. * rgb is tint
  125085. * a is a intensity
  125086. */
  125087. texture: Nullable<BaseTexture>;
  125088. private _roughness;
  125089. /**
  125090. * Defines the sheen roughness.
  125091. * It is not taken into account if linkSheenWithAlbedo is true.
  125092. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  125093. */
  125094. roughness: Nullable<number>;
  125095. private _albedoScaling;
  125096. /**
  125097. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  125098. * It allows the strength of the sheen effect to not depend on the base color of the material,
  125099. * making it easier to setup and tweak the effect
  125100. */
  125101. albedoScaling: boolean;
  125102. /** @hidden */
  125103. private _internalMarkAllSubMeshesAsTexturesDirty;
  125104. /** @hidden */
  125105. _markAllSubMeshesAsTexturesDirty(): void;
  125106. /**
  125107. * Instantiate a new istance of clear coat configuration.
  125108. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125109. */
  125110. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125111. /**
  125112. * Specifies that the submesh is ready to be used.
  125113. * @param defines the list of "defines" to update.
  125114. * @param scene defines the scene the material belongs to.
  125115. * @returns - boolean indicating that the submesh is ready or not.
  125116. */
  125117. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  125118. /**
  125119. * Checks to see if a texture is used in the material.
  125120. * @param defines the list of "defines" to update.
  125121. * @param scene defines the scene the material belongs to.
  125122. */
  125123. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  125124. /**
  125125. * Binds the material data.
  125126. * @param uniformBuffer defines the Uniform buffer to fill in.
  125127. * @param scene defines the scene the material belongs to.
  125128. * @param isFrozen defines wether the material is frozen or not.
  125129. */
  125130. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  125131. /**
  125132. * Checks to see if a texture is used in the material.
  125133. * @param texture - Base texture to use.
  125134. * @returns - Boolean specifying if a texture is used in the material.
  125135. */
  125136. hasTexture(texture: BaseTexture): boolean;
  125137. /**
  125138. * Returns an array of the actively used textures.
  125139. * @param activeTextures Array of BaseTextures
  125140. */
  125141. getActiveTextures(activeTextures: BaseTexture[]): void;
  125142. /**
  125143. * Returns the animatable textures.
  125144. * @param animatables Array of animatable textures.
  125145. */
  125146. getAnimatables(animatables: IAnimatable[]): void;
  125147. /**
  125148. * Disposes the resources of the material.
  125149. * @param forceDisposeTextures - Forces the disposal of all textures.
  125150. */
  125151. dispose(forceDisposeTextures?: boolean): void;
  125152. /**
  125153. * Get the current class name of the texture useful for serialization or dynamic coding.
  125154. * @returns "PBRSheenConfiguration"
  125155. */
  125156. getClassName(): string;
  125157. /**
  125158. * Add fallbacks to the effect fallbacks list.
  125159. * @param defines defines the Base texture to use.
  125160. * @param fallbacks defines the current fallback list.
  125161. * @param currentRank defines the current fallback rank.
  125162. * @returns the new fallback rank.
  125163. */
  125164. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125165. /**
  125166. * Add the required uniforms to the current list.
  125167. * @param uniforms defines the current uniform list.
  125168. */
  125169. static AddUniforms(uniforms: string[]): void;
  125170. /**
  125171. * Add the required uniforms to the current buffer.
  125172. * @param uniformBuffer defines the current uniform buffer.
  125173. */
  125174. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125175. /**
  125176. * Add the required samplers to the current list.
  125177. * @param samplers defines the current sampler list.
  125178. */
  125179. static AddSamplers(samplers: string[]): void;
  125180. /**
  125181. * Makes a duplicate of the current configuration into another one.
  125182. * @param sheenConfiguration define the config where to copy the info
  125183. */
  125184. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  125185. /**
  125186. * Serializes this BRDF configuration.
  125187. * @returns - An object with the serialized config.
  125188. */
  125189. serialize(): any;
  125190. /**
  125191. * Parses a anisotropy Configuration from a serialized object.
  125192. * @param source - Serialized object.
  125193. * @param scene Defines the scene we are parsing for
  125194. * @param rootUrl Defines the rootUrl to load from
  125195. */
  125196. parse(source: any, scene: Scene, rootUrl: string): void;
  125197. }
  125198. }
  125199. declare module BABYLON {
  125200. /**
  125201. * @hidden
  125202. */
  125203. export interface IMaterialSubSurfaceDefines {
  125204. SUBSURFACE: boolean;
  125205. SS_REFRACTION: boolean;
  125206. SS_TRANSLUCENCY: boolean;
  125207. SS_SCATERRING: boolean;
  125208. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125209. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125210. SS_REFRACTIONMAP_3D: boolean;
  125211. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125212. SS_LODINREFRACTIONALPHA: boolean;
  125213. SS_GAMMAREFRACTION: boolean;
  125214. SS_RGBDREFRACTION: boolean;
  125215. SS_LINEARSPECULARREFRACTION: boolean;
  125216. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125217. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125218. /** @hidden */
  125219. _areTexturesDirty: boolean;
  125220. }
  125221. /**
  125222. * Define the code related to the sub surface parameters of the pbr material.
  125223. */
  125224. export class PBRSubSurfaceConfiguration {
  125225. private _isRefractionEnabled;
  125226. /**
  125227. * Defines if the refraction is enabled in the material.
  125228. */
  125229. isRefractionEnabled: boolean;
  125230. private _isTranslucencyEnabled;
  125231. /**
  125232. * Defines if the translucency is enabled in the material.
  125233. */
  125234. isTranslucencyEnabled: boolean;
  125235. private _isScatteringEnabled;
  125236. /**
  125237. * Defines the refraction intensity of the material.
  125238. * The refraction when enabled replaces the Diffuse part of the material.
  125239. * The intensity helps transitionning between diffuse and refraction.
  125240. */
  125241. refractionIntensity: number;
  125242. /**
  125243. * Defines the translucency intensity of the material.
  125244. * When translucency has been enabled, this defines how much of the "translucency"
  125245. * is addded to the diffuse part of the material.
  125246. */
  125247. translucencyIntensity: number;
  125248. /**
  125249. * Defines the scattering intensity of the material.
  125250. * When scattering has been enabled, this defines how much of the "scattered light"
  125251. * is addded to the diffuse part of the material.
  125252. */
  125253. scatteringIntensity: number;
  125254. private _thicknessTexture;
  125255. /**
  125256. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  125257. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  125258. * 0 would mean minimumThickness
  125259. * 1 would mean maximumThickness
  125260. * The other channels might be use as a mask to vary the different effects intensity.
  125261. */
  125262. thicknessTexture: Nullable<BaseTexture>;
  125263. private _refractionTexture;
  125264. /**
  125265. * Defines the texture to use for refraction.
  125266. */
  125267. refractionTexture: Nullable<BaseTexture>;
  125268. private _indexOfRefraction;
  125269. /**
  125270. * Defines the index of refraction used in the material.
  125271. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  125272. */
  125273. indexOfRefraction: number;
  125274. private _invertRefractionY;
  125275. /**
  125276. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  125277. */
  125278. invertRefractionY: boolean;
  125279. private _linkRefractionWithTransparency;
  125280. /**
  125281. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  125282. * Materials half opaque for instance using refraction could benefit from this control.
  125283. */
  125284. linkRefractionWithTransparency: boolean;
  125285. /**
  125286. * Defines the minimum thickness stored in the thickness map.
  125287. * If no thickness map is defined, this value will be used to simulate thickness.
  125288. */
  125289. minimumThickness: number;
  125290. /**
  125291. * Defines the maximum thickness stored in the thickness map.
  125292. */
  125293. maximumThickness: number;
  125294. /**
  125295. * Defines the volume tint of the material.
  125296. * This is used for both translucency and scattering.
  125297. */
  125298. tintColor: Color3;
  125299. /**
  125300. * Defines the distance at which the tint color should be found in the media.
  125301. * This is used for refraction only.
  125302. */
  125303. tintColorAtDistance: number;
  125304. /**
  125305. * Defines how far each channel transmit through the media.
  125306. * It is defined as a color to simplify it selection.
  125307. */
  125308. diffusionDistance: Color3;
  125309. private _useMaskFromThicknessTexture;
  125310. /**
  125311. * Stores the intensity of the different subsurface effects in the thickness texture.
  125312. * * the green channel is the translucency intensity.
  125313. * * the blue channel is the scattering intensity.
  125314. * * the alpha channel is the refraction intensity.
  125315. */
  125316. useMaskFromThicknessTexture: boolean;
  125317. /** @hidden */
  125318. private _internalMarkAllSubMeshesAsTexturesDirty;
  125319. /** @hidden */
  125320. _markAllSubMeshesAsTexturesDirty(): void;
  125321. /**
  125322. * Instantiate a new istance of sub surface configuration.
  125323. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  125324. */
  125325. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  125326. /**
  125327. * Gets wehter the submesh is ready to be used or not.
  125328. * @param defines the list of "defines" to update.
  125329. * @param scene defines the scene the material belongs to.
  125330. * @returns - boolean indicating that the submesh is ready or not.
  125331. */
  125332. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  125333. /**
  125334. * Checks to see if a texture is used in the material.
  125335. * @param defines the list of "defines" to update.
  125336. * @param scene defines the scene to the material belongs to.
  125337. */
  125338. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  125339. /**
  125340. * Binds the material data.
  125341. * @param uniformBuffer defines the Uniform buffer to fill in.
  125342. * @param scene defines the scene the material belongs to.
  125343. * @param engine defines the engine the material belongs to.
  125344. * @param isFrozen defines wether the material is frozen or not.
  125345. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  125346. */
  125347. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  125348. /**
  125349. * Unbinds the material from the mesh.
  125350. * @param activeEffect defines the effect that should be unbound from.
  125351. * @returns true if unbound, otherwise false
  125352. */
  125353. unbind(activeEffect: Effect): boolean;
  125354. /**
  125355. * Returns the texture used for refraction or null if none is used.
  125356. * @param scene defines the scene the material belongs to.
  125357. * @returns - Refraction texture if present. If no refraction texture and refraction
  125358. * is linked with transparency, returns environment texture. Otherwise, returns null.
  125359. */
  125360. private _getRefractionTexture;
  125361. /**
  125362. * Returns true if alpha blending should be disabled.
  125363. */
  125364. get disableAlphaBlending(): boolean;
  125365. /**
  125366. * Fills the list of render target textures.
  125367. * @param renderTargets the list of render targets to update
  125368. */
  125369. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  125370. /**
  125371. * Checks to see if a texture is used in the material.
  125372. * @param texture - Base texture to use.
  125373. * @returns - Boolean specifying if a texture is used in the material.
  125374. */
  125375. hasTexture(texture: BaseTexture): boolean;
  125376. /**
  125377. * Gets a boolean indicating that current material needs to register RTT
  125378. * @returns true if this uses a render target otherwise false.
  125379. */
  125380. hasRenderTargetTextures(): boolean;
  125381. /**
  125382. * Returns an array of the actively used textures.
  125383. * @param activeTextures Array of BaseTextures
  125384. */
  125385. getActiveTextures(activeTextures: BaseTexture[]): void;
  125386. /**
  125387. * Returns the animatable textures.
  125388. * @param animatables Array of animatable textures.
  125389. */
  125390. getAnimatables(animatables: IAnimatable[]): void;
  125391. /**
  125392. * Disposes the resources of the material.
  125393. * @param forceDisposeTextures - Forces the disposal of all textures.
  125394. */
  125395. dispose(forceDisposeTextures?: boolean): void;
  125396. /**
  125397. * Get the current class name of the texture useful for serialization or dynamic coding.
  125398. * @returns "PBRSubSurfaceConfiguration"
  125399. */
  125400. getClassName(): string;
  125401. /**
  125402. * Add fallbacks to the effect fallbacks list.
  125403. * @param defines defines the Base texture to use.
  125404. * @param fallbacks defines the current fallback list.
  125405. * @param currentRank defines the current fallback rank.
  125406. * @returns the new fallback rank.
  125407. */
  125408. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  125409. /**
  125410. * Add the required uniforms to the current list.
  125411. * @param uniforms defines the current uniform list.
  125412. */
  125413. static AddUniforms(uniforms: string[]): void;
  125414. /**
  125415. * Add the required samplers to the current list.
  125416. * @param samplers defines the current sampler list.
  125417. */
  125418. static AddSamplers(samplers: string[]): void;
  125419. /**
  125420. * Add the required uniforms to the current buffer.
  125421. * @param uniformBuffer defines the current uniform buffer.
  125422. */
  125423. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  125424. /**
  125425. * Makes a duplicate of the current configuration into another one.
  125426. * @param configuration define the config where to copy the info
  125427. */
  125428. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  125429. /**
  125430. * Serializes this Sub Surface configuration.
  125431. * @returns - An object with the serialized config.
  125432. */
  125433. serialize(): any;
  125434. /**
  125435. * Parses a anisotropy Configuration from a serialized object.
  125436. * @param source - Serialized object.
  125437. * @param scene Defines the scene we are parsing for
  125438. * @param rootUrl Defines the rootUrl to load from
  125439. */
  125440. parse(source: any, scene: Scene, rootUrl: string): void;
  125441. }
  125442. }
  125443. declare module BABYLON {
  125444. /** @hidden */
  125445. export var pbrFragmentDeclaration: {
  125446. name: string;
  125447. shader: string;
  125448. };
  125449. }
  125450. declare module BABYLON {
  125451. /** @hidden */
  125452. export var pbrUboDeclaration: {
  125453. name: string;
  125454. shader: string;
  125455. };
  125456. }
  125457. declare module BABYLON {
  125458. /** @hidden */
  125459. export var pbrFragmentExtraDeclaration: {
  125460. name: string;
  125461. shader: string;
  125462. };
  125463. }
  125464. declare module BABYLON {
  125465. /** @hidden */
  125466. export var pbrFragmentSamplersDeclaration: {
  125467. name: string;
  125468. shader: string;
  125469. };
  125470. }
  125471. declare module BABYLON {
  125472. /** @hidden */
  125473. export var pbrHelperFunctions: {
  125474. name: string;
  125475. shader: string;
  125476. };
  125477. }
  125478. declare module BABYLON {
  125479. /** @hidden */
  125480. export var harmonicsFunctions: {
  125481. name: string;
  125482. shader: string;
  125483. };
  125484. }
  125485. declare module BABYLON {
  125486. /** @hidden */
  125487. export var pbrDirectLightingSetupFunctions: {
  125488. name: string;
  125489. shader: string;
  125490. };
  125491. }
  125492. declare module BABYLON {
  125493. /** @hidden */
  125494. export var pbrDirectLightingFalloffFunctions: {
  125495. name: string;
  125496. shader: string;
  125497. };
  125498. }
  125499. declare module BABYLON {
  125500. /** @hidden */
  125501. export var pbrBRDFFunctions: {
  125502. name: string;
  125503. shader: string;
  125504. };
  125505. }
  125506. declare module BABYLON {
  125507. /** @hidden */
  125508. export var pbrDirectLightingFunctions: {
  125509. name: string;
  125510. shader: string;
  125511. };
  125512. }
  125513. declare module BABYLON {
  125514. /** @hidden */
  125515. export var pbrIBLFunctions: {
  125516. name: string;
  125517. shader: string;
  125518. };
  125519. }
  125520. declare module BABYLON {
  125521. /** @hidden */
  125522. export var pbrBlockAlbedoOpacity: {
  125523. name: string;
  125524. shader: string;
  125525. };
  125526. }
  125527. declare module BABYLON {
  125528. /** @hidden */
  125529. export var pbrBlockReflectivity: {
  125530. name: string;
  125531. shader: string;
  125532. };
  125533. }
  125534. declare module BABYLON {
  125535. /** @hidden */
  125536. export var pbrBlockAmbientOcclusion: {
  125537. name: string;
  125538. shader: string;
  125539. };
  125540. }
  125541. declare module BABYLON {
  125542. /** @hidden */
  125543. export var pbrBlockAlphaFresnel: {
  125544. name: string;
  125545. shader: string;
  125546. };
  125547. }
  125548. declare module BABYLON {
  125549. /** @hidden */
  125550. export var pbrBlockAnisotropic: {
  125551. name: string;
  125552. shader: string;
  125553. };
  125554. }
  125555. declare module BABYLON {
  125556. /** @hidden */
  125557. export var pbrBlockReflection: {
  125558. name: string;
  125559. shader: string;
  125560. };
  125561. }
  125562. declare module BABYLON {
  125563. /** @hidden */
  125564. export var pbrBlockSheen: {
  125565. name: string;
  125566. shader: string;
  125567. };
  125568. }
  125569. declare module BABYLON {
  125570. /** @hidden */
  125571. export var pbrBlockClearcoat: {
  125572. name: string;
  125573. shader: string;
  125574. };
  125575. }
  125576. declare module BABYLON {
  125577. /** @hidden */
  125578. export var pbrBlockSubSurface: {
  125579. name: string;
  125580. shader: string;
  125581. };
  125582. }
  125583. declare module BABYLON {
  125584. /** @hidden */
  125585. export var pbrBlockNormalGeometric: {
  125586. name: string;
  125587. shader: string;
  125588. };
  125589. }
  125590. declare module BABYLON {
  125591. /** @hidden */
  125592. export var pbrBlockNormalFinal: {
  125593. name: string;
  125594. shader: string;
  125595. };
  125596. }
  125597. declare module BABYLON {
  125598. /** @hidden */
  125599. export var pbrBlockGeometryInfo: {
  125600. name: string;
  125601. shader: string;
  125602. };
  125603. }
  125604. declare module BABYLON {
  125605. /** @hidden */
  125606. export var pbrBlockReflectance0: {
  125607. name: string;
  125608. shader: string;
  125609. };
  125610. }
  125611. declare module BABYLON {
  125612. /** @hidden */
  125613. export var pbrBlockReflectance: {
  125614. name: string;
  125615. shader: string;
  125616. };
  125617. }
  125618. declare module BABYLON {
  125619. /** @hidden */
  125620. export var pbrBlockDirectLighting: {
  125621. name: string;
  125622. shader: string;
  125623. };
  125624. }
  125625. declare module BABYLON {
  125626. /** @hidden */
  125627. export var pbrBlockFinalLitComponents: {
  125628. name: string;
  125629. shader: string;
  125630. };
  125631. }
  125632. declare module BABYLON {
  125633. /** @hidden */
  125634. export var pbrBlockFinalUnlitComponents: {
  125635. name: string;
  125636. shader: string;
  125637. };
  125638. }
  125639. declare module BABYLON {
  125640. /** @hidden */
  125641. export var pbrBlockFinalColorComposition: {
  125642. name: string;
  125643. shader: string;
  125644. };
  125645. }
  125646. declare module BABYLON {
  125647. /** @hidden */
  125648. export var pbrBlockImageProcessing: {
  125649. name: string;
  125650. shader: string;
  125651. };
  125652. }
  125653. declare module BABYLON {
  125654. /** @hidden */
  125655. export var pbrDebug: {
  125656. name: string;
  125657. shader: string;
  125658. };
  125659. }
  125660. declare module BABYLON {
  125661. /** @hidden */
  125662. export var pbrPixelShader: {
  125663. name: string;
  125664. shader: string;
  125665. };
  125666. }
  125667. declare module BABYLON {
  125668. /** @hidden */
  125669. export var pbrVertexDeclaration: {
  125670. name: string;
  125671. shader: string;
  125672. };
  125673. }
  125674. declare module BABYLON {
  125675. /** @hidden */
  125676. export var pbrVertexShader: {
  125677. name: string;
  125678. shader: string;
  125679. };
  125680. }
  125681. declare module BABYLON {
  125682. /**
  125683. * Manages the defines for the PBR Material.
  125684. * @hidden
  125685. */
  125686. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  125687. PBR: boolean;
  125688. MAINUV1: boolean;
  125689. MAINUV2: boolean;
  125690. UV1: boolean;
  125691. UV2: boolean;
  125692. ALBEDO: boolean;
  125693. GAMMAALBEDO: boolean;
  125694. ALBEDODIRECTUV: number;
  125695. VERTEXCOLOR: boolean;
  125696. AMBIENT: boolean;
  125697. AMBIENTDIRECTUV: number;
  125698. AMBIENTINGRAYSCALE: boolean;
  125699. OPACITY: boolean;
  125700. VERTEXALPHA: boolean;
  125701. OPACITYDIRECTUV: number;
  125702. OPACITYRGB: boolean;
  125703. ALPHATEST: boolean;
  125704. DEPTHPREPASS: boolean;
  125705. ALPHABLEND: boolean;
  125706. ALPHAFROMALBEDO: boolean;
  125707. ALPHATESTVALUE: string;
  125708. SPECULAROVERALPHA: boolean;
  125709. RADIANCEOVERALPHA: boolean;
  125710. ALPHAFRESNEL: boolean;
  125711. LINEARALPHAFRESNEL: boolean;
  125712. PREMULTIPLYALPHA: boolean;
  125713. EMISSIVE: boolean;
  125714. EMISSIVEDIRECTUV: number;
  125715. REFLECTIVITY: boolean;
  125716. REFLECTIVITYDIRECTUV: number;
  125717. SPECULARTERM: boolean;
  125718. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  125719. MICROSURFACEAUTOMATIC: boolean;
  125720. LODBASEDMICROSFURACE: boolean;
  125721. MICROSURFACEMAP: boolean;
  125722. MICROSURFACEMAPDIRECTUV: number;
  125723. METALLICWORKFLOW: boolean;
  125724. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  125725. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  125726. METALLNESSSTOREINMETALMAPBLUE: boolean;
  125727. AOSTOREINMETALMAPRED: boolean;
  125728. METALLICF0FACTORFROMMETALLICMAP: boolean;
  125729. ENVIRONMENTBRDF: boolean;
  125730. ENVIRONMENTBRDF_RGBD: boolean;
  125731. NORMAL: boolean;
  125732. TANGENT: boolean;
  125733. BUMP: boolean;
  125734. BUMPDIRECTUV: number;
  125735. OBJECTSPACE_NORMALMAP: boolean;
  125736. PARALLAX: boolean;
  125737. PARALLAXOCCLUSION: boolean;
  125738. NORMALXYSCALE: boolean;
  125739. LIGHTMAP: boolean;
  125740. LIGHTMAPDIRECTUV: number;
  125741. USELIGHTMAPASSHADOWMAP: boolean;
  125742. GAMMALIGHTMAP: boolean;
  125743. RGBDLIGHTMAP: boolean;
  125744. REFLECTION: boolean;
  125745. REFLECTIONMAP_3D: boolean;
  125746. REFLECTIONMAP_SPHERICAL: boolean;
  125747. REFLECTIONMAP_PLANAR: boolean;
  125748. REFLECTIONMAP_CUBIC: boolean;
  125749. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  125750. REFLECTIONMAP_PROJECTION: boolean;
  125751. REFLECTIONMAP_SKYBOX: boolean;
  125752. REFLECTIONMAP_EXPLICIT: boolean;
  125753. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  125754. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  125755. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  125756. INVERTCUBICMAP: boolean;
  125757. USESPHERICALFROMREFLECTIONMAP: boolean;
  125758. USEIRRADIANCEMAP: boolean;
  125759. SPHERICAL_HARMONICS: boolean;
  125760. USESPHERICALINVERTEX: boolean;
  125761. REFLECTIONMAP_OPPOSITEZ: boolean;
  125762. LODINREFLECTIONALPHA: boolean;
  125763. GAMMAREFLECTION: boolean;
  125764. RGBDREFLECTION: boolean;
  125765. LINEARSPECULARREFLECTION: boolean;
  125766. RADIANCEOCCLUSION: boolean;
  125767. HORIZONOCCLUSION: boolean;
  125768. INSTANCES: boolean;
  125769. NUM_BONE_INFLUENCERS: number;
  125770. BonesPerMesh: number;
  125771. BONETEXTURE: boolean;
  125772. NONUNIFORMSCALING: boolean;
  125773. MORPHTARGETS: boolean;
  125774. MORPHTARGETS_NORMAL: boolean;
  125775. MORPHTARGETS_TANGENT: boolean;
  125776. MORPHTARGETS_UV: boolean;
  125777. NUM_MORPH_INFLUENCERS: number;
  125778. IMAGEPROCESSING: boolean;
  125779. VIGNETTE: boolean;
  125780. VIGNETTEBLENDMODEMULTIPLY: boolean;
  125781. VIGNETTEBLENDMODEOPAQUE: boolean;
  125782. TONEMAPPING: boolean;
  125783. TONEMAPPING_ACES: boolean;
  125784. CONTRAST: boolean;
  125785. COLORCURVES: boolean;
  125786. COLORGRADING: boolean;
  125787. COLORGRADING3D: boolean;
  125788. SAMPLER3DGREENDEPTH: boolean;
  125789. SAMPLER3DBGRMAP: boolean;
  125790. IMAGEPROCESSINGPOSTPROCESS: boolean;
  125791. EXPOSURE: boolean;
  125792. MULTIVIEW: boolean;
  125793. USEPHYSICALLIGHTFALLOFF: boolean;
  125794. USEGLTFLIGHTFALLOFF: boolean;
  125795. TWOSIDEDLIGHTING: boolean;
  125796. SHADOWFLOAT: boolean;
  125797. CLIPPLANE: boolean;
  125798. CLIPPLANE2: boolean;
  125799. CLIPPLANE3: boolean;
  125800. CLIPPLANE4: boolean;
  125801. CLIPPLANE5: boolean;
  125802. CLIPPLANE6: boolean;
  125803. POINTSIZE: boolean;
  125804. FOG: boolean;
  125805. LOGARITHMICDEPTH: boolean;
  125806. FORCENORMALFORWARD: boolean;
  125807. SPECULARAA: boolean;
  125808. CLEARCOAT: boolean;
  125809. CLEARCOAT_DEFAULTIOR: boolean;
  125810. CLEARCOAT_TEXTURE: boolean;
  125811. CLEARCOAT_TEXTUREDIRECTUV: number;
  125812. CLEARCOAT_BUMP: boolean;
  125813. CLEARCOAT_BUMPDIRECTUV: number;
  125814. CLEARCOAT_TINT: boolean;
  125815. CLEARCOAT_TINT_TEXTURE: boolean;
  125816. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  125817. ANISOTROPIC: boolean;
  125818. ANISOTROPIC_TEXTURE: boolean;
  125819. ANISOTROPIC_TEXTUREDIRECTUV: number;
  125820. BRDF_V_HEIGHT_CORRELATED: boolean;
  125821. MS_BRDF_ENERGY_CONSERVATION: boolean;
  125822. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  125823. SHEEN: boolean;
  125824. SHEEN_TEXTURE: boolean;
  125825. SHEEN_TEXTUREDIRECTUV: number;
  125826. SHEEN_LINKWITHALBEDO: boolean;
  125827. SHEEN_ROUGHNESS: boolean;
  125828. SHEEN_ALBEDOSCALING: boolean;
  125829. SUBSURFACE: boolean;
  125830. SS_REFRACTION: boolean;
  125831. SS_TRANSLUCENCY: boolean;
  125832. SS_SCATERRING: boolean;
  125833. SS_THICKNESSANDMASK_TEXTURE: boolean;
  125834. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  125835. SS_REFRACTIONMAP_3D: boolean;
  125836. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  125837. SS_LODINREFRACTIONALPHA: boolean;
  125838. SS_GAMMAREFRACTION: boolean;
  125839. SS_RGBDREFRACTION: boolean;
  125840. SS_LINEARSPECULARREFRACTION: boolean;
  125841. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  125842. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  125843. UNLIT: boolean;
  125844. DEBUGMODE: number;
  125845. /**
  125846. * Initializes the PBR Material defines.
  125847. */
  125848. constructor();
  125849. /**
  125850. * Resets the PBR Material defines.
  125851. */
  125852. reset(): void;
  125853. }
  125854. /**
  125855. * The Physically based material base class of BJS.
  125856. *
  125857. * This offers the main features of a standard PBR material.
  125858. * For more information, please refer to the documentation :
  125859. * https://doc.babylonjs.com/how_to/physically_based_rendering
  125860. */
  125861. export abstract class PBRBaseMaterial extends PushMaterial {
  125862. /**
  125863. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  125864. */
  125865. static readonly PBRMATERIAL_OPAQUE: number;
  125866. /**
  125867. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  125868. */
  125869. static readonly PBRMATERIAL_ALPHATEST: number;
  125870. /**
  125871. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125872. */
  125873. static readonly PBRMATERIAL_ALPHABLEND: number;
  125874. /**
  125875. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  125876. * They are also discarded below the alpha cutoff threshold to improve performances.
  125877. */
  125878. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  125879. /**
  125880. * Defines the default value of how much AO map is occluding the analytical lights
  125881. * (point spot...).
  125882. */
  125883. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  125884. /**
  125885. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  125886. */
  125887. static readonly LIGHTFALLOFF_PHYSICAL: number;
  125888. /**
  125889. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  125890. * to enhance interoperability with other engines.
  125891. */
  125892. static readonly LIGHTFALLOFF_GLTF: number;
  125893. /**
  125894. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  125895. * to enhance interoperability with other materials.
  125896. */
  125897. static readonly LIGHTFALLOFF_STANDARD: number;
  125898. /**
  125899. * Intensity of the direct lights e.g. the four lights available in your scene.
  125900. * This impacts both the direct diffuse and specular highlights.
  125901. */
  125902. protected _directIntensity: number;
  125903. /**
  125904. * Intensity of the emissive part of the material.
  125905. * This helps controlling the emissive effect without modifying the emissive color.
  125906. */
  125907. protected _emissiveIntensity: number;
  125908. /**
  125909. * Intensity of the environment e.g. how much the environment will light the object
  125910. * either through harmonics for rough material or through the refelction for shiny ones.
  125911. */
  125912. protected _environmentIntensity: number;
  125913. /**
  125914. * This is a special control allowing the reduction of the specular highlights coming from the
  125915. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  125916. */
  125917. protected _specularIntensity: number;
  125918. /**
  125919. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  125920. */
  125921. private _lightingInfos;
  125922. /**
  125923. * Debug Control allowing disabling the bump map on this material.
  125924. */
  125925. protected _disableBumpMap: boolean;
  125926. /**
  125927. * AKA Diffuse Texture in standard nomenclature.
  125928. */
  125929. protected _albedoTexture: Nullable<BaseTexture>;
  125930. /**
  125931. * AKA Occlusion Texture in other nomenclature.
  125932. */
  125933. protected _ambientTexture: Nullable<BaseTexture>;
  125934. /**
  125935. * AKA Occlusion Texture Intensity in other nomenclature.
  125936. */
  125937. protected _ambientTextureStrength: number;
  125938. /**
  125939. * Defines how much the AO map is occluding the analytical lights (point spot...).
  125940. * 1 means it completely occludes it
  125941. * 0 mean it has no impact
  125942. */
  125943. protected _ambientTextureImpactOnAnalyticalLights: number;
  125944. /**
  125945. * Stores the alpha values in a texture.
  125946. */
  125947. protected _opacityTexture: Nullable<BaseTexture>;
  125948. /**
  125949. * Stores the reflection values in a texture.
  125950. */
  125951. protected _reflectionTexture: Nullable<BaseTexture>;
  125952. /**
  125953. * Stores the emissive values in a texture.
  125954. */
  125955. protected _emissiveTexture: Nullable<BaseTexture>;
  125956. /**
  125957. * AKA Specular texture in other nomenclature.
  125958. */
  125959. protected _reflectivityTexture: Nullable<BaseTexture>;
  125960. /**
  125961. * Used to switch from specular/glossiness to metallic/roughness workflow.
  125962. */
  125963. protected _metallicTexture: Nullable<BaseTexture>;
  125964. /**
  125965. * Specifies the metallic scalar of the metallic/roughness workflow.
  125966. * Can also be used to scale the metalness values of the metallic texture.
  125967. */
  125968. protected _metallic: Nullable<number>;
  125969. /**
  125970. * Specifies the roughness scalar of the metallic/roughness workflow.
  125971. * Can also be used to scale the roughness values of the metallic texture.
  125972. */
  125973. protected _roughness: Nullable<number>;
  125974. /**
  125975. * Specifies the an F0 factor to help configuring the material F0.
  125976. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  125977. * to 0.5 the previously hard coded value stays the same.
  125978. * Can also be used to scale the F0 values of the metallic texture.
  125979. */
  125980. protected _metallicF0Factor: number;
  125981. /**
  125982. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  125983. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  125984. * your expectation as it multiplies with the texture data.
  125985. */
  125986. protected _useMetallicF0FactorFromMetallicTexture: boolean;
  125987. /**
  125988. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  125989. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  125990. */
  125991. protected _microSurfaceTexture: Nullable<BaseTexture>;
  125992. /**
  125993. * Stores surface normal data used to displace a mesh in a texture.
  125994. */
  125995. protected _bumpTexture: Nullable<BaseTexture>;
  125996. /**
  125997. * Stores the pre-calculated light information of a mesh in a texture.
  125998. */
  125999. protected _lightmapTexture: Nullable<BaseTexture>;
  126000. /**
  126001. * The color of a material in ambient lighting.
  126002. */
  126003. protected _ambientColor: Color3;
  126004. /**
  126005. * AKA Diffuse Color in other nomenclature.
  126006. */
  126007. protected _albedoColor: Color3;
  126008. /**
  126009. * AKA Specular Color in other nomenclature.
  126010. */
  126011. protected _reflectivityColor: Color3;
  126012. /**
  126013. * The color applied when light is reflected from a material.
  126014. */
  126015. protected _reflectionColor: Color3;
  126016. /**
  126017. * The color applied when light is emitted from a material.
  126018. */
  126019. protected _emissiveColor: Color3;
  126020. /**
  126021. * AKA Glossiness in other nomenclature.
  126022. */
  126023. protected _microSurface: number;
  126024. /**
  126025. * Specifies that the material will use the light map as a show map.
  126026. */
  126027. protected _useLightmapAsShadowmap: boolean;
  126028. /**
  126029. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126030. * makes the reflect vector face the model (under horizon).
  126031. */
  126032. protected _useHorizonOcclusion: boolean;
  126033. /**
  126034. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126035. * too much the area relying on ambient texture to define their ambient occlusion.
  126036. */
  126037. protected _useRadianceOcclusion: boolean;
  126038. /**
  126039. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126040. */
  126041. protected _useAlphaFromAlbedoTexture: boolean;
  126042. /**
  126043. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  126044. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126045. */
  126046. protected _useSpecularOverAlpha: boolean;
  126047. /**
  126048. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126049. */
  126050. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126051. /**
  126052. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126053. */
  126054. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  126055. /**
  126056. * Specifies if the metallic texture contains the roughness information in its green channel.
  126057. */
  126058. protected _useRoughnessFromMetallicTextureGreen: boolean;
  126059. /**
  126060. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126061. */
  126062. protected _useMetallnessFromMetallicTextureBlue: boolean;
  126063. /**
  126064. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126065. */
  126066. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  126067. /**
  126068. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126069. */
  126070. protected _useAmbientInGrayScale: boolean;
  126071. /**
  126072. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126073. * The material will try to infer what glossiness each pixel should be.
  126074. */
  126075. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  126076. /**
  126077. * Defines the falloff type used in this material.
  126078. * It by default is Physical.
  126079. */
  126080. protected _lightFalloff: number;
  126081. /**
  126082. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126083. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126084. */
  126085. protected _useRadianceOverAlpha: boolean;
  126086. /**
  126087. * Allows using an object space normal map (instead of tangent space).
  126088. */
  126089. protected _useObjectSpaceNormalMap: boolean;
  126090. /**
  126091. * Allows using the bump map in parallax mode.
  126092. */
  126093. protected _useParallax: boolean;
  126094. /**
  126095. * Allows using the bump map in parallax occlusion mode.
  126096. */
  126097. protected _useParallaxOcclusion: boolean;
  126098. /**
  126099. * Controls the scale bias of the parallax mode.
  126100. */
  126101. protected _parallaxScaleBias: number;
  126102. /**
  126103. * If sets to true, disables all the lights affecting the material.
  126104. */
  126105. protected _disableLighting: boolean;
  126106. /**
  126107. * Number of Simultaneous lights allowed on the material.
  126108. */
  126109. protected _maxSimultaneousLights: number;
  126110. /**
  126111. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  126112. */
  126113. protected _invertNormalMapX: boolean;
  126114. /**
  126115. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  126116. */
  126117. protected _invertNormalMapY: boolean;
  126118. /**
  126119. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126120. */
  126121. protected _twoSidedLighting: boolean;
  126122. /**
  126123. * Defines the alpha limits in alpha test mode.
  126124. */
  126125. protected _alphaCutOff: number;
  126126. /**
  126127. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126128. */
  126129. protected _forceAlphaTest: boolean;
  126130. /**
  126131. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126132. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126133. */
  126134. protected _useAlphaFresnel: boolean;
  126135. /**
  126136. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126137. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126138. */
  126139. protected _useLinearAlphaFresnel: boolean;
  126140. /**
  126141. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  126142. * from cos thetav and roughness:
  126143. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  126144. */
  126145. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  126146. /**
  126147. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126148. */
  126149. protected _forceIrradianceInFragment: boolean;
  126150. /**
  126151. * Force normal to face away from face.
  126152. */
  126153. protected _forceNormalForward: boolean;
  126154. /**
  126155. * Enables specular anti aliasing in the PBR shader.
  126156. * It will both interacts on the Geometry for analytical and IBL lighting.
  126157. * It also prefilter the roughness map based on the bump values.
  126158. */
  126159. protected _enableSpecularAntiAliasing: boolean;
  126160. /**
  126161. * Default configuration related to image processing available in the PBR Material.
  126162. */
  126163. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  126164. /**
  126165. * Keep track of the image processing observer to allow dispose and replace.
  126166. */
  126167. private _imageProcessingObserver;
  126168. /**
  126169. * Attaches a new image processing configuration to the PBR Material.
  126170. * @param configuration
  126171. */
  126172. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  126173. /**
  126174. * Stores the available render targets.
  126175. */
  126176. private _renderTargets;
  126177. /**
  126178. * Sets the global ambient color for the material used in lighting calculations.
  126179. */
  126180. private _globalAmbientColor;
  126181. /**
  126182. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  126183. */
  126184. private _useLogarithmicDepth;
  126185. /**
  126186. * If set to true, no lighting calculations will be applied.
  126187. */
  126188. private _unlit;
  126189. private _debugMode;
  126190. /**
  126191. * @hidden
  126192. * This is reserved for the inspector.
  126193. * Defines the material debug mode.
  126194. * It helps seeing only some components of the material while troubleshooting.
  126195. */
  126196. debugMode: number;
  126197. /**
  126198. * @hidden
  126199. * This is reserved for the inspector.
  126200. * Specify from where on screen the debug mode should start.
  126201. * The value goes from -1 (full screen) to 1 (not visible)
  126202. * It helps with side by side comparison against the final render
  126203. * This defaults to -1
  126204. */
  126205. private debugLimit;
  126206. /**
  126207. * @hidden
  126208. * This is reserved for the inspector.
  126209. * As the default viewing range might not be enough (if the ambient is really small for instance)
  126210. * You can use the factor to better multiply the final value.
  126211. */
  126212. private debugFactor;
  126213. /**
  126214. * Defines the clear coat layer parameters for the material.
  126215. */
  126216. readonly clearCoat: PBRClearCoatConfiguration;
  126217. /**
  126218. * Defines the anisotropic parameters for the material.
  126219. */
  126220. readonly anisotropy: PBRAnisotropicConfiguration;
  126221. /**
  126222. * Defines the BRDF parameters for the material.
  126223. */
  126224. readonly brdf: PBRBRDFConfiguration;
  126225. /**
  126226. * Defines the Sheen parameters for the material.
  126227. */
  126228. readonly sheen: PBRSheenConfiguration;
  126229. /**
  126230. * Defines the SubSurface parameters for the material.
  126231. */
  126232. readonly subSurface: PBRSubSurfaceConfiguration;
  126233. /**
  126234. * Custom callback helping to override the default shader used in the material.
  126235. */
  126236. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines, attributes?: string[]) => string;
  126237. protected _rebuildInParallel: boolean;
  126238. /**
  126239. * Instantiates a new PBRMaterial instance.
  126240. *
  126241. * @param name The material name
  126242. * @param scene The scene the material will be use in.
  126243. */
  126244. constructor(name: string, scene: Scene);
  126245. /**
  126246. * Gets a boolean indicating that current material needs to register RTT
  126247. */
  126248. get hasRenderTargetTextures(): boolean;
  126249. /**
  126250. * Gets the name of the material class.
  126251. */
  126252. getClassName(): string;
  126253. /**
  126254. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126255. */
  126256. get useLogarithmicDepth(): boolean;
  126257. /**
  126258. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  126259. */
  126260. set useLogarithmicDepth(value: boolean);
  126261. /**
  126262. * Returns true if alpha blending should be disabled.
  126263. */
  126264. protected get _disableAlphaBlending(): boolean;
  126265. /**
  126266. * Specifies whether or not this material should be rendered in alpha blend mode.
  126267. */
  126268. needAlphaBlending(): boolean;
  126269. /**
  126270. * Specifies whether or not this material should be rendered in alpha test mode.
  126271. */
  126272. needAlphaTesting(): boolean;
  126273. /**
  126274. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  126275. */
  126276. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  126277. /**
  126278. * Gets the texture used for the alpha test.
  126279. */
  126280. getAlphaTestTexture(): Nullable<BaseTexture>;
  126281. /**
  126282. * Specifies that the submesh is ready to be used.
  126283. * @param mesh - BJS mesh.
  126284. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  126285. * @param useInstances - Specifies that instances should be used.
  126286. * @returns - boolean indicating that the submesh is ready or not.
  126287. */
  126288. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  126289. /**
  126290. * Specifies if the material uses metallic roughness workflow.
  126291. * @returns boolean specifiying if the material uses metallic roughness workflow.
  126292. */
  126293. isMetallicWorkflow(): boolean;
  126294. private _prepareEffect;
  126295. private _prepareDefines;
  126296. /**
  126297. * Force shader compilation
  126298. */
  126299. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  126300. /**
  126301. * Initializes the uniform buffer layout for the shader.
  126302. */
  126303. buildUniformLayout(): void;
  126304. /**
  126305. * Unbinds the material from the mesh
  126306. */
  126307. unbind(): void;
  126308. /**
  126309. * Binds the submesh data.
  126310. * @param world - The world matrix.
  126311. * @param mesh - The BJS mesh.
  126312. * @param subMesh - A submesh of the BJS mesh.
  126313. */
  126314. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  126315. /**
  126316. * Returns the animatable textures.
  126317. * @returns - Array of animatable textures.
  126318. */
  126319. getAnimatables(): IAnimatable[];
  126320. /**
  126321. * Returns the texture used for reflections.
  126322. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  126323. */
  126324. private _getReflectionTexture;
  126325. /**
  126326. * Returns an array of the actively used textures.
  126327. * @returns - Array of BaseTextures
  126328. */
  126329. getActiveTextures(): BaseTexture[];
  126330. /**
  126331. * Checks to see if a texture is used in the material.
  126332. * @param texture - Base texture to use.
  126333. * @returns - Boolean specifying if a texture is used in the material.
  126334. */
  126335. hasTexture(texture: BaseTexture): boolean;
  126336. /**
  126337. * Disposes the resources of the material.
  126338. * @param forceDisposeEffect - Forces the disposal of effects.
  126339. * @param forceDisposeTextures - Forces the disposal of all textures.
  126340. */
  126341. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  126342. }
  126343. }
  126344. declare module BABYLON {
  126345. /**
  126346. * The Physically based material of BJS.
  126347. *
  126348. * This offers the main features of a standard PBR material.
  126349. * For more information, please refer to the documentation :
  126350. * https://doc.babylonjs.com/how_to/physically_based_rendering
  126351. */
  126352. export class PBRMaterial extends PBRBaseMaterial {
  126353. /**
  126354. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  126355. */
  126356. static readonly PBRMATERIAL_OPAQUE: number;
  126357. /**
  126358. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  126359. */
  126360. static readonly PBRMATERIAL_ALPHATEST: number;
  126361. /**
  126362. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126363. */
  126364. static readonly PBRMATERIAL_ALPHABLEND: number;
  126365. /**
  126366. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  126367. * They are also discarded below the alpha cutoff threshold to improve performances.
  126368. */
  126369. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  126370. /**
  126371. * Defines the default value of how much AO map is occluding the analytical lights
  126372. * (point spot...).
  126373. */
  126374. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  126375. /**
  126376. * Intensity of the direct lights e.g. the four lights available in your scene.
  126377. * This impacts both the direct diffuse and specular highlights.
  126378. */
  126379. directIntensity: number;
  126380. /**
  126381. * Intensity of the emissive part of the material.
  126382. * This helps controlling the emissive effect without modifying the emissive color.
  126383. */
  126384. emissiveIntensity: number;
  126385. /**
  126386. * Intensity of the environment e.g. how much the environment will light the object
  126387. * either through harmonics for rough material or through the refelction for shiny ones.
  126388. */
  126389. environmentIntensity: number;
  126390. /**
  126391. * This is a special control allowing the reduction of the specular highlights coming from the
  126392. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  126393. */
  126394. specularIntensity: number;
  126395. /**
  126396. * Debug Control allowing disabling the bump map on this material.
  126397. */
  126398. disableBumpMap: boolean;
  126399. /**
  126400. * AKA Diffuse Texture in standard nomenclature.
  126401. */
  126402. albedoTexture: BaseTexture;
  126403. /**
  126404. * AKA Occlusion Texture in other nomenclature.
  126405. */
  126406. ambientTexture: BaseTexture;
  126407. /**
  126408. * AKA Occlusion Texture Intensity in other nomenclature.
  126409. */
  126410. ambientTextureStrength: number;
  126411. /**
  126412. * Defines how much the AO map is occluding the analytical lights (point spot...).
  126413. * 1 means it completely occludes it
  126414. * 0 mean it has no impact
  126415. */
  126416. ambientTextureImpactOnAnalyticalLights: number;
  126417. /**
  126418. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  126419. */
  126420. opacityTexture: BaseTexture;
  126421. /**
  126422. * Stores the reflection values in a texture.
  126423. */
  126424. reflectionTexture: Nullable<BaseTexture>;
  126425. /**
  126426. * Stores the emissive values in a texture.
  126427. */
  126428. emissiveTexture: BaseTexture;
  126429. /**
  126430. * AKA Specular texture in other nomenclature.
  126431. */
  126432. reflectivityTexture: BaseTexture;
  126433. /**
  126434. * Used to switch from specular/glossiness to metallic/roughness workflow.
  126435. */
  126436. metallicTexture: BaseTexture;
  126437. /**
  126438. * Specifies the metallic scalar of the metallic/roughness workflow.
  126439. * Can also be used to scale the metalness values of the metallic texture.
  126440. */
  126441. metallic: Nullable<number>;
  126442. /**
  126443. * Specifies the roughness scalar of the metallic/roughness workflow.
  126444. * Can also be used to scale the roughness values of the metallic texture.
  126445. */
  126446. roughness: Nullable<number>;
  126447. /**
  126448. * Specifies the an F0 factor to help configuring the material F0.
  126449. * Instead of the default 4%, 8% * factor will be used. As the factor is defaulting
  126450. * to 0.5 the previously hard coded value stays the same.
  126451. * Can also be used to scale the F0 values of the metallic texture.
  126452. */
  126453. metallicF0Factor: number;
  126454. /**
  126455. * Specifies whether the F0 factor can be fetched from the mettalic texture.
  126456. * If set to true, please adapt the metallicF0Factor to ensure it fits with
  126457. * your expectation as it multiplies with the texture data.
  126458. */
  126459. useMetallicF0FactorFromMetallicTexture: boolean;
  126460. /**
  126461. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  126462. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  126463. */
  126464. microSurfaceTexture: BaseTexture;
  126465. /**
  126466. * Stores surface normal data used to displace a mesh in a texture.
  126467. */
  126468. bumpTexture: BaseTexture;
  126469. /**
  126470. * Stores the pre-calculated light information of a mesh in a texture.
  126471. */
  126472. lightmapTexture: BaseTexture;
  126473. /**
  126474. * Stores the refracted light information in a texture.
  126475. */
  126476. get refractionTexture(): Nullable<BaseTexture>;
  126477. set refractionTexture(value: Nullable<BaseTexture>);
  126478. /**
  126479. * The color of a material in ambient lighting.
  126480. */
  126481. ambientColor: Color3;
  126482. /**
  126483. * AKA Diffuse Color in other nomenclature.
  126484. */
  126485. albedoColor: Color3;
  126486. /**
  126487. * AKA Specular Color in other nomenclature.
  126488. */
  126489. reflectivityColor: Color3;
  126490. /**
  126491. * The color reflected from the material.
  126492. */
  126493. reflectionColor: Color3;
  126494. /**
  126495. * The color emitted from the material.
  126496. */
  126497. emissiveColor: Color3;
  126498. /**
  126499. * AKA Glossiness in other nomenclature.
  126500. */
  126501. microSurface: number;
  126502. /**
  126503. * source material index of refraction (IOR)' / 'destination material IOR.
  126504. */
  126505. get indexOfRefraction(): number;
  126506. set indexOfRefraction(value: number);
  126507. /**
  126508. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  126509. */
  126510. get invertRefractionY(): boolean;
  126511. set invertRefractionY(value: boolean);
  126512. /**
  126513. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  126514. * Materials half opaque for instance using refraction could benefit from this control.
  126515. */
  126516. get linkRefractionWithTransparency(): boolean;
  126517. set linkRefractionWithTransparency(value: boolean);
  126518. /**
  126519. * If true, the light map contains occlusion information instead of lighting info.
  126520. */
  126521. useLightmapAsShadowmap: boolean;
  126522. /**
  126523. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  126524. */
  126525. useAlphaFromAlbedoTexture: boolean;
  126526. /**
  126527. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  126528. */
  126529. forceAlphaTest: boolean;
  126530. /**
  126531. * Defines the alpha limits in alpha test mode.
  126532. */
  126533. alphaCutOff: number;
  126534. /**
  126535. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  126536. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  126537. */
  126538. useSpecularOverAlpha: boolean;
  126539. /**
  126540. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  126541. */
  126542. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  126543. /**
  126544. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  126545. */
  126546. useRoughnessFromMetallicTextureAlpha: boolean;
  126547. /**
  126548. * Specifies if the metallic texture contains the roughness information in its green channel.
  126549. */
  126550. useRoughnessFromMetallicTextureGreen: boolean;
  126551. /**
  126552. * Specifies if the metallic texture contains the metallness information in its blue channel.
  126553. */
  126554. useMetallnessFromMetallicTextureBlue: boolean;
  126555. /**
  126556. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  126557. */
  126558. useAmbientOcclusionFromMetallicTextureRed: boolean;
  126559. /**
  126560. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  126561. */
  126562. useAmbientInGrayScale: boolean;
  126563. /**
  126564. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  126565. * The material will try to infer what glossiness each pixel should be.
  126566. */
  126567. useAutoMicroSurfaceFromReflectivityMap: boolean;
  126568. /**
  126569. * BJS is using an harcoded light falloff based on a manually sets up range.
  126570. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126571. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126572. */
  126573. get usePhysicalLightFalloff(): boolean;
  126574. /**
  126575. * BJS is using an harcoded light falloff based on a manually sets up range.
  126576. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  126577. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  126578. */
  126579. set usePhysicalLightFalloff(value: boolean);
  126580. /**
  126581. * In order to support the falloff compatibility with gltf, a special mode has been added
  126582. * to reproduce the gltf light falloff.
  126583. */
  126584. get useGLTFLightFalloff(): boolean;
  126585. /**
  126586. * In order to support the falloff compatibility with gltf, a special mode has been added
  126587. * to reproduce the gltf light falloff.
  126588. */
  126589. set useGLTFLightFalloff(value: boolean);
  126590. /**
  126591. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  126592. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  126593. */
  126594. useRadianceOverAlpha: boolean;
  126595. /**
  126596. * Allows using an object space normal map (instead of tangent space).
  126597. */
  126598. useObjectSpaceNormalMap: boolean;
  126599. /**
  126600. * Allows using the bump map in parallax mode.
  126601. */
  126602. useParallax: boolean;
  126603. /**
  126604. * Allows using the bump map in parallax occlusion mode.
  126605. */
  126606. useParallaxOcclusion: boolean;
  126607. /**
  126608. * Controls the scale bias of the parallax mode.
  126609. */
  126610. parallaxScaleBias: number;
  126611. /**
  126612. * If sets to true, disables all the lights affecting the material.
  126613. */
  126614. disableLighting: boolean;
  126615. /**
  126616. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  126617. */
  126618. forceIrradianceInFragment: boolean;
  126619. /**
  126620. * Number of Simultaneous lights allowed on the material.
  126621. */
  126622. maxSimultaneousLights: number;
  126623. /**
  126624. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  126625. */
  126626. invertNormalMapX: boolean;
  126627. /**
  126628. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  126629. */
  126630. invertNormalMapY: boolean;
  126631. /**
  126632. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  126633. */
  126634. twoSidedLighting: boolean;
  126635. /**
  126636. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126637. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  126638. */
  126639. useAlphaFresnel: boolean;
  126640. /**
  126641. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  126642. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  126643. */
  126644. useLinearAlphaFresnel: boolean;
  126645. /**
  126646. * Let user defines the brdf lookup texture used for IBL.
  126647. * A default 8bit version is embedded but you could point at :
  126648. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  126649. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  126650. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  126651. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  126652. */
  126653. environmentBRDFTexture: Nullable<BaseTexture>;
  126654. /**
  126655. * Force normal to face away from face.
  126656. */
  126657. forceNormalForward: boolean;
  126658. /**
  126659. * Enables specular anti aliasing in the PBR shader.
  126660. * It will both interacts on the Geometry for analytical and IBL lighting.
  126661. * It also prefilter the roughness map based on the bump values.
  126662. */
  126663. enableSpecularAntiAliasing: boolean;
  126664. /**
  126665. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  126666. * makes the reflect vector face the model (under horizon).
  126667. */
  126668. useHorizonOcclusion: boolean;
  126669. /**
  126670. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  126671. * too much the area relying on ambient texture to define their ambient occlusion.
  126672. */
  126673. useRadianceOcclusion: boolean;
  126674. /**
  126675. * If set to true, no lighting calculations will be applied.
  126676. */
  126677. unlit: boolean;
  126678. /**
  126679. * Gets the image processing configuration used either in this material.
  126680. */
  126681. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  126682. /**
  126683. * Sets the Default image processing configuration used either in the this material.
  126684. *
  126685. * If sets to null, the scene one is in use.
  126686. */
  126687. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  126688. /**
  126689. * Gets wether the color curves effect is enabled.
  126690. */
  126691. get cameraColorCurvesEnabled(): boolean;
  126692. /**
  126693. * Sets wether the color curves effect is enabled.
  126694. */
  126695. set cameraColorCurvesEnabled(value: boolean);
  126696. /**
  126697. * Gets wether the color grading effect is enabled.
  126698. */
  126699. get cameraColorGradingEnabled(): boolean;
  126700. /**
  126701. * Gets wether the color grading effect is enabled.
  126702. */
  126703. set cameraColorGradingEnabled(value: boolean);
  126704. /**
  126705. * Gets wether tonemapping is enabled or not.
  126706. */
  126707. get cameraToneMappingEnabled(): boolean;
  126708. /**
  126709. * Sets wether tonemapping is enabled or not
  126710. */
  126711. set cameraToneMappingEnabled(value: boolean);
  126712. /**
  126713. * The camera exposure used on this material.
  126714. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126715. * This corresponds to a photographic exposure.
  126716. */
  126717. get cameraExposure(): number;
  126718. /**
  126719. * The camera exposure used on this material.
  126720. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  126721. * This corresponds to a photographic exposure.
  126722. */
  126723. set cameraExposure(value: number);
  126724. /**
  126725. * Gets The camera contrast used on this material.
  126726. */
  126727. get cameraContrast(): number;
  126728. /**
  126729. * Sets The camera contrast used on this material.
  126730. */
  126731. set cameraContrast(value: number);
  126732. /**
  126733. * Gets the Color Grading 2D Lookup Texture.
  126734. */
  126735. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  126736. /**
  126737. * Sets the Color Grading 2D Lookup Texture.
  126738. */
  126739. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  126740. /**
  126741. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126742. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126743. * 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;
  126744. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126745. */
  126746. get cameraColorCurves(): Nullable<ColorCurves>;
  126747. /**
  126748. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  126749. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  126750. * 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;
  126751. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  126752. */
  126753. set cameraColorCurves(value: Nullable<ColorCurves>);
  126754. /**
  126755. * Instantiates a new PBRMaterial instance.
  126756. *
  126757. * @param name The material name
  126758. * @param scene The scene the material will be use in.
  126759. */
  126760. constructor(name: string, scene: Scene);
  126761. /**
  126762. * Returns the name of this material class.
  126763. */
  126764. getClassName(): string;
  126765. /**
  126766. * Makes a duplicate of the current material.
  126767. * @param name - name to use for the new material.
  126768. */
  126769. clone(name: string): PBRMaterial;
  126770. /**
  126771. * Serializes this PBR Material.
  126772. * @returns - An object with the serialized material.
  126773. */
  126774. serialize(): any;
  126775. /**
  126776. * Parses a PBR Material from a serialized object.
  126777. * @param source - Serialized object.
  126778. * @param scene - BJS scene instance.
  126779. * @param rootUrl - url for the scene object
  126780. * @returns - PBRMaterial
  126781. */
  126782. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  126783. }
  126784. }
  126785. declare module BABYLON {
  126786. /**
  126787. * Direct draw surface info
  126788. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  126789. */
  126790. export interface DDSInfo {
  126791. /**
  126792. * Width of the texture
  126793. */
  126794. width: number;
  126795. /**
  126796. * Width of the texture
  126797. */
  126798. height: number;
  126799. /**
  126800. * Number of Mipmaps for the texture
  126801. * @see https://en.wikipedia.org/wiki/Mipmap
  126802. */
  126803. mipmapCount: number;
  126804. /**
  126805. * If the textures format is a known fourCC format
  126806. * @see https://www.fourcc.org/
  126807. */
  126808. isFourCC: boolean;
  126809. /**
  126810. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  126811. */
  126812. isRGB: boolean;
  126813. /**
  126814. * If the texture is a lumincance format
  126815. */
  126816. isLuminance: boolean;
  126817. /**
  126818. * If this is a cube texture
  126819. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  126820. */
  126821. isCube: boolean;
  126822. /**
  126823. * If the texture is a compressed format eg. FOURCC_DXT1
  126824. */
  126825. isCompressed: boolean;
  126826. /**
  126827. * The dxgiFormat of the texture
  126828. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  126829. */
  126830. dxgiFormat: number;
  126831. /**
  126832. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  126833. */
  126834. textureType: number;
  126835. /**
  126836. * Sphericle polynomial created for the dds texture
  126837. */
  126838. sphericalPolynomial?: SphericalPolynomial;
  126839. }
  126840. /**
  126841. * Class used to provide DDS decompression tools
  126842. */
  126843. export class DDSTools {
  126844. /**
  126845. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  126846. */
  126847. static StoreLODInAlphaChannel: boolean;
  126848. /**
  126849. * Gets DDS information from an array buffer
  126850. * @param data defines the array buffer view to read data from
  126851. * @returns the DDS information
  126852. */
  126853. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  126854. private static _FloatView;
  126855. private static _Int32View;
  126856. private static _ToHalfFloat;
  126857. private static _FromHalfFloat;
  126858. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  126859. private static _GetHalfFloatRGBAArrayBuffer;
  126860. private static _GetFloatRGBAArrayBuffer;
  126861. private static _GetFloatAsUIntRGBAArrayBuffer;
  126862. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  126863. private static _GetRGBAArrayBuffer;
  126864. private static _ExtractLongWordOrder;
  126865. private static _GetRGBArrayBuffer;
  126866. private static _GetLuminanceArrayBuffer;
  126867. /**
  126868. * Uploads DDS Levels to a Babylon Texture
  126869. * @hidden
  126870. */
  126871. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  126872. }
  126873. interface ThinEngine {
  126874. /**
  126875. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  126876. * @param rootUrl defines the url where the file to load is located
  126877. * @param scene defines the current scene
  126878. * @param lodScale defines scale to apply to the mip map selection
  126879. * @param lodOffset defines offset to apply to the mip map selection
  126880. * @param onLoad defines an optional callback raised when the texture is loaded
  126881. * @param onError defines an optional callback raised if there is an issue to load the texture
  126882. * @param format defines the format of the data
  126883. * @param forcedExtension defines the extension to use to pick the right loader
  126884. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  126885. * @returns the cube texture as an InternalTexture
  126886. */
  126887. 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;
  126888. }
  126889. }
  126890. declare module BABYLON {
  126891. /**
  126892. * Implementation of the DDS Texture Loader.
  126893. * @hidden
  126894. */
  126895. export class _DDSTextureLoader implements IInternalTextureLoader {
  126896. /**
  126897. * Defines wether the loader supports cascade loading the different faces.
  126898. */
  126899. readonly supportCascades: boolean;
  126900. /**
  126901. * This returns if the loader support the current file information.
  126902. * @param extension defines the file extension of the file being loaded
  126903. * @returns true if the loader can load the specified file
  126904. */
  126905. canLoad(extension: string): boolean;
  126906. /**
  126907. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126908. * @param data contains the texture data
  126909. * @param texture defines the BabylonJS internal texture
  126910. * @param createPolynomials will be true if polynomials have been requested
  126911. * @param onLoad defines the callback to trigger once the texture is ready
  126912. * @param onError defines the callback to trigger in case of error
  126913. */
  126914. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126915. /**
  126916. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126917. * @param data contains the texture data
  126918. * @param texture defines the BabylonJS internal texture
  126919. * @param callback defines the method to call once ready to upload
  126920. */
  126921. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126922. }
  126923. }
  126924. declare module BABYLON {
  126925. /**
  126926. * Implementation of the ENV Texture Loader.
  126927. * @hidden
  126928. */
  126929. export class _ENVTextureLoader implements IInternalTextureLoader {
  126930. /**
  126931. * Defines wether the loader supports cascade loading the different faces.
  126932. */
  126933. readonly supportCascades: boolean;
  126934. /**
  126935. * This returns if the loader support the current file information.
  126936. * @param extension defines the file extension of the file being loaded
  126937. * @returns true if the loader can load the specified file
  126938. */
  126939. canLoad(extension: string): boolean;
  126940. /**
  126941. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  126942. * @param data contains the texture data
  126943. * @param texture defines the BabylonJS internal texture
  126944. * @param createPolynomials will be true if polynomials have been requested
  126945. * @param onLoad defines the callback to trigger once the texture is ready
  126946. * @param onError defines the callback to trigger in case of error
  126947. */
  126948. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  126949. /**
  126950. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  126951. * @param data contains the texture data
  126952. * @param texture defines the BabylonJS internal texture
  126953. * @param callback defines the method to call once ready to upload
  126954. */
  126955. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  126956. }
  126957. }
  126958. declare module BABYLON {
  126959. /**
  126960. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  126961. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  126962. */
  126963. export class KhronosTextureContainer {
  126964. /** contents of the KTX container file */
  126965. data: ArrayBufferView;
  126966. private static HEADER_LEN;
  126967. private static COMPRESSED_2D;
  126968. private static COMPRESSED_3D;
  126969. private static TEX_2D;
  126970. private static TEX_3D;
  126971. /**
  126972. * Gets the openGL type
  126973. */
  126974. glType: number;
  126975. /**
  126976. * Gets the openGL type size
  126977. */
  126978. glTypeSize: number;
  126979. /**
  126980. * Gets the openGL format
  126981. */
  126982. glFormat: number;
  126983. /**
  126984. * Gets the openGL internal format
  126985. */
  126986. glInternalFormat: number;
  126987. /**
  126988. * Gets the base internal format
  126989. */
  126990. glBaseInternalFormat: number;
  126991. /**
  126992. * Gets image width in pixel
  126993. */
  126994. pixelWidth: number;
  126995. /**
  126996. * Gets image height in pixel
  126997. */
  126998. pixelHeight: number;
  126999. /**
  127000. * Gets image depth in pixels
  127001. */
  127002. pixelDepth: number;
  127003. /**
  127004. * Gets the number of array elements
  127005. */
  127006. numberOfArrayElements: number;
  127007. /**
  127008. * Gets the number of faces
  127009. */
  127010. numberOfFaces: number;
  127011. /**
  127012. * Gets the number of mipmap levels
  127013. */
  127014. numberOfMipmapLevels: number;
  127015. /**
  127016. * Gets the bytes of key value data
  127017. */
  127018. bytesOfKeyValueData: number;
  127019. /**
  127020. * Gets the load type
  127021. */
  127022. loadType: number;
  127023. /**
  127024. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  127025. */
  127026. isInvalid: boolean;
  127027. /**
  127028. * Creates a new KhronosTextureContainer
  127029. * @param data contents of the KTX container file
  127030. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  127031. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  127032. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  127033. */
  127034. constructor(
  127035. /** contents of the KTX container file */
  127036. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  127037. /**
  127038. * Uploads KTX content to a Babylon Texture.
  127039. * It is assumed that the texture has already been created & is currently bound
  127040. * @hidden
  127041. */
  127042. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  127043. private _upload2DCompressedLevels;
  127044. /**
  127045. * Checks if the given data starts with a KTX file identifier.
  127046. * @param data the data to check
  127047. * @returns true if the data is a KTX file or false otherwise
  127048. */
  127049. static IsValid(data: ArrayBufferView): boolean;
  127050. }
  127051. }
  127052. declare module BABYLON {
  127053. /**
  127054. * Class for loading KTX2 files
  127055. * !!! Experimental Extension Subject to Changes !!!
  127056. * @hidden
  127057. */
  127058. export class KhronosTextureContainer2 {
  127059. private static _ModulePromise;
  127060. private static _TranscodeFormat;
  127061. constructor(engine: ThinEngine);
  127062. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  127063. private _determineTranscodeFormat;
  127064. /**
  127065. * Checks if the given data starts with a KTX2 file identifier.
  127066. * @param data the data to check
  127067. * @returns true if the data is a KTX2 file or false otherwise
  127068. */
  127069. static IsValid(data: ArrayBufferView): boolean;
  127070. }
  127071. }
  127072. declare module BABYLON {
  127073. /**
  127074. * Implementation of the KTX Texture Loader.
  127075. * @hidden
  127076. */
  127077. export class _KTXTextureLoader implements IInternalTextureLoader {
  127078. /**
  127079. * Defines wether the loader supports cascade loading the different faces.
  127080. */
  127081. readonly supportCascades: boolean;
  127082. /**
  127083. * This returns if the loader support the current file information.
  127084. * @param extension defines the file extension of the file being loaded
  127085. * @returns true if the loader can load the specified file
  127086. */
  127087. canLoad(extension: string): boolean;
  127088. /**
  127089. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  127090. * @param data contains the texture data
  127091. * @param texture defines the BabylonJS internal texture
  127092. * @param createPolynomials will be true if polynomials have been requested
  127093. * @param onLoad defines the callback to trigger once the texture is ready
  127094. * @param onError defines the callback to trigger in case of error
  127095. */
  127096. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  127097. /**
  127098. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  127099. * @param data contains the texture data
  127100. * @param texture defines the BabylonJS internal texture
  127101. * @param callback defines the method to call once ready to upload
  127102. */
  127103. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  127104. }
  127105. }
  127106. declare module BABYLON {
  127107. /** @hidden */
  127108. export var _forceSceneHelpersToBundle: boolean;
  127109. interface Scene {
  127110. /**
  127111. * Creates a default light for the scene.
  127112. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  127113. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  127114. */
  127115. createDefaultLight(replace?: boolean): void;
  127116. /**
  127117. * Creates a default camera for the scene.
  127118. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  127119. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127120. * @param replace has default false, when true replaces the active camera in the scene
  127121. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  127122. */
  127123. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127124. /**
  127125. * Creates a default camera and a default light.
  127126. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  127127. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  127128. * @param replace has the default false, when true replaces the active camera/light in the scene
  127129. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  127130. */
  127131. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  127132. /**
  127133. * Creates a new sky box
  127134. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  127135. * @param environmentTexture defines the texture to use as environment texture
  127136. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  127137. * @param scale defines the overall scale of the skybox
  127138. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  127139. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  127140. * @returns a new mesh holding the sky box
  127141. */
  127142. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  127143. /**
  127144. * Creates a new environment
  127145. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  127146. * @param options defines the options you can use to configure the environment
  127147. * @returns the new EnvironmentHelper
  127148. */
  127149. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  127150. /**
  127151. * Creates a new VREXperienceHelper
  127152. * @see http://doc.babylonjs.com/how_to/webvr_helper
  127153. * @param webVROptions defines the options used to create the new VREXperienceHelper
  127154. * @returns a new VREXperienceHelper
  127155. */
  127156. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  127157. /**
  127158. * Creates a new WebXRDefaultExperience
  127159. * @see http://doc.babylonjs.com/how_to/webxr
  127160. * @param options experience options
  127161. * @returns a promise for a new WebXRDefaultExperience
  127162. */
  127163. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  127164. }
  127165. }
  127166. declare module BABYLON {
  127167. /**
  127168. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  127169. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  127170. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  127171. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  127172. */
  127173. export class VideoDome extends TransformNode {
  127174. /**
  127175. * Define the video source as a Monoscopic panoramic 360 video.
  127176. */
  127177. static readonly MODE_MONOSCOPIC: number;
  127178. /**
  127179. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127180. */
  127181. static readonly MODE_TOPBOTTOM: number;
  127182. /**
  127183. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127184. */
  127185. static readonly MODE_SIDEBYSIDE: number;
  127186. private _halfDome;
  127187. private _useDirectMapping;
  127188. /**
  127189. * The video texture being displayed on the sphere
  127190. */
  127191. protected _videoTexture: VideoTexture;
  127192. /**
  127193. * Gets the video texture being displayed on the sphere
  127194. */
  127195. get videoTexture(): VideoTexture;
  127196. /**
  127197. * The skybox material
  127198. */
  127199. protected _material: BackgroundMaterial;
  127200. /**
  127201. * The surface used for the skybox
  127202. */
  127203. protected _mesh: Mesh;
  127204. /**
  127205. * A mesh that will be used to mask the back of the video dome in case it is a 180 degree movie.
  127206. */
  127207. private _halfDomeMask;
  127208. /**
  127209. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  127210. * Also see the options.resolution property.
  127211. */
  127212. get fovMultiplier(): number;
  127213. set fovMultiplier(value: number);
  127214. private _videoMode;
  127215. /**
  127216. * Gets or set the current video mode for the video. It can be:
  127217. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  127218. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  127219. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  127220. */
  127221. get videoMode(): number;
  127222. set videoMode(value: number);
  127223. /**
  127224. * Is the video a 180 degrees video (half dome) or 360 video (full dome)
  127225. *
  127226. */
  127227. get halfDome(): boolean;
  127228. /**
  127229. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  127230. */
  127231. set halfDome(enabled: boolean);
  127232. /**
  127233. * Oberserver used in Stereoscopic VR Mode.
  127234. */
  127235. private _onBeforeCameraRenderObserver;
  127236. /**
  127237. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  127238. * @param name Element's name, child elements will append suffixes for their own names.
  127239. * @param urlsOrVideo defines the url(s) or the video element to use
  127240. * @param options An object containing optional or exposed sub element properties
  127241. */
  127242. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  127243. resolution?: number;
  127244. clickToPlay?: boolean;
  127245. autoPlay?: boolean;
  127246. loop?: boolean;
  127247. size?: number;
  127248. poster?: string;
  127249. faceForward?: boolean;
  127250. useDirectMapping?: boolean;
  127251. halfDomeMode?: boolean;
  127252. }, scene: Scene);
  127253. private _changeVideoMode;
  127254. /**
  127255. * Releases resources associated with this node.
  127256. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  127257. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  127258. */
  127259. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  127260. }
  127261. }
  127262. declare module BABYLON {
  127263. /**
  127264. * This class can be used to get instrumentation data from a Babylon engine
  127265. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127266. */
  127267. export class EngineInstrumentation implements IDisposable {
  127268. /**
  127269. * Define the instrumented engine.
  127270. */
  127271. engine: Engine;
  127272. private _captureGPUFrameTime;
  127273. private _gpuFrameTimeToken;
  127274. private _gpuFrameTime;
  127275. private _captureShaderCompilationTime;
  127276. private _shaderCompilationTime;
  127277. private _onBeginFrameObserver;
  127278. private _onEndFrameObserver;
  127279. private _onBeforeShaderCompilationObserver;
  127280. private _onAfterShaderCompilationObserver;
  127281. /**
  127282. * Gets the perf counter used for GPU frame time
  127283. */
  127284. get gpuFrameTimeCounter(): PerfCounter;
  127285. /**
  127286. * Gets the GPU frame time capture status
  127287. */
  127288. get captureGPUFrameTime(): boolean;
  127289. /**
  127290. * Enable or disable the GPU frame time capture
  127291. */
  127292. set captureGPUFrameTime(value: boolean);
  127293. /**
  127294. * Gets the perf counter used for shader compilation time
  127295. */
  127296. get shaderCompilationTimeCounter(): PerfCounter;
  127297. /**
  127298. * Gets the shader compilation time capture status
  127299. */
  127300. get captureShaderCompilationTime(): boolean;
  127301. /**
  127302. * Enable or disable the shader compilation time capture
  127303. */
  127304. set captureShaderCompilationTime(value: boolean);
  127305. /**
  127306. * Instantiates a new engine instrumentation.
  127307. * This class can be used to get instrumentation data from a Babylon engine
  127308. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  127309. * @param engine Defines the engine to instrument
  127310. */
  127311. constructor(
  127312. /**
  127313. * Define the instrumented engine.
  127314. */
  127315. engine: Engine);
  127316. /**
  127317. * Dispose and release associated resources.
  127318. */
  127319. dispose(): void;
  127320. }
  127321. }
  127322. declare module BABYLON {
  127323. /**
  127324. * This class can be used to get instrumentation data from a Babylon engine
  127325. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127326. */
  127327. export class SceneInstrumentation implements IDisposable {
  127328. /**
  127329. * Defines the scene to instrument
  127330. */
  127331. scene: Scene;
  127332. private _captureActiveMeshesEvaluationTime;
  127333. private _activeMeshesEvaluationTime;
  127334. private _captureRenderTargetsRenderTime;
  127335. private _renderTargetsRenderTime;
  127336. private _captureFrameTime;
  127337. private _frameTime;
  127338. private _captureRenderTime;
  127339. private _renderTime;
  127340. private _captureInterFrameTime;
  127341. private _interFrameTime;
  127342. private _captureParticlesRenderTime;
  127343. private _particlesRenderTime;
  127344. private _captureSpritesRenderTime;
  127345. private _spritesRenderTime;
  127346. private _capturePhysicsTime;
  127347. private _physicsTime;
  127348. private _captureAnimationsTime;
  127349. private _animationsTime;
  127350. private _captureCameraRenderTime;
  127351. private _cameraRenderTime;
  127352. private _onBeforeActiveMeshesEvaluationObserver;
  127353. private _onAfterActiveMeshesEvaluationObserver;
  127354. private _onBeforeRenderTargetsRenderObserver;
  127355. private _onAfterRenderTargetsRenderObserver;
  127356. private _onAfterRenderObserver;
  127357. private _onBeforeDrawPhaseObserver;
  127358. private _onAfterDrawPhaseObserver;
  127359. private _onBeforeAnimationsObserver;
  127360. private _onBeforeParticlesRenderingObserver;
  127361. private _onAfterParticlesRenderingObserver;
  127362. private _onBeforeSpritesRenderingObserver;
  127363. private _onAfterSpritesRenderingObserver;
  127364. private _onBeforePhysicsObserver;
  127365. private _onAfterPhysicsObserver;
  127366. private _onAfterAnimationsObserver;
  127367. private _onBeforeCameraRenderObserver;
  127368. private _onAfterCameraRenderObserver;
  127369. /**
  127370. * Gets the perf counter used for active meshes evaluation time
  127371. */
  127372. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  127373. /**
  127374. * Gets the active meshes evaluation time capture status
  127375. */
  127376. get captureActiveMeshesEvaluationTime(): boolean;
  127377. /**
  127378. * Enable or disable the active meshes evaluation time capture
  127379. */
  127380. set captureActiveMeshesEvaluationTime(value: boolean);
  127381. /**
  127382. * Gets the perf counter used for render targets render time
  127383. */
  127384. get renderTargetsRenderTimeCounter(): PerfCounter;
  127385. /**
  127386. * Gets the render targets render time capture status
  127387. */
  127388. get captureRenderTargetsRenderTime(): boolean;
  127389. /**
  127390. * Enable or disable the render targets render time capture
  127391. */
  127392. set captureRenderTargetsRenderTime(value: boolean);
  127393. /**
  127394. * Gets the perf counter used for particles render time
  127395. */
  127396. get particlesRenderTimeCounter(): PerfCounter;
  127397. /**
  127398. * Gets the particles render time capture status
  127399. */
  127400. get captureParticlesRenderTime(): boolean;
  127401. /**
  127402. * Enable or disable the particles render time capture
  127403. */
  127404. set captureParticlesRenderTime(value: boolean);
  127405. /**
  127406. * Gets the perf counter used for sprites render time
  127407. */
  127408. get spritesRenderTimeCounter(): PerfCounter;
  127409. /**
  127410. * Gets the sprites render time capture status
  127411. */
  127412. get captureSpritesRenderTime(): boolean;
  127413. /**
  127414. * Enable or disable the sprites render time capture
  127415. */
  127416. set captureSpritesRenderTime(value: boolean);
  127417. /**
  127418. * Gets the perf counter used for physics time
  127419. */
  127420. get physicsTimeCounter(): PerfCounter;
  127421. /**
  127422. * Gets the physics time capture status
  127423. */
  127424. get capturePhysicsTime(): boolean;
  127425. /**
  127426. * Enable or disable the physics time capture
  127427. */
  127428. set capturePhysicsTime(value: boolean);
  127429. /**
  127430. * Gets the perf counter used for animations time
  127431. */
  127432. get animationsTimeCounter(): PerfCounter;
  127433. /**
  127434. * Gets the animations time capture status
  127435. */
  127436. get captureAnimationsTime(): boolean;
  127437. /**
  127438. * Enable or disable the animations time capture
  127439. */
  127440. set captureAnimationsTime(value: boolean);
  127441. /**
  127442. * Gets the perf counter used for frame time capture
  127443. */
  127444. get frameTimeCounter(): PerfCounter;
  127445. /**
  127446. * Gets the frame time capture status
  127447. */
  127448. get captureFrameTime(): boolean;
  127449. /**
  127450. * Enable or disable the frame time capture
  127451. */
  127452. set captureFrameTime(value: boolean);
  127453. /**
  127454. * Gets the perf counter used for inter-frames time capture
  127455. */
  127456. get interFrameTimeCounter(): PerfCounter;
  127457. /**
  127458. * Gets the inter-frames time capture status
  127459. */
  127460. get captureInterFrameTime(): boolean;
  127461. /**
  127462. * Enable or disable the inter-frames time capture
  127463. */
  127464. set captureInterFrameTime(value: boolean);
  127465. /**
  127466. * Gets the perf counter used for render time capture
  127467. */
  127468. get renderTimeCounter(): PerfCounter;
  127469. /**
  127470. * Gets the render time capture status
  127471. */
  127472. get captureRenderTime(): boolean;
  127473. /**
  127474. * Enable or disable the render time capture
  127475. */
  127476. set captureRenderTime(value: boolean);
  127477. /**
  127478. * Gets the perf counter used for camera render time capture
  127479. */
  127480. get cameraRenderTimeCounter(): PerfCounter;
  127481. /**
  127482. * Gets the camera render time capture status
  127483. */
  127484. get captureCameraRenderTime(): boolean;
  127485. /**
  127486. * Enable or disable the camera render time capture
  127487. */
  127488. set captureCameraRenderTime(value: boolean);
  127489. /**
  127490. * Gets the perf counter used for draw calls
  127491. */
  127492. get drawCallsCounter(): PerfCounter;
  127493. /**
  127494. * Instantiates a new scene instrumentation.
  127495. * This class can be used to get instrumentation data from a Babylon engine
  127496. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  127497. * @param scene Defines the scene to instrument
  127498. */
  127499. constructor(
  127500. /**
  127501. * Defines the scene to instrument
  127502. */
  127503. scene: Scene);
  127504. /**
  127505. * Dispose and release associated resources.
  127506. */
  127507. dispose(): void;
  127508. }
  127509. }
  127510. declare module BABYLON {
  127511. /** @hidden */
  127512. export var glowMapGenerationPixelShader: {
  127513. name: string;
  127514. shader: string;
  127515. };
  127516. }
  127517. declare module BABYLON {
  127518. /** @hidden */
  127519. export var glowMapGenerationVertexShader: {
  127520. name: string;
  127521. shader: string;
  127522. };
  127523. }
  127524. declare module BABYLON {
  127525. /**
  127526. * Effect layer options. This helps customizing the behaviour
  127527. * of the effect layer.
  127528. */
  127529. export interface IEffectLayerOptions {
  127530. /**
  127531. * Multiplication factor apply to the canvas size to compute the render target size
  127532. * used to generated the objects (the smaller the faster).
  127533. */
  127534. mainTextureRatio: number;
  127535. /**
  127536. * Enforces a fixed size texture to ensure effect stability across devices.
  127537. */
  127538. mainTextureFixedSize?: number;
  127539. /**
  127540. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  127541. */
  127542. alphaBlendingMode: number;
  127543. /**
  127544. * The camera attached to the layer.
  127545. */
  127546. camera: Nullable<Camera>;
  127547. /**
  127548. * The rendering group to draw the layer in.
  127549. */
  127550. renderingGroupId: number;
  127551. }
  127552. /**
  127553. * The effect layer Helps adding post process effect blended with the main pass.
  127554. *
  127555. * This can be for instance use to generate glow or higlight effects on the scene.
  127556. *
  127557. * The effect layer class can not be used directly and is intented to inherited from to be
  127558. * customized per effects.
  127559. */
  127560. export abstract class EffectLayer {
  127561. private _vertexBuffers;
  127562. private _indexBuffer;
  127563. private _cachedDefines;
  127564. private _effectLayerMapGenerationEffect;
  127565. private _effectLayerOptions;
  127566. private _mergeEffect;
  127567. protected _scene: Scene;
  127568. protected _engine: Engine;
  127569. protected _maxSize: number;
  127570. protected _mainTextureDesiredSize: ISize;
  127571. protected _mainTexture: RenderTargetTexture;
  127572. protected _shouldRender: boolean;
  127573. protected _postProcesses: PostProcess[];
  127574. protected _textures: BaseTexture[];
  127575. protected _emissiveTextureAndColor: {
  127576. texture: Nullable<BaseTexture>;
  127577. color: Color4;
  127578. };
  127579. /**
  127580. * The name of the layer
  127581. */
  127582. name: string;
  127583. /**
  127584. * The clear color of the texture used to generate the glow map.
  127585. */
  127586. neutralColor: Color4;
  127587. /**
  127588. * Specifies whether the highlight layer is enabled or not.
  127589. */
  127590. isEnabled: boolean;
  127591. /**
  127592. * Gets the camera attached to the layer.
  127593. */
  127594. get camera(): Nullable<Camera>;
  127595. /**
  127596. * Gets the rendering group id the layer should render in.
  127597. */
  127598. get renderingGroupId(): number;
  127599. set renderingGroupId(renderingGroupId: number);
  127600. /**
  127601. * An event triggered when the effect layer has been disposed.
  127602. */
  127603. onDisposeObservable: Observable<EffectLayer>;
  127604. /**
  127605. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  127606. */
  127607. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  127608. /**
  127609. * An event triggered when the generated texture is being merged in the scene.
  127610. */
  127611. onBeforeComposeObservable: Observable<EffectLayer>;
  127612. /**
  127613. * An event triggered when the mesh is rendered into the effect render target.
  127614. */
  127615. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  127616. /**
  127617. * An event triggered after the mesh has been rendered into the effect render target.
  127618. */
  127619. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  127620. /**
  127621. * An event triggered when the generated texture has been merged in the scene.
  127622. */
  127623. onAfterComposeObservable: Observable<EffectLayer>;
  127624. /**
  127625. * An event triggered when the efffect layer changes its size.
  127626. */
  127627. onSizeChangedObservable: Observable<EffectLayer>;
  127628. /** @hidden */
  127629. static _SceneComponentInitialization: (scene: Scene) => void;
  127630. /**
  127631. * Instantiates a new effect Layer and references it in the scene.
  127632. * @param name The name of the layer
  127633. * @param scene The scene to use the layer in
  127634. */
  127635. constructor(
  127636. /** The Friendly of the effect in the scene */
  127637. name: string, scene: Scene);
  127638. /**
  127639. * Get the effect name of the layer.
  127640. * @return The effect name
  127641. */
  127642. abstract getEffectName(): string;
  127643. /**
  127644. * Checks for the readiness of the element composing the layer.
  127645. * @param subMesh the mesh to check for
  127646. * @param useInstances specify whether or not to use instances to render the mesh
  127647. * @return true if ready otherwise, false
  127648. */
  127649. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  127650. /**
  127651. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  127652. * @returns true if the effect requires stencil during the main canvas render pass.
  127653. */
  127654. abstract needStencil(): boolean;
  127655. /**
  127656. * Create the merge effect. This is the shader use to blit the information back
  127657. * to the main canvas at the end of the scene rendering.
  127658. * @returns The effect containing the shader used to merge the effect on the main canvas
  127659. */
  127660. protected abstract _createMergeEffect(): Effect;
  127661. /**
  127662. * Creates the render target textures and post processes used in the effect layer.
  127663. */
  127664. protected abstract _createTextureAndPostProcesses(): void;
  127665. /**
  127666. * Implementation specific of rendering the generating effect on the main canvas.
  127667. * @param effect The effect used to render through
  127668. */
  127669. protected abstract _internalRender(effect: Effect): void;
  127670. /**
  127671. * Sets the required values for both the emissive texture and and the main color.
  127672. */
  127673. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  127674. /**
  127675. * Free any resources and references associated to a mesh.
  127676. * Internal use
  127677. * @param mesh The mesh to free.
  127678. */
  127679. abstract _disposeMesh(mesh: Mesh): void;
  127680. /**
  127681. * Serializes this layer (Glow or Highlight for example)
  127682. * @returns a serialized layer object
  127683. */
  127684. abstract serialize?(): any;
  127685. /**
  127686. * Initializes the effect layer with the required options.
  127687. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  127688. */
  127689. protected _init(options: Partial<IEffectLayerOptions>): void;
  127690. /**
  127691. * Generates the index buffer of the full screen quad blending to the main canvas.
  127692. */
  127693. private _generateIndexBuffer;
  127694. /**
  127695. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  127696. */
  127697. private _generateVertexBuffer;
  127698. /**
  127699. * Sets the main texture desired size which is the closest power of two
  127700. * of the engine canvas size.
  127701. */
  127702. private _setMainTextureSize;
  127703. /**
  127704. * Creates the main texture for the effect layer.
  127705. */
  127706. protected _createMainTexture(): void;
  127707. /**
  127708. * Adds specific effects defines.
  127709. * @param defines The defines to add specifics to.
  127710. */
  127711. protected _addCustomEffectDefines(defines: string[]): void;
  127712. /**
  127713. * Checks for the readiness of the element composing the layer.
  127714. * @param subMesh the mesh to check for
  127715. * @param useInstances specify whether or not to use instances to render the mesh
  127716. * @param emissiveTexture the associated emissive texture used to generate the glow
  127717. * @return true if ready otherwise, false
  127718. */
  127719. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  127720. /**
  127721. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  127722. */
  127723. render(): void;
  127724. /**
  127725. * Determine if a given mesh will be used in the current effect.
  127726. * @param mesh mesh to test
  127727. * @returns true if the mesh will be used
  127728. */
  127729. hasMesh(mesh: AbstractMesh): boolean;
  127730. /**
  127731. * Returns true if the layer contains information to display, otherwise false.
  127732. * @returns true if the glow layer should be rendered
  127733. */
  127734. shouldRender(): boolean;
  127735. /**
  127736. * Returns true if the mesh should render, otherwise false.
  127737. * @param mesh The mesh to render
  127738. * @returns true if it should render otherwise false
  127739. */
  127740. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  127741. /**
  127742. * Returns true if the mesh can be rendered, otherwise false.
  127743. * @param mesh The mesh to render
  127744. * @param material The material used on the mesh
  127745. * @returns true if it can be rendered otherwise false
  127746. */
  127747. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  127748. /**
  127749. * Returns true if the mesh should render, otherwise false.
  127750. * @param mesh The mesh to render
  127751. * @returns true if it should render otherwise false
  127752. */
  127753. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  127754. /**
  127755. * Renders the submesh passed in parameter to the generation map.
  127756. */
  127757. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  127758. /**
  127759. * Defines whether the current material of the mesh should be use to render the effect.
  127760. * @param mesh defines the current mesh to render
  127761. */
  127762. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  127763. /**
  127764. * Rebuild the required buffers.
  127765. * @hidden Internal use only.
  127766. */
  127767. _rebuild(): void;
  127768. /**
  127769. * Dispose only the render target textures and post process.
  127770. */
  127771. private _disposeTextureAndPostProcesses;
  127772. /**
  127773. * Dispose the highlight layer and free resources.
  127774. */
  127775. dispose(): void;
  127776. /**
  127777. * Gets the class name of the effect layer
  127778. * @returns the string with the class name of the effect layer
  127779. */
  127780. getClassName(): string;
  127781. /**
  127782. * Creates an effect layer from parsed effect layer data
  127783. * @param parsedEffectLayer defines effect layer data
  127784. * @param scene defines the current scene
  127785. * @param rootUrl defines the root URL containing the effect layer information
  127786. * @returns a parsed effect Layer
  127787. */
  127788. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  127789. }
  127790. }
  127791. declare module BABYLON {
  127792. interface AbstractScene {
  127793. /**
  127794. * The list of effect layers (highlights/glow) added to the scene
  127795. * @see http://doc.babylonjs.com/how_to/highlight_layer
  127796. * @see http://doc.babylonjs.com/how_to/glow_layer
  127797. */
  127798. effectLayers: Array<EffectLayer>;
  127799. /**
  127800. * Removes the given effect layer from this scene.
  127801. * @param toRemove defines the effect layer to remove
  127802. * @returns the index of the removed effect layer
  127803. */
  127804. removeEffectLayer(toRemove: EffectLayer): number;
  127805. /**
  127806. * Adds the given effect layer to this scene
  127807. * @param newEffectLayer defines the effect layer to add
  127808. */
  127809. addEffectLayer(newEffectLayer: EffectLayer): void;
  127810. }
  127811. /**
  127812. * Defines the layer scene component responsible to manage any effect layers
  127813. * in a given scene.
  127814. */
  127815. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  127816. /**
  127817. * The component name helpfull to identify the component in the list of scene components.
  127818. */
  127819. readonly name: string;
  127820. /**
  127821. * The scene the component belongs to.
  127822. */
  127823. scene: Scene;
  127824. private _engine;
  127825. private _renderEffects;
  127826. private _needStencil;
  127827. private _previousStencilState;
  127828. /**
  127829. * Creates a new instance of the component for the given scene
  127830. * @param scene Defines the scene to register the component in
  127831. */
  127832. constructor(scene: Scene);
  127833. /**
  127834. * Registers the component in a given scene
  127835. */
  127836. register(): void;
  127837. /**
  127838. * Rebuilds the elements related to this component in case of
  127839. * context lost for instance.
  127840. */
  127841. rebuild(): void;
  127842. /**
  127843. * Serializes the component data to the specified json object
  127844. * @param serializationObject The object to serialize to
  127845. */
  127846. serialize(serializationObject: any): void;
  127847. /**
  127848. * Adds all the elements from the container to the scene
  127849. * @param container the container holding the elements
  127850. */
  127851. addFromContainer(container: AbstractScene): void;
  127852. /**
  127853. * Removes all the elements in the container from the scene
  127854. * @param container contains the elements to remove
  127855. * @param dispose if the removed element should be disposed (default: false)
  127856. */
  127857. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  127858. /**
  127859. * Disposes the component and the associated ressources.
  127860. */
  127861. dispose(): void;
  127862. private _isReadyForMesh;
  127863. private _renderMainTexture;
  127864. private _setStencil;
  127865. private _setStencilBack;
  127866. private _draw;
  127867. private _drawCamera;
  127868. private _drawRenderingGroup;
  127869. }
  127870. }
  127871. declare module BABYLON {
  127872. /** @hidden */
  127873. export var glowMapMergePixelShader: {
  127874. name: string;
  127875. shader: string;
  127876. };
  127877. }
  127878. declare module BABYLON {
  127879. /** @hidden */
  127880. export var glowMapMergeVertexShader: {
  127881. name: string;
  127882. shader: string;
  127883. };
  127884. }
  127885. declare module BABYLON {
  127886. interface AbstractScene {
  127887. /**
  127888. * Return a the first highlight layer of the scene with a given name.
  127889. * @param name The name of the highlight layer to look for.
  127890. * @return The highlight layer if found otherwise null.
  127891. */
  127892. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  127893. }
  127894. /**
  127895. * Glow layer options. This helps customizing the behaviour
  127896. * of the glow layer.
  127897. */
  127898. export interface IGlowLayerOptions {
  127899. /**
  127900. * Multiplication factor apply to the canvas size to compute the render target size
  127901. * used to generated the glowing objects (the smaller the faster).
  127902. */
  127903. mainTextureRatio: number;
  127904. /**
  127905. * Enforces a fixed size texture to ensure resize independant blur.
  127906. */
  127907. mainTextureFixedSize?: number;
  127908. /**
  127909. * How big is the kernel of the blur texture.
  127910. */
  127911. blurKernelSize: number;
  127912. /**
  127913. * The camera attached to the layer.
  127914. */
  127915. camera: Nullable<Camera>;
  127916. /**
  127917. * Enable MSAA by chosing the number of samples.
  127918. */
  127919. mainTextureSamples?: number;
  127920. /**
  127921. * The rendering group to draw the layer in.
  127922. */
  127923. renderingGroupId: number;
  127924. }
  127925. /**
  127926. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  127927. *
  127928. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  127929. *
  127930. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  127931. */
  127932. export class GlowLayer extends EffectLayer {
  127933. /**
  127934. * Effect Name of the layer.
  127935. */
  127936. static readonly EffectName: string;
  127937. /**
  127938. * The default blur kernel size used for the glow.
  127939. */
  127940. static DefaultBlurKernelSize: number;
  127941. /**
  127942. * The default texture size ratio used for the glow.
  127943. */
  127944. static DefaultTextureRatio: number;
  127945. /**
  127946. * Sets the kernel size of the blur.
  127947. */
  127948. set blurKernelSize(value: number);
  127949. /**
  127950. * Gets the kernel size of the blur.
  127951. */
  127952. get blurKernelSize(): number;
  127953. /**
  127954. * Sets the glow intensity.
  127955. */
  127956. set intensity(value: number);
  127957. /**
  127958. * Gets the glow intensity.
  127959. */
  127960. get intensity(): number;
  127961. private _options;
  127962. private _intensity;
  127963. private _horizontalBlurPostprocess1;
  127964. private _verticalBlurPostprocess1;
  127965. private _horizontalBlurPostprocess2;
  127966. private _verticalBlurPostprocess2;
  127967. private _blurTexture1;
  127968. private _blurTexture2;
  127969. private _postProcesses1;
  127970. private _postProcesses2;
  127971. private _includedOnlyMeshes;
  127972. private _excludedMeshes;
  127973. private _meshesUsingTheirOwnMaterials;
  127974. /**
  127975. * Callback used to let the user override the color selection on a per mesh basis
  127976. */
  127977. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  127978. /**
  127979. * Callback used to let the user override the texture selection on a per mesh basis
  127980. */
  127981. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  127982. /**
  127983. * Instantiates a new glow Layer and references it to the scene.
  127984. * @param name The name of the layer
  127985. * @param scene The scene to use the layer in
  127986. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  127987. */
  127988. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  127989. /**
  127990. * Get the effect name of the layer.
  127991. * @return The effect name
  127992. */
  127993. getEffectName(): string;
  127994. /**
  127995. * Create the merge effect. This is the shader use to blit the information back
  127996. * to the main canvas at the end of the scene rendering.
  127997. */
  127998. protected _createMergeEffect(): Effect;
  127999. /**
  128000. * Creates the render target textures and post processes used in the glow layer.
  128001. */
  128002. protected _createTextureAndPostProcesses(): void;
  128003. /**
  128004. * Checks for the readiness of the element composing the layer.
  128005. * @param subMesh the mesh to check for
  128006. * @param useInstances specify wether or not to use instances to render the mesh
  128007. * @param emissiveTexture the associated emissive texture used to generate the glow
  128008. * @return true if ready otherwise, false
  128009. */
  128010. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128011. /**
  128012. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  128013. */
  128014. needStencil(): boolean;
  128015. /**
  128016. * Returns true if the mesh can be rendered, otherwise false.
  128017. * @param mesh The mesh to render
  128018. * @param material The material used on the mesh
  128019. * @returns true if it can be rendered otherwise false
  128020. */
  128021. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  128022. /**
  128023. * Implementation specific of rendering the generating effect on the main canvas.
  128024. * @param effect The effect used to render through
  128025. */
  128026. protected _internalRender(effect: Effect): void;
  128027. /**
  128028. * Sets the required values for both the emissive texture and and the main color.
  128029. */
  128030. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128031. /**
  128032. * Returns true if the mesh should render, otherwise false.
  128033. * @param mesh The mesh to render
  128034. * @returns true if it should render otherwise false
  128035. */
  128036. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128037. /**
  128038. * Adds specific effects defines.
  128039. * @param defines The defines to add specifics to.
  128040. */
  128041. protected _addCustomEffectDefines(defines: string[]): void;
  128042. /**
  128043. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  128044. * @param mesh The mesh to exclude from the glow layer
  128045. */
  128046. addExcludedMesh(mesh: Mesh): void;
  128047. /**
  128048. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  128049. * @param mesh The mesh to remove
  128050. */
  128051. removeExcludedMesh(mesh: Mesh): void;
  128052. /**
  128053. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  128054. * @param mesh The mesh to include in the glow layer
  128055. */
  128056. addIncludedOnlyMesh(mesh: Mesh): void;
  128057. /**
  128058. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  128059. * @param mesh The mesh to remove
  128060. */
  128061. removeIncludedOnlyMesh(mesh: Mesh): void;
  128062. /**
  128063. * Determine if a given mesh will be used in the glow layer
  128064. * @param mesh The mesh to test
  128065. * @returns true if the mesh will be highlighted by the current glow layer
  128066. */
  128067. hasMesh(mesh: AbstractMesh): boolean;
  128068. /**
  128069. * Defines whether the current material of the mesh should be use to render the effect.
  128070. * @param mesh defines the current mesh to render
  128071. */
  128072. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  128073. /**
  128074. * Add a mesh to be rendered through its own material and not with emissive only.
  128075. * @param mesh The mesh for which we need to use its material
  128076. */
  128077. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  128078. /**
  128079. * Remove a mesh from being rendered through its own material and not with emissive only.
  128080. * @param mesh The mesh for which we need to not use its material
  128081. */
  128082. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  128083. /**
  128084. * Free any resources and references associated to a mesh.
  128085. * Internal use
  128086. * @param mesh The mesh to free.
  128087. * @hidden
  128088. */
  128089. _disposeMesh(mesh: Mesh): void;
  128090. /**
  128091. * Gets the class name of the effect layer
  128092. * @returns the string with the class name of the effect layer
  128093. */
  128094. getClassName(): string;
  128095. /**
  128096. * Serializes this glow layer
  128097. * @returns a serialized glow layer object
  128098. */
  128099. serialize(): any;
  128100. /**
  128101. * Creates a Glow Layer from parsed glow layer data
  128102. * @param parsedGlowLayer defines glow layer data
  128103. * @param scene defines the current scene
  128104. * @param rootUrl defines the root URL containing the glow layer information
  128105. * @returns a parsed Glow Layer
  128106. */
  128107. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  128108. }
  128109. }
  128110. declare module BABYLON {
  128111. /** @hidden */
  128112. export var glowBlurPostProcessPixelShader: {
  128113. name: string;
  128114. shader: string;
  128115. };
  128116. }
  128117. declare module BABYLON {
  128118. interface AbstractScene {
  128119. /**
  128120. * Return a the first highlight layer of the scene with a given name.
  128121. * @param name The name of the highlight layer to look for.
  128122. * @return The highlight layer if found otherwise null.
  128123. */
  128124. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  128125. }
  128126. /**
  128127. * Highlight layer options. This helps customizing the behaviour
  128128. * of the highlight layer.
  128129. */
  128130. export interface IHighlightLayerOptions {
  128131. /**
  128132. * Multiplication factor apply to the canvas size to compute the render target size
  128133. * used to generated the glowing objects (the smaller the faster).
  128134. */
  128135. mainTextureRatio: number;
  128136. /**
  128137. * Enforces a fixed size texture to ensure resize independant blur.
  128138. */
  128139. mainTextureFixedSize?: number;
  128140. /**
  128141. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  128142. * of the picture to blur (the smaller the faster).
  128143. */
  128144. blurTextureSizeRatio: number;
  128145. /**
  128146. * How big in texel of the blur texture is the vertical blur.
  128147. */
  128148. blurVerticalSize: number;
  128149. /**
  128150. * How big in texel of the blur texture is the horizontal blur.
  128151. */
  128152. blurHorizontalSize: number;
  128153. /**
  128154. * Alpha blending mode used to apply the blur. Default is combine.
  128155. */
  128156. alphaBlendingMode: number;
  128157. /**
  128158. * The camera attached to the layer.
  128159. */
  128160. camera: Nullable<Camera>;
  128161. /**
  128162. * Should we display highlight as a solid stroke?
  128163. */
  128164. isStroke?: boolean;
  128165. /**
  128166. * The rendering group to draw the layer in.
  128167. */
  128168. renderingGroupId: number;
  128169. }
  128170. /**
  128171. * The highlight layer Helps adding a glow effect around a mesh.
  128172. *
  128173. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  128174. * glowy meshes to your scene.
  128175. *
  128176. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  128177. */
  128178. export class HighlightLayer extends EffectLayer {
  128179. name: string;
  128180. /**
  128181. * Effect Name of the highlight layer.
  128182. */
  128183. static readonly EffectName: string;
  128184. /**
  128185. * The neutral color used during the preparation of the glow effect.
  128186. * This is black by default as the blend operation is a blend operation.
  128187. */
  128188. static NeutralColor: Color4;
  128189. /**
  128190. * Stencil value used for glowing meshes.
  128191. */
  128192. static GlowingMeshStencilReference: number;
  128193. /**
  128194. * Stencil value used for the other meshes in the scene.
  128195. */
  128196. static NormalMeshStencilReference: number;
  128197. /**
  128198. * Specifies whether or not the inner glow is ACTIVE in the layer.
  128199. */
  128200. innerGlow: boolean;
  128201. /**
  128202. * Specifies whether or not the outer glow is ACTIVE in the layer.
  128203. */
  128204. outerGlow: boolean;
  128205. /**
  128206. * Specifies the horizontal size of the blur.
  128207. */
  128208. set blurHorizontalSize(value: number);
  128209. /**
  128210. * Specifies the vertical size of the blur.
  128211. */
  128212. set blurVerticalSize(value: number);
  128213. /**
  128214. * Gets the horizontal size of the blur.
  128215. */
  128216. get blurHorizontalSize(): number;
  128217. /**
  128218. * Gets the vertical size of the blur.
  128219. */
  128220. get blurVerticalSize(): number;
  128221. /**
  128222. * An event triggered when the highlight layer is being blurred.
  128223. */
  128224. onBeforeBlurObservable: Observable<HighlightLayer>;
  128225. /**
  128226. * An event triggered when the highlight layer has been blurred.
  128227. */
  128228. onAfterBlurObservable: Observable<HighlightLayer>;
  128229. private _instanceGlowingMeshStencilReference;
  128230. private _options;
  128231. private _downSamplePostprocess;
  128232. private _horizontalBlurPostprocess;
  128233. private _verticalBlurPostprocess;
  128234. private _blurTexture;
  128235. private _meshes;
  128236. private _excludedMeshes;
  128237. /**
  128238. * Instantiates a new highlight Layer and references it to the scene..
  128239. * @param name The name of the layer
  128240. * @param scene The scene to use the layer in
  128241. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  128242. */
  128243. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  128244. /**
  128245. * Get the effect name of the layer.
  128246. * @return The effect name
  128247. */
  128248. getEffectName(): string;
  128249. /**
  128250. * Create the merge effect. This is the shader use to blit the information back
  128251. * to the main canvas at the end of the scene rendering.
  128252. */
  128253. protected _createMergeEffect(): Effect;
  128254. /**
  128255. * Creates the render target textures and post processes used in the highlight layer.
  128256. */
  128257. protected _createTextureAndPostProcesses(): void;
  128258. /**
  128259. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  128260. */
  128261. needStencil(): boolean;
  128262. /**
  128263. * Checks for the readiness of the element composing the layer.
  128264. * @param subMesh the mesh to check for
  128265. * @param useInstances specify wether or not to use instances to render the mesh
  128266. * @param emissiveTexture the associated emissive texture used to generate the glow
  128267. * @return true if ready otherwise, false
  128268. */
  128269. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128270. /**
  128271. * Implementation specific of rendering the generating effect on the main canvas.
  128272. * @param effect The effect used to render through
  128273. */
  128274. protected _internalRender(effect: Effect): void;
  128275. /**
  128276. * Returns true if the layer contains information to display, otherwise false.
  128277. */
  128278. shouldRender(): boolean;
  128279. /**
  128280. * Returns true if the mesh should render, otherwise false.
  128281. * @param mesh The mesh to render
  128282. * @returns true if it should render otherwise false
  128283. */
  128284. protected _shouldRenderMesh(mesh: Mesh): boolean;
  128285. /**
  128286. * Adds specific effects defines.
  128287. * @param defines The defines to add specifics to.
  128288. */
  128289. protected _addCustomEffectDefines(defines: string[]): void;
  128290. /**
  128291. * Sets the required values for both the emissive texture and and the main color.
  128292. */
  128293. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  128294. /**
  128295. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  128296. * @param mesh The mesh to exclude from the highlight layer
  128297. */
  128298. addExcludedMesh(mesh: Mesh): void;
  128299. /**
  128300. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  128301. * @param mesh The mesh to highlight
  128302. */
  128303. removeExcludedMesh(mesh: Mesh): void;
  128304. /**
  128305. * Determine if a given mesh will be highlighted by the current HighlightLayer
  128306. * @param mesh mesh to test
  128307. * @returns true if the mesh will be highlighted by the current HighlightLayer
  128308. */
  128309. hasMesh(mesh: AbstractMesh): boolean;
  128310. /**
  128311. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  128312. * @param mesh The mesh to highlight
  128313. * @param color The color of the highlight
  128314. * @param glowEmissiveOnly Extract the glow from the emissive texture
  128315. */
  128316. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  128317. /**
  128318. * Remove a mesh from the highlight layer in order to make it stop glowing.
  128319. * @param mesh The mesh to highlight
  128320. */
  128321. removeMesh(mesh: Mesh): void;
  128322. /**
  128323. * Remove all the meshes currently referenced in the highlight layer
  128324. */
  128325. removeAllMeshes(): void;
  128326. /**
  128327. * Force the stencil to the normal expected value for none glowing parts
  128328. */
  128329. private _defaultStencilReference;
  128330. /**
  128331. * Free any resources and references associated to a mesh.
  128332. * Internal use
  128333. * @param mesh The mesh to free.
  128334. * @hidden
  128335. */
  128336. _disposeMesh(mesh: Mesh): void;
  128337. /**
  128338. * Dispose the highlight layer and free resources.
  128339. */
  128340. dispose(): void;
  128341. /**
  128342. * Gets the class name of the effect layer
  128343. * @returns the string with the class name of the effect layer
  128344. */
  128345. getClassName(): string;
  128346. /**
  128347. * Serializes this Highlight layer
  128348. * @returns a serialized Highlight layer object
  128349. */
  128350. serialize(): any;
  128351. /**
  128352. * Creates a Highlight layer from parsed Highlight layer data
  128353. * @param parsedHightlightLayer defines the Highlight layer data
  128354. * @param scene defines the current scene
  128355. * @param rootUrl defines the root URL containing the Highlight layer information
  128356. * @returns a parsed Highlight layer
  128357. */
  128358. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  128359. }
  128360. }
  128361. declare module BABYLON {
  128362. interface AbstractScene {
  128363. /**
  128364. * The list of layers (background and foreground) of the scene
  128365. */
  128366. layers: Array<Layer>;
  128367. }
  128368. /**
  128369. * Defines the layer scene component responsible to manage any layers
  128370. * in a given scene.
  128371. */
  128372. export class LayerSceneComponent implements ISceneComponent {
  128373. /**
  128374. * The component name helpfull to identify the component in the list of scene components.
  128375. */
  128376. readonly name: string;
  128377. /**
  128378. * The scene the component belongs to.
  128379. */
  128380. scene: Scene;
  128381. private _engine;
  128382. /**
  128383. * Creates a new instance of the component for the given scene
  128384. * @param scene Defines the scene to register the component in
  128385. */
  128386. constructor(scene: Scene);
  128387. /**
  128388. * Registers the component in a given scene
  128389. */
  128390. register(): void;
  128391. /**
  128392. * Rebuilds the elements related to this component in case of
  128393. * context lost for instance.
  128394. */
  128395. rebuild(): void;
  128396. /**
  128397. * Disposes the component and the associated ressources.
  128398. */
  128399. dispose(): void;
  128400. private _draw;
  128401. private _drawCameraPredicate;
  128402. private _drawCameraBackground;
  128403. private _drawCameraForeground;
  128404. private _drawRenderTargetPredicate;
  128405. private _drawRenderTargetBackground;
  128406. private _drawRenderTargetForeground;
  128407. /**
  128408. * Adds all the elements from the container to the scene
  128409. * @param container the container holding the elements
  128410. */
  128411. addFromContainer(container: AbstractScene): void;
  128412. /**
  128413. * Removes all the elements in the container from the scene
  128414. * @param container contains the elements to remove
  128415. * @param dispose if the removed element should be disposed (default: false)
  128416. */
  128417. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128418. }
  128419. }
  128420. declare module BABYLON {
  128421. /** @hidden */
  128422. export var layerPixelShader: {
  128423. name: string;
  128424. shader: string;
  128425. };
  128426. }
  128427. declare module BABYLON {
  128428. /** @hidden */
  128429. export var layerVertexShader: {
  128430. name: string;
  128431. shader: string;
  128432. };
  128433. }
  128434. declare module BABYLON {
  128435. /**
  128436. * This represents a full screen 2d layer.
  128437. * This can be useful to display a picture in the background of your scene for instance.
  128438. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128439. */
  128440. export class Layer {
  128441. /**
  128442. * Define the name of the layer.
  128443. */
  128444. name: string;
  128445. /**
  128446. * Define the texture the layer should display.
  128447. */
  128448. texture: Nullable<Texture>;
  128449. /**
  128450. * Is the layer in background or foreground.
  128451. */
  128452. isBackground: boolean;
  128453. /**
  128454. * Define the color of the layer (instead of texture).
  128455. */
  128456. color: Color4;
  128457. /**
  128458. * Define the scale of the layer in order to zoom in out of the texture.
  128459. */
  128460. scale: Vector2;
  128461. /**
  128462. * Define an offset for the layer in order to shift the texture.
  128463. */
  128464. offset: Vector2;
  128465. /**
  128466. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  128467. */
  128468. alphaBlendingMode: number;
  128469. /**
  128470. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  128471. * Alpha test will not mix with the background color in case of transparency.
  128472. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  128473. */
  128474. alphaTest: boolean;
  128475. /**
  128476. * Define a mask to restrict the layer to only some of the scene cameras.
  128477. */
  128478. layerMask: number;
  128479. /**
  128480. * Define the list of render target the layer is visible into.
  128481. */
  128482. renderTargetTextures: RenderTargetTexture[];
  128483. /**
  128484. * Define if the layer is only used in renderTarget or if it also
  128485. * renders in the main frame buffer of the canvas.
  128486. */
  128487. renderOnlyInRenderTargetTextures: boolean;
  128488. private _scene;
  128489. private _vertexBuffers;
  128490. private _indexBuffer;
  128491. private _effect;
  128492. private _previousDefines;
  128493. /**
  128494. * An event triggered when the layer is disposed.
  128495. */
  128496. onDisposeObservable: Observable<Layer>;
  128497. private _onDisposeObserver;
  128498. /**
  128499. * Back compatibility with callback before the onDisposeObservable existed.
  128500. * The set callback will be triggered when the layer has been disposed.
  128501. */
  128502. set onDispose(callback: () => void);
  128503. /**
  128504. * An event triggered before rendering the scene
  128505. */
  128506. onBeforeRenderObservable: Observable<Layer>;
  128507. private _onBeforeRenderObserver;
  128508. /**
  128509. * Back compatibility with callback before the onBeforeRenderObservable existed.
  128510. * The set callback will be triggered just before rendering the layer.
  128511. */
  128512. set onBeforeRender(callback: () => void);
  128513. /**
  128514. * An event triggered after rendering the scene
  128515. */
  128516. onAfterRenderObservable: Observable<Layer>;
  128517. private _onAfterRenderObserver;
  128518. /**
  128519. * Back compatibility with callback before the onAfterRenderObservable existed.
  128520. * The set callback will be triggered just after rendering the layer.
  128521. */
  128522. set onAfterRender(callback: () => void);
  128523. /**
  128524. * Instantiates a new layer.
  128525. * This represents a full screen 2d layer.
  128526. * This can be useful to display a picture in the background of your scene for instance.
  128527. * @see https://www.babylonjs-playground.com/#08A2BS#1
  128528. * @param name Define the name of the layer in the scene
  128529. * @param imgUrl Define the url of the texture to display in the layer
  128530. * @param scene Define the scene the layer belongs to
  128531. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  128532. * @param color Defines a color for the layer
  128533. */
  128534. constructor(
  128535. /**
  128536. * Define the name of the layer.
  128537. */
  128538. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  128539. private _createIndexBuffer;
  128540. /** @hidden */
  128541. _rebuild(): void;
  128542. /**
  128543. * Renders the layer in the scene.
  128544. */
  128545. render(): void;
  128546. /**
  128547. * Disposes and releases the associated ressources.
  128548. */
  128549. dispose(): void;
  128550. }
  128551. }
  128552. declare module BABYLON {
  128553. /** @hidden */
  128554. export var lensFlarePixelShader: {
  128555. name: string;
  128556. shader: string;
  128557. };
  128558. }
  128559. declare module BABYLON {
  128560. /** @hidden */
  128561. export var lensFlareVertexShader: {
  128562. name: string;
  128563. shader: string;
  128564. };
  128565. }
  128566. declare module BABYLON {
  128567. /**
  128568. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128569. * It is usually composed of several `lensFlare`.
  128570. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128571. */
  128572. export class LensFlareSystem {
  128573. /**
  128574. * Define the name of the lens flare system
  128575. */
  128576. name: string;
  128577. /**
  128578. * List of lens flares used in this system.
  128579. */
  128580. lensFlares: LensFlare[];
  128581. /**
  128582. * Define a limit from the border the lens flare can be visible.
  128583. */
  128584. borderLimit: number;
  128585. /**
  128586. * Define a viewport border we do not want to see the lens flare in.
  128587. */
  128588. viewportBorder: number;
  128589. /**
  128590. * Define a predicate which could limit the list of meshes able to occlude the effect.
  128591. */
  128592. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  128593. /**
  128594. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  128595. */
  128596. layerMask: number;
  128597. /**
  128598. * Define the id of the lens flare system in the scene.
  128599. * (equal to name by default)
  128600. */
  128601. id: string;
  128602. private _scene;
  128603. private _emitter;
  128604. private _vertexBuffers;
  128605. private _indexBuffer;
  128606. private _effect;
  128607. private _positionX;
  128608. private _positionY;
  128609. private _isEnabled;
  128610. /** @hidden */
  128611. static _SceneComponentInitialization: (scene: Scene) => void;
  128612. /**
  128613. * Instantiates a lens flare system.
  128614. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  128615. * It is usually composed of several `lensFlare`.
  128616. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128617. * @param name Define the name of the lens flare system in the scene
  128618. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  128619. * @param scene Define the scene the lens flare system belongs to
  128620. */
  128621. constructor(
  128622. /**
  128623. * Define the name of the lens flare system
  128624. */
  128625. name: string, emitter: any, scene: Scene);
  128626. /**
  128627. * Define if the lens flare system is enabled.
  128628. */
  128629. get isEnabled(): boolean;
  128630. set isEnabled(value: boolean);
  128631. /**
  128632. * Get the scene the effects belongs to.
  128633. * @returns the scene holding the lens flare system
  128634. */
  128635. getScene(): Scene;
  128636. /**
  128637. * Get the emitter of the lens flare system.
  128638. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128639. * @returns the emitter of the lens flare system
  128640. */
  128641. getEmitter(): any;
  128642. /**
  128643. * Set the emitter of the lens flare system.
  128644. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  128645. * @param newEmitter Define the new emitter of the system
  128646. */
  128647. setEmitter(newEmitter: any): void;
  128648. /**
  128649. * Get the lens flare system emitter position.
  128650. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  128651. * @returns the position
  128652. */
  128653. getEmitterPosition(): Vector3;
  128654. /**
  128655. * @hidden
  128656. */
  128657. computeEffectivePosition(globalViewport: Viewport): boolean;
  128658. /** @hidden */
  128659. _isVisible(): boolean;
  128660. /**
  128661. * @hidden
  128662. */
  128663. render(): boolean;
  128664. /**
  128665. * Dispose and release the lens flare with its associated resources.
  128666. */
  128667. dispose(): void;
  128668. /**
  128669. * Parse a lens flare system from a JSON repressentation
  128670. * @param parsedLensFlareSystem Define the JSON to parse
  128671. * @param scene Define the scene the parsed system should be instantiated in
  128672. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  128673. * @returns the parsed system
  128674. */
  128675. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  128676. /**
  128677. * Serialize the current Lens Flare System into a JSON representation.
  128678. * @returns the serialized JSON
  128679. */
  128680. serialize(): any;
  128681. }
  128682. }
  128683. declare module BABYLON {
  128684. /**
  128685. * This represents one of the lens effect in a `lensFlareSystem`.
  128686. * It controls one of the indiviual texture used in the effect.
  128687. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128688. */
  128689. export class LensFlare {
  128690. /**
  128691. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128692. */
  128693. size: number;
  128694. /**
  128695. * 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.
  128696. */
  128697. position: number;
  128698. /**
  128699. * Define the lens color.
  128700. */
  128701. color: Color3;
  128702. /**
  128703. * Define the lens texture.
  128704. */
  128705. texture: Nullable<Texture>;
  128706. /**
  128707. * Define the alpha mode to render this particular lens.
  128708. */
  128709. alphaMode: number;
  128710. private _system;
  128711. /**
  128712. * Creates a new Lens Flare.
  128713. * This represents one of the lens effect in a `lensFlareSystem`.
  128714. * It controls one of the indiviual texture used in the effect.
  128715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128716. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  128717. * @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.
  128718. * @param color Define the lens color
  128719. * @param imgUrl Define the lens texture url
  128720. * @param system Define the `lensFlareSystem` this flare is part of
  128721. * @returns The newly created Lens Flare
  128722. */
  128723. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  128724. /**
  128725. * Instantiates a new Lens Flare.
  128726. * This represents one of the lens effect in a `lensFlareSystem`.
  128727. * It controls one of the indiviual texture used in the effect.
  128728. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128729. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  128730. * @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.
  128731. * @param color Define the lens color
  128732. * @param imgUrl Define the lens texture url
  128733. * @param system Define the `lensFlareSystem` this flare is part of
  128734. */
  128735. constructor(
  128736. /**
  128737. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  128738. */
  128739. size: number,
  128740. /**
  128741. * 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.
  128742. */
  128743. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  128744. /**
  128745. * Dispose and release the lens flare with its associated resources.
  128746. */
  128747. dispose(): void;
  128748. }
  128749. }
  128750. declare module BABYLON {
  128751. interface AbstractScene {
  128752. /**
  128753. * The list of lens flare system added to the scene
  128754. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  128755. */
  128756. lensFlareSystems: Array<LensFlareSystem>;
  128757. /**
  128758. * Removes the given lens flare system from this scene.
  128759. * @param toRemove The lens flare system to remove
  128760. * @returns The index of the removed lens flare system
  128761. */
  128762. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  128763. /**
  128764. * Adds the given lens flare system to this scene
  128765. * @param newLensFlareSystem The lens flare system to add
  128766. */
  128767. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  128768. /**
  128769. * Gets a lens flare system using its name
  128770. * @param name defines the name to look for
  128771. * @returns the lens flare system or null if not found
  128772. */
  128773. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  128774. /**
  128775. * Gets a lens flare system using its id
  128776. * @param id defines the id to look for
  128777. * @returns the lens flare system or null if not found
  128778. */
  128779. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  128780. }
  128781. /**
  128782. * Defines the lens flare scene component responsible to manage any lens flares
  128783. * in a given scene.
  128784. */
  128785. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  128786. /**
  128787. * The component name helpfull to identify the component in the list of scene components.
  128788. */
  128789. readonly name: string;
  128790. /**
  128791. * The scene the component belongs to.
  128792. */
  128793. scene: Scene;
  128794. /**
  128795. * Creates a new instance of the component for the given scene
  128796. * @param scene Defines the scene to register the component in
  128797. */
  128798. constructor(scene: Scene);
  128799. /**
  128800. * Registers the component in a given scene
  128801. */
  128802. register(): void;
  128803. /**
  128804. * Rebuilds the elements related to this component in case of
  128805. * context lost for instance.
  128806. */
  128807. rebuild(): void;
  128808. /**
  128809. * Adds all the elements from the container to the scene
  128810. * @param container the container holding the elements
  128811. */
  128812. addFromContainer(container: AbstractScene): void;
  128813. /**
  128814. * Removes all the elements in the container from the scene
  128815. * @param container contains the elements to remove
  128816. * @param dispose if the removed element should be disposed (default: false)
  128817. */
  128818. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  128819. /**
  128820. * Serializes the component data to the specified json object
  128821. * @param serializationObject The object to serialize to
  128822. */
  128823. serialize(serializationObject: any): void;
  128824. /**
  128825. * Disposes the component and the associated ressources.
  128826. */
  128827. dispose(): void;
  128828. private _draw;
  128829. }
  128830. }
  128831. declare module BABYLON {
  128832. /** @hidden */
  128833. export var depthPixelShader: {
  128834. name: string;
  128835. shader: string;
  128836. };
  128837. }
  128838. declare module BABYLON {
  128839. /** @hidden */
  128840. export var depthVertexShader: {
  128841. name: string;
  128842. shader: string;
  128843. };
  128844. }
  128845. declare module BABYLON {
  128846. /**
  128847. * This represents a depth renderer in Babylon.
  128848. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  128849. */
  128850. export class DepthRenderer {
  128851. private _scene;
  128852. private _depthMap;
  128853. private _effect;
  128854. private readonly _storeNonLinearDepth;
  128855. private readonly _clearColor;
  128856. /** Get if the depth renderer is using packed depth or not */
  128857. readonly isPacked: boolean;
  128858. private _cachedDefines;
  128859. private _camera;
  128860. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  128861. enabled: boolean;
  128862. /**
  128863. * Specifiess that the depth renderer will only be used within
  128864. * the camera it is created for.
  128865. * This can help forcing its rendering during the camera processing.
  128866. */
  128867. useOnlyInActiveCamera: boolean;
  128868. /** @hidden */
  128869. static _SceneComponentInitialization: (scene: Scene) => void;
  128870. /**
  128871. * Instantiates a depth renderer
  128872. * @param scene The scene the renderer belongs to
  128873. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  128874. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  128875. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  128876. */
  128877. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  128878. /**
  128879. * Creates the depth rendering effect and checks if the effect is ready.
  128880. * @param subMesh The submesh to be used to render the depth map of
  128881. * @param useInstances If multiple world instances should be used
  128882. * @returns if the depth renderer is ready to render the depth map
  128883. */
  128884. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  128885. /**
  128886. * Gets the texture which the depth map will be written to.
  128887. * @returns The depth map texture
  128888. */
  128889. getDepthMap(): RenderTargetTexture;
  128890. /**
  128891. * Disposes of the depth renderer.
  128892. */
  128893. dispose(): void;
  128894. }
  128895. }
  128896. declare module BABYLON {
  128897. /** @hidden */
  128898. export var minmaxReduxPixelShader: {
  128899. name: string;
  128900. shader: string;
  128901. };
  128902. }
  128903. declare module BABYLON {
  128904. /**
  128905. * This class computes a min/max reduction from a texture: it means it computes the minimum
  128906. * and maximum values from all values of the texture.
  128907. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  128908. * The source values are read from the red channel of the texture.
  128909. */
  128910. export class MinMaxReducer {
  128911. /**
  128912. * Observable triggered when the computation has been performed
  128913. */
  128914. onAfterReductionPerformed: Observable<{
  128915. min: number;
  128916. max: number;
  128917. }>;
  128918. protected _camera: Camera;
  128919. protected _sourceTexture: Nullable<RenderTargetTexture>;
  128920. protected _reductionSteps: Nullable<Array<PostProcess>>;
  128921. protected _postProcessManager: PostProcessManager;
  128922. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  128923. protected _forceFullscreenViewport: boolean;
  128924. /**
  128925. * Creates a min/max reducer
  128926. * @param camera The camera to use for the post processes
  128927. */
  128928. constructor(camera: Camera);
  128929. /**
  128930. * Gets the texture used to read the values from.
  128931. */
  128932. get sourceTexture(): Nullable<RenderTargetTexture>;
  128933. /**
  128934. * Sets the source texture to read the values from.
  128935. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  128936. * because in such textures '1' value must not be taken into account to compute the maximum
  128937. * as this value is used to clear the texture.
  128938. * Note that the computation is not activated by calling this function, you must call activate() for that!
  128939. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  128940. * @param depthRedux Indicates if the texture is a depth texture or not
  128941. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  128942. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128943. */
  128944. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128945. /**
  128946. * Defines the refresh rate of the computation.
  128947. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  128948. */
  128949. get refreshRate(): number;
  128950. set refreshRate(value: number);
  128951. protected _activated: boolean;
  128952. /**
  128953. * Gets the activation status of the reducer
  128954. */
  128955. get activated(): boolean;
  128956. /**
  128957. * Activates the reduction computation.
  128958. * When activated, the observers registered in onAfterReductionPerformed are
  128959. * called after the compuation is performed
  128960. */
  128961. activate(): void;
  128962. /**
  128963. * Deactivates the reduction computation.
  128964. */
  128965. deactivate(): void;
  128966. /**
  128967. * Disposes the min/max reducer
  128968. * @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.
  128969. */
  128970. dispose(disposeAll?: boolean): void;
  128971. }
  128972. }
  128973. declare module BABYLON {
  128974. /**
  128975. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  128976. */
  128977. export class DepthReducer extends MinMaxReducer {
  128978. private _depthRenderer;
  128979. private _depthRendererId;
  128980. /**
  128981. * Gets the depth renderer used for the computation.
  128982. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  128983. */
  128984. get depthRenderer(): Nullable<DepthRenderer>;
  128985. /**
  128986. * Creates a depth reducer
  128987. * @param camera The camera used to render the depth texture
  128988. */
  128989. constructor(camera: Camera);
  128990. /**
  128991. * Sets the depth renderer to use to generate the depth map
  128992. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  128993. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  128994. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  128995. */
  128996. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  128997. /** @hidden */
  128998. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  128999. /**
  129000. * Activates the reduction computation.
  129001. * When activated, the observers registered in onAfterReductionPerformed are
  129002. * called after the compuation is performed
  129003. */
  129004. activate(): void;
  129005. /**
  129006. * Deactivates the reduction computation.
  129007. */
  129008. deactivate(): void;
  129009. /**
  129010. * Disposes the depth reducer
  129011. * @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.
  129012. */
  129013. dispose(disposeAll?: boolean): void;
  129014. }
  129015. }
  129016. declare module BABYLON {
  129017. /**
  129018. * A CSM implementation allowing casting shadows on large scenes.
  129019. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129020. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  129021. */
  129022. export class CascadedShadowGenerator extends ShadowGenerator {
  129023. private static readonly frustumCornersNDCSpace;
  129024. /**
  129025. * Name of the CSM class
  129026. */
  129027. static CLASSNAME: string;
  129028. /**
  129029. * Defines the default number of cascades used by the CSM.
  129030. */
  129031. static readonly DEFAULT_CASCADES_COUNT: number;
  129032. /**
  129033. * Defines the minimum number of cascades used by the CSM.
  129034. */
  129035. static readonly MIN_CASCADES_COUNT: number;
  129036. /**
  129037. * Defines the maximum number of cascades used by the CSM.
  129038. */
  129039. static readonly MAX_CASCADES_COUNT: number;
  129040. protected _validateFilter(filter: number): number;
  129041. /**
  129042. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  129043. */
  129044. penumbraDarkness: number;
  129045. private _numCascades;
  129046. /**
  129047. * Gets or set the number of cascades used by the CSM.
  129048. */
  129049. get numCascades(): number;
  129050. set numCascades(value: number);
  129051. /**
  129052. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  129053. * The trade off is that you loose some precision in the shadow rendering when enabling this setting.
  129054. */
  129055. stabilizeCascades: boolean;
  129056. private _freezeShadowCastersBoundingInfo;
  129057. private _freezeShadowCastersBoundingInfoObservable;
  129058. /**
  129059. * Enables or disables the shadow casters bounding info computation.
  129060. * If your shadow casters don't move, you can disable this feature.
  129061. * If it is enabled, the bounding box computation is done every frame.
  129062. */
  129063. get freezeShadowCastersBoundingInfo(): boolean;
  129064. set freezeShadowCastersBoundingInfo(freeze: boolean);
  129065. private _scbiMin;
  129066. private _scbiMax;
  129067. protected _computeShadowCastersBoundingInfo(): void;
  129068. protected _shadowCastersBoundingInfo: BoundingInfo;
  129069. /**
  129070. * Gets or sets the shadow casters bounding info.
  129071. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  129072. * so that the system won't overwrite the bounds you provide
  129073. */
  129074. get shadowCastersBoundingInfo(): BoundingInfo;
  129075. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  129076. protected _breaksAreDirty: boolean;
  129077. protected _minDistance: number;
  129078. protected _maxDistance: number;
  129079. /**
  129080. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  129081. *
  129082. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  129083. * If you don't know these values, simply leave them to their defaults and don't call this function.
  129084. * @param min minimal distance for the breaks (default to 0.)
  129085. * @param max maximal distance for the breaks (default to 1.)
  129086. */
  129087. setMinMaxDistance(min: number, max: number): void;
  129088. /** Gets the minimal distance used in the cascade break computation */
  129089. get minDistance(): number;
  129090. /** Gets the maximal distance used in the cascade break computation */
  129091. get maxDistance(): number;
  129092. /**
  129093. * Gets the class name of that object
  129094. * @returns "CascadedShadowGenerator"
  129095. */
  129096. getClassName(): string;
  129097. private _cascadeMinExtents;
  129098. private _cascadeMaxExtents;
  129099. /**
  129100. * Gets a cascade minimum extents
  129101. * @param cascadeIndex index of the cascade
  129102. * @returns the minimum cascade extents
  129103. */
  129104. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  129105. /**
  129106. * Gets a cascade maximum extents
  129107. * @param cascadeIndex index of the cascade
  129108. * @returns the maximum cascade extents
  129109. */
  129110. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  129111. private _cascades;
  129112. private _currentLayer;
  129113. private _viewSpaceFrustumsZ;
  129114. private _viewMatrices;
  129115. private _projectionMatrices;
  129116. private _transformMatrices;
  129117. private _transformMatricesAsArray;
  129118. private _frustumLengths;
  129119. private _lightSizeUVCorrection;
  129120. private _depthCorrection;
  129121. private _frustumCornersWorldSpace;
  129122. private _frustumCenter;
  129123. private _shadowCameraPos;
  129124. private _shadowMaxZ;
  129125. /**
  129126. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  129127. * It defaults to camera.maxZ
  129128. */
  129129. get shadowMaxZ(): number;
  129130. /**
  129131. * Sets the shadow max z distance.
  129132. */
  129133. set shadowMaxZ(value: number);
  129134. protected _debug: boolean;
  129135. /**
  129136. * Gets or sets the debug flag.
  129137. * When enabled, the cascades are materialized by different colors on the screen.
  129138. */
  129139. get debug(): boolean;
  129140. set debug(dbg: boolean);
  129141. private _depthClamp;
  129142. /**
  129143. * Gets or sets the depth clamping value.
  129144. *
  129145. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  129146. * to account for the shadow casters far away.
  129147. *
  129148. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  129149. */
  129150. get depthClamp(): boolean;
  129151. set depthClamp(value: boolean);
  129152. private _cascadeBlendPercentage;
  129153. /**
  129154. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  129155. * It defaults to 0.1 (10% blending).
  129156. */
  129157. get cascadeBlendPercentage(): number;
  129158. set cascadeBlendPercentage(value: number);
  129159. private _lambda;
  129160. /**
  129161. * Gets or set the lambda parameter.
  129162. * This parameter is used to split the camera frustum and create the cascades.
  129163. * 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.
  129164. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  129165. */
  129166. get lambda(): number;
  129167. set lambda(value: number);
  129168. /**
  129169. * Gets the view matrix corresponding to a given cascade
  129170. * @param cascadeNum cascade to retrieve the view matrix from
  129171. * @returns the cascade view matrix
  129172. */
  129173. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  129174. /**
  129175. * Gets the projection matrix corresponding to a given cascade
  129176. * @param cascadeNum cascade to retrieve the projection matrix from
  129177. * @returns the cascade projection matrix
  129178. */
  129179. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  129180. /**
  129181. * Gets the transformation matrix corresponding to a given cascade
  129182. * @param cascadeNum cascade to retrieve the transformation matrix from
  129183. * @returns the cascade transformation matrix
  129184. */
  129185. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  129186. private _depthRenderer;
  129187. /**
  129188. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  129189. *
  129190. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  129191. *
  129192. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  129193. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  129194. * @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
  129195. */
  129196. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  129197. private _depthReducer;
  129198. private _autoCalcDepthBounds;
  129199. /**
  129200. * Gets or sets the autoCalcDepthBounds property.
  129201. *
  129202. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  129203. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  129204. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  129205. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  129206. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  129207. */
  129208. get autoCalcDepthBounds(): boolean;
  129209. set autoCalcDepthBounds(value: boolean);
  129210. /**
  129211. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  129212. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  129213. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  129214. * for setting the refresh rate on the renderer yourself!
  129215. */
  129216. get autoCalcDepthBoundsRefreshRate(): number;
  129217. set autoCalcDepthBoundsRefreshRate(value: number);
  129218. /**
  129219. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  129220. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  129221. * you change the camera near/far planes!
  129222. */
  129223. splitFrustum(): void;
  129224. private _splitFrustum;
  129225. private _computeMatrices;
  129226. private _computeFrustumInWorldSpace;
  129227. private _computeCascadeFrustum;
  129228. /**
  129229. * Support test.
  129230. */
  129231. static get IsSupported(): boolean;
  129232. /** @hidden */
  129233. static _SceneComponentInitialization: (scene: Scene) => void;
  129234. /**
  129235. * Creates a Cascaded Shadow Generator object.
  129236. * A ShadowGenerator is the required tool to use the shadows.
  129237. * Each directional light casting shadows needs to use its own ShadowGenerator.
  129238. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  129239. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  129240. * @param light The directional light object generating the shadows.
  129241. * @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.
  129242. */
  129243. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  129244. protected _initializeGenerator(): void;
  129245. protected _createTargetRenderTexture(): void;
  129246. protected _initializeShadowMap(): void;
  129247. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect): void;
  129248. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  129249. /**
  129250. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  129251. * @param defines Defines of the material we want to update
  129252. * @param lightIndex Index of the light in the enabled light list of the material
  129253. */
  129254. prepareDefines(defines: any, lightIndex: number): void;
  129255. /**
  129256. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  129257. * defined in the generator but impacting the effect).
  129258. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  129259. * @param effect The effect we are binfing the information for
  129260. */
  129261. bindShadowLight(lightIndex: string, effect: Effect): void;
  129262. /**
  129263. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  129264. * (eq to view projection * shadow projection matrices)
  129265. * @returns The transform matrix used to create the shadow map
  129266. */
  129267. getTransformMatrix(): Matrix;
  129268. /**
  129269. * Disposes the ShadowGenerator.
  129270. * Returns nothing.
  129271. */
  129272. dispose(): void;
  129273. /**
  129274. * Serializes the shadow generator setup to a json object.
  129275. * @returns The serialized JSON object
  129276. */
  129277. serialize(): any;
  129278. /**
  129279. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  129280. * @param parsedShadowGenerator The JSON object to parse
  129281. * @param scene The scene to create the shadow map for
  129282. * @returns The parsed shadow generator
  129283. */
  129284. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  129285. }
  129286. }
  129287. declare module BABYLON {
  129288. /**
  129289. * Defines the shadow generator component responsible to manage any shadow generators
  129290. * in a given scene.
  129291. */
  129292. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  129293. /**
  129294. * The component name helpfull to identify the component in the list of scene components.
  129295. */
  129296. readonly name: string;
  129297. /**
  129298. * The scene the component belongs to.
  129299. */
  129300. scene: Scene;
  129301. /**
  129302. * Creates a new instance of the component for the given scene
  129303. * @param scene Defines the scene to register the component in
  129304. */
  129305. constructor(scene: Scene);
  129306. /**
  129307. * Registers the component in a given scene
  129308. */
  129309. register(): void;
  129310. /**
  129311. * Rebuilds the elements related to this component in case of
  129312. * context lost for instance.
  129313. */
  129314. rebuild(): void;
  129315. /**
  129316. * Serializes the component data to the specified json object
  129317. * @param serializationObject The object to serialize to
  129318. */
  129319. serialize(serializationObject: any): void;
  129320. /**
  129321. * Adds all the elements from the container to the scene
  129322. * @param container the container holding the elements
  129323. */
  129324. addFromContainer(container: AbstractScene): void;
  129325. /**
  129326. * Removes all the elements in the container from the scene
  129327. * @param container contains the elements to remove
  129328. * @param dispose if the removed element should be disposed (default: false)
  129329. */
  129330. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  129331. /**
  129332. * Rebuilds the elements related to this component in case of
  129333. * context lost for instance.
  129334. */
  129335. dispose(): void;
  129336. private _gatherRenderTargets;
  129337. }
  129338. }
  129339. declare module BABYLON {
  129340. /**
  129341. * A point light is a light defined by an unique point in world space.
  129342. * The light is emitted in every direction from this point.
  129343. * A good example of a point light is a standard light bulb.
  129344. * Documentation: https://doc.babylonjs.com/babylon101/lights
  129345. */
  129346. export class PointLight extends ShadowLight {
  129347. private _shadowAngle;
  129348. /**
  129349. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129350. * This specifies what angle the shadow will use to be created.
  129351. *
  129352. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129353. */
  129354. get shadowAngle(): number;
  129355. /**
  129356. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129357. * This specifies what angle the shadow will use to be created.
  129358. *
  129359. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  129360. */
  129361. set shadowAngle(value: number);
  129362. /**
  129363. * Gets the direction if it has been set.
  129364. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129365. */
  129366. get direction(): Vector3;
  129367. /**
  129368. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  129369. */
  129370. set direction(value: Vector3);
  129371. /**
  129372. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  129373. * A PointLight emits the light in every direction.
  129374. * It can cast shadows.
  129375. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  129376. * ```javascript
  129377. * var pointLight = new PointLight("pl", camera.position, scene);
  129378. * ```
  129379. * Documentation : https://doc.babylonjs.com/babylon101/lights
  129380. * @param name The light friendly name
  129381. * @param position The position of the point light in the scene
  129382. * @param scene The scene the lights belongs to
  129383. */
  129384. constructor(name: string, position: Vector3, scene: Scene);
  129385. /**
  129386. * Returns the string "PointLight"
  129387. * @returns the class name
  129388. */
  129389. getClassName(): string;
  129390. /**
  129391. * Returns the integer 0.
  129392. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  129393. */
  129394. getTypeID(): number;
  129395. /**
  129396. * Specifies wether or not the shadowmap should be a cube texture.
  129397. * @returns true if the shadowmap needs to be a cube texture.
  129398. */
  129399. needCube(): boolean;
  129400. /**
  129401. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  129402. * @param faceIndex The index of the face we are computed the direction to generate shadow
  129403. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  129404. */
  129405. getShadowDirection(faceIndex?: number): Vector3;
  129406. /**
  129407. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  129408. * - fov = PI / 2
  129409. * - aspect ratio : 1.0
  129410. * - z-near and far equal to the active camera minZ and maxZ.
  129411. * Returns the PointLight.
  129412. */
  129413. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  129414. protected _buildUniformLayout(): void;
  129415. /**
  129416. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  129417. * @param effect The effect to update
  129418. * @param lightIndex The index of the light in the effect to update
  129419. * @returns The point light
  129420. */
  129421. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  129422. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  129423. /**
  129424. * Prepares the list of defines specific to the light type.
  129425. * @param defines the list of defines
  129426. * @param lightIndex defines the index of the light for the effect
  129427. */
  129428. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  129429. }
  129430. }
  129431. declare module BABYLON {
  129432. /**
  129433. * Header information of HDR texture files.
  129434. */
  129435. export interface HDRInfo {
  129436. /**
  129437. * The height of the texture in pixels.
  129438. */
  129439. height: number;
  129440. /**
  129441. * The width of the texture in pixels.
  129442. */
  129443. width: number;
  129444. /**
  129445. * The index of the beginning of the data in the binary file.
  129446. */
  129447. dataPosition: number;
  129448. }
  129449. /**
  129450. * This groups tools to convert HDR texture to native colors array.
  129451. */
  129452. export class HDRTools {
  129453. private static Ldexp;
  129454. private static Rgbe2float;
  129455. private static readStringLine;
  129456. /**
  129457. * Reads header information from an RGBE texture stored in a native array.
  129458. * More information on this format are available here:
  129459. * https://en.wikipedia.org/wiki/RGBE_image_format
  129460. *
  129461. * @param uint8array The binary file stored in native array.
  129462. * @return The header information.
  129463. */
  129464. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  129465. /**
  129466. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  129467. * This RGBE texture needs to store the information as a panorama.
  129468. *
  129469. * More information on this format are available here:
  129470. * https://en.wikipedia.org/wiki/RGBE_image_format
  129471. *
  129472. * @param buffer The binary file stored in an array buffer.
  129473. * @param size The expected size of the extracted cubemap.
  129474. * @return The Cube Map information.
  129475. */
  129476. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  129477. /**
  129478. * Returns the pixels data extracted from an RGBE texture.
  129479. * This pixels will be stored left to right up to down in the R G B order in one array.
  129480. *
  129481. * More information on this format are available here:
  129482. * https://en.wikipedia.org/wiki/RGBE_image_format
  129483. *
  129484. * @param uint8array The binary file stored in an array buffer.
  129485. * @param hdrInfo The header information of the file.
  129486. * @return The pixels data in RGB right to left up to down order.
  129487. */
  129488. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  129489. private static RGBE_ReadPixels_RLE;
  129490. }
  129491. }
  129492. declare module BABYLON {
  129493. /**
  129494. * This represents a texture coming from an HDR input.
  129495. *
  129496. * The only supported format is currently panorama picture stored in RGBE format.
  129497. * Example of such files can be found on HDRLib: http://hdrlib.com/
  129498. */
  129499. export class HDRCubeTexture extends BaseTexture {
  129500. private static _facesMapping;
  129501. private _generateHarmonics;
  129502. private _noMipmap;
  129503. private _textureMatrix;
  129504. private _size;
  129505. private _onLoad;
  129506. private _onError;
  129507. /**
  129508. * The texture URL.
  129509. */
  129510. url: string;
  129511. /**
  129512. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  129513. */
  129514. coordinatesMode: number;
  129515. protected _isBlocking: boolean;
  129516. /**
  129517. * Sets wether or not the texture is blocking during loading.
  129518. */
  129519. set isBlocking(value: boolean);
  129520. /**
  129521. * Gets wether or not the texture is blocking during loading.
  129522. */
  129523. get isBlocking(): boolean;
  129524. protected _rotationY: number;
  129525. /**
  129526. * Sets texture matrix rotation angle around Y axis in radians.
  129527. */
  129528. set rotationY(value: number);
  129529. /**
  129530. * Gets texture matrix rotation angle around Y axis radians.
  129531. */
  129532. get rotationY(): number;
  129533. /**
  129534. * Gets or sets the center of the bounding box associated with the cube texture
  129535. * It must define where the camera used to render the texture was set
  129536. */
  129537. boundingBoxPosition: Vector3;
  129538. private _boundingBoxSize;
  129539. /**
  129540. * Gets or sets the size of the bounding box associated with the cube texture
  129541. * When defined, the cubemap will switch to local mode
  129542. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  129543. * @example https://www.babylonjs-playground.com/#RNASML
  129544. */
  129545. set boundingBoxSize(value: Vector3);
  129546. get boundingBoxSize(): Vector3;
  129547. /**
  129548. * Instantiates an HDRTexture from the following parameters.
  129549. *
  129550. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  129551. * @param scene The scene the texture will be used in
  129552. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  129553. * @param noMipmap Forces to not generate the mipmap if true
  129554. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  129555. * @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)
  129556. * @param reserved Reserved flag for internal use.
  129557. */
  129558. 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>);
  129559. /**
  129560. * Get the current class name of the texture useful for serialization or dynamic coding.
  129561. * @returns "HDRCubeTexture"
  129562. */
  129563. getClassName(): string;
  129564. /**
  129565. * Occurs when the file is raw .hdr file.
  129566. */
  129567. private loadTexture;
  129568. clone(): HDRCubeTexture;
  129569. delayLoad(): void;
  129570. /**
  129571. * Get the texture reflection matrix used to rotate/transform the reflection.
  129572. * @returns the reflection matrix
  129573. */
  129574. getReflectionTextureMatrix(): Matrix;
  129575. /**
  129576. * Set the texture reflection matrix used to rotate/transform the reflection.
  129577. * @param value Define the reflection matrix to set
  129578. */
  129579. setReflectionTextureMatrix(value: Matrix): void;
  129580. /**
  129581. * Parses a JSON representation of an HDR Texture in order to create the texture
  129582. * @param parsedTexture Define the JSON representation
  129583. * @param scene Define the scene the texture should be created in
  129584. * @param rootUrl Define the root url in case we need to load relative dependencies
  129585. * @returns the newly created texture after parsing
  129586. */
  129587. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  129588. serialize(): any;
  129589. }
  129590. }
  129591. declare module BABYLON {
  129592. /**
  129593. * Class used to control physics engine
  129594. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  129595. */
  129596. export class PhysicsEngine implements IPhysicsEngine {
  129597. private _physicsPlugin;
  129598. /**
  129599. * Global value used to control the smallest number supported by the simulation
  129600. */
  129601. static Epsilon: number;
  129602. private _impostors;
  129603. private _joints;
  129604. private _subTimeStep;
  129605. /**
  129606. * Gets the gravity vector used by the simulation
  129607. */
  129608. gravity: Vector3;
  129609. /**
  129610. * Factory used to create the default physics plugin.
  129611. * @returns The default physics plugin
  129612. */
  129613. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  129614. /**
  129615. * Creates a new Physics Engine
  129616. * @param gravity defines the gravity vector used by the simulation
  129617. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  129618. */
  129619. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  129620. /**
  129621. * Sets the gravity vector used by the simulation
  129622. * @param gravity defines the gravity vector to use
  129623. */
  129624. setGravity(gravity: Vector3): void;
  129625. /**
  129626. * Set the time step of the physics engine.
  129627. * Default is 1/60.
  129628. * To slow it down, enter 1/600 for example.
  129629. * To speed it up, 1/30
  129630. * @param newTimeStep defines the new timestep to apply to this world.
  129631. */
  129632. setTimeStep(newTimeStep?: number): void;
  129633. /**
  129634. * Get the time step of the physics engine.
  129635. * @returns the current time step
  129636. */
  129637. getTimeStep(): number;
  129638. /**
  129639. * Set the sub time step of the physics engine.
  129640. * Default is 0 meaning there is no sub steps
  129641. * To increase physics resolution precision, set a small value (like 1 ms)
  129642. * @param subTimeStep defines the new sub timestep used for physics resolution.
  129643. */
  129644. setSubTimeStep(subTimeStep?: number): void;
  129645. /**
  129646. * Get the sub time step of the physics engine.
  129647. * @returns the current sub time step
  129648. */
  129649. getSubTimeStep(): number;
  129650. /**
  129651. * Release all resources
  129652. */
  129653. dispose(): void;
  129654. /**
  129655. * Gets the name of the current physics plugin
  129656. * @returns the name of the plugin
  129657. */
  129658. getPhysicsPluginName(): string;
  129659. /**
  129660. * Adding a new impostor for the impostor tracking.
  129661. * This will be done by the impostor itself.
  129662. * @param impostor the impostor to add
  129663. */
  129664. addImpostor(impostor: PhysicsImpostor): void;
  129665. /**
  129666. * Remove an impostor from the engine.
  129667. * This impostor and its mesh will not longer be updated by the physics engine.
  129668. * @param impostor the impostor to remove
  129669. */
  129670. removeImpostor(impostor: PhysicsImpostor): void;
  129671. /**
  129672. * Add a joint to the physics engine
  129673. * @param mainImpostor defines the main impostor to which the joint is added.
  129674. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  129675. * @param joint defines the joint that will connect both impostors.
  129676. */
  129677. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129678. /**
  129679. * Removes a joint from the simulation
  129680. * @param mainImpostor defines the impostor used with the joint
  129681. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  129682. * @param joint defines the joint to remove
  129683. */
  129684. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  129685. /**
  129686. * Called by the scene. No need to call it.
  129687. * @param delta defines the timespam between frames
  129688. */
  129689. _step(delta: number): void;
  129690. /**
  129691. * Gets the current plugin used to run the simulation
  129692. * @returns current plugin
  129693. */
  129694. getPhysicsPlugin(): IPhysicsEnginePlugin;
  129695. /**
  129696. * Gets the list of physic impostors
  129697. * @returns an array of PhysicsImpostor
  129698. */
  129699. getImpostors(): Array<PhysicsImpostor>;
  129700. /**
  129701. * Gets the impostor for a physics enabled object
  129702. * @param object defines the object impersonated by the impostor
  129703. * @returns the PhysicsImpostor or null if not found
  129704. */
  129705. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  129706. /**
  129707. * Gets the impostor for a physics body object
  129708. * @param body defines physics body used by the impostor
  129709. * @returns the PhysicsImpostor or null if not found
  129710. */
  129711. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  129712. /**
  129713. * Does a raycast in the physics world
  129714. * @param from when should the ray start?
  129715. * @param to when should the ray end?
  129716. * @returns PhysicsRaycastResult
  129717. */
  129718. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129719. }
  129720. }
  129721. declare module BABYLON {
  129722. /** @hidden */
  129723. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  129724. private _useDeltaForWorldStep;
  129725. world: any;
  129726. name: string;
  129727. private _physicsMaterials;
  129728. private _fixedTimeStep;
  129729. private _cannonRaycastResult;
  129730. private _raycastResult;
  129731. private _physicsBodysToRemoveAfterStep;
  129732. BJSCANNON: any;
  129733. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  129734. setGravity(gravity: Vector3): void;
  129735. setTimeStep(timeStep: number): void;
  129736. getTimeStep(): number;
  129737. executeStep(delta: number): void;
  129738. private _removeMarkedPhysicsBodiesFromWorld;
  129739. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129740. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129741. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129742. private _processChildMeshes;
  129743. removePhysicsBody(impostor: PhysicsImpostor): void;
  129744. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129745. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129746. private _addMaterial;
  129747. private _checkWithEpsilon;
  129748. private _createShape;
  129749. private _createHeightmap;
  129750. private _minus90X;
  129751. private _plus90X;
  129752. private _tmpPosition;
  129753. private _tmpDeltaPosition;
  129754. private _tmpUnityRotation;
  129755. private _updatePhysicsBodyTransformation;
  129756. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129757. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129758. isSupported(): boolean;
  129759. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129760. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129761. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129762. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129763. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129764. getBodyMass(impostor: PhysicsImpostor): number;
  129765. getBodyFriction(impostor: PhysicsImpostor): number;
  129766. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129767. getBodyRestitution(impostor: PhysicsImpostor): number;
  129768. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129769. sleepBody(impostor: PhysicsImpostor): void;
  129770. wakeUpBody(impostor: PhysicsImpostor): void;
  129771. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  129772. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  129773. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  129774. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129775. getRadius(impostor: PhysicsImpostor): number;
  129776. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129777. dispose(): void;
  129778. private _extendNamespace;
  129779. /**
  129780. * Does a raycast in the physics world
  129781. * @param from when should the ray start?
  129782. * @param to when should the ray end?
  129783. * @returns PhysicsRaycastResult
  129784. */
  129785. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129786. }
  129787. }
  129788. declare module BABYLON {
  129789. /** @hidden */
  129790. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  129791. world: any;
  129792. name: string;
  129793. BJSOIMO: any;
  129794. private _raycastResult;
  129795. constructor(iterations?: number, oimoInjection?: any);
  129796. setGravity(gravity: Vector3): void;
  129797. setTimeStep(timeStep: number): void;
  129798. getTimeStep(): number;
  129799. private _tmpImpostorsArray;
  129800. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  129801. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129802. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  129803. generatePhysicsBody(impostor: PhysicsImpostor): void;
  129804. private _tmpPositionVector;
  129805. removePhysicsBody(impostor: PhysicsImpostor): void;
  129806. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  129807. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  129808. isSupported(): boolean;
  129809. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  129810. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  129811. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129812. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  129813. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129814. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  129815. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  129816. getBodyMass(impostor: PhysicsImpostor): number;
  129817. getBodyFriction(impostor: PhysicsImpostor): number;
  129818. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  129819. getBodyRestitution(impostor: PhysicsImpostor): number;
  129820. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  129821. sleepBody(impostor: PhysicsImpostor): void;
  129822. wakeUpBody(impostor: PhysicsImpostor): void;
  129823. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  129824. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  129825. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  129826. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  129827. getRadius(impostor: PhysicsImpostor): number;
  129828. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  129829. dispose(): void;
  129830. /**
  129831. * Does a raycast in the physics world
  129832. * @param from when should the ray start?
  129833. * @param to when should the ray end?
  129834. * @returns PhysicsRaycastResult
  129835. */
  129836. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  129837. }
  129838. }
  129839. declare module BABYLON {
  129840. /**
  129841. * Class containing static functions to help procedurally build meshes
  129842. */
  129843. export class RibbonBuilder {
  129844. /**
  129845. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  129846. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  129847. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  129848. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  129849. * * 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
  129850. * * 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
  129851. * * 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
  129852. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129853. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129854. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129855. * * 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
  129856. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  129857. * * 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
  129858. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  129859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129860. * @param name defines the name of the mesh
  129861. * @param options defines the options used to create the mesh
  129862. * @param scene defines the hosting scene
  129863. * @returns the ribbon mesh
  129864. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  129865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129866. */
  129867. static CreateRibbon(name: string, options: {
  129868. pathArray: Vector3[][];
  129869. closeArray?: boolean;
  129870. closePath?: boolean;
  129871. offset?: number;
  129872. updatable?: boolean;
  129873. sideOrientation?: number;
  129874. frontUVs?: Vector4;
  129875. backUVs?: Vector4;
  129876. instance?: Mesh;
  129877. invertUV?: boolean;
  129878. uvs?: Vector2[];
  129879. colors?: Color4[];
  129880. }, scene?: Nullable<Scene>): Mesh;
  129881. }
  129882. }
  129883. declare module BABYLON {
  129884. /**
  129885. * Class containing static functions to help procedurally build meshes
  129886. */
  129887. export class ShapeBuilder {
  129888. /**
  129889. * 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.
  129890. * * 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.
  129891. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129892. * * 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.
  129893. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  129894. * * 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
  129895. * * 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
  129896. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  129897. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129898. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129899. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  129900. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  129901. * @param name defines the name of the mesh
  129902. * @param options defines the options used to create the mesh
  129903. * @param scene defines the hosting scene
  129904. * @returns the extruded shape mesh
  129905. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129906. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129907. */
  129908. static ExtrudeShape(name: string, options: {
  129909. shape: Vector3[];
  129910. path: Vector3[];
  129911. scale?: number;
  129912. rotation?: number;
  129913. cap?: number;
  129914. updatable?: boolean;
  129915. sideOrientation?: number;
  129916. frontUVs?: Vector4;
  129917. backUVs?: Vector4;
  129918. instance?: Mesh;
  129919. invertUV?: boolean;
  129920. }, scene?: Nullable<Scene>): Mesh;
  129921. /**
  129922. * Creates an custom extruded shape mesh.
  129923. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  129924. * * 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.
  129925. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  129926. * * 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
  129927. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  129928. * * 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
  129929. * * It must returns a float value that will be the scale value applied to the shape on each path point
  129930. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  129931. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  129932. * * 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
  129933. * * 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
  129934. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  129935. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129936. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129937. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  129938. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129939. * @param name defines the name of the mesh
  129940. * @param options defines the options used to create the mesh
  129941. * @param scene defines the hosting scene
  129942. * @returns the custom extruded shape mesh
  129943. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  129944. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  129945. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  129946. */
  129947. static ExtrudeShapeCustom(name: string, options: {
  129948. shape: Vector3[];
  129949. path: Vector3[];
  129950. scaleFunction?: any;
  129951. rotationFunction?: any;
  129952. ribbonCloseArray?: boolean;
  129953. ribbonClosePath?: boolean;
  129954. cap?: number;
  129955. updatable?: boolean;
  129956. sideOrientation?: number;
  129957. frontUVs?: Vector4;
  129958. backUVs?: Vector4;
  129959. instance?: Mesh;
  129960. invertUV?: boolean;
  129961. }, scene?: Nullable<Scene>): Mesh;
  129962. private static _ExtrudeShapeGeneric;
  129963. }
  129964. }
  129965. declare module BABYLON {
  129966. /**
  129967. * AmmoJS Physics plugin
  129968. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  129969. * @see https://github.com/kripken/ammo.js/
  129970. */
  129971. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  129972. private _useDeltaForWorldStep;
  129973. /**
  129974. * Reference to the Ammo library
  129975. */
  129976. bjsAMMO: any;
  129977. /**
  129978. * Created ammoJS world which physics bodies are added to
  129979. */
  129980. world: any;
  129981. /**
  129982. * Name of the plugin
  129983. */
  129984. name: string;
  129985. private _timeStep;
  129986. private _fixedTimeStep;
  129987. private _maxSteps;
  129988. private _tmpQuaternion;
  129989. private _tmpAmmoTransform;
  129990. private _tmpAmmoQuaternion;
  129991. private _tmpAmmoConcreteContactResultCallback;
  129992. private _collisionConfiguration;
  129993. private _dispatcher;
  129994. private _overlappingPairCache;
  129995. private _solver;
  129996. private _softBodySolver;
  129997. private _tmpAmmoVectorA;
  129998. private _tmpAmmoVectorB;
  129999. private _tmpAmmoVectorC;
  130000. private _tmpAmmoVectorD;
  130001. private _tmpContactCallbackResult;
  130002. private _tmpAmmoVectorRCA;
  130003. private _tmpAmmoVectorRCB;
  130004. private _raycastResult;
  130005. private static readonly DISABLE_COLLISION_FLAG;
  130006. private static readonly KINEMATIC_FLAG;
  130007. private static readonly DISABLE_DEACTIVATION_FLAG;
  130008. /**
  130009. * Initializes the ammoJS plugin
  130010. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  130011. * @param ammoInjection can be used to inject your own ammo reference
  130012. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  130013. */
  130014. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  130015. /**
  130016. * Sets the gravity of the physics world (m/(s^2))
  130017. * @param gravity Gravity to set
  130018. */
  130019. setGravity(gravity: Vector3): void;
  130020. /**
  130021. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  130022. * @param timeStep timestep to use in seconds
  130023. */
  130024. setTimeStep(timeStep: number): void;
  130025. /**
  130026. * 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)
  130027. * @param fixedTimeStep fixedTimeStep to use in seconds
  130028. */
  130029. setFixedTimeStep(fixedTimeStep: number): void;
  130030. /**
  130031. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  130032. * @param maxSteps the maximum number of steps by the physics engine per frame
  130033. */
  130034. setMaxSteps(maxSteps: number): void;
  130035. /**
  130036. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  130037. * @returns the current timestep in seconds
  130038. */
  130039. getTimeStep(): number;
  130040. /**
  130041. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  130042. */
  130043. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  130044. private _isImpostorInContact;
  130045. private _isImpostorPairInContact;
  130046. private _stepSimulation;
  130047. /**
  130048. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  130049. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  130050. * After the step the babylon meshes are set to the position of the physics imposters
  130051. * @param delta amount of time to step forward
  130052. * @param impostors array of imposters to update before/after the step
  130053. */
  130054. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  130055. /**
  130056. * Update babylon mesh to match physics world object
  130057. * @param impostor imposter to match
  130058. */
  130059. private _afterSoftStep;
  130060. /**
  130061. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130062. * @param impostor imposter to match
  130063. */
  130064. private _ropeStep;
  130065. /**
  130066. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  130067. * @param impostor imposter to match
  130068. */
  130069. private _softbodyOrClothStep;
  130070. private _tmpMatrix;
  130071. /**
  130072. * Applies an impulse on the imposter
  130073. * @param impostor imposter to apply impulse to
  130074. * @param force amount of force to be applied to the imposter
  130075. * @param contactPoint the location to apply the impulse on the imposter
  130076. */
  130077. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130078. /**
  130079. * Applies a force on the imposter
  130080. * @param impostor imposter to apply force
  130081. * @param force amount of force to be applied to the imposter
  130082. * @param contactPoint the location to apply the force on the imposter
  130083. */
  130084. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  130085. /**
  130086. * Creates a physics body using the plugin
  130087. * @param impostor the imposter to create the physics body on
  130088. */
  130089. generatePhysicsBody(impostor: PhysicsImpostor): void;
  130090. /**
  130091. * Removes the physics body from the imposter and disposes of the body's memory
  130092. * @param impostor imposter to remove the physics body from
  130093. */
  130094. removePhysicsBody(impostor: PhysicsImpostor): void;
  130095. /**
  130096. * Generates a joint
  130097. * @param impostorJoint the imposter joint to create the joint with
  130098. */
  130099. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  130100. /**
  130101. * Removes a joint
  130102. * @param impostorJoint the imposter joint to remove the joint from
  130103. */
  130104. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  130105. private _addMeshVerts;
  130106. /**
  130107. * Initialise the soft body vertices to match its object's (mesh) vertices
  130108. * Softbody vertices (nodes) are in world space and to match this
  130109. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  130110. * @param impostor to create the softbody for
  130111. */
  130112. private _softVertexData;
  130113. /**
  130114. * Create an impostor's soft body
  130115. * @param impostor to create the softbody for
  130116. */
  130117. private _createSoftbody;
  130118. /**
  130119. * Create cloth for an impostor
  130120. * @param impostor to create the softbody for
  130121. */
  130122. private _createCloth;
  130123. /**
  130124. * Create rope for an impostor
  130125. * @param impostor to create the softbody for
  130126. */
  130127. private _createRope;
  130128. /**
  130129. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  130130. * @param impostor to create the custom physics shape for
  130131. */
  130132. private _createCustom;
  130133. private _addHullVerts;
  130134. private _createShape;
  130135. /**
  130136. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  130137. * @param impostor imposter containing the physics body and babylon object
  130138. */
  130139. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  130140. /**
  130141. * Sets the babylon object's position/rotation from the physics body's position/rotation
  130142. * @param impostor imposter containing the physics body and babylon object
  130143. * @param newPosition new position
  130144. * @param newRotation new rotation
  130145. */
  130146. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  130147. /**
  130148. * If this plugin is supported
  130149. * @returns true if its supported
  130150. */
  130151. isSupported(): boolean;
  130152. /**
  130153. * Sets the linear velocity of the physics body
  130154. * @param impostor imposter to set the velocity on
  130155. * @param velocity velocity to set
  130156. */
  130157. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130158. /**
  130159. * Sets the angular velocity of the physics body
  130160. * @param impostor imposter to set the velocity on
  130161. * @param velocity velocity to set
  130162. */
  130163. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  130164. /**
  130165. * gets the linear velocity
  130166. * @param impostor imposter to get linear velocity from
  130167. * @returns linear velocity
  130168. */
  130169. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130170. /**
  130171. * gets the angular velocity
  130172. * @param impostor imposter to get angular velocity from
  130173. * @returns angular velocity
  130174. */
  130175. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  130176. /**
  130177. * Sets the mass of physics body
  130178. * @param impostor imposter to set the mass on
  130179. * @param mass mass to set
  130180. */
  130181. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  130182. /**
  130183. * Gets the mass of the physics body
  130184. * @param impostor imposter to get the mass from
  130185. * @returns mass
  130186. */
  130187. getBodyMass(impostor: PhysicsImpostor): number;
  130188. /**
  130189. * Gets friction of the impostor
  130190. * @param impostor impostor to get friction from
  130191. * @returns friction value
  130192. */
  130193. getBodyFriction(impostor: PhysicsImpostor): number;
  130194. /**
  130195. * Sets friction of the impostor
  130196. * @param impostor impostor to set friction on
  130197. * @param friction friction value
  130198. */
  130199. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  130200. /**
  130201. * Gets restitution of the impostor
  130202. * @param impostor impostor to get restitution from
  130203. * @returns restitution value
  130204. */
  130205. getBodyRestitution(impostor: PhysicsImpostor): number;
  130206. /**
  130207. * Sets resitution of the impostor
  130208. * @param impostor impostor to set resitution on
  130209. * @param restitution resitution value
  130210. */
  130211. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  130212. /**
  130213. * Gets pressure inside the impostor
  130214. * @param impostor impostor to get pressure from
  130215. * @returns pressure value
  130216. */
  130217. getBodyPressure(impostor: PhysicsImpostor): number;
  130218. /**
  130219. * Sets pressure inside a soft body impostor
  130220. * Cloth and rope must remain 0 pressure
  130221. * @param impostor impostor to set pressure on
  130222. * @param pressure pressure value
  130223. */
  130224. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  130225. /**
  130226. * Gets stiffness of the impostor
  130227. * @param impostor impostor to get stiffness from
  130228. * @returns pressure value
  130229. */
  130230. getBodyStiffness(impostor: PhysicsImpostor): number;
  130231. /**
  130232. * Sets stiffness of the impostor
  130233. * @param impostor impostor to set stiffness on
  130234. * @param stiffness stiffness value from 0 to 1
  130235. */
  130236. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  130237. /**
  130238. * Gets velocityIterations of the impostor
  130239. * @param impostor impostor to get velocity iterations from
  130240. * @returns velocityIterations value
  130241. */
  130242. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  130243. /**
  130244. * Sets velocityIterations of the impostor
  130245. * @param impostor impostor to set velocity iterations on
  130246. * @param velocityIterations velocityIterations value
  130247. */
  130248. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  130249. /**
  130250. * Gets positionIterations of the impostor
  130251. * @param impostor impostor to get position iterations from
  130252. * @returns positionIterations value
  130253. */
  130254. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  130255. /**
  130256. * Sets positionIterations of the impostor
  130257. * @param impostor impostor to set position on
  130258. * @param positionIterations positionIterations value
  130259. */
  130260. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  130261. /**
  130262. * Append an anchor to a cloth object
  130263. * @param impostor is the cloth impostor to add anchor to
  130264. * @param otherImpostor is the rigid impostor to anchor to
  130265. * @param width ratio across width from 0 to 1
  130266. * @param height ratio up height from 0 to 1
  130267. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  130268. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130269. */
  130270. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130271. /**
  130272. * Append an hook to a rope object
  130273. * @param impostor is the rope impostor to add hook to
  130274. * @param otherImpostor is the rigid impostor to hook to
  130275. * @param length ratio along the rope from 0 to 1
  130276. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  130277. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  130278. */
  130279. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  130280. /**
  130281. * Sleeps the physics body and stops it from being active
  130282. * @param impostor impostor to sleep
  130283. */
  130284. sleepBody(impostor: PhysicsImpostor): void;
  130285. /**
  130286. * Activates the physics body
  130287. * @param impostor impostor to activate
  130288. */
  130289. wakeUpBody(impostor: PhysicsImpostor): void;
  130290. /**
  130291. * Updates the distance parameters of the joint
  130292. * @param joint joint to update
  130293. * @param maxDistance maximum distance of the joint
  130294. * @param minDistance minimum distance of the joint
  130295. */
  130296. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  130297. /**
  130298. * Sets a motor on the joint
  130299. * @param joint joint to set motor on
  130300. * @param speed speed of the motor
  130301. * @param maxForce maximum force of the motor
  130302. * @param motorIndex index of the motor
  130303. */
  130304. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  130305. /**
  130306. * Sets the motors limit
  130307. * @param joint joint to set limit on
  130308. * @param upperLimit upper limit
  130309. * @param lowerLimit lower limit
  130310. */
  130311. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  130312. /**
  130313. * Syncs the position and rotation of a mesh with the impostor
  130314. * @param mesh mesh to sync
  130315. * @param impostor impostor to update the mesh with
  130316. */
  130317. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  130318. /**
  130319. * Gets the radius of the impostor
  130320. * @param impostor impostor to get radius from
  130321. * @returns the radius
  130322. */
  130323. getRadius(impostor: PhysicsImpostor): number;
  130324. /**
  130325. * Gets the box size of the impostor
  130326. * @param impostor impostor to get box size from
  130327. * @param result the resulting box size
  130328. */
  130329. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  130330. /**
  130331. * Disposes of the impostor
  130332. */
  130333. dispose(): void;
  130334. /**
  130335. * Does a raycast in the physics world
  130336. * @param from when should the ray start?
  130337. * @param to when should the ray end?
  130338. * @returns PhysicsRaycastResult
  130339. */
  130340. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  130341. }
  130342. }
  130343. declare module BABYLON {
  130344. interface AbstractScene {
  130345. /**
  130346. * The list of reflection probes added to the scene
  130347. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130348. */
  130349. reflectionProbes: Array<ReflectionProbe>;
  130350. /**
  130351. * Removes the given reflection probe from this scene.
  130352. * @param toRemove The reflection probe to remove
  130353. * @returns The index of the removed reflection probe
  130354. */
  130355. removeReflectionProbe(toRemove: ReflectionProbe): number;
  130356. /**
  130357. * Adds the given reflection probe to this scene.
  130358. * @param newReflectionProbe The reflection probe to add
  130359. */
  130360. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  130361. }
  130362. /**
  130363. * Class used to generate realtime reflection / refraction cube textures
  130364. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  130365. */
  130366. export class ReflectionProbe {
  130367. /** defines the name of the probe */
  130368. name: string;
  130369. private _scene;
  130370. private _renderTargetTexture;
  130371. private _projectionMatrix;
  130372. private _viewMatrix;
  130373. private _target;
  130374. private _add;
  130375. private _attachedMesh;
  130376. private _invertYAxis;
  130377. /** Gets or sets probe position (center of the cube map) */
  130378. position: Vector3;
  130379. /**
  130380. * Creates a new reflection probe
  130381. * @param name defines the name of the probe
  130382. * @param size defines the texture resolution (for each face)
  130383. * @param scene defines the hosting scene
  130384. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  130385. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  130386. */
  130387. constructor(
  130388. /** defines the name of the probe */
  130389. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  130390. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  130391. get samples(): number;
  130392. set samples(value: number);
  130393. /** Gets or sets the refresh rate to use (on every frame by default) */
  130394. get refreshRate(): number;
  130395. set refreshRate(value: number);
  130396. /**
  130397. * Gets the hosting scene
  130398. * @returns a Scene
  130399. */
  130400. getScene(): Scene;
  130401. /** Gets the internal CubeTexture used to render to */
  130402. get cubeTexture(): RenderTargetTexture;
  130403. /** Gets the list of meshes to render */
  130404. get renderList(): Nullable<AbstractMesh[]>;
  130405. /**
  130406. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  130407. * @param mesh defines the mesh to attach to
  130408. */
  130409. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  130410. /**
  130411. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  130412. * @param renderingGroupId The rendering group id corresponding to its index
  130413. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  130414. */
  130415. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  130416. /**
  130417. * Clean all associated resources
  130418. */
  130419. dispose(): void;
  130420. /**
  130421. * Converts the reflection probe information to a readable string for debug purpose.
  130422. * @param fullDetails Supports for multiple levels of logging within scene loading
  130423. * @returns the human readable reflection probe info
  130424. */
  130425. toString(fullDetails?: boolean): string;
  130426. /**
  130427. * Get the class name of the relfection probe.
  130428. * @returns "ReflectionProbe"
  130429. */
  130430. getClassName(): string;
  130431. /**
  130432. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  130433. * @returns The JSON representation of the texture
  130434. */
  130435. serialize(): any;
  130436. /**
  130437. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  130438. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  130439. * @param scene Define the scene the parsed reflection probe should be instantiated in
  130440. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  130441. * @returns The parsed reflection probe if successful
  130442. */
  130443. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  130444. }
  130445. }
  130446. declare module BABYLON {
  130447. /** @hidden */
  130448. export var _BabylonLoaderRegistered: boolean;
  130449. /**
  130450. * Helps setting up some configuration for the babylon file loader.
  130451. */
  130452. export class BabylonFileLoaderConfiguration {
  130453. /**
  130454. * The loader does not allow injecting custom physix engine into the plugins.
  130455. * Unfortunately in ES6, we need to manually inject them into the plugin.
  130456. * So you could set this variable to your engine import to make it work.
  130457. */
  130458. static LoaderInjectedPhysicsEngine: any;
  130459. }
  130460. }
  130461. declare module BABYLON {
  130462. /**
  130463. * The Physically based simple base material of BJS.
  130464. *
  130465. * This enables better naming and convention enforcements on top of the pbrMaterial.
  130466. * It is used as the base class for both the specGloss and metalRough conventions.
  130467. */
  130468. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  130469. /**
  130470. * Number of Simultaneous lights allowed on the material.
  130471. */
  130472. maxSimultaneousLights: number;
  130473. /**
  130474. * If sets to true, disables all the lights affecting the material.
  130475. */
  130476. disableLighting: boolean;
  130477. /**
  130478. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  130479. */
  130480. environmentTexture: BaseTexture;
  130481. /**
  130482. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  130483. */
  130484. invertNormalMapX: boolean;
  130485. /**
  130486. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  130487. */
  130488. invertNormalMapY: boolean;
  130489. /**
  130490. * Normal map used in the model.
  130491. */
  130492. normalTexture: BaseTexture;
  130493. /**
  130494. * Emissivie color used to self-illuminate the model.
  130495. */
  130496. emissiveColor: Color3;
  130497. /**
  130498. * Emissivie texture used to self-illuminate the model.
  130499. */
  130500. emissiveTexture: BaseTexture;
  130501. /**
  130502. * Occlusion Channel Strenght.
  130503. */
  130504. occlusionStrength: number;
  130505. /**
  130506. * Occlusion Texture of the material (adding extra occlusion effects).
  130507. */
  130508. occlusionTexture: BaseTexture;
  130509. /**
  130510. * Defines the alpha limits in alpha test mode.
  130511. */
  130512. alphaCutOff: number;
  130513. /**
  130514. * Gets the current double sided mode.
  130515. */
  130516. get doubleSided(): boolean;
  130517. /**
  130518. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  130519. */
  130520. set doubleSided(value: boolean);
  130521. /**
  130522. * Stores the pre-calculated light information of a mesh in a texture.
  130523. */
  130524. lightmapTexture: BaseTexture;
  130525. /**
  130526. * If true, the light map contains occlusion information instead of lighting info.
  130527. */
  130528. useLightmapAsShadowmap: boolean;
  130529. /**
  130530. * Instantiates a new PBRMaterial instance.
  130531. *
  130532. * @param name The material name
  130533. * @param scene The scene the material will be use in.
  130534. */
  130535. constructor(name: string, scene: Scene);
  130536. getClassName(): string;
  130537. }
  130538. }
  130539. declare module BABYLON {
  130540. /**
  130541. * The PBR material of BJS following the metal roughness convention.
  130542. *
  130543. * This fits to the PBR convention in the GLTF definition:
  130544. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  130545. */
  130546. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  130547. /**
  130548. * The base color has two different interpretations depending on the value of metalness.
  130549. * When the material is a metal, the base color is the specific measured reflectance value
  130550. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  130551. * of the material.
  130552. */
  130553. baseColor: Color3;
  130554. /**
  130555. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  130556. * well as opacity information in the alpha channel.
  130557. */
  130558. baseTexture: BaseTexture;
  130559. /**
  130560. * Specifies the metallic scalar value of the material.
  130561. * Can also be used to scale the metalness values of the metallic texture.
  130562. */
  130563. metallic: number;
  130564. /**
  130565. * Specifies the roughness scalar value of the material.
  130566. * Can also be used to scale the roughness values of the metallic texture.
  130567. */
  130568. roughness: number;
  130569. /**
  130570. * Texture containing both the metallic value in the B channel and the
  130571. * roughness value in the G channel to keep better precision.
  130572. */
  130573. metallicRoughnessTexture: BaseTexture;
  130574. /**
  130575. * Instantiates a new PBRMetalRoughnessMaterial instance.
  130576. *
  130577. * @param name The material name
  130578. * @param scene The scene the material will be use in.
  130579. */
  130580. constructor(name: string, scene: Scene);
  130581. /**
  130582. * Return the currrent class name of the material.
  130583. */
  130584. getClassName(): string;
  130585. /**
  130586. * Makes a duplicate of the current material.
  130587. * @param name - name to use for the new material.
  130588. */
  130589. clone(name: string): PBRMetallicRoughnessMaterial;
  130590. /**
  130591. * Serialize the material to a parsable JSON object.
  130592. */
  130593. serialize(): any;
  130594. /**
  130595. * Parses a JSON object correponding to the serialize function.
  130596. */
  130597. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  130598. }
  130599. }
  130600. declare module BABYLON {
  130601. /**
  130602. * The PBR material of BJS following the specular glossiness convention.
  130603. *
  130604. * This fits to the PBR convention in the GLTF definition:
  130605. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  130606. */
  130607. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  130608. /**
  130609. * Specifies the diffuse color of the material.
  130610. */
  130611. diffuseColor: Color3;
  130612. /**
  130613. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  130614. * channel.
  130615. */
  130616. diffuseTexture: BaseTexture;
  130617. /**
  130618. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  130619. */
  130620. specularColor: Color3;
  130621. /**
  130622. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  130623. */
  130624. glossiness: number;
  130625. /**
  130626. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  130627. */
  130628. specularGlossinessTexture: BaseTexture;
  130629. /**
  130630. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  130631. *
  130632. * @param name The material name
  130633. * @param scene The scene the material will be use in.
  130634. */
  130635. constructor(name: string, scene: Scene);
  130636. /**
  130637. * Return the currrent class name of the material.
  130638. */
  130639. getClassName(): string;
  130640. /**
  130641. * Makes a duplicate of the current material.
  130642. * @param name - name to use for the new material.
  130643. */
  130644. clone(name: string): PBRSpecularGlossinessMaterial;
  130645. /**
  130646. * Serialize the material to a parsable JSON object.
  130647. */
  130648. serialize(): any;
  130649. /**
  130650. * Parses a JSON object correponding to the serialize function.
  130651. */
  130652. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  130653. }
  130654. }
  130655. declare module BABYLON {
  130656. /**
  130657. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  130658. * It can help converting any input color in a desired output one. This can then be used to create effects
  130659. * from sepia, black and white to sixties or futuristic rendering...
  130660. *
  130661. * The only supported format is currently 3dl.
  130662. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  130663. */
  130664. export class ColorGradingTexture extends BaseTexture {
  130665. /**
  130666. * The current texture matrix. (will always be identity in color grading texture)
  130667. */
  130668. private _textureMatrix;
  130669. /**
  130670. * The texture URL.
  130671. */
  130672. url: string;
  130673. /**
  130674. * Empty line regex stored for GC.
  130675. */
  130676. private static _noneEmptyLineRegex;
  130677. private _engine;
  130678. /**
  130679. * Instantiates a ColorGradingTexture from the following parameters.
  130680. *
  130681. * @param url The location of the color gradind data (currently only supporting 3dl)
  130682. * @param scene The scene the texture will be used in
  130683. */
  130684. constructor(url: string, scene: Scene);
  130685. /**
  130686. * Returns the texture matrix used in most of the material.
  130687. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  130688. */
  130689. getTextureMatrix(): Matrix;
  130690. /**
  130691. * Occurs when the file being loaded is a .3dl LUT file.
  130692. */
  130693. private load3dlTexture;
  130694. /**
  130695. * Starts the loading process of the texture.
  130696. */
  130697. private loadTexture;
  130698. /**
  130699. * Clones the color gradind texture.
  130700. */
  130701. clone(): ColorGradingTexture;
  130702. /**
  130703. * Called during delayed load for textures.
  130704. */
  130705. delayLoad(): void;
  130706. /**
  130707. * Parses a color grading texture serialized by Babylon.
  130708. * @param parsedTexture The texture information being parsedTexture
  130709. * @param scene The scene to load the texture in
  130710. * @param rootUrl The root url of the data assets to load
  130711. * @return A color gradind texture
  130712. */
  130713. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  130714. /**
  130715. * Serializes the LUT texture to json format.
  130716. */
  130717. serialize(): any;
  130718. }
  130719. }
  130720. declare module BABYLON {
  130721. /**
  130722. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  130723. */
  130724. export class EquiRectangularCubeTexture extends BaseTexture {
  130725. /** The six faces of the cube. */
  130726. private static _FacesMapping;
  130727. private _noMipmap;
  130728. private _onLoad;
  130729. private _onError;
  130730. /** The size of the cubemap. */
  130731. private _size;
  130732. /** The buffer of the image. */
  130733. private _buffer;
  130734. /** The width of the input image. */
  130735. private _width;
  130736. /** The height of the input image. */
  130737. private _height;
  130738. /** The URL to the image. */
  130739. url: string;
  130740. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  130741. coordinatesMode: number;
  130742. /**
  130743. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  130744. * @param url The location of the image
  130745. * @param scene The scene the texture will be used in
  130746. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  130747. * @param noMipmap Forces to not generate the mipmap if true
  130748. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  130749. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  130750. * @param onLoad — defines a callback called when texture is loaded
  130751. * @param onError — defines a callback called if there is an error
  130752. */
  130753. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  130754. /**
  130755. * Load the image data, by putting the image on a canvas and extracting its buffer.
  130756. */
  130757. private loadImage;
  130758. /**
  130759. * Convert the image buffer into a cubemap and create a CubeTexture.
  130760. */
  130761. private loadTexture;
  130762. /**
  130763. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  130764. * @param buffer The ArrayBuffer that should be converted.
  130765. * @returns The buffer as Float32Array.
  130766. */
  130767. private getFloat32ArrayFromArrayBuffer;
  130768. /**
  130769. * Get the current class name of the texture useful for serialization or dynamic coding.
  130770. * @returns "EquiRectangularCubeTexture"
  130771. */
  130772. getClassName(): string;
  130773. /**
  130774. * Create a clone of the current EquiRectangularCubeTexture and return it.
  130775. * @returns A clone of the current EquiRectangularCubeTexture.
  130776. */
  130777. clone(): EquiRectangularCubeTexture;
  130778. }
  130779. }
  130780. declare module BABYLON {
  130781. /**
  130782. * Based on jsTGALoader - Javascript loader for TGA file
  130783. * By Vincent Thibault
  130784. * @see http://blog.robrowser.com/javascript-tga-loader.html
  130785. */
  130786. export class TGATools {
  130787. private static _TYPE_INDEXED;
  130788. private static _TYPE_RGB;
  130789. private static _TYPE_GREY;
  130790. private static _TYPE_RLE_INDEXED;
  130791. private static _TYPE_RLE_RGB;
  130792. private static _TYPE_RLE_GREY;
  130793. private static _ORIGIN_MASK;
  130794. private static _ORIGIN_SHIFT;
  130795. private static _ORIGIN_BL;
  130796. private static _ORIGIN_BR;
  130797. private static _ORIGIN_UL;
  130798. private static _ORIGIN_UR;
  130799. /**
  130800. * Gets the header of a TGA file
  130801. * @param data defines the TGA data
  130802. * @returns the header
  130803. */
  130804. static GetTGAHeader(data: Uint8Array): any;
  130805. /**
  130806. * Uploads TGA content to a Babylon Texture
  130807. * @hidden
  130808. */
  130809. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  130810. /** @hidden */
  130811. 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;
  130812. /** @hidden */
  130813. 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;
  130814. /** @hidden */
  130815. 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;
  130816. /** @hidden */
  130817. 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;
  130818. /** @hidden */
  130819. 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;
  130820. /** @hidden */
  130821. 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;
  130822. }
  130823. }
  130824. declare module BABYLON {
  130825. /**
  130826. * Implementation of the TGA Texture Loader.
  130827. * @hidden
  130828. */
  130829. export class _TGATextureLoader implements IInternalTextureLoader {
  130830. /**
  130831. * Defines wether the loader supports cascade loading the different faces.
  130832. */
  130833. readonly supportCascades: boolean;
  130834. /**
  130835. * This returns if the loader support the current file information.
  130836. * @param extension defines the file extension of the file being loaded
  130837. * @returns true if the loader can load the specified file
  130838. */
  130839. canLoad(extension: string): boolean;
  130840. /**
  130841. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130842. * @param data contains the texture data
  130843. * @param texture defines the BabylonJS internal texture
  130844. * @param createPolynomials will be true if polynomials have been requested
  130845. * @param onLoad defines the callback to trigger once the texture is ready
  130846. * @param onError defines the callback to trigger in case of error
  130847. */
  130848. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130849. /**
  130850. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130851. * @param data contains the texture data
  130852. * @param texture defines the BabylonJS internal texture
  130853. * @param callback defines the method to call once ready to upload
  130854. */
  130855. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130856. }
  130857. }
  130858. declare module BABYLON {
  130859. /**
  130860. * Info about the .basis files
  130861. */
  130862. class BasisFileInfo {
  130863. /**
  130864. * If the file has alpha
  130865. */
  130866. hasAlpha: boolean;
  130867. /**
  130868. * Info about each image of the basis file
  130869. */
  130870. images: Array<{
  130871. levels: Array<{
  130872. width: number;
  130873. height: number;
  130874. transcodedPixels: ArrayBufferView;
  130875. }>;
  130876. }>;
  130877. }
  130878. /**
  130879. * Result of transcoding a basis file
  130880. */
  130881. class TranscodeResult {
  130882. /**
  130883. * Info about the .basis file
  130884. */
  130885. fileInfo: BasisFileInfo;
  130886. /**
  130887. * Format to use when loading the file
  130888. */
  130889. format: number;
  130890. }
  130891. /**
  130892. * Configuration options for the Basis transcoder
  130893. */
  130894. export class BasisTranscodeConfiguration {
  130895. /**
  130896. * Supported compression formats used to determine the supported output format of the transcoder
  130897. */
  130898. supportedCompressionFormats?: {
  130899. /**
  130900. * etc1 compression format
  130901. */
  130902. etc1?: boolean;
  130903. /**
  130904. * s3tc compression format
  130905. */
  130906. s3tc?: boolean;
  130907. /**
  130908. * pvrtc compression format
  130909. */
  130910. pvrtc?: boolean;
  130911. /**
  130912. * etc2 compression format
  130913. */
  130914. etc2?: boolean;
  130915. };
  130916. /**
  130917. * If mipmap levels should be loaded for transcoded images (Default: true)
  130918. */
  130919. loadMipmapLevels?: boolean;
  130920. /**
  130921. * Index of a single image to load (Default: all images)
  130922. */
  130923. loadSingleImage?: number;
  130924. }
  130925. /**
  130926. * Used to load .Basis files
  130927. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  130928. */
  130929. export class BasisTools {
  130930. private static _IgnoreSupportedFormats;
  130931. /**
  130932. * URL to use when loading the basis transcoder
  130933. */
  130934. static JSModuleURL: string;
  130935. /**
  130936. * URL to use when loading the wasm module for the transcoder
  130937. */
  130938. static WasmModuleURL: string;
  130939. /**
  130940. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  130941. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  130942. * @returns internal format corresponding to the Basis format
  130943. */
  130944. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  130945. private static _WorkerPromise;
  130946. private static _Worker;
  130947. private static _actionId;
  130948. private static _CreateWorkerAsync;
  130949. /**
  130950. * Transcodes a loaded image file to compressed pixel data
  130951. * @param data image data to transcode
  130952. * @param config configuration options for the transcoding
  130953. * @returns a promise resulting in the transcoded image
  130954. */
  130955. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  130956. /**
  130957. * Loads a texture from the transcode result
  130958. * @param texture texture load to
  130959. * @param transcodeResult the result of transcoding the basis file to load from
  130960. */
  130961. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  130962. }
  130963. }
  130964. declare module BABYLON {
  130965. /**
  130966. * Loader for .basis file format
  130967. */
  130968. export class _BasisTextureLoader implements IInternalTextureLoader {
  130969. /**
  130970. * Defines whether the loader supports cascade loading the different faces.
  130971. */
  130972. readonly supportCascades: boolean;
  130973. /**
  130974. * This returns if the loader support the current file information.
  130975. * @param extension defines the file extension of the file being loaded
  130976. * @returns true if the loader can load the specified file
  130977. */
  130978. canLoad(extension: string): boolean;
  130979. /**
  130980. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  130981. * @param data contains the texture data
  130982. * @param texture defines the BabylonJS internal texture
  130983. * @param createPolynomials will be true if polynomials have been requested
  130984. * @param onLoad defines the callback to trigger once the texture is ready
  130985. * @param onError defines the callback to trigger in case of error
  130986. */
  130987. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  130988. /**
  130989. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  130990. * @param data contains the texture data
  130991. * @param texture defines the BabylonJS internal texture
  130992. * @param callback defines the method to call once ready to upload
  130993. */
  130994. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  130995. }
  130996. }
  130997. declare module BABYLON {
  130998. /**
  130999. * 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.
  131000. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  131001. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  131002. */
  131003. export class CustomProceduralTexture extends ProceduralTexture {
  131004. private _animate;
  131005. private _time;
  131006. private _config;
  131007. private _texturePath;
  131008. /**
  131009. * Instantiates a new Custom Procedural Texture.
  131010. * 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.
  131011. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  131012. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  131013. * @param name Define the name of the texture
  131014. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  131015. * @param size Define the size of the texture to create
  131016. * @param scene Define the scene the texture belongs to
  131017. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  131018. * @param generateMipMaps Define if the texture should creates mip maps or not
  131019. */
  131020. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131021. private _loadJson;
  131022. /**
  131023. * Is the texture ready to be used ? (rendered at least once)
  131024. * @returns true if ready, otherwise, false.
  131025. */
  131026. isReady(): boolean;
  131027. /**
  131028. * Render the texture to its associated render target.
  131029. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  131030. */
  131031. render(useCameraPostProcess?: boolean): void;
  131032. /**
  131033. * Update the list of dependant textures samplers in the shader.
  131034. */
  131035. updateTextures(): void;
  131036. /**
  131037. * Update the uniform values of the procedural texture in the shader.
  131038. */
  131039. updateShaderUniforms(): void;
  131040. /**
  131041. * Define if the texture animates or not.
  131042. */
  131043. get animate(): boolean;
  131044. set animate(value: boolean);
  131045. }
  131046. }
  131047. declare module BABYLON {
  131048. /** @hidden */
  131049. export var noisePixelShader: {
  131050. name: string;
  131051. shader: string;
  131052. };
  131053. }
  131054. declare module BABYLON {
  131055. /**
  131056. * Class used to generate noise procedural textures
  131057. */
  131058. export class NoiseProceduralTexture extends ProceduralTexture {
  131059. private _time;
  131060. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  131061. brightness: number;
  131062. /** Defines the number of octaves to process */
  131063. octaves: number;
  131064. /** Defines the level of persistence (0.8 by default) */
  131065. persistence: number;
  131066. /** Gets or sets animation speed factor (default is 1) */
  131067. animationSpeedFactor: number;
  131068. /**
  131069. * Creates a new NoiseProceduralTexture
  131070. * @param name defines the name fo the texture
  131071. * @param size defines the size of the texture (default is 256)
  131072. * @param scene defines the hosting scene
  131073. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  131074. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  131075. */
  131076. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  131077. private _updateShaderUniforms;
  131078. protected _getDefines(): string;
  131079. /** Generate the current state of the procedural texture */
  131080. render(useCameraPostProcess?: boolean): void;
  131081. /**
  131082. * Serializes this noise procedural texture
  131083. * @returns a serialized noise procedural texture object
  131084. */
  131085. serialize(): any;
  131086. /**
  131087. * Clone the texture.
  131088. * @returns the cloned texture
  131089. */
  131090. clone(): NoiseProceduralTexture;
  131091. /**
  131092. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  131093. * @param parsedTexture defines parsed texture data
  131094. * @param scene defines the current scene
  131095. * @param rootUrl defines the root URL containing noise procedural texture information
  131096. * @returns a parsed NoiseProceduralTexture
  131097. */
  131098. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  131099. }
  131100. }
  131101. declare module BABYLON {
  131102. /**
  131103. * Raw cube texture where the raw buffers are passed in
  131104. */
  131105. export class RawCubeTexture extends CubeTexture {
  131106. /**
  131107. * Creates a cube texture where the raw buffers are passed in.
  131108. * @param scene defines the scene the texture is attached to
  131109. * @param data defines the array of data to use to create each face
  131110. * @param size defines the size of the textures
  131111. * @param format defines the format of the data
  131112. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  131113. * @param generateMipMaps defines if the engine should generate the mip levels
  131114. * @param invertY defines if data must be stored with Y axis inverted
  131115. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  131116. * @param compression defines the compression used (null by default)
  131117. */
  131118. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  131119. /**
  131120. * Updates the raw cube texture.
  131121. * @param data defines the data to store
  131122. * @param format defines the data format
  131123. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  131124. * @param invertY defines if data must be stored with Y axis inverted
  131125. * @param compression defines the compression used (null by default)
  131126. * @param level defines which level of the texture to update
  131127. */
  131128. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  131129. /**
  131130. * Updates a raw cube texture with RGBD encoded data.
  131131. * @param data defines the array of data [mipmap][face] to use to create each face
  131132. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  131133. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  131134. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  131135. * @returns a promsie that resolves when the operation is complete
  131136. */
  131137. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  131138. /**
  131139. * Clones the raw cube texture.
  131140. * @return a new cube texture
  131141. */
  131142. clone(): CubeTexture;
  131143. /** @hidden */
  131144. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  131145. }
  131146. }
  131147. declare module BABYLON {
  131148. /**
  131149. * Class used to store 3D textures containing user data
  131150. */
  131151. export class RawTexture3D extends Texture {
  131152. /** Gets or sets the texture format to use */
  131153. format: number;
  131154. private _engine;
  131155. /**
  131156. * Create a new RawTexture3D
  131157. * @param data defines the data of the texture
  131158. * @param width defines the width of the texture
  131159. * @param height defines the height of the texture
  131160. * @param depth defines the depth of the texture
  131161. * @param format defines the texture format to use
  131162. * @param scene defines the hosting scene
  131163. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131164. * @param invertY defines if texture must be stored with Y axis inverted
  131165. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131166. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131167. */
  131168. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131169. /** Gets or sets the texture format to use */
  131170. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131171. /**
  131172. * Update the texture with new data
  131173. * @param data defines the data to store in the texture
  131174. */
  131175. update(data: ArrayBufferView): void;
  131176. }
  131177. }
  131178. declare module BABYLON {
  131179. /**
  131180. * Class used to store 2D array textures containing user data
  131181. */
  131182. export class RawTexture2DArray extends Texture {
  131183. /** Gets or sets the texture format to use */
  131184. format: number;
  131185. private _engine;
  131186. /**
  131187. * Create a new RawTexture2DArray
  131188. * @param data defines the data of the texture
  131189. * @param width defines the width of the texture
  131190. * @param height defines the height of the texture
  131191. * @param depth defines the number of layers of the texture
  131192. * @param format defines the texture format to use
  131193. * @param scene defines the hosting scene
  131194. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  131195. * @param invertY defines if texture must be stored with Y axis inverted
  131196. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  131197. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  131198. */
  131199. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  131200. /** Gets or sets the texture format to use */
  131201. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  131202. /**
  131203. * Update the texture with new data
  131204. * @param data defines the data to store in the texture
  131205. */
  131206. update(data: ArrayBufferView): void;
  131207. }
  131208. }
  131209. declare module BABYLON {
  131210. /**
  131211. * Creates a refraction texture used by refraction channel of the standard material.
  131212. * It is like a mirror but to see through a material.
  131213. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131214. */
  131215. export class RefractionTexture extends RenderTargetTexture {
  131216. /**
  131217. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  131218. * 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.
  131219. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131220. */
  131221. refractionPlane: Plane;
  131222. /**
  131223. * Define how deep under the surface we should see.
  131224. */
  131225. depth: number;
  131226. /**
  131227. * Creates a refraction texture used by refraction channel of the standard material.
  131228. * It is like a mirror but to see through a material.
  131229. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  131230. * @param name Define the texture name
  131231. * @param size Define the size of the underlying texture
  131232. * @param scene Define the scene the refraction belongs to
  131233. * @param generateMipMaps Define if we need to generate mips level for the refraction
  131234. */
  131235. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  131236. /**
  131237. * Clone the refraction texture.
  131238. * @returns the cloned texture
  131239. */
  131240. clone(): RefractionTexture;
  131241. /**
  131242. * Serialize the texture to a JSON representation you could use in Parse later on
  131243. * @returns the serialized JSON representation
  131244. */
  131245. serialize(): any;
  131246. }
  131247. }
  131248. declare module BABYLON {
  131249. /**
  131250. * Defines the options related to the creation of an HtmlElementTexture
  131251. */
  131252. export interface IHtmlElementTextureOptions {
  131253. /**
  131254. * Defines wether mip maps should be created or not.
  131255. */
  131256. generateMipMaps?: boolean;
  131257. /**
  131258. * Defines the sampling mode of the texture.
  131259. */
  131260. samplingMode?: number;
  131261. /**
  131262. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  131263. */
  131264. engine: Nullable<ThinEngine>;
  131265. /**
  131266. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  131267. */
  131268. scene: Nullable<Scene>;
  131269. }
  131270. /**
  131271. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  131272. * To be as efficient as possible depending on your constraints nothing aside the first upload
  131273. * is automatically managed.
  131274. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  131275. * in your application.
  131276. *
  131277. * As the update is not automatic, you need to call them manually.
  131278. */
  131279. export class HtmlElementTexture extends BaseTexture {
  131280. /**
  131281. * The texture URL.
  131282. */
  131283. element: HTMLVideoElement | HTMLCanvasElement;
  131284. private static readonly DefaultOptions;
  131285. private _textureMatrix;
  131286. private _engine;
  131287. private _isVideo;
  131288. private _generateMipMaps;
  131289. private _samplingMode;
  131290. /**
  131291. * Instantiates a HtmlElementTexture from the following parameters.
  131292. *
  131293. * @param name Defines the name of the texture
  131294. * @param element Defines the video or canvas the texture is filled with
  131295. * @param options Defines the other none mandatory texture creation options
  131296. */
  131297. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  131298. private _createInternalTexture;
  131299. /**
  131300. * Returns the texture matrix used in most of the material.
  131301. */
  131302. getTextureMatrix(): Matrix;
  131303. /**
  131304. * Updates the content of the texture.
  131305. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  131306. */
  131307. update(invertY?: Nullable<boolean>): void;
  131308. }
  131309. }
  131310. declare module BABYLON {
  131311. /**
  131312. * Defines the basic options interface of a TexturePacker Frame
  131313. */
  131314. export interface ITexturePackerFrame {
  131315. /**
  131316. * The frame ID
  131317. */
  131318. id: number;
  131319. /**
  131320. * The frames Scale
  131321. */
  131322. scale: Vector2;
  131323. /**
  131324. * The Frames offset
  131325. */
  131326. offset: Vector2;
  131327. }
  131328. /**
  131329. * This is a support class for frame Data on texture packer sets.
  131330. */
  131331. export class TexturePackerFrame implements ITexturePackerFrame {
  131332. /**
  131333. * The frame ID
  131334. */
  131335. id: number;
  131336. /**
  131337. * The frames Scale
  131338. */
  131339. scale: Vector2;
  131340. /**
  131341. * The Frames offset
  131342. */
  131343. offset: Vector2;
  131344. /**
  131345. * Initializes a texture package frame.
  131346. * @param id The numerical frame identifier
  131347. * @param scale Scalar Vector2 for UV frame
  131348. * @param offset Vector2 for the frame position in UV units.
  131349. * @returns TexturePackerFrame
  131350. */
  131351. constructor(id: number, scale: Vector2, offset: Vector2);
  131352. }
  131353. }
  131354. declare module BABYLON {
  131355. /**
  131356. * Defines the basic options interface of a TexturePacker
  131357. */
  131358. export interface ITexturePackerOptions {
  131359. /**
  131360. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  131361. */
  131362. map?: string[];
  131363. /**
  131364. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131365. */
  131366. uvsIn?: string;
  131367. /**
  131368. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  131369. */
  131370. uvsOut?: string;
  131371. /**
  131372. * number representing the layout style. Defaults to LAYOUT_STRIP
  131373. */
  131374. layout?: number;
  131375. /**
  131376. * number of columns if using custom column count layout(2). This defaults to 4.
  131377. */
  131378. colnum?: number;
  131379. /**
  131380. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  131381. */
  131382. updateInputMeshes?: boolean;
  131383. /**
  131384. * boolean flag to dispose all the source textures. Defaults to true.
  131385. */
  131386. disposeSources?: boolean;
  131387. /**
  131388. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  131389. */
  131390. fillBlanks?: boolean;
  131391. /**
  131392. * string value representing the context fill style color. Defaults to 'black'.
  131393. */
  131394. customFillColor?: string;
  131395. /**
  131396. * Width and Height Value of each Frame in the TexturePacker Sets
  131397. */
  131398. frameSize?: number;
  131399. /**
  131400. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  131401. */
  131402. paddingRatio?: number;
  131403. /**
  131404. * Number that declares the fill method for the padding gutter.
  131405. */
  131406. paddingMode?: number;
  131407. /**
  131408. * If in SUBUV_COLOR padding mode what color to use.
  131409. */
  131410. paddingColor?: Color3 | Color4;
  131411. }
  131412. /**
  131413. * Defines the basic interface of a TexturePacker JSON File
  131414. */
  131415. export interface ITexturePackerJSON {
  131416. /**
  131417. * The frame ID
  131418. */
  131419. name: string;
  131420. /**
  131421. * The base64 channel data
  131422. */
  131423. sets: any;
  131424. /**
  131425. * The options of the Packer
  131426. */
  131427. options: ITexturePackerOptions;
  131428. /**
  131429. * The frame data of the Packer
  131430. */
  131431. frames: Array<number>;
  131432. }
  131433. /**
  131434. * This is a support class that generates a series of packed texture sets.
  131435. * @see https://doc.babylonjs.com/babylon101/materials
  131436. */
  131437. export class TexturePacker {
  131438. /** Packer Layout Constant 0 */
  131439. static readonly LAYOUT_STRIP: number;
  131440. /** Packer Layout Constant 1 */
  131441. static readonly LAYOUT_POWER2: number;
  131442. /** Packer Layout Constant 2 */
  131443. static readonly LAYOUT_COLNUM: number;
  131444. /** Packer Layout Constant 0 */
  131445. static readonly SUBUV_WRAP: number;
  131446. /** Packer Layout Constant 1 */
  131447. static readonly SUBUV_EXTEND: number;
  131448. /** Packer Layout Constant 2 */
  131449. static readonly SUBUV_COLOR: number;
  131450. /** The Name of the Texture Package */
  131451. name: string;
  131452. /** The scene scope of the TexturePacker */
  131453. scene: Scene;
  131454. /** The Meshes to target */
  131455. meshes: AbstractMesh[];
  131456. /** Arguments passed with the Constructor */
  131457. options: ITexturePackerOptions;
  131458. /** The promise that is started upon initialization */
  131459. promise: Nullable<Promise<TexturePacker | string>>;
  131460. /** The Container object for the channel sets that are generated */
  131461. sets: object;
  131462. /** The Container array for the frames that are generated */
  131463. frames: TexturePackerFrame[];
  131464. /** The expected number of textures the system is parsing. */
  131465. private _expecting;
  131466. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  131467. private _paddingValue;
  131468. /**
  131469. * Initializes a texture package series from an array of meshes or a single mesh.
  131470. * @param name The name of the package
  131471. * @param meshes The target meshes to compose the package from
  131472. * @param options The arguments that texture packer should follow while building.
  131473. * @param scene The scene which the textures are scoped to.
  131474. * @returns TexturePacker
  131475. */
  131476. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  131477. /**
  131478. * Starts the package process
  131479. * @param resolve The promises resolution function
  131480. * @returns TexturePacker
  131481. */
  131482. private _createFrames;
  131483. /**
  131484. * Calculates the Size of the Channel Sets
  131485. * @returns Vector2
  131486. */
  131487. private _calculateSize;
  131488. /**
  131489. * Calculates the UV data for the frames.
  131490. * @param baseSize the base frameSize
  131491. * @param padding the base frame padding
  131492. * @param dtSize size of the Dynamic Texture for that channel
  131493. * @param dtUnits is 1/dtSize
  131494. * @param update flag to update the input meshes
  131495. */
  131496. private _calculateMeshUVFrames;
  131497. /**
  131498. * Calculates the frames Offset.
  131499. * @param index of the frame
  131500. * @returns Vector2
  131501. */
  131502. private _getFrameOffset;
  131503. /**
  131504. * Updates a Mesh to the frame data
  131505. * @param mesh that is the target
  131506. * @param frameID or the frame index
  131507. */
  131508. private _updateMeshUV;
  131509. /**
  131510. * Updates a Meshes materials to use the texture packer channels
  131511. * @param m is the mesh to target
  131512. * @param force all channels on the packer to be set.
  131513. */
  131514. private _updateTextureReferences;
  131515. /**
  131516. * Public method to set a Mesh to a frame
  131517. * @param m that is the target
  131518. * @param frameID or the frame index
  131519. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  131520. */
  131521. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  131522. /**
  131523. * Starts the async promise to compile the texture packer.
  131524. * @returns Promise<void>
  131525. */
  131526. processAsync(): Promise<void>;
  131527. /**
  131528. * Disposes all textures associated with this packer
  131529. */
  131530. dispose(): void;
  131531. /**
  131532. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  131533. * @param imageType is the image type to use.
  131534. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  131535. */
  131536. download(imageType?: string, quality?: number): void;
  131537. /**
  131538. * Public method to load a texturePacker JSON file.
  131539. * @param data of the JSON file in string format.
  131540. */
  131541. updateFromJSON(data: string): void;
  131542. }
  131543. }
  131544. declare module BABYLON {
  131545. /**
  131546. * Enum used to define the target of a block
  131547. */
  131548. export enum NodeMaterialBlockTargets {
  131549. /** Vertex shader */
  131550. Vertex = 1,
  131551. /** Fragment shader */
  131552. Fragment = 2,
  131553. /** Neutral */
  131554. Neutral = 4,
  131555. /** Vertex and Fragment */
  131556. VertexAndFragment = 3
  131557. }
  131558. }
  131559. declare module BABYLON {
  131560. /**
  131561. * Defines the kind of connection point for node based material
  131562. */
  131563. export enum NodeMaterialBlockConnectionPointTypes {
  131564. /** Float */
  131565. Float = 1,
  131566. /** Int */
  131567. Int = 2,
  131568. /** Vector2 */
  131569. Vector2 = 4,
  131570. /** Vector3 */
  131571. Vector3 = 8,
  131572. /** Vector4 */
  131573. Vector4 = 16,
  131574. /** Color3 */
  131575. Color3 = 32,
  131576. /** Color4 */
  131577. Color4 = 64,
  131578. /** Matrix */
  131579. Matrix = 128,
  131580. /** Detect type based on connection */
  131581. AutoDetect = 1024,
  131582. /** Output type that will be defined by input type */
  131583. BasedOnInput = 2048
  131584. }
  131585. }
  131586. declare module BABYLON {
  131587. /**
  131588. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  131589. */
  131590. export enum NodeMaterialBlockConnectionPointMode {
  131591. /** Value is an uniform */
  131592. Uniform = 0,
  131593. /** Value is a mesh attribute */
  131594. Attribute = 1,
  131595. /** Value is a varying between vertex and fragment shaders */
  131596. Varying = 2,
  131597. /** Mode is undefined */
  131598. Undefined = 3
  131599. }
  131600. }
  131601. declare module BABYLON {
  131602. /**
  131603. * Enum used to define system values e.g. values automatically provided by the system
  131604. */
  131605. export enum NodeMaterialSystemValues {
  131606. /** World */
  131607. World = 1,
  131608. /** View */
  131609. View = 2,
  131610. /** Projection */
  131611. Projection = 3,
  131612. /** ViewProjection */
  131613. ViewProjection = 4,
  131614. /** WorldView */
  131615. WorldView = 5,
  131616. /** WorldViewProjection */
  131617. WorldViewProjection = 6,
  131618. /** CameraPosition */
  131619. CameraPosition = 7,
  131620. /** Fog Color */
  131621. FogColor = 8,
  131622. /** Delta time */
  131623. DeltaTime = 9
  131624. }
  131625. }
  131626. declare module BABYLON {
  131627. /**
  131628. * Root class for all node material optimizers
  131629. */
  131630. export class NodeMaterialOptimizer {
  131631. /**
  131632. * Function used to optimize a NodeMaterial graph
  131633. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  131634. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  131635. */
  131636. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  131637. }
  131638. }
  131639. declare module BABYLON {
  131640. /**
  131641. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  131642. */
  131643. export class TransformBlock extends NodeMaterialBlock {
  131644. /**
  131645. * Defines the value to use to complement W value to transform it to a Vector4
  131646. */
  131647. complementW: number;
  131648. /**
  131649. * Defines the value to use to complement z value to transform it to a Vector4
  131650. */
  131651. complementZ: number;
  131652. /**
  131653. * Creates a new TransformBlock
  131654. * @param name defines the block name
  131655. */
  131656. constructor(name: string);
  131657. /**
  131658. * Gets the current class name
  131659. * @returns the class name
  131660. */
  131661. getClassName(): string;
  131662. /**
  131663. * Gets the vector input
  131664. */
  131665. get vector(): NodeMaterialConnectionPoint;
  131666. /**
  131667. * Gets the output component
  131668. */
  131669. get output(): NodeMaterialConnectionPoint;
  131670. /**
  131671. * Gets the xyz output component
  131672. */
  131673. get xyz(): NodeMaterialConnectionPoint;
  131674. /**
  131675. * Gets the matrix transform input
  131676. */
  131677. get transform(): NodeMaterialConnectionPoint;
  131678. protected _buildBlock(state: NodeMaterialBuildState): this;
  131679. serialize(): any;
  131680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131681. protected _dumpPropertiesCode(): string;
  131682. }
  131683. }
  131684. declare module BABYLON {
  131685. /**
  131686. * Block used to output the vertex position
  131687. */
  131688. export class VertexOutputBlock extends NodeMaterialBlock {
  131689. /**
  131690. * Creates a new VertexOutputBlock
  131691. * @param name defines the block name
  131692. */
  131693. constructor(name: string);
  131694. /**
  131695. * Gets the current class name
  131696. * @returns the class name
  131697. */
  131698. getClassName(): string;
  131699. /**
  131700. * Gets the vector input component
  131701. */
  131702. get vector(): NodeMaterialConnectionPoint;
  131703. protected _buildBlock(state: NodeMaterialBuildState): this;
  131704. }
  131705. }
  131706. declare module BABYLON {
  131707. /**
  131708. * Block used to output the final color
  131709. */
  131710. export class FragmentOutputBlock extends NodeMaterialBlock {
  131711. /**
  131712. * Create a new FragmentOutputBlock
  131713. * @param name defines the block name
  131714. */
  131715. constructor(name: string);
  131716. /**
  131717. * Gets the current class name
  131718. * @returns the class name
  131719. */
  131720. getClassName(): string;
  131721. /**
  131722. * Gets the rgba input component
  131723. */
  131724. get rgba(): NodeMaterialConnectionPoint;
  131725. /**
  131726. * Gets the rgb input component
  131727. */
  131728. get rgb(): NodeMaterialConnectionPoint;
  131729. /**
  131730. * Gets the a input component
  131731. */
  131732. get a(): NodeMaterialConnectionPoint;
  131733. protected _buildBlock(state: NodeMaterialBuildState): this;
  131734. }
  131735. }
  131736. declare module BABYLON {
  131737. /**
  131738. * Block used to read a reflection texture from a sampler
  131739. */
  131740. export class ReflectionTextureBlock extends NodeMaterialBlock {
  131741. private _define3DName;
  131742. private _defineCubicName;
  131743. private _defineExplicitName;
  131744. private _defineProjectionName;
  131745. private _defineLocalCubicName;
  131746. private _defineSphericalName;
  131747. private _definePlanarName;
  131748. private _defineEquirectangularName;
  131749. private _defineMirroredEquirectangularFixedName;
  131750. private _defineEquirectangularFixedName;
  131751. private _defineSkyboxName;
  131752. private _cubeSamplerName;
  131753. private _2DSamplerName;
  131754. private _positionUVWName;
  131755. private _directionWName;
  131756. private _reflectionCoordsName;
  131757. private _reflection2DCoordsName;
  131758. private _reflectionColorName;
  131759. private _reflectionMatrixName;
  131760. /**
  131761. * Gets or sets the texture associated with the node
  131762. */
  131763. texture: Nullable<BaseTexture>;
  131764. /**
  131765. * Create a new TextureBlock
  131766. * @param name defines the block name
  131767. */
  131768. constructor(name: string);
  131769. /**
  131770. * Gets the current class name
  131771. * @returns the class name
  131772. */
  131773. getClassName(): string;
  131774. /**
  131775. * Gets the world position input component
  131776. */
  131777. get position(): NodeMaterialConnectionPoint;
  131778. /**
  131779. * Gets the world position input component
  131780. */
  131781. get worldPosition(): NodeMaterialConnectionPoint;
  131782. /**
  131783. * Gets the world normal input component
  131784. */
  131785. get worldNormal(): NodeMaterialConnectionPoint;
  131786. /**
  131787. * Gets the world input component
  131788. */
  131789. get world(): NodeMaterialConnectionPoint;
  131790. /**
  131791. * Gets the camera (or eye) position component
  131792. */
  131793. get cameraPosition(): NodeMaterialConnectionPoint;
  131794. /**
  131795. * Gets the view input component
  131796. */
  131797. get view(): NodeMaterialConnectionPoint;
  131798. /**
  131799. * Gets the rgb output component
  131800. */
  131801. get rgb(): NodeMaterialConnectionPoint;
  131802. /**
  131803. * Gets the r output component
  131804. */
  131805. get r(): NodeMaterialConnectionPoint;
  131806. /**
  131807. * Gets the g output component
  131808. */
  131809. get g(): NodeMaterialConnectionPoint;
  131810. /**
  131811. * Gets the b output component
  131812. */
  131813. get b(): NodeMaterialConnectionPoint;
  131814. autoConfigure(material: NodeMaterial): void;
  131815. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  131816. isReady(): boolean;
  131817. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  131818. private _injectVertexCode;
  131819. private _writeOutput;
  131820. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  131821. protected _dumpPropertiesCode(): string;
  131822. serialize(): any;
  131823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  131824. }
  131825. }
  131826. declare module BABYLON {
  131827. /**
  131828. * Interface used to configure the node material editor
  131829. */
  131830. export interface INodeMaterialEditorOptions {
  131831. /** Define the URl to load node editor script */
  131832. editorURL?: string;
  131833. }
  131834. /** @hidden */
  131835. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  131836. NORMAL: boolean;
  131837. TANGENT: boolean;
  131838. UV1: boolean;
  131839. /** BONES */
  131840. NUM_BONE_INFLUENCERS: number;
  131841. BonesPerMesh: number;
  131842. BONETEXTURE: boolean;
  131843. /** MORPH TARGETS */
  131844. MORPHTARGETS: boolean;
  131845. MORPHTARGETS_NORMAL: boolean;
  131846. MORPHTARGETS_TANGENT: boolean;
  131847. MORPHTARGETS_UV: boolean;
  131848. NUM_MORPH_INFLUENCERS: number;
  131849. /** IMAGE PROCESSING */
  131850. IMAGEPROCESSING: boolean;
  131851. VIGNETTE: boolean;
  131852. VIGNETTEBLENDMODEMULTIPLY: boolean;
  131853. VIGNETTEBLENDMODEOPAQUE: boolean;
  131854. TONEMAPPING: boolean;
  131855. TONEMAPPING_ACES: boolean;
  131856. CONTRAST: boolean;
  131857. EXPOSURE: boolean;
  131858. COLORCURVES: boolean;
  131859. COLORGRADING: boolean;
  131860. COLORGRADING3D: boolean;
  131861. SAMPLER3DGREENDEPTH: boolean;
  131862. SAMPLER3DBGRMAP: boolean;
  131863. IMAGEPROCESSINGPOSTPROCESS: boolean;
  131864. /** MISC. */
  131865. BUMPDIRECTUV: number;
  131866. constructor();
  131867. setValue(name: string, value: boolean): void;
  131868. }
  131869. /**
  131870. * Class used to configure NodeMaterial
  131871. */
  131872. export interface INodeMaterialOptions {
  131873. /**
  131874. * Defines if blocks should emit comments
  131875. */
  131876. emitComments: boolean;
  131877. }
  131878. /**
  131879. * Class used to create a node based material built by assembling shader blocks
  131880. */
  131881. export class NodeMaterial extends PushMaterial {
  131882. private static _BuildIdGenerator;
  131883. private _options;
  131884. private _vertexCompilationState;
  131885. private _fragmentCompilationState;
  131886. private _sharedData;
  131887. private _buildId;
  131888. private _buildWasSuccessful;
  131889. private _cachedWorldViewMatrix;
  131890. private _cachedWorldViewProjectionMatrix;
  131891. private _optimizers;
  131892. private _animationFrame;
  131893. /** Define the Url to load node editor script */
  131894. static EditorURL: string;
  131895. /** Define the Url to load snippets */
  131896. static SnippetUrl: string;
  131897. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  131898. static IgnoreTexturesAtLoadTime: boolean;
  131899. private BJSNODEMATERIALEDITOR;
  131900. /** Get the inspector from bundle or global */
  131901. private _getGlobalNodeMaterialEditor;
  131902. /**
  131903. * Snippet ID if the material was created from the snippet server
  131904. */
  131905. snippetId: string;
  131906. /**
  131907. * Gets or sets data used by visual editor
  131908. * @see https://nme.babylonjs.com
  131909. */
  131910. editorData: any;
  131911. /**
  131912. * 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)
  131913. */
  131914. ignoreAlpha: boolean;
  131915. /**
  131916. * Defines the maximum number of lights that can be used in the material
  131917. */
  131918. maxSimultaneousLights: number;
  131919. /**
  131920. * Observable raised when the material is built
  131921. */
  131922. onBuildObservable: Observable<NodeMaterial>;
  131923. /**
  131924. * Gets or sets the root nodes of the material vertex shader
  131925. */
  131926. _vertexOutputNodes: NodeMaterialBlock[];
  131927. /**
  131928. * Gets or sets the root nodes of the material fragment (pixel) shader
  131929. */
  131930. _fragmentOutputNodes: NodeMaterialBlock[];
  131931. /** Gets or sets options to control the node material overall behavior */
  131932. get options(): INodeMaterialOptions;
  131933. set options(options: INodeMaterialOptions);
  131934. /**
  131935. * Default configuration related to image processing available in the standard Material.
  131936. */
  131937. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  131938. /**
  131939. * Gets the image processing configuration used either in this material.
  131940. */
  131941. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  131942. /**
  131943. * Sets the Default image processing configuration used either in the this material.
  131944. *
  131945. * If sets to null, the scene one is in use.
  131946. */
  131947. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  131948. /**
  131949. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  131950. */
  131951. attachedBlocks: NodeMaterialBlock[];
  131952. /**
  131953. * Create a new node based material
  131954. * @param name defines the material name
  131955. * @param scene defines the hosting scene
  131956. * @param options defines creation option
  131957. */
  131958. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  131959. /**
  131960. * Gets the current class name of the material e.g. "NodeMaterial"
  131961. * @returns the class name
  131962. */
  131963. getClassName(): string;
  131964. /**
  131965. * Keep track of the image processing observer to allow dispose and replace.
  131966. */
  131967. private _imageProcessingObserver;
  131968. /**
  131969. * Attaches a new image processing configuration to the Standard Material.
  131970. * @param configuration
  131971. */
  131972. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  131973. /**
  131974. * Get a block by its name
  131975. * @param name defines the name of the block to retrieve
  131976. * @returns the required block or null if not found
  131977. */
  131978. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  131979. /**
  131980. * Get a block by its name
  131981. * @param predicate defines the predicate used to find the good candidate
  131982. * @returns the required block or null if not found
  131983. */
  131984. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  131985. /**
  131986. * Get an input block by its name
  131987. * @param predicate defines the predicate used to find the good candidate
  131988. * @returns the required input block or null if not found
  131989. */
  131990. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  131991. /**
  131992. * Gets the list of input blocks attached to this material
  131993. * @returns an array of InputBlocks
  131994. */
  131995. getInputBlocks(): InputBlock[];
  131996. /**
  131997. * Adds a new optimizer to the list of optimizers
  131998. * @param optimizer defines the optimizers to add
  131999. * @returns the current material
  132000. */
  132001. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  132002. /**
  132003. * Remove an optimizer from the list of optimizers
  132004. * @param optimizer defines the optimizers to remove
  132005. * @returns the current material
  132006. */
  132007. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  132008. /**
  132009. * Add a new block to the list of output nodes
  132010. * @param node defines the node to add
  132011. * @returns the current material
  132012. */
  132013. addOutputNode(node: NodeMaterialBlock): this;
  132014. /**
  132015. * Remove a block from the list of root nodes
  132016. * @param node defines the node to remove
  132017. * @returns the current material
  132018. */
  132019. removeOutputNode(node: NodeMaterialBlock): this;
  132020. private _addVertexOutputNode;
  132021. private _removeVertexOutputNode;
  132022. private _addFragmentOutputNode;
  132023. private _removeFragmentOutputNode;
  132024. /**
  132025. * Specifies if the material will require alpha blending
  132026. * @returns a boolean specifying if alpha blending is needed
  132027. */
  132028. needAlphaBlending(): boolean;
  132029. /**
  132030. * Specifies if this material should be rendered in alpha test mode
  132031. * @returns a boolean specifying if an alpha test is needed.
  132032. */
  132033. needAlphaTesting(): boolean;
  132034. private _initializeBlock;
  132035. private _resetDualBlocks;
  132036. /**
  132037. * Remove a block from the current node material
  132038. * @param block defines the block to remove
  132039. */
  132040. removeBlock(block: NodeMaterialBlock): void;
  132041. /**
  132042. * Build the material and generates the inner effect
  132043. * @param verbose defines if the build should log activity
  132044. */
  132045. build(verbose?: boolean): void;
  132046. /**
  132047. * Runs an otpimization phase to try to improve the shader code
  132048. */
  132049. optimize(): void;
  132050. private _prepareDefinesForAttributes;
  132051. /**
  132052. * Get if the submesh is ready to be used and all its information available.
  132053. * Child classes can use it to update shaders
  132054. * @param mesh defines the mesh to check
  132055. * @param subMesh defines which submesh to check
  132056. * @param useInstances specifies that instances should be used
  132057. * @returns a boolean indicating that the submesh is ready or not
  132058. */
  132059. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  132060. /**
  132061. * Get a string representing the shaders built by the current node graph
  132062. */
  132063. get compiledShaders(): string;
  132064. /**
  132065. * Binds the world matrix to the material
  132066. * @param world defines the world transformation matrix
  132067. */
  132068. bindOnlyWorldMatrix(world: Matrix): void;
  132069. /**
  132070. * Binds the submesh to this material by preparing the effect and shader to draw
  132071. * @param world defines the world transformation matrix
  132072. * @param mesh defines the mesh containing the submesh
  132073. * @param subMesh defines the submesh to bind the material to
  132074. */
  132075. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  132076. /**
  132077. * Gets the active textures from the material
  132078. * @returns an array of textures
  132079. */
  132080. getActiveTextures(): BaseTexture[];
  132081. /**
  132082. * Gets the list of texture blocks
  132083. * @returns an array of texture blocks
  132084. */
  132085. getTextureBlocks(): (TextureBlock | ReflectionTextureBlock)[];
  132086. /**
  132087. * Specifies if the material uses a texture
  132088. * @param texture defines the texture to check against the material
  132089. * @returns a boolean specifying if the material uses the texture
  132090. */
  132091. hasTexture(texture: BaseTexture): boolean;
  132092. /**
  132093. * Disposes the material
  132094. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  132095. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  132096. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  132097. */
  132098. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  132099. /** Creates the node editor window. */
  132100. private _createNodeEditor;
  132101. /**
  132102. * Launch the node material editor
  132103. * @param config Define the configuration of the editor
  132104. * @return a promise fulfilled when the node editor is visible
  132105. */
  132106. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  132107. /**
  132108. * Clear the current material
  132109. */
  132110. clear(): void;
  132111. /**
  132112. * Clear the current material and set it to a default state
  132113. */
  132114. setToDefault(): void;
  132115. /**
  132116. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  132117. * @param url defines the url to load from
  132118. * @returns a promise that will fullfil when the material is fully loaded
  132119. */
  132120. loadAsync(url: string): Promise<void>;
  132121. private _gatherBlocks;
  132122. /**
  132123. * Generate a string containing the code declaration required to create an equivalent of this material
  132124. * @returns a string
  132125. */
  132126. generateCode(): string;
  132127. /**
  132128. * Serializes this material in a JSON representation
  132129. * @returns the serialized material object
  132130. */
  132131. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  132132. private _restoreConnections;
  132133. /**
  132134. * Clear the current graph and load a new one from a serialization object
  132135. * @param source defines the JSON representation of the material
  132136. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132137. */
  132138. loadFromSerialization(source: any, rootUrl?: string): void;
  132139. /**
  132140. * Makes a duplicate of the current material.
  132141. * @param name - name to use for the new material.
  132142. */
  132143. clone(name: string): NodeMaterial;
  132144. /**
  132145. * Creates a node material from parsed material data
  132146. * @param source defines the JSON representation of the material
  132147. * @param scene defines the hosting scene
  132148. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132149. * @returns a new node material
  132150. */
  132151. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  132152. /**
  132153. * Creates a node material from a snippet saved in a remote file
  132154. * @param name defines the name of the material to create
  132155. * @param url defines the url to load from
  132156. * @param scene defines the hosting scene
  132157. * @returns a promise that will resolve to the new node material
  132158. */
  132159. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  132160. /**
  132161. * Creates a node material from a snippet saved by the node material editor
  132162. * @param snippetId defines the snippet to load
  132163. * @param scene defines the hosting scene
  132164. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132165. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  132166. * @returns a promise that will resolve to the new node material
  132167. */
  132168. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  132169. /**
  132170. * Creates a new node material set to default basic configuration
  132171. * @param name defines the name of the material
  132172. * @param scene defines the hosting scene
  132173. * @returns a new NodeMaterial
  132174. */
  132175. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  132176. }
  132177. }
  132178. declare module BABYLON {
  132179. /**
  132180. * Block used to read a texture from a sampler
  132181. */
  132182. export class TextureBlock extends NodeMaterialBlock {
  132183. private _defineName;
  132184. private _linearDefineName;
  132185. private _tempTextureRead;
  132186. private _samplerName;
  132187. private _transformedUVName;
  132188. private _textureTransformName;
  132189. private _textureInfoName;
  132190. private _mainUVName;
  132191. private _mainUVDefineName;
  132192. /**
  132193. * Gets or sets the texture associated with the node
  132194. */
  132195. texture: Nullable<Texture>;
  132196. /**
  132197. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  132198. */
  132199. convertToGammaSpace: boolean;
  132200. /**
  132201. * Create a new TextureBlock
  132202. * @param name defines the block name
  132203. */
  132204. constructor(name: string);
  132205. /**
  132206. * Gets the current class name
  132207. * @returns the class name
  132208. */
  132209. getClassName(): string;
  132210. /**
  132211. * Gets the uv input component
  132212. */
  132213. get uv(): NodeMaterialConnectionPoint;
  132214. /**
  132215. * Gets the rgba output component
  132216. */
  132217. get rgba(): NodeMaterialConnectionPoint;
  132218. /**
  132219. * Gets the rgb output component
  132220. */
  132221. get rgb(): NodeMaterialConnectionPoint;
  132222. /**
  132223. * Gets the r output component
  132224. */
  132225. get r(): NodeMaterialConnectionPoint;
  132226. /**
  132227. * Gets the g output component
  132228. */
  132229. get g(): NodeMaterialConnectionPoint;
  132230. /**
  132231. * Gets the b output component
  132232. */
  132233. get b(): NodeMaterialConnectionPoint;
  132234. /**
  132235. * Gets the a output component
  132236. */
  132237. get a(): NodeMaterialConnectionPoint;
  132238. get target(): NodeMaterialBlockTargets;
  132239. autoConfigure(material: NodeMaterial): void;
  132240. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132241. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  132242. isReady(): boolean;
  132243. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132244. private get _isMixed();
  132245. private _injectVertexCode;
  132246. private _writeTextureRead;
  132247. private _writeOutput;
  132248. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  132249. protected _dumpPropertiesCode(): string;
  132250. serialize(): any;
  132251. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132252. }
  132253. }
  132254. declare module BABYLON {
  132255. /**
  132256. * Class used to store shared data between 2 NodeMaterialBuildState
  132257. */
  132258. export class NodeMaterialBuildStateSharedData {
  132259. /**
  132260. * Gets the list of emitted varyings
  132261. */
  132262. temps: string[];
  132263. /**
  132264. * Gets the list of emitted varyings
  132265. */
  132266. varyings: string[];
  132267. /**
  132268. * Gets the varying declaration string
  132269. */
  132270. varyingDeclaration: string;
  132271. /**
  132272. * Input blocks
  132273. */
  132274. inputBlocks: InputBlock[];
  132275. /**
  132276. * Input blocks
  132277. */
  132278. textureBlocks: (ReflectionTextureBlock | TextureBlock)[];
  132279. /**
  132280. * Bindable blocks (Blocks that need to set data to the effect)
  132281. */
  132282. bindableBlocks: NodeMaterialBlock[];
  132283. /**
  132284. * List of blocks that can provide a compilation fallback
  132285. */
  132286. blocksWithFallbacks: NodeMaterialBlock[];
  132287. /**
  132288. * List of blocks that can provide a define update
  132289. */
  132290. blocksWithDefines: NodeMaterialBlock[];
  132291. /**
  132292. * List of blocks that can provide a repeatable content
  132293. */
  132294. repeatableContentBlocks: NodeMaterialBlock[];
  132295. /**
  132296. * List of blocks that can provide a dynamic list of uniforms
  132297. */
  132298. dynamicUniformBlocks: NodeMaterialBlock[];
  132299. /**
  132300. * List of blocks that can block the isReady function for the material
  132301. */
  132302. blockingBlocks: NodeMaterialBlock[];
  132303. /**
  132304. * Gets the list of animated inputs
  132305. */
  132306. animatedInputs: InputBlock[];
  132307. /**
  132308. * Build Id used to avoid multiple recompilations
  132309. */
  132310. buildId: number;
  132311. /** List of emitted variables */
  132312. variableNames: {
  132313. [key: string]: number;
  132314. };
  132315. /** List of emitted defines */
  132316. defineNames: {
  132317. [key: string]: number;
  132318. };
  132319. /** Should emit comments? */
  132320. emitComments: boolean;
  132321. /** Emit build activity */
  132322. verbose: boolean;
  132323. /** Gets or sets the hosting scene */
  132324. scene: Scene;
  132325. /**
  132326. * Gets the compilation hints emitted at compilation time
  132327. */
  132328. hints: {
  132329. needWorldViewMatrix: boolean;
  132330. needWorldViewProjectionMatrix: boolean;
  132331. needAlphaBlending: boolean;
  132332. needAlphaTesting: boolean;
  132333. };
  132334. /**
  132335. * List of compilation checks
  132336. */
  132337. checks: {
  132338. emitVertex: boolean;
  132339. emitFragment: boolean;
  132340. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  132341. };
  132342. /** Creates a new shared data */
  132343. constructor();
  132344. /**
  132345. * Emits console errors and exceptions if there is a failing check
  132346. */
  132347. emitErrors(): void;
  132348. }
  132349. }
  132350. declare module BABYLON {
  132351. /**
  132352. * Class used to store node based material build state
  132353. */
  132354. export class NodeMaterialBuildState {
  132355. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  132356. supportUniformBuffers: boolean;
  132357. /**
  132358. * Gets the list of emitted attributes
  132359. */
  132360. attributes: string[];
  132361. /**
  132362. * Gets the list of emitted uniforms
  132363. */
  132364. uniforms: string[];
  132365. /**
  132366. * Gets the list of emitted constants
  132367. */
  132368. constants: string[];
  132369. /**
  132370. * Gets the list of emitted samplers
  132371. */
  132372. samplers: string[];
  132373. /**
  132374. * Gets the list of emitted functions
  132375. */
  132376. functions: {
  132377. [key: string]: string;
  132378. };
  132379. /**
  132380. * Gets the list of emitted extensions
  132381. */
  132382. extensions: {
  132383. [key: string]: string;
  132384. };
  132385. /**
  132386. * Gets the target of the compilation state
  132387. */
  132388. target: NodeMaterialBlockTargets;
  132389. /**
  132390. * Gets the list of emitted counters
  132391. */
  132392. counters: {
  132393. [key: string]: number;
  132394. };
  132395. /**
  132396. * Shared data between multiple NodeMaterialBuildState instances
  132397. */
  132398. sharedData: NodeMaterialBuildStateSharedData;
  132399. /** @hidden */
  132400. _vertexState: NodeMaterialBuildState;
  132401. /** @hidden */
  132402. _attributeDeclaration: string;
  132403. /** @hidden */
  132404. _uniformDeclaration: string;
  132405. /** @hidden */
  132406. _constantDeclaration: string;
  132407. /** @hidden */
  132408. _samplerDeclaration: string;
  132409. /** @hidden */
  132410. _varyingTransfer: string;
  132411. private _repeatableContentAnchorIndex;
  132412. /** @hidden */
  132413. _builtCompilationString: string;
  132414. /**
  132415. * Gets the emitted compilation strings
  132416. */
  132417. compilationString: string;
  132418. /**
  132419. * Finalize the compilation strings
  132420. * @param state defines the current compilation state
  132421. */
  132422. finalize(state: NodeMaterialBuildState): void;
  132423. /** @hidden */
  132424. get _repeatableContentAnchor(): string;
  132425. /** @hidden */
  132426. _getFreeVariableName(prefix: string): string;
  132427. /** @hidden */
  132428. _getFreeDefineName(prefix: string): string;
  132429. /** @hidden */
  132430. _excludeVariableName(name: string): void;
  132431. /** @hidden */
  132432. _emit2DSampler(name: string): void;
  132433. /** @hidden */
  132434. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  132435. /** @hidden */
  132436. _emitExtension(name: string, extension: string): void;
  132437. /** @hidden */
  132438. _emitFunction(name: string, code: string, comments: string): void;
  132439. /** @hidden */
  132440. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  132441. replaceStrings?: {
  132442. search: RegExp;
  132443. replace: string;
  132444. }[];
  132445. repeatKey?: string;
  132446. }): string;
  132447. /** @hidden */
  132448. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  132449. repeatKey?: string;
  132450. removeAttributes?: boolean;
  132451. removeUniforms?: boolean;
  132452. removeVaryings?: boolean;
  132453. removeIfDef?: boolean;
  132454. replaceStrings?: {
  132455. search: RegExp;
  132456. replace: string;
  132457. }[];
  132458. }, storeKey?: string): void;
  132459. /** @hidden */
  132460. _registerTempVariable(name: string): boolean;
  132461. /** @hidden */
  132462. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  132463. /** @hidden */
  132464. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  132465. /** @hidden */
  132466. _emitFloat(value: number): string;
  132467. }
  132468. }
  132469. declare module BABYLON {
  132470. /**
  132471. * Defines a block that can be used inside a node based material
  132472. */
  132473. export class NodeMaterialBlock {
  132474. private _buildId;
  132475. private _buildTarget;
  132476. private _target;
  132477. private _isFinalMerger;
  132478. private _isInput;
  132479. protected _isUnique: boolean;
  132480. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  132481. inputsAreExclusive: boolean;
  132482. /** @hidden */
  132483. _codeVariableName: string;
  132484. /** @hidden */
  132485. _inputs: NodeMaterialConnectionPoint[];
  132486. /** @hidden */
  132487. _outputs: NodeMaterialConnectionPoint[];
  132488. /** @hidden */
  132489. _preparationId: number;
  132490. /**
  132491. * Gets or sets the name of the block
  132492. */
  132493. name: string;
  132494. /**
  132495. * Gets or sets the unique id of the node
  132496. */
  132497. uniqueId: number;
  132498. /**
  132499. * Gets or sets the comments associated with this block
  132500. */
  132501. comments: string;
  132502. /**
  132503. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  132504. */
  132505. get isUnique(): boolean;
  132506. /**
  132507. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  132508. */
  132509. get isFinalMerger(): boolean;
  132510. /**
  132511. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  132512. */
  132513. get isInput(): boolean;
  132514. /**
  132515. * Gets or sets the build Id
  132516. */
  132517. get buildId(): number;
  132518. set buildId(value: number);
  132519. /**
  132520. * Gets or sets the target of the block
  132521. */
  132522. get target(): NodeMaterialBlockTargets;
  132523. set target(value: NodeMaterialBlockTargets);
  132524. /**
  132525. * Gets the list of input points
  132526. */
  132527. get inputs(): NodeMaterialConnectionPoint[];
  132528. /** Gets the list of output points */
  132529. get outputs(): NodeMaterialConnectionPoint[];
  132530. /**
  132531. * Find an input by its name
  132532. * @param name defines the name of the input to look for
  132533. * @returns the input or null if not found
  132534. */
  132535. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132536. /**
  132537. * Find an output by its name
  132538. * @param name defines the name of the outputto look for
  132539. * @returns the output or null if not found
  132540. */
  132541. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  132542. /**
  132543. * Creates a new NodeMaterialBlock
  132544. * @param name defines the block name
  132545. * @param target defines the target of that block (Vertex by default)
  132546. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  132547. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  132548. */
  132549. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  132550. /**
  132551. * Initialize the block and prepare the context for build
  132552. * @param state defines the state that will be used for the build
  132553. */
  132554. initialize(state: NodeMaterialBuildState): void;
  132555. /**
  132556. * Bind data to effect. Will only be called for blocks with isBindable === true
  132557. * @param effect defines the effect to bind data to
  132558. * @param nodeMaterial defines the hosting NodeMaterial
  132559. * @param mesh defines the mesh that will be rendered
  132560. */
  132561. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  132562. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  132563. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  132564. protected _writeFloat(value: number): string;
  132565. /**
  132566. * Gets the current class name e.g. "NodeMaterialBlock"
  132567. * @returns the class name
  132568. */
  132569. getClassName(): string;
  132570. /**
  132571. * Register a new input. Must be called inside a block constructor
  132572. * @param name defines the connection point name
  132573. * @param type defines the connection point type
  132574. * @param isOptional defines a boolean indicating that this input can be omitted
  132575. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132576. * @returns the current block
  132577. */
  132578. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets): this;
  132579. /**
  132580. * Register a new output. Must be called inside a block constructor
  132581. * @param name defines the connection point name
  132582. * @param type defines the connection point type
  132583. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  132584. * @returns the current block
  132585. */
  132586. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets): this;
  132587. /**
  132588. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  132589. * @param forOutput defines an optional connection point to check compatibility with
  132590. * @returns the first available input or null
  132591. */
  132592. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  132593. /**
  132594. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  132595. * @param forBlock defines an optional block to check compatibility with
  132596. * @returns the first available input or null
  132597. */
  132598. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  132599. /**
  132600. * Gets the sibling of the given output
  132601. * @param current defines the current output
  132602. * @returns the next output in the list or null
  132603. */
  132604. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  132605. /**
  132606. * Connect current block with another block
  132607. * @param other defines the block to connect with
  132608. * @param options define the various options to help pick the right connections
  132609. * @returns the current block
  132610. */
  132611. connectTo(other: NodeMaterialBlock, options?: {
  132612. input?: string;
  132613. output?: string;
  132614. outputSwizzle?: string;
  132615. }): this | undefined;
  132616. protected _buildBlock(state: NodeMaterialBuildState): void;
  132617. /**
  132618. * Add uniforms, samplers and uniform buffers at compilation time
  132619. * @param state defines the state to update
  132620. * @param nodeMaterial defines the node material requesting the update
  132621. * @param defines defines the material defines to update
  132622. * @param uniformBuffers defines the list of uniform buffer names
  132623. */
  132624. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  132625. /**
  132626. * Add potential fallbacks if shader compilation fails
  132627. * @param mesh defines the mesh to be rendered
  132628. * @param fallbacks defines the current prioritized list of fallbacks
  132629. */
  132630. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  132631. /**
  132632. * Initialize defines for shader compilation
  132633. * @param mesh defines the mesh to be rendered
  132634. * @param nodeMaterial defines the node material requesting the update
  132635. * @param defines defines the material defines to update
  132636. * @param useInstances specifies that instances should be used
  132637. */
  132638. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132639. /**
  132640. * Update defines for shader compilation
  132641. * @param mesh defines the mesh to be rendered
  132642. * @param nodeMaterial defines the node material requesting the update
  132643. * @param defines defines the material defines to update
  132644. * @param useInstances specifies that instances should be used
  132645. */
  132646. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  132647. /**
  132648. * Lets the block try to connect some inputs automatically
  132649. * @param material defines the hosting NodeMaterial
  132650. */
  132651. autoConfigure(material: NodeMaterial): void;
  132652. /**
  132653. * Function called when a block is declared as repeatable content generator
  132654. * @param vertexShaderState defines the current compilation state for the vertex shader
  132655. * @param fragmentShaderState defines the current compilation state for the fragment shader
  132656. * @param mesh defines the mesh to be rendered
  132657. * @param defines defines the material defines to update
  132658. */
  132659. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  132660. /**
  132661. * Checks if the block is ready
  132662. * @param mesh defines the mesh to be rendered
  132663. * @param nodeMaterial defines the node material requesting the update
  132664. * @param defines defines the material defines to update
  132665. * @param useInstances specifies that instances should be used
  132666. * @returns true if the block is ready
  132667. */
  132668. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  132669. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  132670. private _processBuild;
  132671. /**
  132672. * Compile the current node and generate the shader code
  132673. * @param state defines the current compilation state (uniforms, samplers, current string)
  132674. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  132675. * @returns true if already built
  132676. */
  132677. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  132678. protected _inputRename(name: string): string;
  132679. protected _outputRename(name: string): string;
  132680. protected _dumpPropertiesCode(): string;
  132681. /** @hidden */
  132682. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  132683. /** @hidden */
  132684. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  132685. /**
  132686. * Clone the current block to a new identical block
  132687. * @param scene defines the hosting scene
  132688. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  132689. * @returns a copy of the current block
  132690. */
  132691. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  132692. /**
  132693. * Serializes this block in a JSON representation
  132694. * @returns the serialized block object
  132695. */
  132696. serialize(): any;
  132697. /** @hidden */
  132698. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132699. /**
  132700. * Release resources
  132701. */
  132702. dispose(): void;
  132703. }
  132704. }
  132705. declare module BABYLON {
  132706. /**
  132707. * Enum defining the type of animations supported by InputBlock
  132708. */
  132709. export enum AnimatedInputBlockTypes {
  132710. /** No animation */
  132711. None = 0,
  132712. /** Time based animation. Will only work for floats */
  132713. Time = 1
  132714. }
  132715. }
  132716. declare module BABYLON {
  132717. /**
  132718. * Block used to expose an input value
  132719. */
  132720. export class InputBlock extends NodeMaterialBlock {
  132721. private _mode;
  132722. private _associatedVariableName;
  132723. private _storedValue;
  132724. private _valueCallback;
  132725. private _type;
  132726. private _animationType;
  132727. /** Gets or set a value used to limit the range of float values */
  132728. min: number;
  132729. /** Gets or set a value used to limit the range of float values */
  132730. max: number;
  132731. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  132732. isBoolean: boolean;
  132733. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  132734. matrixMode: number;
  132735. /** @hidden */
  132736. _systemValue: Nullable<NodeMaterialSystemValues>;
  132737. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  132738. visibleInInspector: boolean;
  132739. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  132740. isConstant: boolean;
  132741. /** Gets or sets the group to use to display this block in the Inspector */
  132742. groupInInspector: string;
  132743. /** Gets an observable raised when the value is changed */
  132744. onValueChangedObservable: Observable<InputBlock>;
  132745. /**
  132746. * Gets or sets the connection point type (default is float)
  132747. */
  132748. get type(): NodeMaterialBlockConnectionPointTypes;
  132749. /**
  132750. * Creates a new InputBlock
  132751. * @param name defines the block name
  132752. * @param target defines the target of that block (Vertex by default)
  132753. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  132754. */
  132755. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  132756. /**
  132757. * Gets the output component
  132758. */
  132759. get output(): NodeMaterialConnectionPoint;
  132760. /**
  132761. * Set the source of this connection point to a vertex attribute
  132762. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  132763. * @returns the current connection point
  132764. */
  132765. setAsAttribute(attributeName?: string): InputBlock;
  132766. /**
  132767. * Set the source of this connection point to a system value
  132768. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  132769. * @returns the current connection point
  132770. */
  132771. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  132772. /**
  132773. * Gets or sets the value of that point.
  132774. * Please note that this value will be ignored if valueCallback is defined
  132775. */
  132776. get value(): any;
  132777. set value(value: any);
  132778. /**
  132779. * Gets or sets a callback used to get the value of that point.
  132780. * Please note that setting this value will force the connection point to ignore the value property
  132781. */
  132782. get valueCallback(): () => any;
  132783. set valueCallback(value: () => any);
  132784. /**
  132785. * Gets or sets the associated variable name in the shader
  132786. */
  132787. get associatedVariableName(): string;
  132788. set associatedVariableName(value: string);
  132789. /** Gets or sets the type of animation applied to the input */
  132790. get animationType(): AnimatedInputBlockTypes;
  132791. set animationType(value: AnimatedInputBlockTypes);
  132792. /**
  132793. * Gets a boolean indicating that this connection point not defined yet
  132794. */
  132795. get isUndefined(): boolean;
  132796. /**
  132797. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  132798. * In this case the connection point name must be the name of the uniform to use.
  132799. * Can only be set on inputs
  132800. */
  132801. get isUniform(): boolean;
  132802. set isUniform(value: boolean);
  132803. /**
  132804. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  132805. * In this case the connection point name must be the name of the attribute to use
  132806. * Can only be set on inputs
  132807. */
  132808. get isAttribute(): boolean;
  132809. set isAttribute(value: boolean);
  132810. /**
  132811. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  132812. * Can only be set on exit points
  132813. */
  132814. get isVarying(): boolean;
  132815. set isVarying(value: boolean);
  132816. /**
  132817. * Gets a boolean indicating that the current connection point is a system value
  132818. */
  132819. get isSystemValue(): boolean;
  132820. /**
  132821. * Gets or sets the current well known value or null if not defined as a system value
  132822. */
  132823. get systemValue(): Nullable<NodeMaterialSystemValues>;
  132824. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  132825. /**
  132826. * Gets the current class name
  132827. * @returns the class name
  132828. */
  132829. getClassName(): string;
  132830. /**
  132831. * Animate the input if animationType !== None
  132832. * @param scene defines the rendering scene
  132833. */
  132834. animate(scene: Scene): void;
  132835. private _emitDefine;
  132836. initialize(state: NodeMaterialBuildState): void;
  132837. /**
  132838. * Set the input block to its default value (based on its type)
  132839. */
  132840. setDefaultValue(): void;
  132841. private _emitConstant;
  132842. private _emit;
  132843. /** @hidden */
  132844. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  132845. /** @hidden */
  132846. _transmit(effect: Effect, scene: Scene): void;
  132847. protected _buildBlock(state: NodeMaterialBuildState): void;
  132848. protected _dumpPropertiesCode(): string;
  132849. dispose(): void;
  132850. serialize(): any;
  132851. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  132852. }
  132853. }
  132854. declare module BABYLON {
  132855. /**
  132856. * Enum used to define the compatibility state between two connection points
  132857. */
  132858. export enum NodeMaterialConnectionPointCompatibilityStates {
  132859. /** Points are compatibles */
  132860. Compatible = 0,
  132861. /** Points are incompatible because of their types */
  132862. TypeIncompatible = 1,
  132863. /** Points are incompatible because of their targets (vertex vs fragment) */
  132864. TargetIncompatible = 2
  132865. }
  132866. /**
  132867. * Defines the direction of a connection point
  132868. */
  132869. export enum NodeMaterialConnectionPointDirection {
  132870. /** Input */
  132871. Input = 0,
  132872. /** Output */
  132873. Output = 1
  132874. }
  132875. /**
  132876. * Defines a connection point for a block
  132877. */
  132878. export class NodeMaterialConnectionPoint {
  132879. /** @hidden */
  132880. _ownerBlock: NodeMaterialBlock;
  132881. /** @hidden */
  132882. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  132883. private _endpoints;
  132884. private _associatedVariableName;
  132885. private _direction;
  132886. /** @hidden */
  132887. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132888. /** @hidden */
  132889. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  132890. private _type;
  132891. /** @hidden */
  132892. _enforceAssociatedVariableName: boolean;
  132893. /** Gets the direction of the point */
  132894. get direction(): NodeMaterialConnectionPointDirection;
  132895. /**
  132896. * Gets or sets the additional types supported by this connection point
  132897. */
  132898. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132899. /**
  132900. * Gets or sets the additional types excluded by this connection point
  132901. */
  132902. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  132903. /**
  132904. * Observable triggered when this point is connected
  132905. */
  132906. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  132907. /**
  132908. * Gets or sets the associated variable name in the shader
  132909. */
  132910. get associatedVariableName(): string;
  132911. set associatedVariableName(value: string);
  132912. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  132913. get innerType(): NodeMaterialBlockConnectionPointTypes;
  132914. /**
  132915. * Gets or sets the connection point type (default is float)
  132916. */
  132917. get type(): NodeMaterialBlockConnectionPointTypes;
  132918. set type(value: NodeMaterialBlockConnectionPointTypes);
  132919. /**
  132920. * Gets or sets the connection point name
  132921. */
  132922. name: string;
  132923. /**
  132924. * Gets or sets a boolean indicating that this connection point can be omitted
  132925. */
  132926. isOptional: boolean;
  132927. /**
  132928. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  132929. */
  132930. define: string;
  132931. /** @hidden */
  132932. _prioritizeVertex: boolean;
  132933. private _target;
  132934. /** Gets or sets the target of that connection point */
  132935. get target(): NodeMaterialBlockTargets;
  132936. set target(value: NodeMaterialBlockTargets);
  132937. /**
  132938. * Gets a boolean indicating that the current point is connected
  132939. */
  132940. get isConnected(): boolean;
  132941. /**
  132942. * Gets a boolean indicating that the current point is connected to an input block
  132943. */
  132944. get isConnectedToInputBlock(): boolean;
  132945. /**
  132946. * Gets a the connected input block (if any)
  132947. */
  132948. get connectInputBlock(): Nullable<InputBlock>;
  132949. /** Get the other side of the connection (if any) */
  132950. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  132951. /** Get the block that owns this connection point */
  132952. get ownerBlock(): NodeMaterialBlock;
  132953. /** Get the block connected on the other side of this connection (if any) */
  132954. get sourceBlock(): Nullable<NodeMaterialBlock>;
  132955. /** Get the block connected on the endpoints of this connection (if any) */
  132956. get connectedBlocks(): Array<NodeMaterialBlock>;
  132957. /** Gets the list of connected endpoints */
  132958. get endpoints(): NodeMaterialConnectionPoint[];
  132959. /** Gets a boolean indicating if that output point is connected to at least one input */
  132960. get hasEndpoints(): boolean;
  132961. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  132962. get isConnectedInVertexShader(): boolean;
  132963. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  132964. get isConnectedInFragmentShader(): boolean;
  132965. /**
  132966. * Creates a new connection point
  132967. * @param name defines the connection point name
  132968. * @param ownerBlock defines the block hosting this connection point
  132969. * @param direction defines the direction of the connection point
  132970. */
  132971. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  132972. /**
  132973. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  132974. * @returns the class name
  132975. */
  132976. getClassName(): string;
  132977. /**
  132978. * Gets a boolean indicating if the current point can be connected to another point
  132979. * @param connectionPoint defines the other connection point
  132980. * @returns a boolean
  132981. */
  132982. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  132983. /**
  132984. * Gets a number indicating if the current point can be connected to another point
  132985. * @param connectionPoint defines the other connection point
  132986. * @returns a number defining the compatibility state
  132987. */
  132988. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  132989. /**
  132990. * Connect this point to another connection point
  132991. * @param connectionPoint defines the other connection point
  132992. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  132993. * @returns the current connection point
  132994. */
  132995. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  132996. /**
  132997. * Disconnect this point from one of his endpoint
  132998. * @param endpoint defines the other connection point
  132999. * @returns the current connection point
  133000. */
  133001. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  133002. /**
  133003. * Serializes this point in a JSON representation
  133004. * @returns the serialized point object
  133005. */
  133006. serialize(): any;
  133007. /**
  133008. * Release resources
  133009. */
  133010. dispose(): void;
  133011. }
  133012. }
  133013. declare module BABYLON {
  133014. /**
  133015. * Block used to add support for vertex skinning (bones)
  133016. */
  133017. export class BonesBlock extends NodeMaterialBlock {
  133018. /**
  133019. * Creates a new BonesBlock
  133020. * @param name defines the block name
  133021. */
  133022. constructor(name: string);
  133023. /**
  133024. * Initialize the block and prepare the context for build
  133025. * @param state defines the state that will be used for the build
  133026. */
  133027. initialize(state: NodeMaterialBuildState): void;
  133028. /**
  133029. * Gets the current class name
  133030. * @returns the class name
  133031. */
  133032. getClassName(): string;
  133033. /**
  133034. * Gets the matrix indices input component
  133035. */
  133036. get matricesIndices(): NodeMaterialConnectionPoint;
  133037. /**
  133038. * Gets the matrix weights input component
  133039. */
  133040. get matricesWeights(): NodeMaterialConnectionPoint;
  133041. /**
  133042. * Gets the extra matrix indices input component
  133043. */
  133044. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  133045. /**
  133046. * Gets the extra matrix weights input component
  133047. */
  133048. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  133049. /**
  133050. * Gets the world input component
  133051. */
  133052. get world(): NodeMaterialConnectionPoint;
  133053. /**
  133054. * Gets the output component
  133055. */
  133056. get output(): NodeMaterialConnectionPoint;
  133057. autoConfigure(material: NodeMaterial): void;
  133058. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  133059. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133060. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133061. protected _buildBlock(state: NodeMaterialBuildState): this;
  133062. }
  133063. }
  133064. declare module BABYLON {
  133065. /**
  133066. * Block used to add support for instances
  133067. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  133068. */
  133069. export class InstancesBlock extends NodeMaterialBlock {
  133070. /**
  133071. * Creates a new InstancesBlock
  133072. * @param name defines the block name
  133073. */
  133074. constructor(name: string);
  133075. /**
  133076. * Gets the current class name
  133077. * @returns the class name
  133078. */
  133079. getClassName(): string;
  133080. /**
  133081. * Gets the first world row input component
  133082. */
  133083. get world0(): NodeMaterialConnectionPoint;
  133084. /**
  133085. * Gets the second world row input component
  133086. */
  133087. get world1(): NodeMaterialConnectionPoint;
  133088. /**
  133089. * Gets the third world row input component
  133090. */
  133091. get world2(): NodeMaterialConnectionPoint;
  133092. /**
  133093. * Gets the forth world row input component
  133094. */
  133095. get world3(): NodeMaterialConnectionPoint;
  133096. /**
  133097. * Gets the world input component
  133098. */
  133099. get world(): NodeMaterialConnectionPoint;
  133100. /**
  133101. * Gets the output component
  133102. */
  133103. get output(): NodeMaterialConnectionPoint;
  133104. /**
  133105. * Gets the isntanceID component
  133106. */
  133107. get instanceID(): NodeMaterialConnectionPoint;
  133108. autoConfigure(material: NodeMaterial): void;
  133109. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  133110. protected _buildBlock(state: NodeMaterialBuildState): this;
  133111. }
  133112. }
  133113. declare module BABYLON {
  133114. /**
  133115. * Block used to add morph targets support to vertex shader
  133116. */
  133117. export class MorphTargetsBlock extends NodeMaterialBlock {
  133118. private _repeatableContentAnchor;
  133119. /**
  133120. * Create a new MorphTargetsBlock
  133121. * @param name defines the block name
  133122. */
  133123. constructor(name: string);
  133124. /**
  133125. * Gets the current class name
  133126. * @returns the class name
  133127. */
  133128. getClassName(): string;
  133129. /**
  133130. * Gets the position input component
  133131. */
  133132. get position(): NodeMaterialConnectionPoint;
  133133. /**
  133134. * Gets the normal input component
  133135. */
  133136. get normal(): NodeMaterialConnectionPoint;
  133137. /**
  133138. * Gets the tangent input component
  133139. */
  133140. get tangent(): NodeMaterialConnectionPoint;
  133141. /**
  133142. * Gets the tangent input component
  133143. */
  133144. get uv(): NodeMaterialConnectionPoint;
  133145. /**
  133146. * Gets the position output component
  133147. */
  133148. get positionOutput(): NodeMaterialConnectionPoint;
  133149. /**
  133150. * Gets the normal output component
  133151. */
  133152. get normalOutput(): NodeMaterialConnectionPoint;
  133153. /**
  133154. * Gets the tangent output component
  133155. */
  133156. get tangentOutput(): NodeMaterialConnectionPoint;
  133157. /**
  133158. * Gets the tangent output component
  133159. */
  133160. get uvOutput(): NodeMaterialConnectionPoint;
  133161. initialize(state: NodeMaterialBuildState): void;
  133162. autoConfigure(material: NodeMaterial): void;
  133163. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133164. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133165. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  133166. protected _buildBlock(state: NodeMaterialBuildState): this;
  133167. }
  133168. }
  133169. declare module BABYLON {
  133170. /**
  133171. * Block used to get data information from a light
  133172. */
  133173. export class LightInformationBlock extends NodeMaterialBlock {
  133174. private _lightDataUniformName;
  133175. private _lightColorUniformName;
  133176. private _lightTypeDefineName;
  133177. /**
  133178. * Gets or sets the light associated with this block
  133179. */
  133180. light: Nullable<Light>;
  133181. /**
  133182. * Creates a new LightInformationBlock
  133183. * @param name defines the block name
  133184. */
  133185. constructor(name: string);
  133186. /**
  133187. * Gets the current class name
  133188. * @returns the class name
  133189. */
  133190. getClassName(): string;
  133191. /**
  133192. * Gets the world position input component
  133193. */
  133194. get worldPosition(): NodeMaterialConnectionPoint;
  133195. /**
  133196. * Gets the direction output component
  133197. */
  133198. get direction(): NodeMaterialConnectionPoint;
  133199. /**
  133200. * Gets the direction output component
  133201. */
  133202. get color(): NodeMaterialConnectionPoint;
  133203. /**
  133204. * Gets the direction output component
  133205. */
  133206. get intensity(): NodeMaterialConnectionPoint;
  133207. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133208. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133209. protected _buildBlock(state: NodeMaterialBuildState): this;
  133210. serialize(): any;
  133211. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133212. }
  133213. }
  133214. declare module BABYLON {
  133215. /**
  133216. * Block used to add image processing support to fragment shader
  133217. */
  133218. export class ImageProcessingBlock extends NodeMaterialBlock {
  133219. /**
  133220. * Create a new ImageProcessingBlock
  133221. * @param name defines the block name
  133222. */
  133223. constructor(name: string);
  133224. /**
  133225. * Gets the current class name
  133226. * @returns the class name
  133227. */
  133228. getClassName(): string;
  133229. /**
  133230. * Gets the color input component
  133231. */
  133232. get color(): NodeMaterialConnectionPoint;
  133233. /**
  133234. * Gets the output component
  133235. */
  133236. get output(): NodeMaterialConnectionPoint;
  133237. /**
  133238. * Initialize the block and prepare the context for build
  133239. * @param state defines the state that will be used for the build
  133240. */
  133241. initialize(state: NodeMaterialBuildState): void;
  133242. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  133243. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133244. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133245. protected _buildBlock(state: NodeMaterialBuildState): this;
  133246. }
  133247. }
  133248. declare module BABYLON {
  133249. /**
  133250. * Block used to pertub normals based on a normal map
  133251. */
  133252. export class PerturbNormalBlock extends NodeMaterialBlock {
  133253. private _tangentSpaceParameterName;
  133254. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  133255. invertX: boolean;
  133256. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  133257. invertY: boolean;
  133258. /**
  133259. * Create a new PerturbNormalBlock
  133260. * @param name defines the block name
  133261. */
  133262. constructor(name: string);
  133263. /**
  133264. * Gets the current class name
  133265. * @returns the class name
  133266. */
  133267. getClassName(): string;
  133268. /**
  133269. * Gets the world position input component
  133270. */
  133271. get worldPosition(): NodeMaterialConnectionPoint;
  133272. /**
  133273. * Gets the world normal input component
  133274. */
  133275. get worldNormal(): NodeMaterialConnectionPoint;
  133276. /**
  133277. * Gets the world tangent input component
  133278. */
  133279. get worldTangent(): NodeMaterialConnectionPoint;
  133280. /**
  133281. * Gets the uv input component
  133282. */
  133283. get uv(): NodeMaterialConnectionPoint;
  133284. /**
  133285. * Gets the normal map color input component
  133286. */
  133287. get normalMapColor(): NodeMaterialConnectionPoint;
  133288. /**
  133289. * Gets the strength input component
  133290. */
  133291. get strength(): NodeMaterialConnectionPoint;
  133292. /**
  133293. * Gets the output component
  133294. */
  133295. get output(): NodeMaterialConnectionPoint;
  133296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133298. autoConfigure(material: NodeMaterial): void;
  133299. protected _buildBlock(state: NodeMaterialBuildState): this;
  133300. protected _dumpPropertiesCode(): string;
  133301. serialize(): any;
  133302. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133303. }
  133304. }
  133305. declare module BABYLON {
  133306. /**
  133307. * Block used to discard a pixel if a value is smaller than a cutoff
  133308. */
  133309. export class DiscardBlock extends NodeMaterialBlock {
  133310. /**
  133311. * Create a new DiscardBlock
  133312. * @param name defines the block name
  133313. */
  133314. constructor(name: string);
  133315. /**
  133316. * Gets the current class name
  133317. * @returns the class name
  133318. */
  133319. getClassName(): string;
  133320. /**
  133321. * Gets the color input component
  133322. */
  133323. get value(): NodeMaterialConnectionPoint;
  133324. /**
  133325. * Gets the cutoff input component
  133326. */
  133327. get cutoff(): NodeMaterialConnectionPoint;
  133328. protected _buildBlock(state: NodeMaterialBuildState): this;
  133329. }
  133330. }
  133331. declare module BABYLON {
  133332. /**
  133333. * Block used to test if the fragment shader is front facing
  133334. */
  133335. export class FrontFacingBlock extends NodeMaterialBlock {
  133336. /**
  133337. * Creates a new FrontFacingBlock
  133338. * @param name defines the block name
  133339. */
  133340. constructor(name: string);
  133341. /**
  133342. * Gets the current class name
  133343. * @returns the class name
  133344. */
  133345. getClassName(): string;
  133346. /**
  133347. * Gets the output component
  133348. */
  133349. get output(): NodeMaterialConnectionPoint;
  133350. protected _buildBlock(state: NodeMaterialBuildState): this;
  133351. }
  133352. }
  133353. declare module BABYLON {
  133354. /**
  133355. * Block used to get the derivative value on x and y of a given input
  133356. */
  133357. export class DerivativeBlock extends NodeMaterialBlock {
  133358. /**
  133359. * Create a new DerivativeBlock
  133360. * @param name defines the block name
  133361. */
  133362. constructor(name: string);
  133363. /**
  133364. * Gets the current class name
  133365. * @returns the class name
  133366. */
  133367. getClassName(): string;
  133368. /**
  133369. * Gets the input component
  133370. */
  133371. get input(): NodeMaterialConnectionPoint;
  133372. /**
  133373. * Gets the derivative output on x
  133374. */
  133375. get dx(): NodeMaterialConnectionPoint;
  133376. /**
  133377. * Gets the derivative output on y
  133378. */
  133379. get dy(): NodeMaterialConnectionPoint;
  133380. protected _buildBlock(state: NodeMaterialBuildState): this;
  133381. }
  133382. }
  133383. declare module BABYLON {
  133384. /**
  133385. * Block used to add support for scene fog
  133386. */
  133387. export class FogBlock extends NodeMaterialBlock {
  133388. private _fogDistanceName;
  133389. private _fogParameters;
  133390. /**
  133391. * Create a new FogBlock
  133392. * @param name defines the block name
  133393. */
  133394. constructor(name: string);
  133395. /**
  133396. * Gets the current class name
  133397. * @returns the class name
  133398. */
  133399. getClassName(): string;
  133400. /**
  133401. * Gets the world position input component
  133402. */
  133403. get worldPosition(): NodeMaterialConnectionPoint;
  133404. /**
  133405. * Gets the view input component
  133406. */
  133407. get view(): NodeMaterialConnectionPoint;
  133408. /**
  133409. * Gets the color input component
  133410. */
  133411. get input(): NodeMaterialConnectionPoint;
  133412. /**
  133413. * Gets the fog color input component
  133414. */
  133415. get fogColor(): NodeMaterialConnectionPoint;
  133416. /**
  133417. * Gets the output component
  133418. */
  133419. get output(): NodeMaterialConnectionPoint;
  133420. autoConfigure(material: NodeMaterial): void;
  133421. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133422. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133423. protected _buildBlock(state: NodeMaterialBuildState): this;
  133424. }
  133425. }
  133426. declare module BABYLON {
  133427. /**
  133428. * Block used to add light in the fragment shader
  133429. */
  133430. export class LightBlock extends NodeMaterialBlock {
  133431. private _lightId;
  133432. /**
  133433. * Gets or sets the light associated with this block
  133434. */
  133435. light: Nullable<Light>;
  133436. /**
  133437. * Create a new LightBlock
  133438. * @param name defines the block name
  133439. */
  133440. constructor(name: string);
  133441. /**
  133442. * Gets the current class name
  133443. * @returns the class name
  133444. */
  133445. getClassName(): string;
  133446. /**
  133447. * Gets the world position input component
  133448. */
  133449. get worldPosition(): NodeMaterialConnectionPoint;
  133450. /**
  133451. * Gets the world normal input component
  133452. */
  133453. get worldNormal(): NodeMaterialConnectionPoint;
  133454. /**
  133455. * Gets the camera (or eye) position component
  133456. */
  133457. get cameraPosition(): NodeMaterialConnectionPoint;
  133458. /**
  133459. * Gets the glossiness component
  133460. */
  133461. get glossiness(): NodeMaterialConnectionPoint;
  133462. /**
  133463. * Gets the glossinness power component
  133464. */
  133465. get glossPower(): NodeMaterialConnectionPoint;
  133466. /**
  133467. * Gets the diffuse color component
  133468. */
  133469. get diffuseColor(): NodeMaterialConnectionPoint;
  133470. /**
  133471. * Gets the specular color component
  133472. */
  133473. get specularColor(): NodeMaterialConnectionPoint;
  133474. /**
  133475. * Gets the diffuse output component
  133476. */
  133477. get diffuseOutput(): NodeMaterialConnectionPoint;
  133478. /**
  133479. * Gets the specular output component
  133480. */
  133481. get specularOutput(): NodeMaterialConnectionPoint;
  133482. /**
  133483. * Gets the shadow output component
  133484. */
  133485. get shadow(): NodeMaterialConnectionPoint;
  133486. autoConfigure(material: NodeMaterial): void;
  133487. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  133488. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  133489. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  133490. private _injectVertexCode;
  133491. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133492. serialize(): any;
  133493. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133494. }
  133495. }
  133496. declare module BABYLON {
  133497. /**
  133498. * Block used to multiply 2 values
  133499. */
  133500. export class MultiplyBlock extends NodeMaterialBlock {
  133501. /**
  133502. * Creates a new MultiplyBlock
  133503. * @param name defines the block name
  133504. */
  133505. constructor(name: string);
  133506. /**
  133507. * Gets the current class name
  133508. * @returns the class name
  133509. */
  133510. getClassName(): string;
  133511. /**
  133512. * Gets the left operand input component
  133513. */
  133514. get left(): NodeMaterialConnectionPoint;
  133515. /**
  133516. * Gets the right operand input component
  133517. */
  133518. get right(): NodeMaterialConnectionPoint;
  133519. /**
  133520. * Gets the output component
  133521. */
  133522. get output(): NodeMaterialConnectionPoint;
  133523. protected _buildBlock(state: NodeMaterialBuildState): this;
  133524. }
  133525. }
  133526. declare module BABYLON {
  133527. /**
  133528. * Block used to add 2 vectors
  133529. */
  133530. export class AddBlock extends NodeMaterialBlock {
  133531. /**
  133532. * Creates a new AddBlock
  133533. * @param name defines the block name
  133534. */
  133535. constructor(name: string);
  133536. /**
  133537. * Gets the current class name
  133538. * @returns the class name
  133539. */
  133540. getClassName(): string;
  133541. /**
  133542. * Gets the left operand input component
  133543. */
  133544. get left(): NodeMaterialConnectionPoint;
  133545. /**
  133546. * Gets the right operand input component
  133547. */
  133548. get right(): NodeMaterialConnectionPoint;
  133549. /**
  133550. * Gets the output component
  133551. */
  133552. get output(): NodeMaterialConnectionPoint;
  133553. protected _buildBlock(state: NodeMaterialBuildState): this;
  133554. }
  133555. }
  133556. declare module BABYLON {
  133557. /**
  133558. * Block used to scale a vector by a float
  133559. */
  133560. export class ScaleBlock extends NodeMaterialBlock {
  133561. /**
  133562. * Creates a new ScaleBlock
  133563. * @param name defines the block name
  133564. */
  133565. constructor(name: string);
  133566. /**
  133567. * Gets the current class name
  133568. * @returns the class name
  133569. */
  133570. getClassName(): string;
  133571. /**
  133572. * Gets the input component
  133573. */
  133574. get input(): NodeMaterialConnectionPoint;
  133575. /**
  133576. * Gets the factor input component
  133577. */
  133578. get factor(): NodeMaterialConnectionPoint;
  133579. /**
  133580. * Gets the output component
  133581. */
  133582. get output(): NodeMaterialConnectionPoint;
  133583. protected _buildBlock(state: NodeMaterialBuildState): this;
  133584. }
  133585. }
  133586. declare module BABYLON {
  133587. /**
  133588. * Block used to clamp a float
  133589. */
  133590. export class ClampBlock extends NodeMaterialBlock {
  133591. /** Gets or sets the minimum range */
  133592. minimum: number;
  133593. /** Gets or sets the maximum range */
  133594. maximum: number;
  133595. /**
  133596. * Creates a new ClampBlock
  133597. * @param name defines the block name
  133598. */
  133599. constructor(name: string);
  133600. /**
  133601. * Gets the current class name
  133602. * @returns the class name
  133603. */
  133604. getClassName(): string;
  133605. /**
  133606. * Gets the value input component
  133607. */
  133608. get value(): NodeMaterialConnectionPoint;
  133609. /**
  133610. * Gets the output component
  133611. */
  133612. get output(): NodeMaterialConnectionPoint;
  133613. protected _buildBlock(state: NodeMaterialBuildState): this;
  133614. protected _dumpPropertiesCode(): string;
  133615. serialize(): any;
  133616. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133617. }
  133618. }
  133619. declare module BABYLON {
  133620. /**
  133621. * Block used to apply a cross product between 2 vectors
  133622. */
  133623. export class CrossBlock extends NodeMaterialBlock {
  133624. /**
  133625. * Creates a new CrossBlock
  133626. * @param name defines the block name
  133627. */
  133628. constructor(name: string);
  133629. /**
  133630. * Gets the current class name
  133631. * @returns the class name
  133632. */
  133633. getClassName(): string;
  133634. /**
  133635. * Gets the left operand input component
  133636. */
  133637. get left(): NodeMaterialConnectionPoint;
  133638. /**
  133639. * Gets the right operand input component
  133640. */
  133641. get right(): NodeMaterialConnectionPoint;
  133642. /**
  133643. * Gets the output component
  133644. */
  133645. get output(): NodeMaterialConnectionPoint;
  133646. protected _buildBlock(state: NodeMaterialBuildState): this;
  133647. }
  133648. }
  133649. declare module BABYLON {
  133650. /**
  133651. * Block used to apply a dot product between 2 vectors
  133652. */
  133653. export class DotBlock extends NodeMaterialBlock {
  133654. /**
  133655. * Creates a new DotBlock
  133656. * @param name defines the block name
  133657. */
  133658. constructor(name: string);
  133659. /**
  133660. * Gets the current class name
  133661. * @returns the class name
  133662. */
  133663. getClassName(): string;
  133664. /**
  133665. * Gets the left operand input component
  133666. */
  133667. get left(): NodeMaterialConnectionPoint;
  133668. /**
  133669. * Gets the right operand input component
  133670. */
  133671. get right(): NodeMaterialConnectionPoint;
  133672. /**
  133673. * Gets the output component
  133674. */
  133675. get output(): NodeMaterialConnectionPoint;
  133676. protected _buildBlock(state: NodeMaterialBuildState): this;
  133677. }
  133678. }
  133679. declare module BABYLON {
  133680. /**
  133681. * Block used to remap a float from a range to a new one
  133682. */
  133683. export class RemapBlock extends NodeMaterialBlock {
  133684. /**
  133685. * Gets or sets the source range
  133686. */
  133687. sourceRange: Vector2;
  133688. /**
  133689. * Gets or sets the target range
  133690. */
  133691. targetRange: Vector2;
  133692. /**
  133693. * Creates a new RemapBlock
  133694. * @param name defines the block name
  133695. */
  133696. constructor(name: string);
  133697. /**
  133698. * Gets the current class name
  133699. * @returns the class name
  133700. */
  133701. getClassName(): string;
  133702. /**
  133703. * Gets the input component
  133704. */
  133705. get input(): NodeMaterialConnectionPoint;
  133706. /**
  133707. * Gets the source min input component
  133708. */
  133709. get sourceMin(): NodeMaterialConnectionPoint;
  133710. /**
  133711. * Gets the source max input component
  133712. */
  133713. get sourceMax(): NodeMaterialConnectionPoint;
  133714. /**
  133715. * Gets the target min input component
  133716. */
  133717. get targetMin(): NodeMaterialConnectionPoint;
  133718. /**
  133719. * Gets the target max input component
  133720. */
  133721. get targetMax(): NodeMaterialConnectionPoint;
  133722. /**
  133723. * Gets the output component
  133724. */
  133725. get output(): NodeMaterialConnectionPoint;
  133726. protected _buildBlock(state: NodeMaterialBuildState): this;
  133727. protected _dumpPropertiesCode(): string;
  133728. serialize(): any;
  133729. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133730. }
  133731. }
  133732. declare module BABYLON {
  133733. /**
  133734. * Block used to normalize a vector
  133735. */
  133736. export class NormalizeBlock extends NodeMaterialBlock {
  133737. /**
  133738. * Creates a new NormalizeBlock
  133739. * @param name defines the block name
  133740. */
  133741. constructor(name: string);
  133742. /**
  133743. * Gets the current class name
  133744. * @returns the class name
  133745. */
  133746. getClassName(): string;
  133747. /**
  133748. * Gets the input component
  133749. */
  133750. get input(): NodeMaterialConnectionPoint;
  133751. /**
  133752. * Gets the output component
  133753. */
  133754. get output(): NodeMaterialConnectionPoint;
  133755. protected _buildBlock(state: NodeMaterialBuildState): this;
  133756. }
  133757. }
  133758. declare module BABYLON {
  133759. /**
  133760. * Operations supported by the Trigonometry block
  133761. */
  133762. export enum TrigonometryBlockOperations {
  133763. /** Cos */
  133764. Cos = 0,
  133765. /** Sin */
  133766. Sin = 1,
  133767. /** Abs */
  133768. Abs = 2,
  133769. /** Exp */
  133770. Exp = 3,
  133771. /** Exp2 */
  133772. Exp2 = 4,
  133773. /** Round */
  133774. Round = 5,
  133775. /** Floor */
  133776. Floor = 6,
  133777. /** Ceiling */
  133778. Ceiling = 7,
  133779. /** Square root */
  133780. Sqrt = 8,
  133781. /** Log */
  133782. Log = 9,
  133783. /** Tangent */
  133784. Tan = 10,
  133785. /** Arc tangent */
  133786. ArcTan = 11,
  133787. /** Arc cosinus */
  133788. ArcCos = 12,
  133789. /** Arc sinus */
  133790. ArcSin = 13,
  133791. /** Fraction */
  133792. Fract = 14,
  133793. /** Sign */
  133794. Sign = 15,
  133795. /** To radians (from degrees) */
  133796. Radians = 16,
  133797. /** To degrees (from radians) */
  133798. Degrees = 17
  133799. }
  133800. /**
  133801. * Block used to apply trigonometry operation to floats
  133802. */
  133803. export class TrigonometryBlock extends NodeMaterialBlock {
  133804. /**
  133805. * Gets or sets the operation applied by the block
  133806. */
  133807. operation: TrigonometryBlockOperations;
  133808. /**
  133809. * Creates a new TrigonometryBlock
  133810. * @param name defines the block name
  133811. */
  133812. constructor(name: string);
  133813. /**
  133814. * Gets the current class name
  133815. * @returns the class name
  133816. */
  133817. getClassName(): string;
  133818. /**
  133819. * Gets the input component
  133820. */
  133821. get input(): NodeMaterialConnectionPoint;
  133822. /**
  133823. * Gets the output component
  133824. */
  133825. get output(): NodeMaterialConnectionPoint;
  133826. protected _buildBlock(state: NodeMaterialBuildState): this;
  133827. serialize(): any;
  133828. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  133829. protected _dumpPropertiesCode(): string;
  133830. }
  133831. }
  133832. declare module BABYLON {
  133833. /**
  133834. * Block used to create a Color3/4 out of individual inputs (one for each component)
  133835. */
  133836. export class ColorMergerBlock extends NodeMaterialBlock {
  133837. /**
  133838. * Create a new ColorMergerBlock
  133839. * @param name defines the block name
  133840. */
  133841. constructor(name: string);
  133842. /**
  133843. * Gets the current class name
  133844. * @returns the class name
  133845. */
  133846. getClassName(): string;
  133847. /**
  133848. * Gets the rgb component (input)
  133849. */
  133850. get rgbIn(): NodeMaterialConnectionPoint;
  133851. /**
  133852. * Gets the r component (input)
  133853. */
  133854. get r(): NodeMaterialConnectionPoint;
  133855. /**
  133856. * Gets the g component (input)
  133857. */
  133858. get g(): NodeMaterialConnectionPoint;
  133859. /**
  133860. * Gets the b component (input)
  133861. */
  133862. get b(): NodeMaterialConnectionPoint;
  133863. /**
  133864. * Gets the a component (input)
  133865. */
  133866. get a(): NodeMaterialConnectionPoint;
  133867. /**
  133868. * Gets the rgba component (output)
  133869. */
  133870. get rgba(): NodeMaterialConnectionPoint;
  133871. /**
  133872. * Gets the rgb component (output)
  133873. */
  133874. get rgbOut(): NodeMaterialConnectionPoint;
  133875. /**
  133876. * Gets the rgb component (output)
  133877. * @deprecated Please use rgbOut instead.
  133878. */
  133879. get rgb(): NodeMaterialConnectionPoint;
  133880. protected _buildBlock(state: NodeMaterialBuildState): this;
  133881. }
  133882. }
  133883. declare module BABYLON {
  133884. /**
  133885. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  133886. */
  133887. export class VectorMergerBlock extends NodeMaterialBlock {
  133888. /**
  133889. * Create a new VectorMergerBlock
  133890. * @param name defines the block name
  133891. */
  133892. constructor(name: string);
  133893. /**
  133894. * Gets the current class name
  133895. * @returns the class name
  133896. */
  133897. getClassName(): string;
  133898. /**
  133899. * Gets the xyz component (input)
  133900. */
  133901. get xyzIn(): NodeMaterialConnectionPoint;
  133902. /**
  133903. * Gets the xy component (input)
  133904. */
  133905. get xyIn(): NodeMaterialConnectionPoint;
  133906. /**
  133907. * Gets the x component (input)
  133908. */
  133909. get x(): NodeMaterialConnectionPoint;
  133910. /**
  133911. * Gets the y component (input)
  133912. */
  133913. get y(): NodeMaterialConnectionPoint;
  133914. /**
  133915. * Gets the z component (input)
  133916. */
  133917. get z(): NodeMaterialConnectionPoint;
  133918. /**
  133919. * Gets the w component (input)
  133920. */
  133921. get w(): NodeMaterialConnectionPoint;
  133922. /**
  133923. * Gets the xyzw component (output)
  133924. */
  133925. get xyzw(): NodeMaterialConnectionPoint;
  133926. /**
  133927. * Gets the xyz component (output)
  133928. */
  133929. get xyzOut(): NodeMaterialConnectionPoint;
  133930. /**
  133931. * Gets the xy component (output)
  133932. */
  133933. get xyOut(): NodeMaterialConnectionPoint;
  133934. /**
  133935. * Gets the xy component (output)
  133936. * @deprecated Please use xyOut instead.
  133937. */
  133938. get xy(): NodeMaterialConnectionPoint;
  133939. /**
  133940. * Gets the xyz component (output)
  133941. * @deprecated Please use xyzOut instead.
  133942. */
  133943. get xyz(): NodeMaterialConnectionPoint;
  133944. protected _buildBlock(state: NodeMaterialBuildState): this;
  133945. }
  133946. }
  133947. declare module BABYLON {
  133948. /**
  133949. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  133950. */
  133951. export class ColorSplitterBlock extends NodeMaterialBlock {
  133952. /**
  133953. * Create a new ColorSplitterBlock
  133954. * @param name defines the block name
  133955. */
  133956. constructor(name: string);
  133957. /**
  133958. * Gets the current class name
  133959. * @returns the class name
  133960. */
  133961. getClassName(): string;
  133962. /**
  133963. * Gets the rgba component (input)
  133964. */
  133965. get rgba(): NodeMaterialConnectionPoint;
  133966. /**
  133967. * Gets the rgb component (input)
  133968. */
  133969. get rgbIn(): NodeMaterialConnectionPoint;
  133970. /**
  133971. * Gets the rgb component (output)
  133972. */
  133973. get rgbOut(): NodeMaterialConnectionPoint;
  133974. /**
  133975. * Gets the r component (output)
  133976. */
  133977. get r(): NodeMaterialConnectionPoint;
  133978. /**
  133979. * Gets the g component (output)
  133980. */
  133981. get g(): NodeMaterialConnectionPoint;
  133982. /**
  133983. * Gets the b component (output)
  133984. */
  133985. get b(): NodeMaterialConnectionPoint;
  133986. /**
  133987. * Gets the a component (output)
  133988. */
  133989. get a(): NodeMaterialConnectionPoint;
  133990. protected _inputRename(name: string): string;
  133991. protected _outputRename(name: string): string;
  133992. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  133993. }
  133994. }
  133995. declare module BABYLON {
  133996. /**
  133997. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  133998. */
  133999. export class VectorSplitterBlock extends NodeMaterialBlock {
  134000. /**
  134001. * Create a new VectorSplitterBlock
  134002. * @param name defines the block name
  134003. */
  134004. constructor(name: string);
  134005. /**
  134006. * Gets the current class name
  134007. * @returns the class name
  134008. */
  134009. getClassName(): string;
  134010. /**
  134011. * Gets the xyzw component (input)
  134012. */
  134013. get xyzw(): NodeMaterialConnectionPoint;
  134014. /**
  134015. * Gets the xyz component (input)
  134016. */
  134017. get xyzIn(): NodeMaterialConnectionPoint;
  134018. /**
  134019. * Gets the xy component (input)
  134020. */
  134021. get xyIn(): NodeMaterialConnectionPoint;
  134022. /**
  134023. * Gets the xyz component (output)
  134024. */
  134025. get xyzOut(): NodeMaterialConnectionPoint;
  134026. /**
  134027. * Gets the xy component (output)
  134028. */
  134029. get xyOut(): NodeMaterialConnectionPoint;
  134030. /**
  134031. * Gets the x component (output)
  134032. */
  134033. get x(): NodeMaterialConnectionPoint;
  134034. /**
  134035. * Gets the y component (output)
  134036. */
  134037. get y(): NodeMaterialConnectionPoint;
  134038. /**
  134039. * Gets the z component (output)
  134040. */
  134041. get z(): NodeMaterialConnectionPoint;
  134042. /**
  134043. * Gets the w component (output)
  134044. */
  134045. get w(): NodeMaterialConnectionPoint;
  134046. protected _inputRename(name: string): string;
  134047. protected _outputRename(name: string): string;
  134048. protected _buildBlock(state: NodeMaterialBuildState): this;
  134049. }
  134050. }
  134051. declare module BABYLON {
  134052. /**
  134053. * Block used to lerp between 2 values
  134054. */
  134055. export class LerpBlock extends NodeMaterialBlock {
  134056. /**
  134057. * Creates a new LerpBlock
  134058. * @param name defines the block name
  134059. */
  134060. constructor(name: string);
  134061. /**
  134062. * Gets the current class name
  134063. * @returns the class name
  134064. */
  134065. getClassName(): string;
  134066. /**
  134067. * Gets the left operand input component
  134068. */
  134069. get left(): NodeMaterialConnectionPoint;
  134070. /**
  134071. * Gets the right operand input component
  134072. */
  134073. get right(): NodeMaterialConnectionPoint;
  134074. /**
  134075. * Gets the gradient operand input component
  134076. */
  134077. get gradient(): NodeMaterialConnectionPoint;
  134078. /**
  134079. * Gets the output component
  134080. */
  134081. get output(): NodeMaterialConnectionPoint;
  134082. protected _buildBlock(state: NodeMaterialBuildState): this;
  134083. }
  134084. }
  134085. declare module BABYLON {
  134086. /**
  134087. * Block used to divide 2 vectors
  134088. */
  134089. export class DivideBlock extends NodeMaterialBlock {
  134090. /**
  134091. * Creates a new DivideBlock
  134092. * @param name defines the block name
  134093. */
  134094. constructor(name: string);
  134095. /**
  134096. * Gets the current class name
  134097. * @returns the class name
  134098. */
  134099. getClassName(): string;
  134100. /**
  134101. * Gets the left operand input component
  134102. */
  134103. get left(): NodeMaterialConnectionPoint;
  134104. /**
  134105. * Gets the right operand input component
  134106. */
  134107. get right(): NodeMaterialConnectionPoint;
  134108. /**
  134109. * Gets the output component
  134110. */
  134111. get output(): NodeMaterialConnectionPoint;
  134112. protected _buildBlock(state: NodeMaterialBuildState): this;
  134113. }
  134114. }
  134115. declare module BABYLON {
  134116. /**
  134117. * Block used to subtract 2 vectors
  134118. */
  134119. export class SubtractBlock extends NodeMaterialBlock {
  134120. /**
  134121. * Creates a new SubtractBlock
  134122. * @param name defines the block name
  134123. */
  134124. constructor(name: string);
  134125. /**
  134126. * Gets the current class name
  134127. * @returns the class name
  134128. */
  134129. getClassName(): string;
  134130. /**
  134131. * Gets the left operand input component
  134132. */
  134133. get left(): NodeMaterialConnectionPoint;
  134134. /**
  134135. * Gets the right operand input component
  134136. */
  134137. get right(): NodeMaterialConnectionPoint;
  134138. /**
  134139. * Gets the output component
  134140. */
  134141. get output(): NodeMaterialConnectionPoint;
  134142. protected _buildBlock(state: NodeMaterialBuildState): this;
  134143. }
  134144. }
  134145. declare module BABYLON {
  134146. /**
  134147. * Block used to step a value
  134148. */
  134149. export class StepBlock extends NodeMaterialBlock {
  134150. /**
  134151. * Creates a new StepBlock
  134152. * @param name defines the block name
  134153. */
  134154. constructor(name: string);
  134155. /**
  134156. * Gets the current class name
  134157. * @returns the class name
  134158. */
  134159. getClassName(): string;
  134160. /**
  134161. * Gets the value operand input component
  134162. */
  134163. get value(): NodeMaterialConnectionPoint;
  134164. /**
  134165. * Gets the edge operand input component
  134166. */
  134167. get edge(): NodeMaterialConnectionPoint;
  134168. /**
  134169. * Gets the output component
  134170. */
  134171. get output(): NodeMaterialConnectionPoint;
  134172. protected _buildBlock(state: NodeMaterialBuildState): this;
  134173. }
  134174. }
  134175. declare module BABYLON {
  134176. /**
  134177. * Block used to get the opposite (1 - x) of a value
  134178. */
  134179. export class OneMinusBlock extends NodeMaterialBlock {
  134180. /**
  134181. * Creates a new OneMinusBlock
  134182. * @param name defines the block name
  134183. */
  134184. constructor(name: string);
  134185. /**
  134186. * Gets the current class name
  134187. * @returns the class name
  134188. */
  134189. getClassName(): string;
  134190. /**
  134191. * Gets the input component
  134192. */
  134193. get input(): NodeMaterialConnectionPoint;
  134194. /**
  134195. * Gets the output component
  134196. */
  134197. get output(): NodeMaterialConnectionPoint;
  134198. protected _buildBlock(state: NodeMaterialBuildState): this;
  134199. }
  134200. }
  134201. declare module BABYLON {
  134202. /**
  134203. * Block used to get the view direction
  134204. */
  134205. export class ViewDirectionBlock extends NodeMaterialBlock {
  134206. /**
  134207. * Creates a new ViewDirectionBlock
  134208. * @param name defines the block name
  134209. */
  134210. constructor(name: string);
  134211. /**
  134212. * Gets the current class name
  134213. * @returns the class name
  134214. */
  134215. getClassName(): string;
  134216. /**
  134217. * Gets the world position component
  134218. */
  134219. get worldPosition(): NodeMaterialConnectionPoint;
  134220. /**
  134221. * Gets the camera position component
  134222. */
  134223. get cameraPosition(): NodeMaterialConnectionPoint;
  134224. /**
  134225. * Gets the output component
  134226. */
  134227. get output(): NodeMaterialConnectionPoint;
  134228. autoConfigure(material: NodeMaterial): void;
  134229. protected _buildBlock(state: NodeMaterialBuildState): this;
  134230. }
  134231. }
  134232. declare module BABYLON {
  134233. /**
  134234. * Block used to compute fresnel value
  134235. */
  134236. export class FresnelBlock extends NodeMaterialBlock {
  134237. /**
  134238. * Create a new FresnelBlock
  134239. * @param name defines the block name
  134240. */
  134241. constructor(name: string);
  134242. /**
  134243. * Gets the current class name
  134244. * @returns the class name
  134245. */
  134246. getClassName(): string;
  134247. /**
  134248. * Gets the world normal input component
  134249. */
  134250. get worldNormal(): NodeMaterialConnectionPoint;
  134251. /**
  134252. * Gets the view direction input component
  134253. */
  134254. get viewDirection(): NodeMaterialConnectionPoint;
  134255. /**
  134256. * Gets the bias input component
  134257. */
  134258. get bias(): NodeMaterialConnectionPoint;
  134259. /**
  134260. * Gets the camera (or eye) position component
  134261. */
  134262. get power(): NodeMaterialConnectionPoint;
  134263. /**
  134264. * Gets the fresnel output component
  134265. */
  134266. get fresnel(): NodeMaterialConnectionPoint;
  134267. autoConfigure(material: NodeMaterial): void;
  134268. protected _buildBlock(state: NodeMaterialBuildState): this;
  134269. }
  134270. }
  134271. declare module BABYLON {
  134272. /**
  134273. * Block used to get the max of 2 values
  134274. */
  134275. export class MaxBlock extends NodeMaterialBlock {
  134276. /**
  134277. * Creates a new MaxBlock
  134278. * @param name defines the block name
  134279. */
  134280. constructor(name: string);
  134281. /**
  134282. * Gets the current class name
  134283. * @returns the class name
  134284. */
  134285. getClassName(): string;
  134286. /**
  134287. * Gets the left operand input component
  134288. */
  134289. get left(): NodeMaterialConnectionPoint;
  134290. /**
  134291. * Gets the right operand input component
  134292. */
  134293. get right(): NodeMaterialConnectionPoint;
  134294. /**
  134295. * Gets the output component
  134296. */
  134297. get output(): NodeMaterialConnectionPoint;
  134298. protected _buildBlock(state: NodeMaterialBuildState): this;
  134299. }
  134300. }
  134301. declare module BABYLON {
  134302. /**
  134303. * Block used to get the min of 2 values
  134304. */
  134305. export class MinBlock extends NodeMaterialBlock {
  134306. /**
  134307. * Creates a new MinBlock
  134308. * @param name defines the block name
  134309. */
  134310. constructor(name: string);
  134311. /**
  134312. * Gets the current class name
  134313. * @returns the class name
  134314. */
  134315. getClassName(): string;
  134316. /**
  134317. * Gets the left operand input component
  134318. */
  134319. get left(): NodeMaterialConnectionPoint;
  134320. /**
  134321. * Gets the right operand input component
  134322. */
  134323. get right(): NodeMaterialConnectionPoint;
  134324. /**
  134325. * Gets the output component
  134326. */
  134327. get output(): NodeMaterialConnectionPoint;
  134328. protected _buildBlock(state: NodeMaterialBuildState): this;
  134329. }
  134330. }
  134331. declare module BABYLON {
  134332. /**
  134333. * Block used to get the distance between 2 values
  134334. */
  134335. export class DistanceBlock extends NodeMaterialBlock {
  134336. /**
  134337. * Creates a new DistanceBlock
  134338. * @param name defines the block name
  134339. */
  134340. constructor(name: string);
  134341. /**
  134342. * Gets the current class name
  134343. * @returns the class name
  134344. */
  134345. getClassName(): string;
  134346. /**
  134347. * Gets the left operand input component
  134348. */
  134349. get left(): NodeMaterialConnectionPoint;
  134350. /**
  134351. * Gets the right operand input component
  134352. */
  134353. get right(): NodeMaterialConnectionPoint;
  134354. /**
  134355. * Gets the output component
  134356. */
  134357. get output(): NodeMaterialConnectionPoint;
  134358. protected _buildBlock(state: NodeMaterialBuildState): this;
  134359. }
  134360. }
  134361. declare module BABYLON {
  134362. /**
  134363. * Block used to get the length of a vector
  134364. */
  134365. export class LengthBlock extends NodeMaterialBlock {
  134366. /**
  134367. * Creates a new LengthBlock
  134368. * @param name defines the block name
  134369. */
  134370. constructor(name: string);
  134371. /**
  134372. * Gets the current class name
  134373. * @returns the class name
  134374. */
  134375. getClassName(): string;
  134376. /**
  134377. * Gets the value input component
  134378. */
  134379. get value(): NodeMaterialConnectionPoint;
  134380. /**
  134381. * Gets the output component
  134382. */
  134383. get output(): NodeMaterialConnectionPoint;
  134384. protected _buildBlock(state: NodeMaterialBuildState): this;
  134385. }
  134386. }
  134387. declare module BABYLON {
  134388. /**
  134389. * Block used to get negative version of a value (i.e. x * -1)
  134390. */
  134391. export class NegateBlock extends NodeMaterialBlock {
  134392. /**
  134393. * Creates a new NegateBlock
  134394. * @param name defines the block name
  134395. */
  134396. constructor(name: string);
  134397. /**
  134398. * Gets the current class name
  134399. * @returns the class name
  134400. */
  134401. getClassName(): string;
  134402. /**
  134403. * Gets the value input component
  134404. */
  134405. get value(): NodeMaterialConnectionPoint;
  134406. /**
  134407. * Gets the output component
  134408. */
  134409. get output(): NodeMaterialConnectionPoint;
  134410. protected _buildBlock(state: NodeMaterialBuildState): this;
  134411. }
  134412. }
  134413. declare module BABYLON {
  134414. /**
  134415. * Block used to get the value of the first parameter raised to the power of the second
  134416. */
  134417. export class PowBlock extends NodeMaterialBlock {
  134418. /**
  134419. * Creates a new PowBlock
  134420. * @param name defines the block name
  134421. */
  134422. constructor(name: string);
  134423. /**
  134424. * Gets the current class name
  134425. * @returns the class name
  134426. */
  134427. getClassName(): string;
  134428. /**
  134429. * Gets the value operand input component
  134430. */
  134431. get value(): NodeMaterialConnectionPoint;
  134432. /**
  134433. * Gets the power operand input component
  134434. */
  134435. get power(): NodeMaterialConnectionPoint;
  134436. /**
  134437. * Gets the output component
  134438. */
  134439. get output(): NodeMaterialConnectionPoint;
  134440. protected _buildBlock(state: NodeMaterialBuildState): this;
  134441. }
  134442. }
  134443. declare module BABYLON {
  134444. /**
  134445. * Block used to get a random number
  134446. */
  134447. export class RandomNumberBlock extends NodeMaterialBlock {
  134448. /**
  134449. * Creates a new RandomNumberBlock
  134450. * @param name defines the block name
  134451. */
  134452. constructor(name: string);
  134453. /**
  134454. * Gets the current class name
  134455. * @returns the class name
  134456. */
  134457. getClassName(): string;
  134458. /**
  134459. * Gets the seed input component
  134460. */
  134461. get seed(): NodeMaterialConnectionPoint;
  134462. /**
  134463. * Gets the output component
  134464. */
  134465. get output(): NodeMaterialConnectionPoint;
  134466. protected _buildBlock(state: NodeMaterialBuildState): this;
  134467. }
  134468. }
  134469. declare module BABYLON {
  134470. /**
  134471. * Block used to compute arc tangent of 2 values
  134472. */
  134473. export class ArcTan2Block extends NodeMaterialBlock {
  134474. /**
  134475. * Creates a new ArcTan2Block
  134476. * @param name defines the block name
  134477. */
  134478. constructor(name: string);
  134479. /**
  134480. * Gets the current class name
  134481. * @returns the class name
  134482. */
  134483. getClassName(): string;
  134484. /**
  134485. * Gets the x operand input component
  134486. */
  134487. get x(): NodeMaterialConnectionPoint;
  134488. /**
  134489. * Gets the y operand input component
  134490. */
  134491. get y(): NodeMaterialConnectionPoint;
  134492. /**
  134493. * Gets the output component
  134494. */
  134495. get output(): NodeMaterialConnectionPoint;
  134496. protected _buildBlock(state: NodeMaterialBuildState): this;
  134497. }
  134498. }
  134499. declare module BABYLON {
  134500. /**
  134501. * Block used to smooth step a value
  134502. */
  134503. export class SmoothStepBlock extends NodeMaterialBlock {
  134504. /**
  134505. * Creates a new SmoothStepBlock
  134506. * @param name defines the block name
  134507. */
  134508. constructor(name: string);
  134509. /**
  134510. * Gets the current class name
  134511. * @returns the class name
  134512. */
  134513. getClassName(): string;
  134514. /**
  134515. * Gets the value operand input component
  134516. */
  134517. get value(): NodeMaterialConnectionPoint;
  134518. /**
  134519. * Gets the first edge operand input component
  134520. */
  134521. get edge0(): NodeMaterialConnectionPoint;
  134522. /**
  134523. * Gets the second edge operand input component
  134524. */
  134525. get edge1(): NodeMaterialConnectionPoint;
  134526. /**
  134527. * Gets the output component
  134528. */
  134529. get output(): NodeMaterialConnectionPoint;
  134530. protected _buildBlock(state: NodeMaterialBuildState): this;
  134531. }
  134532. }
  134533. declare module BABYLON {
  134534. /**
  134535. * Block used to get the reciprocal (1 / x) of a value
  134536. */
  134537. export class ReciprocalBlock extends NodeMaterialBlock {
  134538. /**
  134539. * Creates a new ReciprocalBlock
  134540. * @param name defines the block name
  134541. */
  134542. constructor(name: string);
  134543. /**
  134544. * Gets the current class name
  134545. * @returns the class name
  134546. */
  134547. getClassName(): string;
  134548. /**
  134549. * Gets the input component
  134550. */
  134551. get input(): NodeMaterialConnectionPoint;
  134552. /**
  134553. * Gets the output component
  134554. */
  134555. get output(): NodeMaterialConnectionPoint;
  134556. protected _buildBlock(state: NodeMaterialBuildState): this;
  134557. }
  134558. }
  134559. declare module BABYLON {
  134560. /**
  134561. * Block used to replace a color by another one
  134562. */
  134563. export class ReplaceColorBlock extends NodeMaterialBlock {
  134564. /**
  134565. * Creates a new ReplaceColorBlock
  134566. * @param name defines the block name
  134567. */
  134568. constructor(name: string);
  134569. /**
  134570. * Gets the current class name
  134571. * @returns the class name
  134572. */
  134573. getClassName(): string;
  134574. /**
  134575. * Gets the value input component
  134576. */
  134577. get value(): NodeMaterialConnectionPoint;
  134578. /**
  134579. * Gets the reference input component
  134580. */
  134581. get reference(): NodeMaterialConnectionPoint;
  134582. /**
  134583. * Gets the distance input component
  134584. */
  134585. get distance(): NodeMaterialConnectionPoint;
  134586. /**
  134587. * Gets the replacement input component
  134588. */
  134589. get replacement(): NodeMaterialConnectionPoint;
  134590. /**
  134591. * Gets the output component
  134592. */
  134593. get output(): NodeMaterialConnectionPoint;
  134594. protected _buildBlock(state: NodeMaterialBuildState): this;
  134595. }
  134596. }
  134597. declare module BABYLON {
  134598. /**
  134599. * Block used to posterize a value
  134600. * @see https://en.wikipedia.org/wiki/Posterization
  134601. */
  134602. export class PosterizeBlock extends NodeMaterialBlock {
  134603. /**
  134604. * Creates a new PosterizeBlock
  134605. * @param name defines the block name
  134606. */
  134607. constructor(name: string);
  134608. /**
  134609. * Gets the current class name
  134610. * @returns the class name
  134611. */
  134612. getClassName(): string;
  134613. /**
  134614. * Gets the value input component
  134615. */
  134616. get value(): NodeMaterialConnectionPoint;
  134617. /**
  134618. * Gets the steps input component
  134619. */
  134620. get steps(): NodeMaterialConnectionPoint;
  134621. /**
  134622. * Gets the output component
  134623. */
  134624. get output(): NodeMaterialConnectionPoint;
  134625. protected _buildBlock(state: NodeMaterialBuildState): this;
  134626. }
  134627. }
  134628. declare module BABYLON {
  134629. /**
  134630. * Operations supported by the Wave block
  134631. */
  134632. export enum WaveBlockKind {
  134633. /** SawTooth */
  134634. SawTooth = 0,
  134635. /** Square */
  134636. Square = 1,
  134637. /** Triangle */
  134638. Triangle = 2
  134639. }
  134640. /**
  134641. * Block used to apply wave operation to floats
  134642. */
  134643. export class WaveBlock extends NodeMaterialBlock {
  134644. /**
  134645. * Gets or sets the kibnd of wave to be applied by the block
  134646. */
  134647. kind: WaveBlockKind;
  134648. /**
  134649. * Creates a new WaveBlock
  134650. * @param name defines the block name
  134651. */
  134652. constructor(name: string);
  134653. /**
  134654. * Gets the current class name
  134655. * @returns the class name
  134656. */
  134657. getClassName(): string;
  134658. /**
  134659. * Gets the input component
  134660. */
  134661. get input(): NodeMaterialConnectionPoint;
  134662. /**
  134663. * Gets the output component
  134664. */
  134665. get output(): NodeMaterialConnectionPoint;
  134666. protected _buildBlock(state: NodeMaterialBuildState): this;
  134667. serialize(): any;
  134668. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134669. }
  134670. }
  134671. declare module BABYLON {
  134672. /**
  134673. * Class used to store a color step for the GradientBlock
  134674. */
  134675. export class GradientBlockColorStep {
  134676. /**
  134677. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134678. */
  134679. step: number;
  134680. /**
  134681. * Gets or sets the color associated with this step
  134682. */
  134683. color: Color3;
  134684. /**
  134685. * Creates a new GradientBlockColorStep
  134686. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  134687. * @param color defines the color associated with this step
  134688. */
  134689. constructor(
  134690. /**
  134691. * Gets or sets a value indicating which step this color is associated with (between 0 and 1)
  134692. */
  134693. step: number,
  134694. /**
  134695. * Gets or sets the color associated with this step
  134696. */
  134697. color: Color3);
  134698. }
  134699. /**
  134700. * Block used to return a color from a gradient based on an input value between 0 and 1
  134701. */
  134702. export class GradientBlock extends NodeMaterialBlock {
  134703. /**
  134704. * Gets or sets the list of color steps
  134705. */
  134706. colorSteps: GradientBlockColorStep[];
  134707. /**
  134708. * Creates a new GradientBlock
  134709. * @param name defines the block name
  134710. */
  134711. constructor(name: string);
  134712. /**
  134713. * Gets the current class name
  134714. * @returns the class name
  134715. */
  134716. getClassName(): string;
  134717. /**
  134718. * Gets the gradient input component
  134719. */
  134720. get gradient(): NodeMaterialConnectionPoint;
  134721. /**
  134722. * Gets the output component
  134723. */
  134724. get output(): NodeMaterialConnectionPoint;
  134725. private _writeColorConstant;
  134726. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134727. serialize(): any;
  134728. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134729. protected _dumpPropertiesCode(): string;
  134730. }
  134731. }
  134732. declare module BABYLON {
  134733. /**
  134734. * Block used to normalize lerp between 2 values
  134735. */
  134736. export class NLerpBlock extends NodeMaterialBlock {
  134737. /**
  134738. * Creates a new NLerpBlock
  134739. * @param name defines the block name
  134740. */
  134741. constructor(name: string);
  134742. /**
  134743. * Gets the current class name
  134744. * @returns the class name
  134745. */
  134746. getClassName(): string;
  134747. /**
  134748. * Gets the left operand input component
  134749. */
  134750. get left(): NodeMaterialConnectionPoint;
  134751. /**
  134752. * Gets the right operand input component
  134753. */
  134754. get right(): NodeMaterialConnectionPoint;
  134755. /**
  134756. * Gets the gradient operand input component
  134757. */
  134758. get gradient(): NodeMaterialConnectionPoint;
  134759. /**
  134760. * Gets the output component
  134761. */
  134762. get output(): NodeMaterialConnectionPoint;
  134763. protected _buildBlock(state: NodeMaterialBuildState): this;
  134764. }
  134765. }
  134766. declare module BABYLON {
  134767. /**
  134768. * block used to Generate a Worley Noise 3D Noise Pattern
  134769. */
  134770. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  134771. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  134772. manhattanDistance: boolean;
  134773. /**
  134774. * Creates a new WorleyNoise3DBlock
  134775. * @param name defines the block name
  134776. */
  134777. constructor(name: string);
  134778. /**
  134779. * Gets the current class name
  134780. * @returns the class name
  134781. */
  134782. getClassName(): string;
  134783. /**
  134784. * Gets the seed input component
  134785. */
  134786. get seed(): NodeMaterialConnectionPoint;
  134787. /**
  134788. * Gets the jitter input component
  134789. */
  134790. get jitter(): NodeMaterialConnectionPoint;
  134791. /**
  134792. * Gets the output component
  134793. */
  134794. get output(): NodeMaterialConnectionPoint;
  134795. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134796. /**
  134797. * Exposes the properties to the UI?
  134798. */
  134799. protected _dumpPropertiesCode(): string;
  134800. /**
  134801. * Exposes the properties to the Seralize?
  134802. */
  134803. serialize(): any;
  134804. /**
  134805. * Exposes the properties to the deseralize?
  134806. */
  134807. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  134808. }
  134809. }
  134810. declare module BABYLON {
  134811. /**
  134812. * block used to Generate a Simplex Perlin 3d Noise Pattern
  134813. */
  134814. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  134815. /**
  134816. * Creates a new SimplexPerlin3DBlock
  134817. * @param name defines the block name
  134818. */
  134819. constructor(name: string);
  134820. /**
  134821. * Gets the current class name
  134822. * @returns the class name
  134823. */
  134824. getClassName(): string;
  134825. /**
  134826. * Gets the seed operand input component
  134827. */
  134828. get seed(): NodeMaterialConnectionPoint;
  134829. /**
  134830. * Gets the output component
  134831. */
  134832. get output(): NodeMaterialConnectionPoint;
  134833. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  134834. }
  134835. }
  134836. declare module BABYLON {
  134837. /**
  134838. * Block used to blend normals
  134839. */
  134840. export class NormalBlendBlock extends NodeMaterialBlock {
  134841. /**
  134842. * Creates a new NormalBlendBlock
  134843. * @param name defines the block name
  134844. */
  134845. constructor(name: string);
  134846. /**
  134847. * Gets the current class name
  134848. * @returns the class name
  134849. */
  134850. getClassName(): string;
  134851. /**
  134852. * Gets the first input component
  134853. */
  134854. get normalMap0(): NodeMaterialConnectionPoint;
  134855. /**
  134856. * Gets the second input component
  134857. */
  134858. get normalMap1(): NodeMaterialConnectionPoint;
  134859. /**
  134860. * Gets the output component
  134861. */
  134862. get output(): NodeMaterialConnectionPoint;
  134863. protected _buildBlock(state: NodeMaterialBuildState): this;
  134864. }
  134865. }
  134866. declare module BABYLON {
  134867. /**
  134868. * Block used to rotate a 2d vector by a given angle
  134869. */
  134870. export class Rotate2dBlock extends NodeMaterialBlock {
  134871. /**
  134872. * Creates a new Rotate2dBlock
  134873. * @param name defines the block name
  134874. */
  134875. constructor(name: string);
  134876. /**
  134877. * Gets the current class name
  134878. * @returns the class name
  134879. */
  134880. getClassName(): string;
  134881. /**
  134882. * Gets the input vector
  134883. */
  134884. get input(): NodeMaterialConnectionPoint;
  134885. /**
  134886. * Gets the input angle
  134887. */
  134888. get angle(): NodeMaterialConnectionPoint;
  134889. /**
  134890. * Gets the output component
  134891. */
  134892. get output(): NodeMaterialConnectionPoint;
  134893. autoConfigure(material: NodeMaterial): void;
  134894. protected _buildBlock(state: NodeMaterialBuildState): this;
  134895. }
  134896. }
  134897. declare module BABYLON {
  134898. /**
  134899. * Block used to get the reflected vector from a direction and a normal
  134900. */
  134901. export class ReflectBlock extends NodeMaterialBlock {
  134902. /**
  134903. * Creates a new ReflectBlock
  134904. * @param name defines the block name
  134905. */
  134906. constructor(name: string);
  134907. /**
  134908. * Gets the current class name
  134909. * @returns the class name
  134910. */
  134911. getClassName(): string;
  134912. /**
  134913. * Gets the incident component
  134914. */
  134915. get incident(): NodeMaterialConnectionPoint;
  134916. /**
  134917. * Gets the normal component
  134918. */
  134919. get normal(): NodeMaterialConnectionPoint;
  134920. /**
  134921. * Gets the output component
  134922. */
  134923. get output(): NodeMaterialConnectionPoint;
  134924. protected _buildBlock(state: NodeMaterialBuildState): this;
  134925. }
  134926. }
  134927. declare module BABYLON {
  134928. /**
  134929. * Block used to get the refracted vector from a direction and a normal
  134930. */
  134931. export class RefractBlock extends NodeMaterialBlock {
  134932. /**
  134933. * Creates a new RefractBlock
  134934. * @param name defines the block name
  134935. */
  134936. constructor(name: string);
  134937. /**
  134938. * Gets the current class name
  134939. * @returns the class name
  134940. */
  134941. getClassName(): string;
  134942. /**
  134943. * Gets the incident component
  134944. */
  134945. get incident(): NodeMaterialConnectionPoint;
  134946. /**
  134947. * Gets the normal component
  134948. */
  134949. get normal(): NodeMaterialConnectionPoint;
  134950. /**
  134951. * Gets the index of refraction component
  134952. */
  134953. get ior(): NodeMaterialConnectionPoint;
  134954. /**
  134955. * Gets the output component
  134956. */
  134957. get output(): NodeMaterialConnectionPoint;
  134958. protected _buildBlock(state: NodeMaterialBuildState): this;
  134959. }
  134960. }
  134961. declare module BABYLON {
  134962. /**
  134963. * Block used to desaturate a color
  134964. */
  134965. export class DesaturateBlock extends NodeMaterialBlock {
  134966. /**
  134967. * Creates a new DesaturateBlock
  134968. * @param name defines the block name
  134969. */
  134970. constructor(name: string);
  134971. /**
  134972. * Gets the current class name
  134973. * @returns the class name
  134974. */
  134975. getClassName(): string;
  134976. /**
  134977. * Gets the color operand input component
  134978. */
  134979. get color(): NodeMaterialConnectionPoint;
  134980. /**
  134981. * Gets the level operand input component
  134982. */
  134983. get level(): NodeMaterialConnectionPoint;
  134984. /**
  134985. * Gets the output component
  134986. */
  134987. get output(): NodeMaterialConnectionPoint;
  134988. protected _buildBlock(state: NodeMaterialBuildState): this;
  134989. }
  134990. }
  134991. declare module BABYLON {
  134992. /**
  134993. * Effect Render Options
  134994. */
  134995. export interface IEffectRendererOptions {
  134996. /**
  134997. * Defines the vertices positions.
  134998. */
  134999. positions?: number[];
  135000. /**
  135001. * Defines the indices.
  135002. */
  135003. indices?: number[];
  135004. }
  135005. /**
  135006. * Helper class to render one or more effects.
  135007. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  135008. */
  135009. export class EffectRenderer {
  135010. private engine;
  135011. private static _DefaultOptions;
  135012. private _vertexBuffers;
  135013. private _indexBuffer;
  135014. private _fullscreenViewport;
  135015. /**
  135016. * Creates an effect renderer
  135017. * @param engine the engine to use for rendering
  135018. * @param options defines the options of the effect renderer
  135019. */
  135020. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  135021. /**
  135022. * Sets the current viewport in normalized coordinates 0-1
  135023. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  135024. */
  135025. setViewport(viewport?: Viewport): void;
  135026. /**
  135027. * Binds the embedded attributes buffer to the effect.
  135028. * @param effect Defines the effect to bind the attributes for
  135029. */
  135030. bindBuffers(effect: Effect): void;
  135031. /**
  135032. * Sets the current effect wrapper to use during draw.
  135033. * The effect needs to be ready before calling this api.
  135034. * This also sets the default full screen position attribute.
  135035. * @param effectWrapper Defines the effect to draw with
  135036. */
  135037. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  135038. /**
  135039. * Draws a full screen quad.
  135040. */
  135041. draw(): void;
  135042. private isRenderTargetTexture;
  135043. /**
  135044. * renders one or more effects to a specified texture
  135045. * @param effectWrapper the effect to renderer
  135046. * @param outputTexture texture to draw to, if null it will render to the screen.
  135047. */
  135048. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  135049. /**
  135050. * Disposes of the effect renderer
  135051. */
  135052. dispose(): void;
  135053. }
  135054. /**
  135055. * Options to create an EffectWrapper
  135056. */
  135057. interface EffectWrapperCreationOptions {
  135058. /**
  135059. * Engine to use to create the effect
  135060. */
  135061. engine: ThinEngine;
  135062. /**
  135063. * Fragment shader for the effect
  135064. */
  135065. fragmentShader: string;
  135066. /**
  135067. * Vertex shader for the effect
  135068. */
  135069. vertexShader?: string;
  135070. /**
  135071. * Attributes to use in the shader
  135072. */
  135073. attributeNames?: Array<string>;
  135074. /**
  135075. * Uniforms to use in the shader
  135076. */
  135077. uniformNames?: Array<string>;
  135078. /**
  135079. * Texture sampler names to use in the shader
  135080. */
  135081. samplerNames?: Array<string>;
  135082. /**
  135083. * The friendly name of the effect displayed in Spector.
  135084. */
  135085. name?: string;
  135086. }
  135087. /**
  135088. * Wraps an effect to be used for rendering
  135089. */
  135090. export class EffectWrapper {
  135091. /**
  135092. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  135093. */
  135094. onApplyObservable: Observable<{}>;
  135095. /**
  135096. * The underlying effect
  135097. */
  135098. effect: Effect;
  135099. /**
  135100. * Creates an effect to be renderer
  135101. * @param creationOptions options to create the effect
  135102. */
  135103. constructor(creationOptions: EffectWrapperCreationOptions);
  135104. /**
  135105. * Disposes of the effect wrapper
  135106. */
  135107. dispose(): void;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /**
  135112. * Helper class to push actions to a pool of workers.
  135113. */
  135114. export class WorkerPool implements IDisposable {
  135115. private _workerInfos;
  135116. private _pendingActions;
  135117. /**
  135118. * Constructor
  135119. * @param workers Array of workers to use for actions
  135120. */
  135121. constructor(workers: Array<Worker>);
  135122. /**
  135123. * Terminates all workers and clears any pending actions.
  135124. */
  135125. dispose(): void;
  135126. /**
  135127. * Pushes an action to the worker pool. If all the workers are active, the action will be
  135128. * pended until a worker has completed its action.
  135129. * @param action The action to perform. Call onComplete when the action is complete.
  135130. */
  135131. push(action: (worker: Worker, onComplete: () => void) => void): void;
  135132. private _execute;
  135133. }
  135134. }
  135135. declare module BABYLON {
  135136. /**
  135137. * Configuration for Draco compression
  135138. */
  135139. export interface IDracoCompressionConfiguration {
  135140. /**
  135141. * Configuration for the decoder.
  135142. */
  135143. decoder: {
  135144. /**
  135145. * The url to the WebAssembly module.
  135146. */
  135147. wasmUrl?: string;
  135148. /**
  135149. * The url to the WebAssembly binary.
  135150. */
  135151. wasmBinaryUrl?: string;
  135152. /**
  135153. * The url to the fallback JavaScript module.
  135154. */
  135155. fallbackUrl?: string;
  135156. };
  135157. }
  135158. /**
  135159. * Draco compression (https://google.github.io/draco/)
  135160. *
  135161. * This class wraps the Draco module.
  135162. *
  135163. * **Encoder**
  135164. *
  135165. * The encoder is not currently implemented.
  135166. *
  135167. * **Decoder**
  135168. *
  135169. * 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.
  135170. *
  135171. * To update the configuration, use the following code:
  135172. * ```javascript
  135173. * DracoCompression.Configuration = {
  135174. * decoder: {
  135175. * wasmUrl: "<url to the WebAssembly library>",
  135176. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  135177. * fallbackUrl: "<url to the fallback JavaScript library>",
  135178. * }
  135179. * };
  135180. * ```
  135181. *
  135182. * 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.
  135183. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  135184. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  135185. *
  135186. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  135187. * ```javascript
  135188. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  135189. * ```
  135190. *
  135191. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  135192. */
  135193. export class DracoCompression implements IDisposable {
  135194. private _workerPoolPromise?;
  135195. private _decoderModulePromise?;
  135196. /**
  135197. * The configuration. Defaults to the following urls:
  135198. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  135199. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  135200. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  135201. */
  135202. static Configuration: IDracoCompressionConfiguration;
  135203. /**
  135204. * Returns true if the decoder configuration is available.
  135205. */
  135206. static get DecoderAvailable(): boolean;
  135207. /**
  135208. * Default number of workers to create when creating the draco compression object.
  135209. */
  135210. static DefaultNumWorkers: number;
  135211. private static GetDefaultNumWorkers;
  135212. private static _Default;
  135213. /**
  135214. * Default instance for the draco compression object.
  135215. */
  135216. static get Default(): DracoCompression;
  135217. /**
  135218. * Constructor
  135219. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  135220. */
  135221. constructor(numWorkers?: number);
  135222. /**
  135223. * Stop all async operations and release resources.
  135224. */
  135225. dispose(): void;
  135226. /**
  135227. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  135228. * @returns a promise that resolves when ready
  135229. */
  135230. whenReadyAsync(): Promise<void>;
  135231. /**
  135232. * Decode Draco compressed mesh data to vertex data.
  135233. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  135234. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  135235. * @returns A promise that resolves with the decoded vertex data
  135236. */
  135237. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  135238. [kind: string]: number;
  135239. }): Promise<VertexData>;
  135240. }
  135241. }
  135242. declare module BABYLON {
  135243. /**
  135244. * Class for building Constructive Solid Geometry
  135245. */
  135246. export class CSG {
  135247. private polygons;
  135248. /**
  135249. * The world matrix
  135250. */
  135251. matrix: Matrix;
  135252. /**
  135253. * Stores the position
  135254. */
  135255. position: Vector3;
  135256. /**
  135257. * Stores the rotation
  135258. */
  135259. rotation: Vector3;
  135260. /**
  135261. * Stores the rotation quaternion
  135262. */
  135263. rotationQuaternion: Nullable<Quaternion>;
  135264. /**
  135265. * Stores the scaling vector
  135266. */
  135267. scaling: Vector3;
  135268. /**
  135269. * Convert the Mesh to CSG
  135270. * @param mesh The Mesh to convert to CSG
  135271. * @returns A new CSG from the Mesh
  135272. */
  135273. static FromMesh(mesh: Mesh): CSG;
  135274. /**
  135275. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  135276. * @param polygons Polygons used to construct a CSG solid
  135277. */
  135278. private static FromPolygons;
  135279. /**
  135280. * Clones, or makes a deep copy, of the CSG
  135281. * @returns A new CSG
  135282. */
  135283. clone(): CSG;
  135284. /**
  135285. * Unions this CSG with another CSG
  135286. * @param csg The CSG to union against this CSG
  135287. * @returns The unioned CSG
  135288. */
  135289. union(csg: CSG): CSG;
  135290. /**
  135291. * Unions this CSG with another CSG in place
  135292. * @param csg The CSG to union against this CSG
  135293. */
  135294. unionInPlace(csg: CSG): void;
  135295. /**
  135296. * Subtracts this CSG with another CSG
  135297. * @param csg The CSG to subtract against this CSG
  135298. * @returns A new CSG
  135299. */
  135300. subtract(csg: CSG): CSG;
  135301. /**
  135302. * Subtracts this CSG with another CSG in place
  135303. * @param csg The CSG to subtact against this CSG
  135304. */
  135305. subtractInPlace(csg: CSG): void;
  135306. /**
  135307. * Intersect this CSG with another CSG
  135308. * @param csg The CSG to intersect against this CSG
  135309. * @returns A new CSG
  135310. */
  135311. intersect(csg: CSG): CSG;
  135312. /**
  135313. * Intersects this CSG with another CSG in place
  135314. * @param csg The CSG to intersect against this CSG
  135315. */
  135316. intersectInPlace(csg: CSG): void;
  135317. /**
  135318. * Return a new CSG solid with solid and empty space switched. This solid is
  135319. * not modified.
  135320. * @returns A new CSG solid with solid and empty space switched
  135321. */
  135322. inverse(): CSG;
  135323. /**
  135324. * Inverses the CSG in place
  135325. */
  135326. inverseInPlace(): void;
  135327. /**
  135328. * This is used to keep meshes transformations so they can be restored
  135329. * when we build back a Babylon Mesh
  135330. * NB : All CSG operations are performed in world coordinates
  135331. * @param csg The CSG to copy the transform attributes from
  135332. * @returns This CSG
  135333. */
  135334. copyTransformAttributes(csg: CSG): CSG;
  135335. /**
  135336. * Build Raw mesh from CSG
  135337. * Coordinates here are in world space
  135338. * @param name The name of the mesh geometry
  135339. * @param scene The Scene
  135340. * @param keepSubMeshes Specifies if the submeshes should be kept
  135341. * @returns A new Mesh
  135342. */
  135343. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135344. /**
  135345. * Build Mesh from CSG taking material and transforms into account
  135346. * @param name The name of the Mesh
  135347. * @param material The material of the Mesh
  135348. * @param scene The Scene
  135349. * @param keepSubMeshes Specifies if submeshes should be kept
  135350. * @returns The new Mesh
  135351. */
  135352. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  135353. }
  135354. }
  135355. declare module BABYLON {
  135356. /**
  135357. * Class used to create a trail following a mesh
  135358. */
  135359. export class TrailMesh extends Mesh {
  135360. private _generator;
  135361. private _autoStart;
  135362. private _running;
  135363. private _diameter;
  135364. private _length;
  135365. private _sectionPolygonPointsCount;
  135366. private _sectionVectors;
  135367. private _sectionNormalVectors;
  135368. private _beforeRenderObserver;
  135369. /**
  135370. * @constructor
  135371. * @param name The value used by scene.getMeshByName() to do a lookup.
  135372. * @param generator The mesh or transform node to generate a trail.
  135373. * @param scene The scene to add this mesh to.
  135374. * @param diameter Diameter of trailing mesh. Default is 1.
  135375. * @param length Length of trailing mesh. Default is 60.
  135376. * @param autoStart Automatically start trailing mesh. Default true.
  135377. */
  135378. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  135379. /**
  135380. * "TrailMesh"
  135381. * @returns "TrailMesh"
  135382. */
  135383. getClassName(): string;
  135384. private _createMesh;
  135385. /**
  135386. * Start trailing mesh.
  135387. */
  135388. start(): void;
  135389. /**
  135390. * Stop trailing mesh.
  135391. */
  135392. stop(): void;
  135393. /**
  135394. * Update trailing mesh geometry.
  135395. */
  135396. update(): void;
  135397. /**
  135398. * Returns a new TrailMesh object.
  135399. * @param name is a string, the name given to the new mesh
  135400. * @param newGenerator use new generator object for cloned trail mesh
  135401. * @returns a new mesh
  135402. */
  135403. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  135404. /**
  135405. * Serializes this trail mesh
  135406. * @param serializationObject object to write serialization to
  135407. */
  135408. serialize(serializationObject: any): void;
  135409. /**
  135410. * Parses a serialized trail mesh
  135411. * @param parsedMesh the serialized mesh
  135412. * @param scene the scene to create the trail mesh in
  135413. * @returns the created trail mesh
  135414. */
  135415. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  135416. }
  135417. }
  135418. declare module BABYLON {
  135419. /**
  135420. * Class containing static functions to help procedurally build meshes
  135421. */
  135422. export class TiledBoxBuilder {
  135423. /**
  135424. * Creates a box mesh
  135425. * 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)
  135426. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135427. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135428. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135429. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135430. * @param name defines the name of the mesh
  135431. * @param options defines the options used to create the mesh
  135432. * @param scene defines the hosting scene
  135433. * @returns the box mesh
  135434. */
  135435. static CreateTiledBox(name: string, options: {
  135436. pattern?: number;
  135437. width?: number;
  135438. height?: number;
  135439. depth?: number;
  135440. tileSize?: number;
  135441. tileWidth?: number;
  135442. tileHeight?: number;
  135443. alignHorizontal?: number;
  135444. alignVertical?: number;
  135445. faceUV?: Vector4[];
  135446. faceColors?: Color4[];
  135447. sideOrientation?: number;
  135448. updatable?: boolean;
  135449. }, scene?: Nullable<Scene>): Mesh;
  135450. }
  135451. }
  135452. declare module BABYLON {
  135453. /**
  135454. * Class containing static functions to help procedurally build meshes
  135455. */
  135456. export class TorusKnotBuilder {
  135457. /**
  135458. * Creates a torus knot mesh
  135459. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  135460. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  135461. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  135462. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  135463. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135464. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  135466. * @param name defines the name of the mesh
  135467. * @param options defines the options used to create the mesh
  135468. * @param scene defines the hosting scene
  135469. * @returns the torus knot mesh
  135470. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  135471. */
  135472. static CreateTorusKnot(name: string, options: {
  135473. radius?: number;
  135474. tube?: number;
  135475. radialSegments?: number;
  135476. tubularSegments?: number;
  135477. p?: number;
  135478. q?: number;
  135479. updatable?: boolean;
  135480. sideOrientation?: number;
  135481. frontUVs?: Vector4;
  135482. backUVs?: Vector4;
  135483. }, scene: any): Mesh;
  135484. }
  135485. }
  135486. declare module BABYLON {
  135487. /**
  135488. * Polygon
  135489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  135490. */
  135491. export class Polygon {
  135492. /**
  135493. * Creates a rectangle
  135494. * @param xmin bottom X coord
  135495. * @param ymin bottom Y coord
  135496. * @param xmax top X coord
  135497. * @param ymax top Y coord
  135498. * @returns points that make the resulting rectation
  135499. */
  135500. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  135501. /**
  135502. * Creates a circle
  135503. * @param radius radius of circle
  135504. * @param cx scale in x
  135505. * @param cy scale in y
  135506. * @param numberOfSides number of sides that make up the circle
  135507. * @returns points that make the resulting circle
  135508. */
  135509. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  135510. /**
  135511. * Creates a polygon from input string
  135512. * @param input Input polygon data
  135513. * @returns the parsed points
  135514. */
  135515. static Parse(input: string): Vector2[];
  135516. /**
  135517. * Starts building a polygon from x and y coordinates
  135518. * @param x x coordinate
  135519. * @param y y coordinate
  135520. * @returns the started path2
  135521. */
  135522. static StartingAt(x: number, y: number): Path2;
  135523. }
  135524. /**
  135525. * Builds a polygon
  135526. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  135527. */
  135528. export class PolygonMeshBuilder {
  135529. private _points;
  135530. private _outlinepoints;
  135531. private _holes;
  135532. private _name;
  135533. private _scene;
  135534. private _epoints;
  135535. private _eholes;
  135536. private _addToepoint;
  135537. /**
  135538. * Babylon reference to the earcut plugin.
  135539. */
  135540. bjsEarcut: any;
  135541. /**
  135542. * Creates a PolygonMeshBuilder
  135543. * @param name name of the builder
  135544. * @param contours Path of the polygon
  135545. * @param scene scene to add to when creating the mesh
  135546. * @param earcutInjection can be used to inject your own earcut reference
  135547. */
  135548. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  135549. /**
  135550. * Adds a whole within the polygon
  135551. * @param hole Array of points defining the hole
  135552. * @returns this
  135553. */
  135554. addHole(hole: Vector2[]): PolygonMeshBuilder;
  135555. /**
  135556. * Creates the polygon
  135557. * @param updatable If the mesh should be updatable
  135558. * @param depth The depth of the mesh created
  135559. * @returns the created mesh
  135560. */
  135561. build(updatable?: boolean, depth?: number): Mesh;
  135562. /**
  135563. * Creates the polygon
  135564. * @param depth The depth of the mesh created
  135565. * @returns the created VertexData
  135566. */
  135567. buildVertexData(depth?: number): VertexData;
  135568. /**
  135569. * Adds a side to the polygon
  135570. * @param positions points that make the polygon
  135571. * @param normals normals of the polygon
  135572. * @param uvs uvs of the polygon
  135573. * @param indices indices of the polygon
  135574. * @param bounds bounds of the polygon
  135575. * @param points points of the polygon
  135576. * @param depth depth of the polygon
  135577. * @param flip flip of the polygon
  135578. */
  135579. private addSide;
  135580. }
  135581. }
  135582. declare module BABYLON {
  135583. /**
  135584. * Class containing static functions to help procedurally build meshes
  135585. */
  135586. export class PolygonBuilder {
  135587. /**
  135588. * Creates a polygon mesh
  135589. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  135590. * * 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
  135591. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135592. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135593. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  135594. * * Remember you can only change the shape positions, not their number when updating a polygon
  135595. * @param name defines the name of the mesh
  135596. * @param options defines the options used to create the mesh
  135597. * @param scene defines the hosting scene
  135598. * @param earcutInjection can be used to inject your own earcut reference
  135599. * @returns the polygon mesh
  135600. */
  135601. static CreatePolygon(name: string, options: {
  135602. shape: Vector3[];
  135603. holes?: Vector3[][];
  135604. depth?: number;
  135605. faceUV?: Vector4[];
  135606. faceColors?: Color4[];
  135607. updatable?: boolean;
  135608. sideOrientation?: number;
  135609. frontUVs?: Vector4;
  135610. backUVs?: Vector4;
  135611. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135612. /**
  135613. * Creates an extruded polygon mesh, with depth in the Y direction.
  135614. * * 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)
  135615. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135616. * @param name defines the name of the mesh
  135617. * @param options defines the options used to create the mesh
  135618. * @param scene defines the hosting scene
  135619. * @param earcutInjection can be used to inject your own earcut reference
  135620. * @returns the polygon mesh
  135621. */
  135622. static ExtrudePolygon(name: string, options: {
  135623. shape: Vector3[];
  135624. holes?: Vector3[][];
  135625. depth?: number;
  135626. faceUV?: Vector4[];
  135627. faceColors?: Color4[];
  135628. updatable?: boolean;
  135629. sideOrientation?: number;
  135630. frontUVs?: Vector4;
  135631. backUVs?: Vector4;
  135632. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  135633. }
  135634. }
  135635. declare module BABYLON {
  135636. /**
  135637. * Class containing static functions to help procedurally build meshes
  135638. */
  135639. export class LatheBuilder {
  135640. /**
  135641. * Creates lathe mesh.
  135642. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  135643. * * 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
  135644. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  135645. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  135646. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  135647. * * 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
  135648. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  135649. * * 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
  135650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135652. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135653. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135654. * @param name defines the name of the mesh
  135655. * @param options defines the options used to create the mesh
  135656. * @param scene defines the hosting scene
  135657. * @returns the lathe mesh
  135658. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  135659. */
  135660. static CreateLathe(name: string, options: {
  135661. shape: Vector3[];
  135662. radius?: number;
  135663. tessellation?: number;
  135664. clip?: number;
  135665. arc?: number;
  135666. closed?: boolean;
  135667. updatable?: boolean;
  135668. sideOrientation?: number;
  135669. frontUVs?: Vector4;
  135670. backUVs?: Vector4;
  135671. cap?: number;
  135672. invertUV?: boolean;
  135673. }, scene?: Nullable<Scene>): Mesh;
  135674. }
  135675. }
  135676. declare module BABYLON {
  135677. /**
  135678. * Class containing static functions to help procedurally build meshes
  135679. */
  135680. export class TiledPlaneBuilder {
  135681. /**
  135682. * Creates a tiled plane mesh
  135683. * * The parameter `pattern` will, depending on value, do nothing or
  135684. * * * flip (reflect about central vertical) alternate tiles across and up
  135685. * * * flip every tile on alternate rows
  135686. * * * rotate (180 degs) alternate tiles across and up
  135687. * * * rotate every tile on alternate rows
  135688. * * * flip and rotate alternate tiles across and up
  135689. * * * flip and rotate every tile on alternate rows
  135690. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  135691. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  135692. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135693. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  135694. * * 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)
  135695. * * 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)
  135696. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135697. * @param name defines the name of the mesh
  135698. * @param options defines the options used to create the mesh
  135699. * @param scene defines the hosting scene
  135700. * @returns the box mesh
  135701. */
  135702. static CreateTiledPlane(name: string, options: {
  135703. pattern?: number;
  135704. tileSize?: number;
  135705. tileWidth?: number;
  135706. tileHeight?: number;
  135707. size?: number;
  135708. width?: number;
  135709. height?: number;
  135710. alignHorizontal?: number;
  135711. alignVertical?: number;
  135712. sideOrientation?: number;
  135713. frontUVs?: Vector4;
  135714. backUVs?: Vector4;
  135715. updatable?: boolean;
  135716. }, scene?: Nullable<Scene>): Mesh;
  135717. }
  135718. }
  135719. declare module BABYLON {
  135720. /**
  135721. * Class containing static functions to help procedurally build meshes
  135722. */
  135723. export class TubeBuilder {
  135724. /**
  135725. * Creates a tube mesh.
  135726. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135727. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  135728. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  135729. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  135730. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  135731. * * 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)
  135732. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  135733. * * 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
  135734. * * 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
  135735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135737. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135738. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135739. * @param name defines the name of the mesh
  135740. * @param options defines the options used to create the mesh
  135741. * @param scene defines the hosting scene
  135742. * @returns the tube mesh
  135743. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135744. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  135745. */
  135746. static CreateTube(name: string, options: {
  135747. path: Vector3[];
  135748. radius?: number;
  135749. tessellation?: number;
  135750. radiusFunction?: {
  135751. (i: number, distance: number): number;
  135752. };
  135753. cap?: number;
  135754. arc?: number;
  135755. updatable?: boolean;
  135756. sideOrientation?: number;
  135757. frontUVs?: Vector4;
  135758. backUVs?: Vector4;
  135759. instance?: Mesh;
  135760. invertUV?: boolean;
  135761. }, scene?: Nullable<Scene>): Mesh;
  135762. }
  135763. }
  135764. declare module BABYLON {
  135765. /**
  135766. * Class containing static functions to help procedurally build meshes
  135767. */
  135768. export class IcoSphereBuilder {
  135769. /**
  135770. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135771. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135772. * * 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`)
  135773. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135774. * * 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
  135775. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135776. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135777. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135778. * @param name defines the name of the mesh
  135779. * @param options defines the options used to create the mesh
  135780. * @param scene defines the hosting scene
  135781. * @returns the icosahedron mesh
  135782. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135783. */
  135784. static CreateIcoSphere(name: string, options: {
  135785. radius?: number;
  135786. radiusX?: number;
  135787. radiusY?: number;
  135788. radiusZ?: number;
  135789. flat?: boolean;
  135790. subdivisions?: number;
  135791. sideOrientation?: number;
  135792. frontUVs?: Vector4;
  135793. backUVs?: Vector4;
  135794. updatable?: boolean;
  135795. }, scene?: Nullable<Scene>): Mesh;
  135796. }
  135797. }
  135798. declare module BABYLON {
  135799. /**
  135800. * Class containing static functions to help procedurally build meshes
  135801. */
  135802. export class DecalBuilder {
  135803. /**
  135804. * Creates a decal mesh.
  135805. * 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
  135806. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  135807. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  135808. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  135809. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  135810. * @param name defines the name of the mesh
  135811. * @param sourceMesh defines the mesh where the decal must be applied
  135812. * @param options defines the options used to create the mesh
  135813. * @param scene defines the hosting scene
  135814. * @returns the decal mesh
  135815. * @see https://doc.babylonjs.com/how_to/decals
  135816. */
  135817. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  135818. position?: Vector3;
  135819. normal?: Vector3;
  135820. size?: Vector3;
  135821. angle?: number;
  135822. }): Mesh;
  135823. }
  135824. }
  135825. declare module BABYLON {
  135826. /**
  135827. * Class containing static functions to help procedurally build meshes
  135828. */
  135829. export class MeshBuilder {
  135830. /**
  135831. * Creates a box mesh
  135832. * * The parameter `size` sets the size (float) of each box side (default 1)
  135833. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  135834. * * 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)
  135835. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  135836. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135837. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135838. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135839. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  135840. * @param name defines the name of the mesh
  135841. * @param options defines the options used to create the mesh
  135842. * @param scene defines the hosting scene
  135843. * @returns the box mesh
  135844. */
  135845. static CreateBox(name: string, options: {
  135846. size?: number;
  135847. width?: number;
  135848. height?: number;
  135849. depth?: number;
  135850. faceUV?: Vector4[];
  135851. faceColors?: Color4[];
  135852. sideOrientation?: number;
  135853. frontUVs?: Vector4;
  135854. backUVs?: Vector4;
  135855. wrap?: boolean;
  135856. topBaseAt?: number;
  135857. bottomBaseAt?: number;
  135858. updatable?: boolean;
  135859. }, scene?: Nullable<Scene>): Mesh;
  135860. /**
  135861. * Creates a tiled box mesh
  135862. * * faceTiles sets the pattern, tile size and number of tiles for a face
  135863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135864. * @param name defines the name of the mesh
  135865. * @param options defines the options used to create the mesh
  135866. * @param scene defines the hosting scene
  135867. * @returns the tiled box mesh
  135868. */
  135869. static CreateTiledBox(name: string, options: {
  135870. pattern?: number;
  135871. size?: number;
  135872. width?: number;
  135873. height?: number;
  135874. depth: number;
  135875. tileSize?: number;
  135876. tileWidth?: number;
  135877. tileHeight?: number;
  135878. faceUV?: Vector4[];
  135879. faceColors?: Color4[];
  135880. alignHorizontal?: number;
  135881. alignVertical?: number;
  135882. sideOrientation?: number;
  135883. updatable?: boolean;
  135884. }, scene?: Nullable<Scene>): Mesh;
  135885. /**
  135886. * Creates a sphere mesh
  135887. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  135888. * * 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`)
  135889. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  135890. * * 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
  135891. * * 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)
  135892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135893. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135894. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135895. * @param name defines the name of the mesh
  135896. * @param options defines the options used to create the mesh
  135897. * @param scene defines the hosting scene
  135898. * @returns the sphere mesh
  135899. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  135900. */
  135901. static CreateSphere(name: string, options: {
  135902. segments?: number;
  135903. diameter?: number;
  135904. diameterX?: number;
  135905. diameterY?: number;
  135906. diameterZ?: number;
  135907. arc?: number;
  135908. slice?: number;
  135909. sideOrientation?: number;
  135910. frontUVs?: Vector4;
  135911. backUVs?: Vector4;
  135912. updatable?: boolean;
  135913. }, scene?: Nullable<Scene>): Mesh;
  135914. /**
  135915. * Creates a plane polygonal mesh. By default, this is a disc
  135916. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  135917. * * 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
  135918. * * 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
  135919. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135920. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135921. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135922. * @param name defines the name of the mesh
  135923. * @param options defines the options used to create the mesh
  135924. * @param scene defines the hosting scene
  135925. * @returns the plane polygonal mesh
  135926. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  135927. */
  135928. static CreateDisc(name: string, options: {
  135929. radius?: number;
  135930. tessellation?: number;
  135931. arc?: number;
  135932. updatable?: boolean;
  135933. sideOrientation?: number;
  135934. frontUVs?: Vector4;
  135935. backUVs?: Vector4;
  135936. }, scene?: Nullable<Scene>): Mesh;
  135937. /**
  135938. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  135939. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  135940. * * 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`)
  135941. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  135942. * * 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
  135943. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135944. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135945. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135946. * @param name defines the name of the mesh
  135947. * @param options defines the options used to create the mesh
  135948. * @param scene defines the hosting scene
  135949. * @returns the icosahedron mesh
  135950. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  135951. */
  135952. static CreateIcoSphere(name: string, options: {
  135953. radius?: number;
  135954. radiusX?: number;
  135955. radiusY?: number;
  135956. radiusZ?: number;
  135957. flat?: boolean;
  135958. subdivisions?: number;
  135959. sideOrientation?: number;
  135960. frontUVs?: Vector4;
  135961. backUVs?: Vector4;
  135962. updatable?: boolean;
  135963. }, scene?: Nullable<Scene>): Mesh;
  135964. /**
  135965. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  135966. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  135967. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  135968. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  135969. * * 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
  135970. * * 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
  135971. * * 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
  135972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  135973. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  135974. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  135975. * * 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
  135976. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  135977. * * 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
  135978. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  135979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  135980. * @param name defines the name of the mesh
  135981. * @param options defines the options used to create the mesh
  135982. * @param scene defines the hosting scene
  135983. * @returns the ribbon mesh
  135984. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  135985. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  135986. */
  135987. static CreateRibbon(name: string, options: {
  135988. pathArray: Vector3[][];
  135989. closeArray?: boolean;
  135990. closePath?: boolean;
  135991. offset?: number;
  135992. updatable?: boolean;
  135993. sideOrientation?: number;
  135994. frontUVs?: Vector4;
  135995. backUVs?: Vector4;
  135996. instance?: Mesh;
  135997. invertUV?: boolean;
  135998. uvs?: Vector2[];
  135999. colors?: Color4[];
  136000. }, scene?: Nullable<Scene>): Mesh;
  136001. /**
  136002. * Creates a cylinder or a cone mesh
  136003. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  136004. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  136005. * * 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.
  136006. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  136007. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  136008. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  136009. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  136010. * * 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).
  136011. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  136012. * * 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).
  136013. * * 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
  136014. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  136015. * * 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
  136016. * * 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.
  136017. * * If `enclose` is false, a ring surface is one element.
  136018. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  136019. * * 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
  136020. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136021. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136022. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136023. * @param name defines the name of the mesh
  136024. * @param options defines the options used to create the mesh
  136025. * @param scene defines the hosting scene
  136026. * @returns the cylinder mesh
  136027. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  136028. */
  136029. static CreateCylinder(name: string, options: {
  136030. height?: number;
  136031. diameterTop?: number;
  136032. diameterBottom?: number;
  136033. diameter?: number;
  136034. tessellation?: number;
  136035. subdivisions?: number;
  136036. arc?: number;
  136037. faceColors?: Color4[];
  136038. faceUV?: Vector4[];
  136039. updatable?: boolean;
  136040. hasRings?: boolean;
  136041. enclose?: boolean;
  136042. cap?: number;
  136043. sideOrientation?: number;
  136044. frontUVs?: Vector4;
  136045. backUVs?: Vector4;
  136046. }, scene?: Nullable<Scene>): Mesh;
  136047. /**
  136048. * Creates a torus mesh
  136049. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  136050. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  136051. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  136052. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136053. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136054. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136055. * @param name defines the name of the mesh
  136056. * @param options defines the options used to create the mesh
  136057. * @param scene defines the hosting scene
  136058. * @returns the torus mesh
  136059. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  136060. */
  136061. static CreateTorus(name: string, options: {
  136062. diameter?: number;
  136063. thickness?: number;
  136064. tessellation?: number;
  136065. updatable?: boolean;
  136066. sideOrientation?: number;
  136067. frontUVs?: Vector4;
  136068. backUVs?: Vector4;
  136069. }, scene?: Nullable<Scene>): Mesh;
  136070. /**
  136071. * Creates a torus knot mesh
  136072. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  136073. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  136074. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  136075. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  136076. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136077. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136078. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136079. * @param name defines the name of the mesh
  136080. * @param options defines the options used to create the mesh
  136081. * @param scene defines the hosting scene
  136082. * @returns the torus knot mesh
  136083. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  136084. */
  136085. static CreateTorusKnot(name: string, options: {
  136086. radius?: number;
  136087. tube?: number;
  136088. radialSegments?: number;
  136089. tubularSegments?: number;
  136090. p?: number;
  136091. q?: number;
  136092. updatable?: boolean;
  136093. sideOrientation?: number;
  136094. frontUVs?: Vector4;
  136095. backUVs?: Vector4;
  136096. }, scene?: Nullable<Scene>): Mesh;
  136097. /**
  136098. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  136099. * * 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
  136100. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  136101. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  136102. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  136103. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  136104. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  136105. * * 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
  136106. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  136107. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136108. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  136109. * @param name defines the name of the new line system
  136110. * @param options defines the options used to create the line system
  136111. * @param scene defines the hosting scene
  136112. * @returns a new line system mesh
  136113. */
  136114. static CreateLineSystem(name: string, options: {
  136115. lines: Vector3[][];
  136116. updatable?: boolean;
  136117. instance?: Nullable<LinesMesh>;
  136118. colors?: Nullable<Color4[][]>;
  136119. useVertexAlpha?: boolean;
  136120. }, scene: Nullable<Scene>): LinesMesh;
  136121. /**
  136122. * Creates a line mesh
  136123. * 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
  136124. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136125. * * The parameter `points` is an array successive Vector3
  136126. * * 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
  136127. * * The optional parameter `colors` is an array of successive Color4, one per line point
  136128. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  136129. * * When updating an instance, remember that only point positions can change, not the number of points
  136130. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136131. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  136132. * @param name defines the name of the new line system
  136133. * @param options defines the options used to create the line system
  136134. * @param scene defines the hosting scene
  136135. * @returns a new line mesh
  136136. */
  136137. static CreateLines(name: string, options: {
  136138. points: Vector3[];
  136139. updatable?: boolean;
  136140. instance?: Nullable<LinesMesh>;
  136141. colors?: Color4[];
  136142. useVertexAlpha?: boolean;
  136143. }, scene?: Nullable<Scene>): LinesMesh;
  136144. /**
  136145. * Creates a dashed line mesh
  136146. * * 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
  136147. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  136148. * * The parameter `points` is an array successive Vector3
  136149. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  136150. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  136151. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  136152. * * 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
  136153. * * When updating an instance, remember that only point positions can change, not the number of points
  136154. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136155. * @param name defines the name of the mesh
  136156. * @param options defines the options used to create the mesh
  136157. * @param scene defines the hosting scene
  136158. * @returns the dashed line mesh
  136159. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  136160. */
  136161. static CreateDashedLines(name: string, options: {
  136162. points: Vector3[];
  136163. dashSize?: number;
  136164. gapSize?: number;
  136165. dashNb?: number;
  136166. updatable?: boolean;
  136167. instance?: LinesMesh;
  136168. }, scene?: Nullable<Scene>): LinesMesh;
  136169. /**
  136170. * 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.
  136171. * * 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.
  136172. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136173. * * 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.
  136174. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  136175. * * 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
  136176. * * 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
  136177. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  136178. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136179. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136180. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  136181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136182. * @param name defines the name of the mesh
  136183. * @param options defines the options used to create the mesh
  136184. * @param scene defines the hosting scene
  136185. * @returns the extruded shape mesh
  136186. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136187. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136188. */
  136189. static ExtrudeShape(name: string, options: {
  136190. shape: Vector3[];
  136191. path: Vector3[];
  136192. scale?: number;
  136193. rotation?: number;
  136194. cap?: number;
  136195. updatable?: boolean;
  136196. sideOrientation?: number;
  136197. frontUVs?: Vector4;
  136198. backUVs?: Vector4;
  136199. instance?: Mesh;
  136200. invertUV?: boolean;
  136201. }, scene?: Nullable<Scene>): Mesh;
  136202. /**
  136203. * Creates an custom extruded shape mesh.
  136204. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  136205. * * 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.
  136206. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  136207. * * 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
  136208. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  136209. * * 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
  136210. * * It must returns a float value that will be the scale value applied to the shape on each path point
  136211. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  136212. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  136213. * * 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
  136214. * * 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
  136215. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  136216. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136217. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136218. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136220. * @param name defines the name of the mesh
  136221. * @param options defines the options used to create the mesh
  136222. * @param scene defines the hosting scene
  136223. * @returns the custom extruded shape mesh
  136224. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  136225. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136226. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  136227. */
  136228. static ExtrudeShapeCustom(name: string, options: {
  136229. shape: Vector3[];
  136230. path: Vector3[];
  136231. scaleFunction?: any;
  136232. rotationFunction?: any;
  136233. ribbonCloseArray?: boolean;
  136234. ribbonClosePath?: boolean;
  136235. cap?: number;
  136236. updatable?: boolean;
  136237. sideOrientation?: number;
  136238. frontUVs?: Vector4;
  136239. backUVs?: Vector4;
  136240. instance?: Mesh;
  136241. invertUV?: boolean;
  136242. }, scene?: Nullable<Scene>): Mesh;
  136243. /**
  136244. * Creates lathe mesh.
  136245. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  136246. * * 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
  136247. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  136248. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  136249. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  136250. * * 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
  136251. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  136252. * * 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
  136253. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136254. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136255. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136257. * @param name defines the name of the mesh
  136258. * @param options defines the options used to create the mesh
  136259. * @param scene defines the hosting scene
  136260. * @returns the lathe mesh
  136261. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  136262. */
  136263. static CreateLathe(name: string, options: {
  136264. shape: Vector3[];
  136265. radius?: number;
  136266. tessellation?: number;
  136267. clip?: number;
  136268. arc?: number;
  136269. closed?: boolean;
  136270. updatable?: boolean;
  136271. sideOrientation?: number;
  136272. frontUVs?: Vector4;
  136273. backUVs?: Vector4;
  136274. cap?: number;
  136275. invertUV?: boolean;
  136276. }, scene?: Nullable<Scene>): Mesh;
  136277. /**
  136278. * Creates a tiled plane mesh
  136279. * * You can set a limited pattern arrangement with the tiles
  136280. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136281. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136282. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136283. * @param name defines the name of the mesh
  136284. * @param options defines the options used to create the mesh
  136285. * @param scene defines the hosting scene
  136286. * @returns the plane mesh
  136287. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136288. */
  136289. static CreateTiledPlane(name: string, options: {
  136290. pattern?: number;
  136291. tileSize?: number;
  136292. tileWidth?: number;
  136293. tileHeight?: number;
  136294. size?: number;
  136295. width?: number;
  136296. height?: number;
  136297. alignHorizontal?: number;
  136298. alignVertical?: number;
  136299. sideOrientation?: number;
  136300. frontUVs?: Vector4;
  136301. backUVs?: Vector4;
  136302. updatable?: boolean;
  136303. }, scene?: Nullable<Scene>): Mesh;
  136304. /**
  136305. * Creates a plane mesh
  136306. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  136307. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  136308. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  136309. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136310. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136311. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136312. * @param name defines the name of the mesh
  136313. * @param options defines the options used to create the mesh
  136314. * @param scene defines the hosting scene
  136315. * @returns the plane mesh
  136316. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  136317. */
  136318. static CreatePlane(name: string, options: {
  136319. size?: number;
  136320. width?: number;
  136321. height?: number;
  136322. sideOrientation?: number;
  136323. frontUVs?: Vector4;
  136324. backUVs?: Vector4;
  136325. updatable?: boolean;
  136326. sourcePlane?: Plane;
  136327. }, scene?: Nullable<Scene>): Mesh;
  136328. /**
  136329. * Creates a ground mesh
  136330. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  136331. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  136332. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136333. * @param name defines the name of the mesh
  136334. * @param options defines the options used to create the mesh
  136335. * @param scene defines the hosting scene
  136336. * @returns the ground mesh
  136337. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  136338. */
  136339. static CreateGround(name: string, options: {
  136340. width?: number;
  136341. height?: number;
  136342. subdivisions?: number;
  136343. subdivisionsX?: number;
  136344. subdivisionsY?: number;
  136345. updatable?: boolean;
  136346. }, scene?: Nullable<Scene>): Mesh;
  136347. /**
  136348. * Creates a tiled ground mesh
  136349. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  136350. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  136351. * * 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
  136352. * * 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
  136353. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136354. * @param name defines the name of the mesh
  136355. * @param options defines the options used to create the mesh
  136356. * @param scene defines the hosting scene
  136357. * @returns the tiled ground mesh
  136358. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  136359. */
  136360. static CreateTiledGround(name: string, options: {
  136361. xmin: number;
  136362. zmin: number;
  136363. xmax: number;
  136364. zmax: number;
  136365. subdivisions?: {
  136366. w: number;
  136367. h: number;
  136368. };
  136369. precision?: {
  136370. w: number;
  136371. h: number;
  136372. };
  136373. updatable?: boolean;
  136374. }, scene?: Nullable<Scene>): Mesh;
  136375. /**
  136376. * Creates a ground mesh from a height map
  136377. * * The parameter `url` sets the URL of the height map image resource.
  136378. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  136379. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  136380. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  136381. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  136382. * * 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.
  136383. * * 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).
  136384. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  136385. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  136386. * @param name defines the name of the mesh
  136387. * @param url defines the url to the height map
  136388. * @param options defines the options used to create the mesh
  136389. * @param scene defines the hosting scene
  136390. * @returns the ground mesh
  136391. * @see https://doc.babylonjs.com/babylon101/height_map
  136392. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  136393. */
  136394. static CreateGroundFromHeightMap(name: string, url: string, options: {
  136395. width?: number;
  136396. height?: number;
  136397. subdivisions?: number;
  136398. minHeight?: number;
  136399. maxHeight?: number;
  136400. colorFilter?: Color3;
  136401. alphaFilter?: number;
  136402. updatable?: boolean;
  136403. onReady?: (mesh: GroundMesh) => void;
  136404. }, scene?: Nullable<Scene>): GroundMesh;
  136405. /**
  136406. * Creates a polygon mesh
  136407. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  136408. * * 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
  136409. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  136410. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136411. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  136412. * * Remember you can only change the shape positions, not their number when updating a polygon
  136413. * @param name defines the name of the mesh
  136414. * @param options defines the options used to create the mesh
  136415. * @param scene defines the hosting scene
  136416. * @param earcutInjection can be used to inject your own earcut reference
  136417. * @returns the polygon mesh
  136418. */
  136419. static CreatePolygon(name: string, options: {
  136420. shape: Vector3[];
  136421. holes?: Vector3[][];
  136422. depth?: number;
  136423. faceUV?: Vector4[];
  136424. faceColors?: Color4[];
  136425. updatable?: boolean;
  136426. sideOrientation?: number;
  136427. frontUVs?: Vector4;
  136428. backUVs?: Vector4;
  136429. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136430. /**
  136431. * Creates an extruded polygon mesh, with depth in the Y direction.
  136432. * * 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)
  136433. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  136434. * @param name defines the name of the mesh
  136435. * @param options defines the options used to create the mesh
  136436. * @param scene defines the hosting scene
  136437. * @param earcutInjection can be used to inject your own earcut reference
  136438. * @returns the polygon mesh
  136439. */
  136440. static ExtrudePolygon(name: string, options: {
  136441. shape: Vector3[];
  136442. holes?: Vector3[][];
  136443. depth?: number;
  136444. faceUV?: Vector4[];
  136445. faceColors?: Color4[];
  136446. updatable?: boolean;
  136447. sideOrientation?: number;
  136448. frontUVs?: Vector4;
  136449. backUVs?: Vector4;
  136450. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  136451. /**
  136452. * Creates a tube mesh.
  136453. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  136454. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  136455. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  136456. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  136457. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  136458. * * 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)
  136459. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  136460. * * 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
  136461. * * 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
  136462. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136463. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136464. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  136465. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136466. * @param name defines the name of the mesh
  136467. * @param options defines the options used to create the mesh
  136468. * @param scene defines the hosting scene
  136469. * @returns the tube mesh
  136470. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  136471. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  136472. */
  136473. static CreateTube(name: string, options: {
  136474. path: Vector3[];
  136475. radius?: number;
  136476. tessellation?: number;
  136477. radiusFunction?: {
  136478. (i: number, distance: number): number;
  136479. };
  136480. cap?: number;
  136481. arc?: number;
  136482. updatable?: boolean;
  136483. sideOrientation?: number;
  136484. frontUVs?: Vector4;
  136485. backUVs?: Vector4;
  136486. instance?: Mesh;
  136487. invertUV?: boolean;
  136488. }, scene?: Nullable<Scene>): Mesh;
  136489. /**
  136490. * Creates a polyhedron mesh
  136491. * * 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
  136492. * * The parameter `size` (positive float, default 1) sets the polygon size
  136493. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  136494. * * 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`
  136495. * * 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
  136496. * * 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)`)
  136497. * * 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
  136498. * * 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
  136499. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  136500. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  136501. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  136502. * @param name defines the name of the mesh
  136503. * @param options defines the options used to create the mesh
  136504. * @param scene defines the hosting scene
  136505. * @returns the polyhedron mesh
  136506. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  136507. */
  136508. static CreatePolyhedron(name: string, options: {
  136509. type?: number;
  136510. size?: number;
  136511. sizeX?: number;
  136512. sizeY?: number;
  136513. sizeZ?: number;
  136514. custom?: any;
  136515. faceUV?: Vector4[];
  136516. faceColors?: Color4[];
  136517. flat?: boolean;
  136518. updatable?: boolean;
  136519. sideOrientation?: number;
  136520. frontUVs?: Vector4;
  136521. backUVs?: Vector4;
  136522. }, scene?: Nullable<Scene>): Mesh;
  136523. /**
  136524. * Creates a decal mesh.
  136525. * 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
  136526. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  136527. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  136528. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  136529. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  136530. * @param name defines the name of the mesh
  136531. * @param sourceMesh defines the mesh where the decal must be applied
  136532. * @param options defines the options used to create the mesh
  136533. * @param scene defines the hosting scene
  136534. * @returns the decal mesh
  136535. * @see https://doc.babylonjs.com/how_to/decals
  136536. */
  136537. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  136538. position?: Vector3;
  136539. normal?: Vector3;
  136540. size?: Vector3;
  136541. angle?: number;
  136542. }): Mesh;
  136543. }
  136544. }
  136545. declare module BABYLON {
  136546. /**
  136547. * A simplifier interface for future simplification implementations
  136548. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136549. */
  136550. export interface ISimplifier {
  136551. /**
  136552. * Simplification of a given mesh according to the given settings.
  136553. * Since this requires computation, it is assumed that the function runs async.
  136554. * @param settings The settings of the simplification, including quality and distance
  136555. * @param successCallback A callback that will be called after the mesh was simplified.
  136556. * @param errorCallback in case of an error, this callback will be called. optional.
  136557. */
  136558. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  136559. }
  136560. /**
  136561. * Expected simplification settings.
  136562. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  136563. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136564. */
  136565. export interface ISimplificationSettings {
  136566. /**
  136567. * Gets or sets the expected quality
  136568. */
  136569. quality: number;
  136570. /**
  136571. * Gets or sets the distance when this optimized version should be used
  136572. */
  136573. distance: number;
  136574. /**
  136575. * Gets an already optimized mesh
  136576. */
  136577. optimizeMesh?: boolean;
  136578. }
  136579. /**
  136580. * Class used to specify simplification options
  136581. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136582. */
  136583. export class SimplificationSettings implements ISimplificationSettings {
  136584. /** expected quality */
  136585. quality: number;
  136586. /** distance when this optimized version should be used */
  136587. distance: number;
  136588. /** already optimized mesh */
  136589. optimizeMesh?: boolean | undefined;
  136590. /**
  136591. * Creates a SimplificationSettings
  136592. * @param quality expected quality
  136593. * @param distance distance when this optimized version should be used
  136594. * @param optimizeMesh already optimized mesh
  136595. */
  136596. constructor(
  136597. /** expected quality */
  136598. quality: number,
  136599. /** distance when this optimized version should be used */
  136600. distance: number,
  136601. /** already optimized mesh */
  136602. optimizeMesh?: boolean | undefined);
  136603. }
  136604. /**
  136605. * Interface used to define a simplification task
  136606. */
  136607. export interface ISimplificationTask {
  136608. /**
  136609. * Array of settings
  136610. */
  136611. settings: Array<ISimplificationSettings>;
  136612. /**
  136613. * Simplification type
  136614. */
  136615. simplificationType: SimplificationType;
  136616. /**
  136617. * Mesh to simplify
  136618. */
  136619. mesh: Mesh;
  136620. /**
  136621. * Callback called on success
  136622. */
  136623. successCallback?: () => void;
  136624. /**
  136625. * Defines if parallel processing can be used
  136626. */
  136627. parallelProcessing: boolean;
  136628. }
  136629. /**
  136630. * Queue used to order the simplification tasks
  136631. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136632. */
  136633. export class SimplificationQueue {
  136634. private _simplificationArray;
  136635. /**
  136636. * Gets a boolean indicating that the process is still running
  136637. */
  136638. running: boolean;
  136639. /**
  136640. * Creates a new queue
  136641. */
  136642. constructor();
  136643. /**
  136644. * Adds a new simplification task
  136645. * @param task defines a task to add
  136646. */
  136647. addTask(task: ISimplificationTask): void;
  136648. /**
  136649. * Execute next task
  136650. */
  136651. executeNext(): void;
  136652. /**
  136653. * Execute a simplification task
  136654. * @param task defines the task to run
  136655. */
  136656. runSimplification(task: ISimplificationTask): void;
  136657. private getSimplifier;
  136658. }
  136659. /**
  136660. * The implemented types of simplification
  136661. * At the moment only Quadratic Error Decimation is implemented
  136662. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136663. */
  136664. export enum SimplificationType {
  136665. /** Quadratic error decimation */
  136666. QUADRATIC = 0
  136667. }
  136668. /**
  136669. * An implementation of the Quadratic Error simplification algorithm.
  136670. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  136671. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  136672. * @author RaananW
  136673. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136674. */
  136675. export class QuadraticErrorSimplification implements ISimplifier {
  136676. private _mesh;
  136677. private triangles;
  136678. private vertices;
  136679. private references;
  136680. private _reconstructedMesh;
  136681. /** Gets or sets the number pf sync interations */
  136682. syncIterations: number;
  136683. /** Gets or sets the aggressiveness of the simplifier */
  136684. aggressiveness: number;
  136685. /** Gets or sets the number of allowed iterations for decimation */
  136686. decimationIterations: number;
  136687. /** Gets or sets the espilon to use for bounding box computation */
  136688. boundingBoxEpsilon: number;
  136689. /**
  136690. * Creates a new QuadraticErrorSimplification
  136691. * @param _mesh defines the target mesh
  136692. */
  136693. constructor(_mesh: Mesh);
  136694. /**
  136695. * Simplification of a given mesh according to the given settings.
  136696. * Since this requires computation, it is assumed that the function runs async.
  136697. * @param settings The settings of the simplification, including quality and distance
  136698. * @param successCallback A callback that will be called after the mesh was simplified.
  136699. */
  136700. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  136701. private runDecimation;
  136702. private initWithMesh;
  136703. private init;
  136704. private reconstructMesh;
  136705. private initDecimatedMesh;
  136706. private isFlipped;
  136707. private updateTriangles;
  136708. private identifyBorder;
  136709. private updateMesh;
  136710. private vertexError;
  136711. private calculateError;
  136712. }
  136713. }
  136714. declare module BABYLON {
  136715. interface Scene {
  136716. /** @hidden (Backing field) */
  136717. _simplificationQueue: SimplificationQueue;
  136718. /**
  136719. * Gets or sets the simplification queue attached to the scene
  136720. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  136721. */
  136722. simplificationQueue: SimplificationQueue;
  136723. }
  136724. interface Mesh {
  136725. /**
  136726. * Simplify the mesh according to the given array of settings.
  136727. * Function will return immediately and will simplify async
  136728. * @param settings a collection of simplification settings
  136729. * @param parallelProcessing should all levels calculate parallel or one after the other
  136730. * @param simplificationType the type of simplification to run
  136731. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  136732. * @returns the current mesh
  136733. */
  136734. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  136735. }
  136736. /**
  136737. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  136738. * created in a scene
  136739. */
  136740. export class SimplicationQueueSceneComponent implements ISceneComponent {
  136741. /**
  136742. * The component name helpfull to identify the component in the list of scene components.
  136743. */
  136744. readonly name: string;
  136745. /**
  136746. * The scene the component belongs to.
  136747. */
  136748. scene: Scene;
  136749. /**
  136750. * Creates a new instance of the component for the given scene
  136751. * @param scene Defines the scene to register the component in
  136752. */
  136753. constructor(scene: Scene);
  136754. /**
  136755. * Registers the component in a given scene
  136756. */
  136757. register(): void;
  136758. /**
  136759. * Rebuilds the elements related to this component in case of
  136760. * context lost for instance.
  136761. */
  136762. rebuild(): void;
  136763. /**
  136764. * Disposes the component and the associated ressources
  136765. */
  136766. dispose(): void;
  136767. private _beforeCameraUpdate;
  136768. }
  136769. }
  136770. declare module BABYLON {
  136771. /**
  136772. * Navigation plugin interface to add navigation constrained by a navigation mesh
  136773. */
  136774. export interface INavigationEnginePlugin {
  136775. /**
  136776. * plugin name
  136777. */
  136778. name: string;
  136779. /**
  136780. * Creates a navigation mesh
  136781. * @param meshes array of all the geometry used to compute the navigatio mesh
  136782. * @param parameters bunch of parameters used to filter geometry
  136783. */
  136784. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  136785. /**
  136786. * Create a navigation mesh debug mesh
  136787. * @param scene is where the mesh will be added
  136788. * @returns debug display mesh
  136789. */
  136790. createDebugNavMesh(scene: Scene): Mesh;
  136791. /**
  136792. * Get a navigation mesh constrained position, closest to the parameter position
  136793. * @param position world position
  136794. * @returns the closest point to position constrained by the navigation mesh
  136795. */
  136796. getClosestPoint(position: Vector3): Vector3;
  136797. /**
  136798. * Get a navigation mesh constrained position, closest to the parameter position
  136799. * @param position world position
  136800. * @param result output the closest point to position constrained by the navigation mesh
  136801. */
  136802. getClosestPointToRef(position: Vector3, result: Vector3): void;
  136803. /**
  136804. * Get a navigation mesh constrained position, within a particular radius
  136805. * @param position world position
  136806. * @param maxRadius the maximum distance to the constrained world position
  136807. * @returns the closest point to position constrained by the navigation mesh
  136808. */
  136809. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  136810. /**
  136811. * Get a navigation mesh constrained position, within a particular radius
  136812. * @param position world position
  136813. * @param maxRadius the maximum distance to the constrained world position
  136814. * @param result output the closest point to position constrained by the navigation mesh
  136815. */
  136816. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  136817. /**
  136818. * Compute the final position from a segment made of destination-position
  136819. * @param position world position
  136820. * @param destination world position
  136821. * @returns the resulting point along the navmesh
  136822. */
  136823. moveAlong(position: Vector3, destination: Vector3): Vector3;
  136824. /**
  136825. * Compute the final position from a segment made of destination-position
  136826. * @param position world position
  136827. * @param destination world position
  136828. * @param result output the resulting point along the navmesh
  136829. */
  136830. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  136831. /**
  136832. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  136833. * @param start world position
  136834. * @param end world position
  136835. * @returns array containing world position composing the path
  136836. */
  136837. computePath(start: Vector3, end: Vector3): Vector3[];
  136838. /**
  136839. * If this plugin is supported
  136840. * @returns true if plugin is supported
  136841. */
  136842. isSupported(): boolean;
  136843. /**
  136844. * Create a new Crowd so you can add agents
  136845. * @param maxAgents the maximum agent count in the crowd
  136846. * @param maxAgentRadius the maximum radius an agent can have
  136847. * @param scene to attach the crowd to
  136848. * @returns the crowd you can add agents to
  136849. */
  136850. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  136851. /**
  136852. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136853. * The queries will try to find a solution within those bounds
  136854. * default is (1,1,1)
  136855. * @param extent x,y,z value that define the extent around the queries point of reference
  136856. */
  136857. setDefaultQueryExtent(extent: Vector3): void;
  136858. /**
  136859. * Get the Bounding box extent specified by setDefaultQueryExtent
  136860. * @returns the box extent values
  136861. */
  136862. getDefaultQueryExtent(): Vector3;
  136863. /**
  136864. * build the navmesh from a previously saved state using getNavmeshData
  136865. * @param data the Uint8Array returned by getNavmeshData
  136866. */
  136867. buildFromNavmeshData(data: Uint8Array): void;
  136868. /**
  136869. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  136870. * @returns data the Uint8Array that can be saved and reused
  136871. */
  136872. getNavmeshData(): Uint8Array;
  136873. /**
  136874. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136875. * @param result output the box extent values
  136876. */
  136877. getDefaultQueryExtentToRef(result: Vector3): void;
  136878. /**
  136879. * Release all resources
  136880. */
  136881. dispose(): void;
  136882. }
  136883. /**
  136884. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  136885. */
  136886. export interface ICrowd {
  136887. /**
  136888. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  136889. * You can attach anything to that node. The node position is updated in the scene update tick.
  136890. * @param pos world position that will be constrained by the navigation mesh
  136891. * @param parameters agent parameters
  136892. * @param transform hooked to the agent that will be update by the scene
  136893. * @returns agent index
  136894. */
  136895. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  136896. /**
  136897. * Returns the agent position in world space
  136898. * @param index agent index returned by addAgent
  136899. * @returns world space position
  136900. */
  136901. getAgentPosition(index: number): Vector3;
  136902. /**
  136903. * Gets the agent position result in world space
  136904. * @param index agent index returned by addAgent
  136905. * @param result output world space position
  136906. */
  136907. getAgentPositionToRef(index: number, result: Vector3): void;
  136908. /**
  136909. * Gets the agent velocity in world space
  136910. * @param index agent index returned by addAgent
  136911. * @returns world space velocity
  136912. */
  136913. getAgentVelocity(index: number): Vector3;
  136914. /**
  136915. * Gets the agent velocity result in world space
  136916. * @param index agent index returned by addAgent
  136917. * @param result output world space velocity
  136918. */
  136919. getAgentVelocityToRef(index: number, result: Vector3): void;
  136920. /**
  136921. * remove a particular agent previously created
  136922. * @param index agent index returned by addAgent
  136923. */
  136924. removeAgent(index: number): void;
  136925. /**
  136926. * get the list of all agents attached to this crowd
  136927. * @returns list of agent indices
  136928. */
  136929. getAgents(): number[];
  136930. /**
  136931. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  136932. * @param deltaTime in seconds
  136933. */
  136934. update(deltaTime: number): void;
  136935. /**
  136936. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  136937. * @param index agent index returned by addAgent
  136938. * @param destination targeted world position
  136939. */
  136940. agentGoto(index: number, destination: Vector3): void;
  136941. /**
  136942. * Teleport the agent to a new position
  136943. * @param index agent index returned by addAgent
  136944. * @param destination targeted world position
  136945. */
  136946. agentTeleport(index: number, destination: Vector3): void;
  136947. /**
  136948. * Update agent parameters
  136949. * @param index agent index returned by addAgent
  136950. * @param parameters agent parameters
  136951. */
  136952. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  136953. /**
  136954. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  136955. * The queries will try to find a solution within those bounds
  136956. * default is (1,1,1)
  136957. * @param extent x,y,z value that define the extent around the queries point of reference
  136958. */
  136959. setDefaultQueryExtent(extent: Vector3): void;
  136960. /**
  136961. * Get the Bounding box extent specified by setDefaultQueryExtent
  136962. * @returns the box extent values
  136963. */
  136964. getDefaultQueryExtent(): Vector3;
  136965. /**
  136966. * Get the Bounding box extent result specified by setDefaultQueryExtent
  136967. * @param result output the box extent values
  136968. */
  136969. getDefaultQueryExtentToRef(result: Vector3): void;
  136970. /**
  136971. * Release all resources
  136972. */
  136973. dispose(): void;
  136974. }
  136975. /**
  136976. * Configures an agent
  136977. */
  136978. export interface IAgentParameters {
  136979. /**
  136980. * Agent radius. [Limit: >= 0]
  136981. */
  136982. radius: number;
  136983. /**
  136984. * Agent height. [Limit: > 0]
  136985. */
  136986. height: number;
  136987. /**
  136988. * Maximum allowed acceleration. [Limit: >= 0]
  136989. */
  136990. maxAcceleration: number;
  136991. /**
  136992. * Maximum allowed speed. [Limit: >= 0]
  136993. */
  136994. maxSpeed: number;
  136995. /**
  136996. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  136997. */
  136998. collisionQueryRange: number;
  136999. /**
  137000. * The path visibility optimization range. [Limit: > 0]
  137001. */
  137002. pathOptimizationRange: number;
  137003. /**
  137004. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  137005. */
  137006. separationWeight: number;
  137007. }
  137008. /**
  137009. * Configures the navigation mesh creation
  137010. */
  137011. export interface INavMeshParameters {
  137012. /**
  137013. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  137014. */
  137015. cs: number;
  137016. /**
  137017. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  137018. */
  137019. ch: number;
  137020. /**
  137021. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  137022. */
  137023. walkableSlopeAngle: number;
  137024. /**
  137025. * Minimum floor to 'ceiling' height that will still allow the floor area to
  137026. * be considered walkable. [Limit: >= 3] [Units: vx]
  137027. */
  137028. walkableHeight: number;
  137029. /**
  137030. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  137031. */
  137032. walkableClimb: number;
  137033. /**
  137034. * The distance to erode/shrink the walkable area of the heightfield away from
  137035. * obstructions. [Limit: >=0] [Units: vx]
  137036. */
  137037. walkableRadius: number;
  137038. /**
  137039. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  137040. */
  137041. maxEdgeLen: number;
  137042. /**
  137043. * The maximum distance a simplfied contour's border edges should deviate
  137044. * the original raw contour. [Limit: >=0] [Units: vx]
  137045. */
  137046. maxSimplificationError: number;
  137047. /**
  137048. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  137049. */
  137050. minRegionArea: number;
  137051. /**
  137052. * Any regions with a span count smaller than this value will, if possible,
  137053. * be merged with larger regions. [Limit: >=0] [Units: vx]
  137054. */
  137055. mergeRegionArea: number;
  137056. /**
  137057. * The maximum number of vertices allowed for polygons generated during the
  137058. * contour to polygon conversion process. [Limit: >= 3]
  137059. */
  137060. maxVertsPerPoly: number;
  137061. /**
  137062. * Sets the sampling distance to use when generating the detail mesh.
  137063. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  137064. */
  137065. detailSampleDist: number;
  137066. /**
  137067. * The maximum distance the detail mesh surface should deviate from heightfield
  137068. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  137069. */
  137070. detailSampleMaxError: number;
  137071. }
  137072. }
  137073. declare module BABYLON {
  137074. /**
  137075. * RecastJS navigation plugin
  137076. */
  137077. export class RecastJSPlugin implements INavigationEnginePlugin {
  137078. /**
  137079. * Reference to the Recast library
  137080. */
  137081. bjsRECAST: any;
  137082. /**
  137083. * plugin name
  137084. */
  137085. name: string;
  137086. /**
  137087. * the first navmesh created. We might extend this to support multiple navmeshes
  137088. */
  137089. navMesh: any;
  137090. /**
  137091. * Initializes the recastJS plugin
  137092. * @param recastInjection can be used to inject your own recast reference
  137093. */
  137094. constructor(recastInjection?: any);
  137095. /**
  137096. * Creates a navigation mesh
  137097. * @param meshes array of all the geometry used to compute the navigatio mesh
  137098. * @param parameters bunch of parameters used to filter geometry
  137099. */
  137100. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  137101. /**
  137102. * Create a navigation mesh debug mesh
  137103. * @param scene is where the mesh will be added
  137104. * @returns debug display mesh
  137105. */
  137106. createDebugNavMesh(scene: Scene): Mesh;
  137107. /**
  137108. * Get a navigation mesh constrained position, closest to the parameter position
  137109. * @param position world position
  137110. * @returns the closest point to position constrained by the navigation mesh
  137111. */
  137112. getClosestPoint(position: Vector3): Vector3;
  137113. /**
  137114. * Get a navigation mesh constrained position, closest to the parameter position
  137115. * @param position world position
  137116. * @param result output the closest point to position constrained by the navigation mesh
  137117. */
  137118. getClosestPointToRef(position: Vector3, result: Vector3): void;
  137119. /**
  137120. * Get a navigation mesh constrained position, within a particular radius
  137121. * @param position world position
  137122. * @param maxRadius the maximum distance to the constrained world position
  137123. * @returns the closest point to position constrained by the navigation mesh
  137124. */
  137125. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  137126. /**
  137127. * Get a navigation mesh constrained position, within a particular radius
  137128. * @param position world position
  137129. * @param maxRadius the maximum distance to the constrained world position
  137130. * @param result output the closest point to position constrained by the navigation mesh
  137131. */
  137132. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  137133. /**
  137134. * Compute the final position from a segment made of destination-position
  137135. * @param position world position
  137136. * @param destination world position
  137137. * @returns the resulting point along the navmesh
  137138. */
  137139. moveAlong(position: Vector3, destination: Vector3): Vector3;
  137140. /**
  137141. * Compute the final position from a segment made of destination-position
  137142. * @param position world position
  137143. * @param destination world position
  137144. * @param result output the resulting point along the navmesh
  137145. */
  137146. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  137147. /**
  137148. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  137149. * @param start world position
  137150. * @param end world position
  137151. * @returns array containing world position composing the path
  137152. */
  137153. computePath(start: Vector3, end: Vector3): Vector3[];
  137154. /**
  137155. * Create a new Crowd so you can add agents
  137156. * @param maxAgents the maximum agent count in the crowd
  137157. * @param maxAgentRadius the maximum radius an agent can have
  137158. * @param scene to attach the crowd to
  137159. * @returns the crowd you can add agents to
  137160. */
  137161. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  137162. /**
  137163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137164. * The queries will try to find a solution within those bounds
  137165. * default is (1,1,1)
  137166. * @param extent x,y,z value that define the extent around the queries point of reference
  137167. */
  137168. setDefaultQueryExtent(extent: Vector3): void;
  137169. /**
  137170. * Get the Bounding box extent specified by setDefaultQueryExtent
  137171. * @returns the box extent values
  137172. */
  137173. getDefaultQueryExtent(): Vector3;
  137174. /**
  137175. * build the navmesh from a previously saved state using getNavmeshData
  137176. * @param data the Uint8Array returned by getNavmeshData
  137177. */
  137178. buildFromNavmeshData(data: Uint8Array): void;
  137179. /**
  137180. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  137181. * @returns data the Uint8Array that can be saved and reused
  137182. */
  137183. getNavmeshData(): Uint8Array;
  137184. /**
  137185. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137186. * @param result output the box extent values
  137187. */
  137188. getDefaultQueryExtentToRef(result: Vector3): void;
  137189. /**
  137190. * Disposes
  137191. */
  137192. dispose(): void;
  137193. /**
  137194. * If this plugin is supported
  137195. * @returns true if plugin is supported
  137196. */
  137197. isSupported(): boolean;
  137198. }
  137199. /**
  137200. * Recast detour crowd implementation
  137201. */
  137202. export class RecastJSCrowd implements ICrowd {
  137203. /**
  137204. * Recast/detour plugin
  137205. */
  137206. bjsRECASTPlugin: RecastJSPlugin;
  137207. /**
  137208. * Link to the detour crowd
  137209. */
  137210. recastCrowd: any;
  137211. /**
  137212. * One transform per agent
  137213. */
  137214. transforms: TransformNode[];
  137215. /**
  137216. * All agents created
  137217. */
  137218. agents: number[];
  137219. /**
  137220. * Link to the scene is kept to unregister the crowd from the scene
  137221. */
  137222. private _scene;
  137223. /**
  137224. * Observer for crowd updates
  137225. */
  137226. private _onBeforeAnimationsObserver;
  137227. /**
  137228. * Constructor
  137229. * @param plugin recastJS plugin
  137230. * @param maxAgents the maximum agent count in the crowd
  137231. * @param maxAgentRadius the maximum radius an agent can have
  137232. * @param scene to attach the crowd to
  137233. * @returns the crowd you can add agents to
  137234. */
  137235. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  137236. /**
  137237. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  137238. * You can attach anything to that node. The node position is updated in the scene update tick.
  137239. * @param pos world position that will be constrained by the navigation mesh
  137240. * @param parameters agent parameters
  137241. * @param transform hooked to the agent that will be update by the scene
  137242. * @returns agent index
  137243. */
  137244. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  137245. /**
  137246. * Returns the agent position in world space
  137247. * @param index agent index returned by addAgent
  137248. * @returns world space position
  137249. */
  137250. getAgentPosition(index: number): Vector3;
  137251. /**
  137252. * Returns the agent position result in world space
  137253. * @param index agent index returned by addAgent
  137254. * @param result output world space position
  137255. */
  137256. getAgentPositionToRef(index: number, result: Vector3): void;
  137257. /**
  137258. * Returns the agent velocity in world space
  137259. * @param index agent index returned by addAgent
  137260. * @returns world space velocity
  137261. */
  137262. getAgentVelocity(index: number): Vector3;
  137263. /**
  137264. * Returns the agent velocity result in world space
  137265. * @param index agent index returned by addAgent
  137266. * @param result output world space velocity
  137267. */
  137268. getAgentVelocityToRef(index: number, result: Vector3): void;
  137269. /**
  137270. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  137271. * @param index agent index returned by addAgent
  137272. * @param destination targeted world position
  137273. */
  137274. agentGoto(index: number, destination: Vector3): void;
  137275. /**
  137276. * Teleport the agent to a new position
  137277. * @param index agent index returned by addAgent
  137278. * @param destination targeted world position
  137279. */
  137280. agentTeleport(index: number, destination: Vector3): void;
  137281. /**
  137282. * Update agent parameters
  137283. * @param index agent index returned by addAgent
  137284. * @param parameters agent parameters
  137285. */
  137286. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  137287. /**
  137288. * remove a particular agent previously created
  137289. * @param index agent index returned by addAgent
  137290. */
  137291. removeAgent(index: number): void;
  137292. /**
  137293. * get the list of all agents attached to this crowd
  137294. * @returns list of agent indices
  137295. */
  137296. getAgents(): number[];
  137297. /**
  137298. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  137299. * @param deltaTime in seconds
  137300. */
  137301. update(deltaTime: number): void;
  137302. /**
  137303. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  137304. * The queries will try to find a solution within those bounds
  137305. * default is (1,1,1)
  137306. * @param extent x,y,z value that define the extent around the queries point of reference
  137307. */
  137308. setDefaultQueryExtent(extent: Vector3): void;
  137309. /**
  137310. * Get the Bounding box extent specified by setDefaultQueryExtent
  137311. * @returns the box extent values
  137312. */
  137313. getDefaultQueryExtent(): Vector3;
  137314. /**
  137315. * Get the Bounding box extent result specified by setDefaultQueryExtent
  137316. * @param result output the box extent values
  137317. */
  137318. getDefaultQueryExtentToRef(result: Vector3): void;
  137319. /**
  137320. * Release all resources
  137321. */
  137322. dispose(): void;
  137323. }
  137324. }
  137325. declare module BABYLON {
  137326. /**
  137327. * Class used to enable access to IndexedDB
  137328. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  137329. */
  137330. export class Database implements IOfflineProvider {
  137331. private _callbackManifestChecked;
  137332. private _currentSceneUrl;
  137333. private _db;
  137334. private _enableSceneOffline;
  137335. private _enableTexturesOffline;
  137336. private _manifestVersionFound;
  137337. private _mustUpdateRessources;
  137338. private _hasReachedQuota;
  137339. private _isSupported;
  137340. private _idbFactory;
  137341. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  137342. private static IsUASupportingBlobStorage;
  137343. /**
  137344. * Gets a boolean indicating if Database storate is enabled (off by default)
  137345. */
  137346. static IDBStorageEnabled: boolean;
  137347. /**
  137348. * Gets a boolean indicating if scene must be saved in the database
  137349. */
  137350. get enableSceneOffline(): boolean;
  137351. /**
  137352. * Gets a boolean indicating if textures must be saved in the database
  137353. */
  137354. get enableTexturesOffline(): boolean;
  137355. /**
  137356. * Creates a new Database
  137357. * @param urlToScene defines the url to load the scene
  137358. * @param callbackManifestChecked defines the callback to use when manifest is checked
  137359. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  137360. */
  137361. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  137362. private static _ParseURL;
  137363. private static _ReturnFullUrlLocation;
  137364. private _checkManifestFile;
  137365. /**
  137366. * Open the database and make it available
  137367. * @param successCallback defines the callback to call on success
  137368. * @param errorCallback defines the callback to call on error
  137369. */
  137370. open(successCallback: () => void, errorCallback: () => void): void;
  137371. /**
  137372. * Loads an image from the database
  137373. * @param url defines the url to load from
  137374. * @param image defines the target DOM image
  137375. */
  137376. loadImage(url: string, image: HTMLImageElement): void;
  137377. private _loadImageFromDBAsync;
  137378. private _saveImageIntoDBAsync;
  137379. private _checkVersionFromDB;
  137380. private _loadVersionFromDBAsync;
  137381. private _saveVersionIntoDBAsync;
  137382. /**
  137383. * Loads a file from database
  137384. * @param url defines the URL to load from
  137385. * @param sceneLoaded defines a callback to call on success
  137386. * @param progressCallBack defines a callback to call when progress changed
  137387. * @param errorCallback defines a callback to call on error
  137388. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  137389. */
  137390. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  137391. private _loadFileAsync;
  137392. private _saveFileAsync;
  137393. /**
  137394. * Validates if xhr data is correct
  137395. * @param xhr defines the request to validate
  137396. * @param dataType defines the expected data type
  137397. * @returns true if data is correct
  137398. */
  137399. private static _ValidateXHRData;
  137400. }
  137401. }
  137402. declare module BABYLON {
  137403. /** @hidden */
  137404. export var gpuUpdateParticlesPixelShader: {
  137405. name: string;
  137406. shader: string;
  137407. };
  137408. }
  137409. declare module BABYLON {
  137410. /** @hidden */
  137411. export var gpuUpdateParticlesVertexShader: {
  137412. name: string;
  137413. shader: string;
  137414. };
  137415. }
  137416. declare module BABYLON {
  137417. /** @hidden */
  137418. export var clipPlaneFragmentDeclaration2: {
  137419. name: string;
  137420. shader: string;
  137421. };
  137422. }
  137423. declare module BABYLON {
  137424. /** @hidden */
  137425. export var gpuRenderParticlesPixelShader: {
  137426. name: string;
  137427. shader: string;
  137428. };
  137429. }
  137430. declare module BABYLON {
  137431. /** @hidden */
  137432. export var clipPlaneVertexDeclaration2: {
  137433. name: string;
  137434. shader: string;
  137435. };
  137436. }
  137437. declare module BABYLON {
  137438. /** @hidden */
  137439. export var gpuRenderParticlesVertexShader: {
  137440. name: string;
  137441. shader: string;
  137442. };
  137443. }
  137444. declare module BABYLON {
  137445. /**
  137446. * This represents a GPU particle system in Babylon
  137447. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  137448. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  137449. */
  137450. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  137451. /**
  137452. * The layer mask we are rendering the particles through.
  137453. */
  137454. layerMask: number;
  137455. private _capacity;
  137456. private _activeCount;
  137457. private _currentActiveCount;
  137458. private _accumulatedCount;
  137459. private _renderEffect;
  137460. private _updateEffect;
  137461. private _buffer0;
  137462. private _buffer1;
  137463. private _spriteBuffer;
  137464. private _updateVAO;
  137465. private _renderVAO;
  137466. private _targetIndex;
  137467. private _sourceBuffer;
  137468. private _targetBuffer;
  137469. private _engine;
  137470. private _currentRenderId;
  137471. private _started;
  137472. private _stopped;
  137473. private _timeDelta;
  137474. private _randomTexture;
  137475. private _randomTexture2;
  137476. private _attributesStrideSize;
  137477. private _updateEffectOptions;
  137478. private _randomTextureSize;
  137479. private _actualFrame;
  137480. private readonly _rawTextureWidth;
  137481. /**
  137482. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  137483. */
  137484. static get IsSupported(): boolean;
  137485. /**
  137486. * An event triggered when the system is disposed.
  137487. */
  137488. onDisposeObservable: Observable<GPUParticleSystem>;
  137489. /**
  137490. * Gets the maximum number of particles active at the same time.
  137491. * @returns The max number of active particles.
  137492. */
  137493. getCapacity(): number;
  137494. /**
  137495. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  137496. * to override the particles.
  137497. */
  137498. forceDepthWrite: boolean;
  137499. /**
  137500. * Gets or set the number of active particles
  137501. */
  137502. get activeParticleCount(): number;
  137503. set activeParticleCount(value: number);
  137504. private _preWarmDone;
  137505. /**
  137506. * Specifies if the particles are updated in emitter local space or world space.
  137507. * This is always false for GPU particles
  137508. */
  137509. get isLocal(): boolean;
  137510. set isLocal(value: boolean);
  137511. /**
  137512. * Is this system ready to be used/rendered
  137513. * @return true if the system is ready
  137514. */
  137515. isReady(): boolean;
  137516. /**
  137517. * Gets if the system has been started. (Note: this will still be true after stop is called)
  137518. * @returns True if it has been started, otherwise false.
  137519. */
  137520. isStarted(): boolean;
  137521. /**
  137522. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  137523. * @returns True if it has been stopped, otherwise false.
  137524. */
  137525. isStopped(): boolean;
  137526. /**
  137527. * Gets a boolean indicating that the system is stopping
  137528. * @returns true if the system is currently stopping
  137529. */
  137530. isStopping(): boolean;
  137531. /**
  137532. * Gets the number of particles active at the same time.
  137533. * @returns The number of active particles.
  137534. */
  137535. getActiveCount(): number;
  137536. /**
  137537. * Starts the particle system and begins to emit
  137538. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  137539. */
  137540. start(delay?: number): void;
  137541. /**
  137542. * Stops the particle system.
  137543. */
  137544. stop(): void;
  137545. /**
  137546. * Remove all active particles
  137547. */
  137548. reset(): void;
  137549. /**
  137550. * Returns the string "GPUParticleSystem"
  137551. * @returns a string containing the class name
  137552. */
  137553. getClassName(): string;
  137554. private _colorGradientsTexture;
  137555. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  137556. /**
  137557. * Adds a new color gradient
  137558. * @param gradient defines the gradient to use (between 0 and 1)
  137559. * @param color1 defines the color to affect to the specified gradient
  137560. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  137561. * @returns the current particle system
  137562. */
  137563. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  137564. private _refreshColorGradient;
  137565. /** Force the system to rebuild all gradients that need to be resync */
  137566. forceRefreshGradients(): void;
  137567. /**
  137568. * Remove a specific color gradient
  137569. * @param gradient defines the gradient to remove
  137570. * @returns the current particle system
  137571. */
  137572. removeColorGradient(gradient: number): GPUParticleSystem;
  137573. private _angularSpeedGradientsTexture;
  137574. private _sizeGradientsTexture;
  137575. private _velocityGradientsTexture;
  137576. private _limitVelocityGradientsTexture;
  137577. private _dragGradientsTexture;
  137578. private _addFactorGradient;
  137579. /**
  137580. * Adds a new size gradient
  137581. * @param gradient defines the gradient to use (between 0 and 1)
  137582. * @param factor defines the size factor to affect to the specified gradient
  137583. * @returns the current particle system
  137584. */
  137585. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  137586. /**
  137587. * Remove a specific size gradient
  137588. * @param gradient defines the gradient to remove
  137589. * @returns the current particle system
  137590. */
  137591. removeSizeGradient(gradient: number): GPUParticleSystem;
  137592. private _refreshFactorGradient;
  137593. /**
  137594. * Adds a new angular speed gradient
  137595. * @param gradient defines the gradient to use (between 0 and 1)
  137596. * @param factor defines the angular speed to affect to the specified gradient
  137597. * @returns the current particle system
  137598. */
  137599. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  137600. /**
  137601. * Remove a specific angular speed gradient
  137602. * @param gradient defines the gradient to remove
  137603. * @returns the current particle system
  137604. */
  137605. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  137606. /**
  137607. * Adds a new velocity gradient
  137608. * @param gradient defines the gradient to use (between 0 and 1)
  137609. * @param factor defines the velocity to affect to the specified gradient
  137610. * @returns the current particle system
  137611. */
  137612. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137613. /**
  137614. * Remove a specific velocity gradient
  137615. * @param gradient defines the gradient to remove
  137616. * @returns the current particle system
  137617. */
  137618. removeVelocityGradient(gradient: number): GPUParticleSystem;
  137619. /**
  137620. * Adds a new limit velocity gradient
  137621. * @param gradient defines the gradient to use (between 0 and 1)
  137622. * @param factor defines the limit velocity value to affect to the specified gradient
  137623. * @returns the current particle system
  137624. */
  137625. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  137626. /**
  137627. * Remove a specific limit velocity gradient
  137628. * @param gradient defines the gradient to remove
  137629. * @returns the current particle system
  137630. */
  137631. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  137632. /**
  137633. * Adds a new drag gradient
  137634. * @param gradient defines the gradient to use (between 0 and 1)
  137635. * @param factor defines the drag value to affect to the specified gradient
  137636. * @returns the current particle system
  137637. */
  137638. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  137639. /**
  137640. * Remove a specific drag gradient
  137641. * @param gradient defines the gradient to remove
  137642. * @returns the current particle system
  137643. */
  137644. removeDragGradient(gradient: number): GPUParticleSystem;
  137645. /**
  137646. * Not supported by GPUParticleSystem
  137647. * @param gradient defines the gradient to use (between 0 and 1)
  137648. * @param factor defines the emit rate value to affect to the specified gradient
  137649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137650. * @returns the current particle system
  137651. */
  137652. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137653. /**
  137654. * Not supported by GPUParticleSystem
  137655. * @param gradient defines the gradient to remove
  137656. * @returns the current particle system
  137657. */
  137658. removeEmitRateGradient(gradient: number): IParticleSystem;
  137659. /**
  137660. * Not supported by GPUParticleSystem
  137661. * @param gradient defines the gradient to use (between 0 and 1)
  137662. * @param factor defines the start size value to affect to the specified gradient
  137663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137664. * @returns the current particle system
  137665. */
  137666. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137667. /**
  137668. * Not supported by GPUParticleSystem
  137669. * @param gradient defines the gradient to remove
  137670. * @returns the current particle system
  137671. */
  137672. removeStartSizeGradient(gradient: number): IParticleSystem;
  137673. /**
  137674. * Not supported by GPUParticleSystem
  137675. * @param gradient defines the gradient to use (between 0 and 1)
  137676. * @param min defines the color remap minimal range
  137677. * @param max defines the color remap maximal range
  137678. * @returns the current particle system
  137679. */
  137680. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137681. /**
  137682. * Not supported by GPUParticleSystem
  137683. * @param gradient defines the gradient to remove
  137684. * @returns the current particle system
  137685. */
  137686. removeColorRemapGradient(): IParticleSystem;
  137687. /**
  137688. * Not supported by GPUParticleSystem
  137689. * @param gradient defines the gradient to use (between 0 and 1)
  137690. * @param min defines the alpha remap minimal range
  137691. * @param max defines the alpha remap maximal range
  137692. * @returns the current particle system
  137693. */
  137694. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  137695. /**
  137696. * Not supported by GPUParticleSystem
  137697. * @param gradient defines the gradient to remove
  137698. * @returns the current particle system
  137699. */
  137700. removeAlphaRemapGradient(): IParticleSystem;
  137701. /**
  137702. * Not supported by GPUParticleSystem
  137703. * @param gradient defines the gradient to use (between 0 and 1)
  137704. * @param color defines the color to affect to the specified gradient
  137705. * @returns the current particle system
  137706. */
  137707. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  137708. /**
  137709. * Not supported by GPUParticleSystem
  137710. * @param gradient defines the gradient to remove
  137711. * @returns the current particle system
  137712. */
  137713. removeRampGradient(): IParticleSystem;
  137714. /**
  137715. * Not supported by GPUParticleSystem
  137716. * @returns the list of ramp gradients
  137717. */
  137718. getRampGradients(): Nullable<Array<Color3Gradient>>;
  137719. /**
  137720. * Not supported by GPUParticleSystem
  137721. * Gets or sets a boolean indicating that ramp gradients must be used
  137722. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  137723. */
  137724. get useRampGradients(): boolean;
  137725. set useRampGradients(value: boolean);
  137726. /**
  137727. * Not supported by GPUParticleSystem
  137728. * @param gradient defines the gradient to use (between 0 and 1)
  137729. * @param factor defines the life time factor to affect to the specified gradient
  137730. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  137731. * @returns the current particle system
  137732. */
  137733. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  137734. /**
  137735. * Not supported by GPUParticleSystem
  137736. * @param gradient defines the gradient to remove
  137737. * @returns the current particle system
  137738. */
  137739. removeLifeTimeGradient(gradient: number): IParticleSystem;
  137740. /**
  137741. * Instantiates a GPU particle system.
  137742. * 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.
  137743. * @param name The name of the particle system
  137744. * @param options The options used to create the system
  137745. * @param scene The scene the particle system belongs to
  137746. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  137747. */
  137748. constructor(name: string, options: Partial<{
  137749. capacity: number;
  137750. randomTextureSize: number;
  137751. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  137752. protected _reset(): void;
  137753. private _createUpdateVAO;
  137754. private _createRenderVAO;
  137755. private _initialize;
  137756. /** @hidden */
  137757. _recreateUpdateEffect(): void;
  137758. /** @hidden */
  137759. _recreateRenderEffect(): void;
  137760. /**
  137761. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  137762. * @param preWarm defines if we are in the pre-warmimg phase
  137763. */
  137764. animate(preWarm?: boolean): void;
  137765. private _createFactorGradientTexture;
  137766. private _createSizeGradientTexture;
  137767. private _createAngularSpeedGradientTexture;
  137768. private _createVelocityGradientTexture;
  137769. private _createLimitVelocityGradientTexture;
  137770. private _createDragGradientTexture;
  137771. private _createColorGradientTexture;
  137772. /**
  137773. * Renders the particle system in its current state
  137774. * @param preWarm defines if the system should only update the particles but not render them
  137775. * @returns the current number of particles
  137776. */
  137777. render(preWarm?: boolean): number;
  137778. /**
  137779. * Rebuilds the particle system
  137780. */
  137781. rebuild(): void;
  137782. private _releaseBuffers;
  137783. private _releaseVAOs;
  137784. /**
  137785. * Disposes the particle system and free the associated resources
  137786. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  137787. */
  137788. dispose(disposeTexture?: boolean): void;
  137789. /**
  137790. * Clones the particle system.
  137791. * @param name The name of the cloned object
  137792. * @param newEmitter The new emitter to use
  137793. * @returns the cloned particle system
  137794. */
  137795. clone(name: string, newEmitter: any): GPUParticleSystem;
  137796. /**
  137797. * Serializes the particle system to a JSON object
  137798. * @param serializeTexture defines if the texture must be serialized as well
  137799. * @returns the JSON object
  137800. */
  137801. serialize(serializeTexture?: boolean): any;
  137802. /**
  137803. * Parses a JSON object to create a GPU particle system.
  137804. * @param parsedParticleSystem The JSON object to parse
  137805. * @param scene The scene to create the particle system in
  137806. * @param rootUrl The root url to use to load external dependencies like texture
  137807. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  137808. * @returns the parsed GPU particle system
  137809. */
  137810. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  137811. }
  137812. }
  137813. declare module BABYLON {
  137814. /**
  137815. * Represents a set of particle systems working together to create a specific effect
  137816. */
  137817. export class ParticleSystemSet implements IDisposable {
  137818. /**
  137819. * Gets or sets base Assets URL
  137820. */
  137821. static BaseAssetsUrl: string;
  137822. private _emitterCreationOptions;
  137823. private _emitterNode;
  137824. /**
  137825. * Gets the particle system list
  137826. */
  137827. systems: IParticleSystem[];
  137828. /**
  137829. * Gets the emitter node used with this set
  137830. */
  137831. get emitterNode(): Nullable<TransformNode>;
  137832. /**
  137833. * Creates a new emitter mesh as a sphere
  137834. * @param options defines the options used to create the sphere
  137835. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  137836. * @param scene defines the hosting scene
  137837. */
  137838. setEmitterAsSphere(options: {
  137839. diameter: number;
  137840. segments: number;
  137841. color: Color3;
  137842. }, renderingGroupId: number, scene: Scene): void;
  137843. /**
  137844. * Starts all particle systems of the set
  137845. * @param emitter defines an optional mesh to use as emitter for the particle systems
  137846. */
  137847. start(emitter?: AbstractMesh): void;
  137848. /**
  137849. * Release all associated resources
  137850. */
  137851. dispose(): void;
  137852. /**
  137853. * Serialize the set into a JSON compatible object
  137854. * @param serializeTexture defines if the texture must be serialized as well
  137855. * @returns a JSON compatible representation of the set
  137856. */
  137857. serialize(serializeTexture?: boolean): any;
  137858. /**
  137859. * Parse a new ParticleSystemSet from a serialized source
  137860. * @param data defines a JSON compatible representation of the set
  137861. * @param scene defines the hosting scene
  137862. * @param gpu defines if we want GPU particles or CPU particles
  137863. * @returns a new ParticleSystemSet
  137864. */
  137865. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  137866. }
  137867. }
  137868. declare module BABYLON {
  137869. /**
  137870. * This class is made for on one-liner static method to help creating particle system set.
  137871. */
  137872. export class ParticleHelper {
  137873. /**
  137874. * Gets or sets base Assets URL
  137875. */
  137876. static BaseAssetsUrl: string;
  137877. /** Define the Url to load snippets */
  137878. static SnippetUrl: string;
  137879. /**
  137880. * Create a default particle system that you can tweak
  137881. * @param emitter defines the emitter to use
  137882. * @param capacity defines the system capacity (default is 500 particles)
  137883. * @param scene defines the hosting scene
  137884. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  137885. * @returns the new Particle system
  137886. */
  137887. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  137888. /**
  137889. * This is the main static method (one-liner) of this helper to create different particle systems
  137890. * @param type This string represents the type to the particle system to create
  137891. * @param scene The scene where the particle system should live
  137892. * @param gpu If the system will use gpu
  137893. * @returns the ParticleSystemSet created
  137894. */
  137895. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  137896. /**
  137897. * Static function used to export a particle system to a ParticleSystemSet variable.
  137898. * Please note that the emitter shape is not exported
  137899. * @param systems defines the particle systems to export
  137900. * @returns the created particle system set
  137901. */
  137902. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  137903. /**
  137904. * Creates a particle system from a snippet saved in a remote file
  137905. * @param name defines the name of the particle system to create
  137906. * @param url defines the url to load from
  137907. * @param scene defines the hosting scene
  137908. * @param gpu If the system will use gpu
  137909. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137910. * @returns a promise that will resolve to the new particle system
  137911. */
  137912. static ParseFromFileAsync(name: string, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137913. /**
  137914. * Creates a particle system from a snippet saved by the particle system editor
  137915. * @param snippetId defines the snippet to load
  137916. * @param scene defines the hosting scene
  137917. * @param gpu If the system will use gpu
  137918. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  137919. * @returns a promise that will resolve to the new particle system
  137920. */
  137921. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  137922. }
  137923. }
  137924. declare module BABYLON {
  137925. interface Engine {
  137926. /**
  137927. * Create an effect to use with particle systems.
  137928. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  137929. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  137930. * @param uniformsNames defines a list of attribute names
  137931. * @param samplers defines an array of string used to represent textures
  137932. * @param defines defines the string containing the defines to use to compile the shaders
  137933. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  137934. * @param onCompiled defines a function to call when the effect creation is successful
  137935. * @param onError defines a function to call when the effect creation has failed
  137936. * @returns the new Effect
  137937. */
  137938. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  137939. }
  137940. interface Mesh {
  137941. /**
  137942. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  137943. * @returns an array of IParticleSystem
  137944. */
  137945. getEmittedParticleSystems(): IParticleSystem[];
  137946. /**
  137947. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  137948. * @returns an array of IParticleSystem
  137949. */
  137950. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  137951. }
  137952. /**
  137953. * @hidden
  137954. */
  137955. export var _IDoNeedToBeInTheBuild: number;
  137956. }
  137957. declare module BABYLON {
  137958. /** Defines the 4 color options */
  137959. export enum PointColor {
  137960. /** color value */
  137961. Color = 2,
  137962. /** uv value */
  137963. UV = 1,
  137964. /** random value */
  137965. Random = 0,
  137966. /** stated value */
  137967. Stated = 3
  137968. }
  137969. /**
  137970. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  137971. * 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.
  137972. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  137973. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  137974. *
  137975. * Full documentation here : TO BE ENTERED
  137976. */
  137977. export class PointsCloudSystem implements IDisposable {
  137978. /**
  137979. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  137980. * Example : var p = SPS.particles[i];
  137981. */
  137982. particles: CloudPoint[];
  137983. /**
  137984. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  137985. */
  137986. nbParticles: number;
  137987. /**
  137988. * This a counter for your own usage. It's not set by any SPS functions.
  137989. */
  137990. counter: number;
  137991. /**
  137992. * The PCS name. This name is also given to the underlying mesh.
  137993. */
  137994. name: string;
  137995. /**
  137996. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  137997. */
  137998. mesh: Mesh;
  137999. /**
  138000. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  138001. * Please read :
  138002. */
  138003. vars: any;
  138004. /**
  138005. * @hidden
  138006. */
  138007. _size: number;
  138008. private _scene;
  138009. private _promises;
  138010. private _positions;
  138011. private _indices;
  138012. private _normals;
  138013. private _colors;
  138014. private _uvs;
  138015. private _indices32;
  138016. private _positions32;
  138017. private _colors32;
  138018. private _uvs32;
  138019. private _updatable;
  138020. private _isVisibilityBoxLocked;
  138021. private _alwaysVisible;
  138022. private _groups;
  138023. private _groupCounter;
  138024. private _computeParticleColor;
  138025. private _computeParticleTexture;
  138026. private _computeParticleRotation;
  138027. private _computeBoundingBox;
  138028. private _isReady;
  138029. /**
  138030. * Creates a PCS (Points Cloud System) object
  138031. * @param name (String) is the PCS name, this will be the underlying mesh name
  138032. * @param pointSize (number) is the size for each point
  138033. * @param scene (Scene) is the scene in which the PCS is added
  138034. * @param options defines the options of the PCS e.g.
  138035. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  138036. */
  138037. constructor(name: string, pointSize: number, scene: Scene, options?: {
  138038. updatable?: boolean;
  138039. });
  138040. /**
  138041. * Builds the PCS underlying mesh. Returns a standard Mesh.
  138042. * If no points were added to the PCS, the returned mesh is just a single point.
  138043. * @returns a promise for the created mesh
  138044. */
  138045. buildMeshAsync(): Promise<Mesh>;
  138046. /**
  138047. * @hidden
  138048. */
  138049. private _buildMesh;
  138050. private _addParticle;
  138051. private _randomUnitVector;
  138052. private _getColorIndicesForCoord;
  138053. private _setPointsColorOrUV;
  138054. private _colorFromTexture;
  138055. private _calculateDensity;
  138056. /**
  138057. * Adds points to the PCS in random positions within a unit sphere
  138058. * @param nb (positive integer) the number of particles to be created from this model
  138059. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  138060. * @returns the number of groups in the system
  138061. */
  138062. addPoints(nb: number, pointFunction?: any): number;
  138063. /**
  138064. * Adds points to the PCS from the surface of the model shape
  138065. * @param mesh is any Mesh object that will be used as a surface model for the points
  138066. * @param nb (positive integer) the number of particles to be created from this model
  138067. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138068. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138069. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138070. * @returns the number of groups in the system
  138071. */
  138072. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138073. /**
  138074. * Adds points to the PCS inside the model shape
  138075. * @param mesh is any Mesh object that will be used as a surface model for the points
  138076. * @param nb (positive integer) the number of particles to be created from this model
  138077. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  138078. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  138079. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  138080. * @returns the number of groups in the system
  138081. */
  138082. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  138083. /**
  138084. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  138085. * This method calls `updateParticle()` for each particle of the SPS.
  138086. * For an animated SPS, it is usually called within the render loop.
  138087. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  138088. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  138089. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  138090. * @returns the PCS.
  138091. */
  138092. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  138093. /**
  138094. * Disposes the PCS.
  138095. */
  138096. dispose(): void;
  138097. /**
  138098. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  138099. * doc :
  138100. * @returns the PCS.
  138101. */
  138102. refreshVisibleSize(): PointsCloudSystem;
  138103. /**
  138104. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  138105. * @param size the size (float) of the visibility box
  138106. * note : this doesn't lock the PCS mesh bounding box.
  138107. * doc :
  138108. */
  138109. setVisibilityBox(size: number): void;
  138110. /**
  138111. * Gets whether the PCS is always visible or not
  138112. * doc :
  138113. */
  138114. get isAlwaysVisible(): boolean;
  138115. /**
  138116. * Sets the PCS as always visible or not
  138117. * doc :
  138118. */
  138119. set isAlwaysVisible(val: boolean);
  138120. /**
  138121. * Tells to `setParticles()` to compute the particle rotations or not
  138122. * Default value : false. The PCS is faster when it's set to false
  138123. * Note : particle rotations are only applied to parent particles
  138124. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  138125. */
  138126. set computeParticleRotation(val: boolean);
  138127. /**
  138128. * Tells to `setParticles()` to compute the particle colors or not.
  138129. * Default value : true. The PCS is faster when it's set to false.
  138130. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138131. */
  138132. set computeParticleColor(val: boolean);
  138133. set computeParticleTexture(val: boolean);
  138134. /**
  138135. * Gets if `setParticles()` computes the particle colors or not.
  138136. * Default value : false. The PCS is faster when it's set to false.
  138137. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  138138. */
  138139. get computeParticleColor(): boolean;
  138140. /**
  138141. * Gets if `setParticles()` computes the particle textures or not.
  138142. * Default value : false. The PCS is faster when it's set to false.
  138143. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  138144. */
  138145. get computeParticleTexture(): boolean;
  138146. /**
  138147. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  138148. */
  138149. set computeBoundingBox(val: boolean);
  138150. /**
  138151. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  138152. */
  138153. get computeBoundingBox(): boolean;
  138154. /**
  138155. * This function does nothing. It may be overwritten to set all the particle first values.
  138156. * The PCS doesn't call this function, you may have to call it by your own.
  138157. * doc :
  138158. */
  138159. initParticles(): void;
  138160. /**
  138161. * This function does nothing. It may be overwritten to recycle a particle
  138162. * The PCS doesn't call this function, you can to call it
  138163. * doc :
  138164. * @param particle The particle to recycle
  138165. * @returns the recycled particle
  138166. */
  138167. recycleParticle(particle: CloudPoint): CloudPoint;
  138168. /**
  138169. * Updates a particle : this function should be overwritten by the user.
  138170. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  138171. * doc :
  138172. * @example : just set a particle position or velocity and recycle conditions
  138173. * @param particle The particle to update
  138174. * @returns the updated particle
  138175. */
  138176. updateParticle(particle: CloudPoint): CloudPoint;
  138177. /**
  138178. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  138179. * This does nothing and may be overwritten by the user.
  138180. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138181. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138182. * @param update the boolean update value actually passed to setParticles()
  138183. */
  138184. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138185. /**
  138186. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  138187. * This will be passed three parameters.
  138188. * This does nothing and may be overwritten by the user.
  138189. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  138190. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  138191. * @param update the boolean update value actually passed to setParticles()
  138192. */
  138193. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  138194. }
  138195. }
  138196. declare module BABYLON {
  138197. /**
  138198. * Represents one particle of a points cloud system.
  138199. */
  138200. export class CloudPoint {
  138201. /**
  138202. * particle global index
  138203. */
  138204. idx: number;
  138205. /**
  138206. * The color of the particle
  138207. */
  138208. color: Nullable<Color4>;
  138209. /**
  138210. * The world space position of the particle.
  138211. */
  138212. position: Vector3;
  138213. /**
  138214. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  138215. */
  138216. rotation: Vector3;
  138217. /**
  138218. * The world space rotation quaternion of the particle.
  138219. */
  138220. rotationQuaternion: Nullable<Quaternion>;
  138221. /**
  138222. * The uv of the particle.
  138223. */
  138224. uv: Nullable<Vector2>;
  138225. /**
  138226. * The current speed of the particle.
  138227. */
  138228. velocity: Vector3;
  138229. /**
  138230. * The pivot point in the particle local space.
  138231. */
  138232. pivot: Vector3;
  138233. /**
  138234. * Must the particle be translated from its pivot point in its local space ?
  138235. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  138236. * Default : false
  138237. */
  138238. translateFromPivot: boolean;
  138239. /**
  138240. * Index of this particle in the global "positions" array (Internal use)
  138241. * @hidden
  138242. */
  138243. _pos: number;
  138244. /**
  138245. * @hidden Index of this particle in the global "indices" array (Internal use)
  138246. */
  138247. _ind: number;
  138248. /**
  138249. * Group this particle belongs to
  138250. */
  138251. _group: PointsGroup;
  138252. /**
  138253. * Group id of this particle
  138254. */
  138255. groupId: number;
  138256. /**
  138257. * Index of the particle in its group id (Internal use)
  138258. */
  138259. idxInGroup: number;
  138260. /**
  138261. * @hidden Particle BoundingInfo object (Internal use)
  138262. */
  138263. _boundingInfo: BoundingInfo;
  138264. /**
  138265. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  138266. */
  138267. _pcs: PointsCloudSystem;
  138268. /**
  138269. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  138270. */
  138271. _stillInvisible: boolean;
  138272. /**
  138273. * @hidden Last computed particle rotation matrix
  138274. */
  138275. _rotationMatrix: number[];
  138276. /**
  138277. * Parent particle Id, if any.
  138278. * Default null.
  138279. */
  138280. parentId: Nullable<number>;
  138281. /**
  138282. * @hidden Internal global position in the PCS.
  138283. */
  138284. _globalPosition: Vector3;
  138285. /**
  138286. * Creates a Point Cloud object.
  138287. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  138288. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  138289. * @param group (PointsGroup) is the group the particle belongs to
  138290. * @param groupId (integer) is the group identifier in the PCS.
  138291. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  138292. * @param pcs defines the PCS it is associated to
  138293. */
  138294. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  138295. /**
  138296. * get point size
  138297. */
  138298. get size(): Vector3;
  138299. /**
  138300. * Set point size
  138301. */
  138302. set size(scale: Vector3);
  138303. /**
  138304. * Legacy support, changed quaternion to rotationQuaternion
  138305. */
  138306. get quaternion(): Nullable<Quaternion>;
  138307. /**
  138308. * Legacy support, changed quaternion to rotationQuaternion
  138309. */
  138310. set quaternion(q: Nullable<Quaternion>);
  138311. /**
  138312. * Returns a boolean. True if the particle intersects a mesh, else false
  138313. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  138314. * @param target is the object (point or mesh) what the intersection is computed against
  138315. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  138316. * @returns true if it intersects
  138317. */
  138318. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  138319. /**
  138320. * get the rotation matrix of the particle
  138321. * @hidden
  138322. */
  138323. getRotationMatrix(m: Matrix): void;
  138324. }
  138325. /**
  138326. * Represents a group of points in a points cloud system
  138327. * * PCS internal tool, don't use it manually.
  138328. */
  138329. export class PointsGroup {
  138330. /**
  138331. * The group id
  138332. * @hidden
  138333. */
  138334. groupID: number;
  138335. /**
  138336. * image data for group (internal use)
  138337. * @hidden
  138338. */
  138339. _groupImageData: Nullable<ArrayBufferView>;
  138340. /**
  138341. * Image Width (internal use)
  138342. * @hidden
  138343. */
  138344. _groupImgWidth: number;
  138345. /**
  138346. * Image Height (internal use)
  138347. * @hidden
  138348. */
  138349. _groupImgHeight: number;
  138350. /**
  138351. * Custom position function (internal use)
  138352. * @hidden
  138353. */
  138354. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  138355. /**
  138356. * density per facet for surface points
  138357. * @hidden
  138358. */
  138359. _groupDensity: number[];
  138360. /**
  138361. * Only when points are colored by texture carries pointer to texture list array
  138362. * @hidden
  138363. */
  138364. _textureNb: number;
  138365. /**
  138366. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  138367. * PCS internal tool, don't use it manually.
  138368. * @hidden
  138369. */
  138370. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  138371. }
  138372. }
  138373. declare module BABYLON {
  138374. interface Scene {
  138375. /** @hidden (Backing field) */
  138376. _physicsEngine: Nullable<IPhysicsEngine>;
  138377. /** @hidden */
  138378. _physicsTimeAccumulator: number;
  138379. /**
  138380. * Gets the current physics engine
  138381. * @returns a IPhysicsEngine or null if none attached
  138382. */
  138383. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  138384. /**
  138385. * Enables physics to the current scene
  138386. * @param gravity defines the scene's gravity for the physics engine
  138387. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  138388. * @return a boolean indicating if the physics engine was initialized
  138389. */
  138390. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  138391. /**
  138392. * Disables and disposes the physics engine associated with the scene
  138393. */
  138394. disablePhysicsEngine(): void;
  138395. /**
  138396. * Gets a boolean indicating if there is an active physics engine
  138397. * @returns a boolean indicating if there is an active physics engine
  138398. */
  138399. isPhysicsEnabled(): boolean;
  138400. /**
  138401. * Deletes a physics compound impostor
  138402. * @param compound defines the compound to delete
  138403. */
  138404. deleteCompoundImpostor(compound: any): void;
  138405. /**
  138406. * An event triggered when physic simulation is about to be run
  138407. */
  138408. onBeforePhysicsObservable: Observable<Scene>;
  138409. /**
  138410. * An event triggered when physic simulation has been done
  138411. */
  138412. onAfterPhysicsObservable: Observable<Scene>;
  138413. }
  138414. interface AbstractMesh {
  138415. /** @hidden */
  138416. _physicsImpostor: Nullable<PhysicsImpostor>;
  138417. /**
  138418. * Gets or sets impostor used for physic simulation
  138419. * @see http://doc.babylonjs.com/features/physics_engine
  138420. */
  138421. physicsImpostor: Nullable<PhysicsImpostor>;
  138422. /**
  138423. * Gets the current physics impostor
  138424. * @see http://doc.babylonjs.com/features/physics_engine
  138425. * @returns a physics impostor or null
  138426. */
  138427. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  138428. /** Apply a physic impulse to the mesh
  138429. * @param force defines the force to apply
  138430. * @param contactPoint defines where to apply the force
  138431. * @returns the current mesh
  138432. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  138433. */
  138434. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  138435. /**
  138436. * Creates a physic joint between two meshes
  138437. * @param otherMesh defines the other mesh to use
  138438. * @param pivot1 defines the pivot to use on this mesh
  138439. * @param pivot2 defines the pivot to use on the other mesh
  138440. * @param options defines additional options (can be plugin dependent)
  138441. * @returns the current mesh
  138442. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  138443. */
  138444. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  138445. /** @hidden */
  138446. _disposePhysicsObserver: Nullable<Observer<Node>>;
  138447. }
  138448. /**
  138449. * Defines the physics engine scene component responsible to manage a physics engine
  138450. */
  138451. export class PhysicsEngineSceneComponent implements ISceneComponent {
  138452. /**
  138453. * The component name helpful to identify the component in the list of scene components.
  138454. */
  138455. readonly name: string;
  138456. /**
  138457. * The scene the component belongs to.
  138458. */
  138459. scene: Scene;
  138460. /**
  138461. * Creates a new instance of the component for the given scene
  138462. * @param scene Defines the scene to register the component in
  138463. */
  138464. constructor(scene: Scene);
  138465. /**
  138466. * Registers the component in a given scene
  138467. */
  138468. register(): void;
  138469. /**
  138470. * Rebuilds the elements related to this component in case of
  138471. * context lost for instance.
  138472. */
  138473. rebuild(): void;
  138474. /**
  138475. * Disposes the component and the associated ressources
  138476. */
  138477. dispose(): void;
  138478. }
  138479. }
  138480. declare module BABYLON {
  138481. /**
  138482. * A helper for physics simulations
  138483. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138484. */
  138485. export class PhysicsHelper {
  138486. private _scene;
  138487. private _physicsEngine;
  138488. /**
  138489. * Initializes the Physics helper
  138490. * @param scene Babylon.js scene
  138491. */
  138492. constructor(scene: Scene);
  138493. /**
  138494. * Applies a radial explosion impulse
  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 radial explosion event, or null
  138500. */
  138501. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138502. /**
  138503. * Applies a radial explosion force
  138504. * @param origin the origin of the explosion
  138505. * @param radiusOrEventOptions the radius or the options of radial explosion
  138506. * @param strength the explosion strength
  138507. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138508. * @returns A physics radial explosion event, or null
  138509. */
  138510. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  138511. /**
  138512. * Creates a gravitational field
  138513. * @param origin the origin of the explosion
  138514. * @param radiusOrEventOptions the radius or the options of radial explosion
  138515. * @param strength the explosion strength
  138516. * @param falloff possible options: Constant & Linear. Defaults to Constant
  138517. * @returns A physics gravitational field event, or null
  138518. */
  138519. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  138520. /**
  138521. * Creates a physics updraft event
  138522. * @param origin the origin of the updraft
  138523. * @param radiusOrEventOptions the radius or the options of the updraft
  138524. * @param strength the strength of the updraft
  138525. * @param height the height of the updraft
  138526. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  138527. * @returns A physics updraft event, or null
  138528. */
  138529. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  138530. /**
  138531. * Creates a physics vortex event
  138532. * @param origin the of the vortex
  138533. * @param radiusOrEventOptions the radius or the options of the vortex
  138534. * @param strength the strength of the vortex
  138535. * @param height the height of the vortex
  138536. * @returns a Physics vortex event, or null
  138537. * A physics vortex event or null
  138538. */
  138539. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  138540. }
  138541. /**
  138542. * Represents a physics radial explosion event
  138543. */
  138544. class PhysicsRadialExplosionEvent {
  138545. private _scene;
  138546. private _options;
  138547. private _sphere;
  138548. private _dataFetched;
  138549. /**
  138550. * Initializes a radial explosioin event
  138551. * @param _scene BabylonJS scene
  138552. * @param _options The options for the vortex event
  138553. */
  138554. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  138555. /**
  138556. * Returns the data related to the radial explosion event (sphere).
  138557. * @returns The radial explosion event data
  138558. */
  138559. getData(): PhysicsRadialExplosionEventData;
  138560. /**
  138561. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  138562. * @param impostor A physics imposter
  138563. * @param origin the origin of the explosion
  138564. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  138565. */
  138566. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  138567. /**
  138568. * Triggers affecterd impostors callbacks
  138569. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  138570. */
  138571. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  138572. /**
  138573. * Disposes the sphere.
  138574. * @param force Specifies if the sphere should be disposed by force
  138575. */
  138576. dispose(force?: boolean): void;
  138577. /*** Helpers ***/
  138578. private _prepareSphere;
  138579. private _intersectsWithSphere;
  138580. }
  138581. /**
  138582. * Represents a gravitational field event
  138583. */
  138584. class PhysicsGravitationalFieldEvent {
  138585. private _physicsHelper;
  138586. private _scene;
  138587. private _origin;
  138588. private _options;
  138589. private _tickCallback;
  138590. private _sphere;
  138591. private _dataFetched;
  138592. /**
  138593. * Initializes the physics gravitational field event
  138594. * @param _physicsHelper A physics helper
  138595. * @param _scene BabylonJS scene
  138596. * @param _origin The origin position of the gravitational field event
  138597. * @param _options The options for the vortex event
  138598. */
  138599. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  138600. /**
  138601. * Returns the data related to the gravitational field event (sphere).
  138602. * @returns A gravitational field event
  138603. */
  138604. getData(): PhysicsGravitationalFieldEventData;
  138605. /**
  138606. * Enables the gravitational field.
  138607. */
  138608. enable(): void;
  138609. /**
  138610. * Disables the gravitational field.
  138611. */
  138612. disable(): void;
  138613. /**
  138614. * Disposes the sphere.
  138615. * @param force The force to dispose from the gravitational field event
  138616. */
  138617. dispose(force?: boolean): void;
  138618. private _tick;
  138619. }
  138620. /**
  138621. * Represents a physics updraft event
  138622. */
  138623. class PhysicsUpdraftEvent {
  138624. private _scene;
  138625. private _origin;
  138626. private _options;
  138627. private _physicsEngine;
  138628. private _originTop;
  138629. private _originDirection;
  138630. private _tickCallback;
  138631. private _cylinder;
  138632. private _cylinderPosition;
  138633. private _dataFetched;
  138634. /**
  138635. * Initializes the physics updraft event
  138636. * @param _scene BabylonJS scene
  138637. * @param _origin The origin position of the updraft
  138638. * @param _options The options for the updraft event
  138639. */
  138640. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  138641. /**
  138642. * Returns the data related to the updraft event (cylinder).
  138643. * @returns A physics updraft event
  138644. */
  138645. getData(): PhysicsUpdraftEventData;
  138646. /**
  138647. * Enables the updraft.
  138648. */
  138649. enable(): void;
  138650. /**
  138651. * Disables the updraft.
  138652. */
  138653. disable(): void;
  138654. /**
  138655. * Disposes the cylinder.
  138656. * @param force Specifies if the updraft should be disposed by force
  138657. */
  138658. dispose(force?: boolean): void;
  138659. private getImpostorHitData;
  138660. private _tick;
  138661. /*** Helpers ***/
  138662. private _prepareCylinder;
  138663. private _intersectsWithCylinder;
  138664. }
  138665. /**
  138666. * Represents a physics vortex event
  138667. */
  138668. class PhysicsVortexEvent {
  138669. private _scene;
  138670. private _origin;
  138671. private _options;
  138672. private _physicsEngine;
  138673. private _originTop;
  138674. private _tickCallback;
  138675. private _cylinder;
  138676. private _cylinderPosition;
  138677. private _dataFetched;
  138678. /**
  138679. * Initializes the physics vortex event
  138680. * @param _scene The BabylonJS scene
  138681. * @param _origin The origin position of the vortex
  138682. * @param _options The options for the vortex event
  138683. */
  138684. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  138685. /**
  138686. * Returns the data related to the vortex event (cylinder).
  138687. * @returns The physics vortex event data
  138688. */
  138689. getData(): PhysicsVortexEventData;
  138690. /**
  138691. * Enables the vortex.
  138692. */
  138693. enable(): void;
  138694. /**
  138695. * Disables the cortex.
  138696. */
  138697. disable(): void;
  138698. /**
  138699. * Disposes the sphere.
  138700. * @param force
  138701. */
  138702. dispose(force?: boolean): void;
  138703. private getImpostorHitData;
  138704. private _tick;
  138705. /*** Helpers ***/
  138706. private _prepareCylinder;
  138707. private _intersectsWithCylinder;
  138708. }
  138709. /**
  138710. * Options fot the radial explosion event
  138711. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138712. */
  138713. export class PhysicsRadialExplosionEventOptions {
  138714. /**
  138715. * The radius of the sphere for the radial explosion.
  138716. */
  138717. radius: number;
  138718. /**
  138719. * The strenth of the explosion.
  138720. */
  138721. strength: number;
  138722. /**
  138723. * The strenght of the force in correspondence to the distance of the affected object
  138724. */
  138725. falloff: PhysicsRadialImpulseFalloff;
  138726. /**
  138727. * Sphere options for the radial explosion.
  138728. */
  138729. sphere: {
  138730. segments: number;
  138731. diameter: number;
  138732. };
  138733. /**
  138734. * Sphere options for the radial explosion.
  138735. */
  138736. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  138737. }
  138738. /**
  138739. * Options fot the updraft event
  138740. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138741. */
  138742. export class PhysicsUpdraftEventOptions {
  138743. /**
  138744. * The radius of the cylinder for the vortex
  138745. */
  138746. radius: number;
  138747. /**
  138748. * The strenth of the updraft.
  138749. */
  138750. strength: number;
  138751. /**
  138752. * The height of the cylinder for the updraft.
  138753. */
  138754. height: number;
  138755. /**
  138756. * The mode for the the updraft.
  138757. */
  138758. updraftMode: PhysicsUpdraftMode;
  138759. }
  138760. /**
  138761. * Options fot the vortex event
  138762. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138763. */
  138764. export class PhysicsVortexEventOptions {
  138765. /**
  138766. * The radius of the cylinder for the vortex
  138767. */
  138768. radius: number;
  138769. /**
  138770. * The strenth of the vortex.
  138771. */
  138772. strength: number;
  138773. /**
  138774. * The height of the cylinder for the vortex.
  138775. */
  138776. height: number;
  138777. /**
  138778. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  138779. */
  138780. centripetalForceThreshold: number;
  138781. /**
  138782. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  138783. */
  138784. centripetalForceMultiplier: number;
  138785. /**
  138786. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  138787. */
  138788. centrifugalForceMultiplier: number;
  138789. /**
  138790. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  138791. */
  138792. updraftForceMultiplier: number;
  138793. }
  138794. /**
  138795. * The strenght of the force in correspondence to the distance of the affected object
  138796. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138797. */
  138798. export enum PhysicsRadialImpulseFalloff {
  138799. /** Defines that impulse is constant in strength across it's whole radius */
  138800. Constant = 0,
  138801. /** Defines that impulse gets weaker if it's further from the origin */
  138802. Linear = 1
  138803. }
  138804. /**
  138805. * The strength of the force in correspondence to the distance of the affected object
  138806. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138807. */
  138808. export enum PhysicsUpdraftMode {
  138809. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  138810. Center = 0,
  138811. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  138812. Perpendicular = 1
  138813. }
  138814. /**
  138815. * Interface for a physics hit data
  138816. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138817. */
  138818. export interface PhysicsHitData {
  138819. /**
  138820. * The force applied at the contact point
  138821. */
  138822. force: Vector3;
  138823. /**
  138824. * The contact point
  138825. */
  138826. contactPoint: Vector3;
  138827. /**
  138828. * The distance from the origin to the contact point
  138829. */
  138830. distanceFromOrigin: number;
  138831. }
  138832. /**
  138833. * Interface for radial explosion event data
  138834. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138835. */
  138836. export interface PhysicsRadialExplosionEventData {
  138837. /**
  138838. * A sphere used for the radial explosion event
  138839. */
  138840. sphere: Mesh;
  138841. }
  138842. /**
  138843. * Interface for gravitational field event data
  138844. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138845. */
  138846. export interface PhysicsGravitationalFieldEventData {
  138847. /**
  138848. * A sphere mesh used for the gravitational field event
  138849. */
  138850. sphere: Mesh;
  138851. }
  138852. /**
  138853. * Interface for updraft event data
  138854. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138855. */
  138856. export interface PhysicsUpdraftEventData {
  138857. /**
  138858. * A cylinder used for the updraft event
  138859. */
  138860. cylinder: Mesh;
  138861. }
  138862. /**
  138863. * Interface for vortex event data
  138864. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138865. */
  138866. export interface PhysicsVortexEventData {
  138867. /**
  138868. * A cylinder used for the vortex event
  138869. */
  138870. cylinder: Mesh;
  138871. }
  138872. /**
  138873. * Interface for an affected physics impostor
  138874. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  138875. */
  138876. export interface PhysicsAffectedImpostorWithData {
  138877. /**
  138878. * The impostor affected by the effect
  138879. */
  138880. impostor: PhysicsImpostor;
  138881. /**
  138882. * The data about the hit/horce from the explosion
  138883. */
  138884. hitData: PhysicsHitData;
  138885. }
  138886. }
  138887. declare module BABYLON {
  138888. /** @hidden */
  138889. export var blackAndWhitePixelShader: {
  138890. name: string;
  138891. shader: string;
  138892. };
  138893. }
  138894. declare module BABYLON {
  138895. /**
  138896. * Post process used to render in black and white
  138897. */
  138898. export class BlackAndWhitePostProcess extends PostProcess {
  138899. /**
  138900. * Linear about to convert he result to black and white (default: 1)
  138901. */
  138902. degree: number;
  138903. /**
  138904. * Creates a black and white post process
  138905. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  138906. * @param name The name of the effect.
  138907. * @param options The required width/height ratio to downsize to before computing the render pass.
  138908. * @param camera The camera to apply the render pass to.
  138909. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  138910. * @param engine The engine which the post process will be applied. (default: current engine)
  138911. * @param reusable If the post process can be reused on the same frame. (default: false)
  138912. */
  138913. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  138914. }
  138915. }
  138916. declare module BABYLON {
  138917. /**
  138918. * This represents a set of one or more post processes in Babylon.
  138919. * A post process can be used to apply a shader to a texture after it is rendered.
  138920. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  138921. */
  138922. export class PostProcessRenderEffect {
  138923. private _postProcesses;
  138924. private _getPostProcesses;
  138925. private _singleInstance;
  138926. private _cameras;
  138927. private _indicesForCamera;
  138928. /**
  138929. * Name of the effect
  138930. * @hidden
  138931. */
  138932. _name: string;
  138933. /**
  138934. * Instantiates a post process render effect.
  138935. * A post process can be used to apply a shader to a texture after it is rendered.
  138936. * @param engine The engine the effect is tied to
  138937. * @param name The name of the effect
  138938. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  138939. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  138940. */
  138941. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  138942. /**
  138943. * Checks if all the post processes in the effect are supported.
  138944. */
  138945. get isSupported(): boolean;
  138946. /**
  138947. * Updates the current state of the effect
  138948. * @hidden
  138949. */
  138950. _update(): void;
  138951. /**
  138952. * Attaches the effect on cameras
  138953. * @param cameras The camera to attach to.
  138954. * @hidden
  138955. */
  138956. _attachCameras(cameras: Camera): void;
  138957. /**
  138958. * Attaches the effect on cameras
  138959. * @param cameras The camera to attach to.
  138960. * @hidden
  138961. */
  138962. _attachCameras(cameras: Camera[]): void;
  138963. /**
  138964. * Detaches the effect on cameras
  138965. * @param cameras The camera to detatch from.
  138966. * @hidden
  138967. */
  138968. _detachCameras(cameras: Camera): void;
  138969. /**
  138970. * Detatches the effect on cameras
  138971. * @param cameras The camera to detatch from.
  138972. * @hidden
  138973. */
  138974. _detachCameras(cameras: Camera[]): void;
  138975. /**
  138976. * Enables the effect on given cameras
  138977. * @param cameras The camera to enable.
  138978. * @hidden
  138979. */
  138980. _enable(cameras: Camera): void;
  138981. /**
  138982. * Enables the effect on given cameras
  138983. * @param cameras The camera to enable.
  138984. * @hidden
  138985. */
  138986. _enable(cameras: Nullable<Camera[]>): void;
  138987. /**
  138988. * Disables the effect on the given cameras
  138989. * @param cameras The camera to disable.
  138990. * @hidden
  138991. */
  138992. _disable(cameras: Camera): void;
  138993. /**
  138994. * Disables the effect on the given cameras
  138995. * @param cameras The camera to disable.
  138996. * @hidden
  138997. */
  138998. _disable(cameras: Nullable<Camera[]>): void;
  138999. /**
  139000. * Gets a list of the post processes contained in the effect.
  139001. * @param camera The camera to get the post processes on.
  139002. * @returns The list of the post processes in the effect.
  139003. */
  139004. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  139005. }
  139006. }
  139007. declare module BABYLON {
  139008. /** @hidden */
  139009. export var extractHighlightsPixelShader: {
  139010. name: string;
  139011. shader: string;
  139012. };
  139013. }
  139014. declare module BABYLON {
  139015. /**
  139016. * 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.
  139017. */
  139018. export class ExtractHighlightsPostProcess extends PostProcess {
  139019. /**
  139020. * The luminance threshold, pixels below this value will be set to black.
  139021. */
  139022. threshold: number;
  139023. /** @hidden */
  139024. _exposure: number;
  139025. /**
  139026. * Post process which has the input texture to be used when performing highlight extraction
  139027. * @hidden
  139028. */
  139029. _inputPostProcess: Nullable<PostProcess>;
  139030. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139031. }
  139032. }
  139033. declare module BABYLON {
  139034. /** @hidden */
  139035. export var bloomMergePixelShader: {
  139036. name: string;
  139037. shader: string;
  139038. };
  139039. }
  139040. declare module BABYLON {
  139041. /**
  139042. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139043. */
  139044. export class BloomMergePostProcess extends PostProcess {
  139045. /** Weight of the bloom to be added to the original input. */
  139046. weight: number;
  139047. /**
  139048. * Creates a new instance of @see BloomMergePostProcess
  139049. * @param name The name of the effect.
  139050. * @param originalFromInput Post process which's input will be used for the merge.
  139051. * @param blurred Blurred highlights post process which's output will be used.
  139052. * @param weight Weight of the bloom to be added to the original input.
  139053. * @param options The required width/height ratio to downsize to before computing the render pass.
  139054. * @param camera The camera to apply the render pass to.
  139055. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139056. * @param engine The engine which the post process will be applied. (default: current engine)
  139057. * @param reusable If the post process can be reused on the same frame. (default: false)
  139058. * @param textureType Type of textures used when performing the post process. (default: 0)
  139059. * @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)
  139060. */
  139061. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  139062. /** Weight of the bloom to be added to the original input. */
  139063. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139064. }
  139065. }
  139066. declare module BABYLON {
  139067. /**
  139068. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  139069. */
  139070. export class BloomEffect extends PostProcessRenderEffect {
  139071. private bloomScale;
  139072. /**
  139073. * @hidden Internal
  139074. */
  139075. _effects: Array<PostProcess>;
  139076. /**
  139077. * @hidden Internal
  139078. */
  139079. _downscale: ExtractHighlightsPostProcess;
  139080. private _blurX;
  139081. private _blurY;
  139082. private _merge;
  139083. /**
  139084. * The luminance threshold to find bright areas of the image to bloom.
  139085. */
  139086. get threshold(): number;
  139087. set threshold(value: number);
  139088. /**
  139089. * The strength of the bloom.
  139090. */
  139091. get weight(): number;
  139092. set weight(value: number);
  139093. /**
  139094. * Specifies the size of the bloom blur kernel, relative to the final output size
  139095. */
  139096. get kernel(): number;
  139097. set kernel(value: number);
  139098. /**
  139099. * Creates a new instance of @see BloomEffect
  139100. * @param scene The scene the effect belongs to.
  139101. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  139102. * @param bloomKernel The size of the kernel to be used when applying the blur.
  139103. * @param bloomWeight The the strength of bloom.
  139104. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139105. * @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)
  139106. */
  139107. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  139108. /**
  139109. * Disposes each of the internal effects for a given camera.
  139110. * @param camera The camera to dispose the effect on.
  139111. */
  139112. disposeEffects(camera: Camera): void;
  139113. /**
  139114. * @hidden Internal
  139115. */
  139116. _updateEffects(): void;
  139117. /**
  139118. * Internal
  139119. * @returns if all the contained post processes are ready.
  139120. * @hidden
  139121. */
  139122. _isReady(): boolean;
  139123. }
  139124. }
  139125. declare module BABYLON {
  139126. /** @hidden */
  139127. export var chromaticAberrationPixelShader: {
  139128. name: string;
  139129. shader: string;
  139130. };
  139131. }
  139132. declare module BABYLON {
  139133. /**
  139134. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  139135. */
  139136. export class ChromaticAberrationPostProcess extends PostProcess {
  139137. /**
  139138. * The amount of seperation of rgb channels (default: 30)
  139139. */
  139140. aberrationAmount: number;
  139141. /**
  139142. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  139143. */
  139144. radialIntensity: number;
  139145. /**
  139146. * 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))
  139147. */
  139148. direction: Vector2;
  139149. /**
  139150. * 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))
  139151. */
  139152. centerPosition: Vector2;
  139153. /**
  139154. * Creates a new instance ChromaticAberrationPostProcess
  139155. * @param name The name of the effect.
  139156. * @param screenWidth The width of the screen to apply the effect on.
  139157. * @param screenHeight The height of the screen to apply the effect on.
  139158. * @param options The required width/height ratio to downsize to before computing the render pass.
  139159. * @param camera The camera to apply the render pass to.
  139160. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139161. * @param engine The engine which the post process will be applied. (default: current engine)
  139162. * @param reusable If the post process can be reused on the same frame. (default: false)
  139163. * @param textureType Type of textures used when performing the post process. (default: 0)
  139164. * @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)
  139165. */
  139166. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139167. }
  139168. }
  139169. declare module BABYLON {
  139170. /** @hidden */
  139171. export var circleOfConfusionPixelShader: {
  139172. name: string;
  139173. shader: string;
  139174. };
  139175. }
  139176. declare module BABYLON {
  139177. /**
  139178. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  139179. */
  139180. export class CircleOfConfusionPostProcess extends PostProcess {
  139181. /**
  139182. * 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.
  139183. */
  139184. lensSize: number;
  139185. /**
  139186. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139187. */
  139188. fStop: number;
  139189. /**
  139190. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139191. */
  139192. focusDistance: number;
  139193. /**
  139194. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  139195. */
  139196. focalLength: number;
  139197. private _depthTexture;
  139198. /**
  139199. * Creates a new instance CircleOfConfusionPostProcess
  139200. * @param name The name of the effect.
  139201. * @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.
  139202. * @param options The required width/height ratio to downsize to before computing the render pass.
  139203. * @param camera The camera to apply the render pass to.
  139204. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139205. * @param engine The engine which the post process will be applied. (default: current engine)
  139206. * @param reusable If the post process can be reused on the same frame. (default: false)
  139207. * @param textureType Type of textures used when performing the post process. (default: 0)
  139208. * @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)
  139209. */
  139210. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139211. /**
  139212. * 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.
  139213. */
  139214. set depthTexture(value: RenderTargetTexture);
  139215. }
  139216. }
  139217. declare module BABYLON {
  139218. /** @hidden */
  139219. export var colorCorrectionPixelShader: {
  139220. name: string;
  139221. shader: string;
  139222. };
  139223. }
  139224. declare module BABYLON {
  139225. /**
  139226. *
  139227. * This post-process allows the modification of rendered colors by using
  139228. * a 'look-up table' (LUT). This effect is also called Color Grading.
  139229. *
  139230. * The object needs to be provided an url to a texture containing the color
  139231. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  139232. * Use an image editing software to tweak the LUT to match your needs.
  139233. *
  139234. * For an example of a color LUT, see here:
  139235. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  139236. * For explanations on color grading, see here:
  139237. * @see http://udn.epicgames.com/Three/ColorGrading.html
  139238. *
  139239. */
  139240. export class ColorCorrectionPostProcess extends PostProcess {
  139241. private _colorTableTexture;
  139242. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139243. }
  139244. }
  139245. declare module BABYLON {
  139246. /** @hidden */
  139247. export var convolutionPixelShader: {
  139248. name: string;
  139249. shader: string;
  139250. };
  139251. }
  139252. declare module BABYLON {
  139253. /**
  139254. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  139255. * input texture to perform effects such as edge detection or sharpening
  139256. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139257. */
  139258. export class ConvolutionPostProcess extends PostProcess {
  139259. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139260. kernel: number[];
  139261. /**
  139262. * Creates a new instance ConvolutionPostProcess
  139263. * @param name The name of the effect.
  139264. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  139265. * @param options The required width/height ratio to downsize to before computing the render pass.
  139266. * @param camera The camera to apply the render pass to.
  139267. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139268. * @param engine The engine which the post process will be applied. (default: current engine)
  139269. * @param reusable If the post process can be reused on the same frame. (default: false)
  139270. * @param textureType Type of textures used when performing the post process. (default: 0)
  139271. */
  139272. constructor(name: string,
  139273. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  139274. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139275. /**
  139276. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139277. */
  139278. static EdgeDetect0Kernel: number[];
  139279. /**
  139280. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139281. */
  139282. static EdgeDetect1Kernel: number[];
  139283. /**
  139284. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139285. */
  139286. static EdgeDetect2Kernel: number[];
  139287. /**
  139288. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139289. */
  139290. static SharpenKernel: number[];
  139291. /**
  139292. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139293. */
  139294. static EmbossKernel: number[];
  139295. /**
  139296. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  139297. */
  139298. static GaussianKernel: number[];
  139299. }
  139300. }
  139301. declare module BABYLON {
  139302. /**
  139303. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  139304. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  139305. * based on samples that have a large difference in distance than the center pixel.
  139306. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  139307. */
  139308. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  139309. direction: Vector2;
  139310. /**
  139311. * Creates a new instance CircleOfConfusionPostProcess
  139312. * @param name The name of the effect.
  139313. * @param scene The scene the effect belongs to.
  139314. * @param direction The direction the blur should be applied.
  139315. * @param kernel The size of the kernel used to blur.
  139316. * @param options The required width/height ratio to downsize to before computing the render pass.
  139317. * @param camera The camera to apply the render pass to.
  139318. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  139319. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  139320. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139321. * @param engine The engine which the post process will be applied. (default: current engine)
  139322. * @param reusable If the post process can be reused on the same frame. (default: false)
  139323. * @param textureType Type of textures used when performing the post process. (default: 0)
  139324. * @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)
  139325. */
  139326. 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);
  139327. }
  139328. }
  139329. declare module BABYLON {
  139330. /** @hidden */
  139331. export var depthOfFieldMergePixelShader: {
  139332. name: string;
  139333. shader: string;
  139334. };
  139335. }
  139336. declare module BABYLON {
  139337. /**
  139338. * Options to be set when merging outputs from the default pipeline.
  139339. */
  139340. export class DepthOfFieldMergePostProcessOptions {
  139341. /**
  139342. * The original image to merge on top of
  139343. */
  139344. originalFromInput: PostProcess;
  139345. /**
  139346. * Parameters to perform the merge of the depth of field effect
  139347. */
  139348. depthOfField?: {
  139349. circleOfConfusion: PostProcess;
  139350. blurSteps: Array<PostProcess>;
  139351. };
  139352. /**
  139353. * Parameters to perform the merge of bloom effect
  139354. */
  139355. bloom?: {
  139356. blurred: PostProcess;
  139357. weight: number;
  139358. };
  139359. }
  139360. /**
  139361. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  139362. */
  139363. export class DepthOfFieldMergePostProcess extends PostProcess {
  139364. private blurSteps;
  139365. /**
  139366. * Creates a new instance of DepthOfFieldMergePostProcess
  139367. * @param name The name of the effect.
  139368. * @param originalFromInput Post process which's input will be used for the merge.
  139369. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  139370. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  139371. * @param options The required width/height ratio to downsize to before computing the render pass.
  139372. * @param camera The camera to apply the render pass to.
  139373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139374. * @param engine The engine which the post process will be applied. (default: current engine)
  139375. * @param reusable If the post process can be reused on the same frame. (default: false)
  139376. * @param textureType Type of textures used when performing the post process. (default: 0)
  139377. * @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)
  139378. */
  139379. 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);
  139380. /**
  139381. * Updates the effect with the current post process compile time values and recompiles the shader.
  139382. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  139383. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  139384. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  139385. * @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
  139386. * @param onCompiled Called when the shader has been compiled.
  139387. * @param onError Called if there is an error when compiling a shader.
  139388. */
  139389. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  139390. }
  139391. }
  139392. declare module BABYLON {
  139393. /**
  139394. * Specifies the level of max blur that should be applied when using the depth of field effect
  139395. */
  139396. export enum DepthOfFieldEffectBlurLevel {
  139397. /**
  139398. * Subtle blur
  139399. */
  139400. Low = 0,
  139401. /**
  139402. * Medium blur
  139403. */
  139404. Medium = 1,
  139405. /**
  139406. * Large blur
  139407. */
  139408. High = 2
  139409. }
  139410. /**
  139411. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  139412. */
  139413. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  139414. private _circleOfConfusion;
  139415. /**
  139416. * @hidden Internal, blurs from high to low
  139417. */
  139418. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  139419. private _depthOfFieldBlurY;
  139420. private _dofMerge;
  139421. /**
  139422. * @hidden Internal post processes in depth of field effect
  139423. */
  139424. _effects: Array<PostProcess>;
  139425. /**
  139426. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  139427. */
  139428. set focalLength(value: number);
  139429. get focalLength(): number;
  139430. /**
  139431. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  139432. */
  139433. set fStop(value: number);
  139434. get fStop(): number;
  139435. /**
  139436. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  139437. */
  139438. set focusDistance(value: number);
  139439. get focusDistance(): number;
  139440. /**
  139441. * 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.
  139442. */
  139443. set lensSize(value: number);
  139444. get lensSize(): number;
  139445. /**
  139446. * Creates a new instance DepthOfFieldEffect
  139447. * @param scene The scene the effect belongs to.
  139448. * @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.
  139449. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  139450. * @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)
  139451. */
  139452. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  139453. /**
  139454. * Get the current class name of the current effet
  139455. * @returns "DepthOfFieldEffect"
  139456. */
  139457. getClassName(): string;
  139458. /**
  139459. * 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.
  139460. */
  139461. set depthTexture(value: RenderTargetTexture);
  139462. /**
  139463. * Disposes each of the internal effects for a given camera.
  139464. * @param camera The camera to dispose the effect on.
  139465. */
  139466. disposeEffects(camera: Camera): void;
  139467. /**
  139468. * @hidden Internal
  139469. */
  139470. _updateEffects(): void;
  139471. /**
  139472. * Internal
  139473. * @returns if all the contained post processes are ready.
  139474. * @hidden
  139475. */
  139476. _isReady(): boolean;
  139477. }
  139478. }
  139479. declare module BABYLON {
  139480. /** @hidden */
  139481. export var displayPassPixelShader: {
  139482. name: string;
  139483. shader: string;
  139484. };
  139485. }
  139486. declare module BABYLON {
  139487. /**
  139488. * DisplayPassPostProcess which produces an output the same as it's input
  139489. */
  139490. export class DisplayPassPostProcess extends PostProcess {
  139491. /**
  139492. * Creates the DisplayPassPostProcess
  139493. * @param name The name of the effect.
  139494. * @param options The required width/height ratio to downsize to before computing the render pass.
  139495. * @param camera The camera to apply the render pass to.
  139496. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139497. * @param engine The engine which the post process will be applied. (default: current engine)
  139498. * @param reusable If the post process can be reused on the same frame. (default: false)
  139499. */
  139500. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139501. }
  139502. }
  139503. declare module BABYLON {
  139504. /** @hidden */
  139505. export var filterPixelShader: {
  139506. name: string;
  139507. shader: string;
  139508. };
  139509. }
  139510. declare module BABYLON {
  139511. /**
  139512. * Applies a kernel filter to the image
  139513. */
  139514. export class FilterPostProcess extends PostProcess {
  139515. /** The matrix to be applied to the image */
  139516. kernelMatrix: Matrix;
  139517. /**
  139518. *
  139519. * @param name The name of the effect.
  139520. * @param kernelMatrix The matrix to be applied to the image
  139521. * @param options The required width/height ratio to downsize to before computing the render pass.
  139522. * @param camera The camera to apply the render pass to.
  139523. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139524. * @param engine The engine which the post process will be applied. (default: current engine)
  139525. * @param reusable If the post process can be reused on the same frame. (default: false)
  139526. */
  139527. constructor(name: string,
  139528. /** The matrix to be applied to the image */
  139529. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139530. }
  139531. }
  139532. declare module BABYLON {
  139533. /** @hidden */
  139534. export var fxaaPixelShader: {
  139535. name: string;
  139536. shader: string;
  139537. };
  139538. }
  139539. declare module BABYLON {
  139540. /** @hidden */
  139541. export var fxaaVertexShader: {
  139542. name: string;
  139543. shader: string;
  139544. };
  139545. }
  139546. declare module BABYLON {
  139547. /**
  139548. * Fxaa post process
  139549. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  139550. */
  139551. export class FxaaPostProcess extends PostProcess {
  139552. /** @hidden */
  139553. texelWidth: number;
  139554. /** @hidden */
  139555. texelHeight: number;
  139556. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139557. private _getDefines;
  139558. }
  139559. }
  139560. declare module BABYLON {
  139561. /** @hidden */
  139562. export var grainPixelShader: {
  139563. name: string;
  139564. shader: string;
  139565. };
  139566. }
  139567. declare module BABYLON {
  139568. /**
  139569. * The GrainPostProcess adds noise to the image at mid luminance levels
  139570. */
  139571. export class GrainPostProcess extends PostProcess {
  139572. /**
  139573. * The intensity of the grain added (default: 30)
  139574. */
  139575. intensity: number;
  139576. /**
  139577. * If the grain should be randomized on every frame
  139578. */
  139579. animated: boolean;
  139580. /**
  139581. * Creates a new instance of @see GrainPostProcess
  139582. * @param name The name of the effect.
  139583. * @param options The required width/height ratio to downsize to before computing the render pass.
  139584. * @param camera The camera to apply the render pass to.
  139585. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139586. * @param engine The engine which the post process will be applied. (default: current engine)
  139587. * @param reusable If the post process can be reused on the same frame. (default: false)
  139588. * @param textureType Type of textures used when performing the post process. (default: 0)
  139589. * @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)
  139590. */
  139591. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139592. }
  139593. }
  139594. declare module BABYLON {
  139595. /** @hidden */
  139596. export var highlightsPixelShader: {
  139597. name: string;
  139598. shader: string;
  139599. };
  139600. }
  139601. declare module BABYLON {
  139602. /**
  139603. * Extracts highlights from the image
  139604. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139605. */
  139606. export class HighlightsPostProcess extends PostProcess {
  139607. /**
  139608. * Extracts highlights from the image
  139609. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  139610. * @param name The name of the effect.
  139611. * @param options The required width/height ratio to downsize to before computing the render pass.
  139612. * @param camera The camera to apply the render pass to.
  139613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139614. * @param engine The engine which the post process will be applied. (default: current engine)
  139615. * @param reusable If the post process can be reused on the same frame. (default: false)
  139616. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  139617. */
  139618. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  139619. }
  139620. }
  139621. declare module BABYLON {
  139622. /** @hidden */
  139623. export var mrtFragmentDeclaration: {
  139624. name: string;
  139625. shader: string;
  139626. };
  139627. }
  139628. declare module BABYLON {
  139629. /** @hidden */
  139630. export var geometryPixelShader: {
  139631. name: string;
  139632. shader: string;
  139633. };
  139634. }
  139635. declare module BABYLON {
  139636. /** @hidden */
  139637. export var geometryVertexShader: {
  139638. name: string;
  139639. shader: string;
  139640. };
  139641. }
  139642. declare module BABYLON {
  139643. /** @hidden */
  139644. interface ISavedTransformationMatrix {
  139645. world: Matrix;
  139646. viewProjection: Matrix;
  139647. }
  139648. /**
  139649. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  139650. */
  139651. export class GeometryBufferRenderer {
  139652. /**
  139653. * Constant used to retrieve the position texture index in the G-Buffer textures array
  139654. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  139655. */
  139656. static readonly POSITION_TEXTURE_TYPE: number;
  139657. /**
  139658. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  139659. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  139660. */
  139661. static readonly VELOCITY_TEXTURE_TYPE: number;
  139662. /**
  139663. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  139664. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  139665. */
  139666. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  139667. /**
  139668. * Dictionary used to store the previous transformation matrices of each rendered mesh
  139669. * in order to compute objects velocities when enableVelocity is set to "true"
  139670. * @hidden
  139671. */
  139672. _previousTransformationMatrices: {
  139673. [index: number]: ISavedTransformationMatrix;
  139674. };
  139675. /**
  139676. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  139677. * in order to compute objects velocities when enableVelocity is set to "true"
  139678. * @hidden
  139679. */
  139680. _previousBonesTransformationMatrices: {
  139681. [index: number]: Float32Array;
  139682. };
  139683. /**
  139684. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  139685. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  139686. */
  139687. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  139688. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  139689. renderTransparentMeshes: boolean;
  139690. private _scene;
  139691. private _multiRenderTarget;
  139692. private _ratio;
  139693. private _enablePosition;
  139694. private _enableVelocity;
  139695. private _enableReflectivity;
  139696. private _positionIndex;
  139697. private _velocityIndex;
  139698. private _reflectivityIndex;
  139699. protected _effect: Effect;
  139700. protected _cachedDefines: string;
  139701. /**
  139702. * Set the render list (meshes to be rendered) used in the G buffer.
  139703. */
  139704. set renderList(meshes: Mesh[]);
  139705. /**
  139706. * Gets wether or not G buffer are supported by the running hardware.
  139707. * This requires draw buffer supports
  139708. */
  139709. get isSupported(): boolean;
  139710. /**
  139711. * Returns the index of the given texture type in the G-Buffer textures array
  139712. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  139713. * @returns the index of the given texture type in the G-Buffer textures array
  139714. */
  139715. getTextureIndex(textureType: number): number;
  139716. /**
  139717. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  139718. */
  139719. get enablePosition(): boolean;
  139720. /**
  139721. * Sets whether or not objects positions are enabled for the G buffer.
  139722. */
  139723. set enablePosition(enable: boolean);
  139724. /**
  139725. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  139726. */
  139727. get enableVelocity(): boolean;
  139728. /**
  139729. * Sets wether or not objects velocities are enabled for the G buffer.
  139730. */
  139731. set enableVelocity(enable: boolean);
  139732. /**
  139733. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  139734. */
  139735. get enableReflectivity(): boolean;
  139736. /**
  139737. * Sets wether or not objects roughness are enabled for the G buffer.
  139738. */
  139739. set enableReflectivity(enable: boolean);
  139740. /**
  139741. * Gets the scene associated with the buffer.
  139742. */
  139743. get scene(): Scene;
  139744. /**
  139745. * Gets the ratio used by the buffer during its creation.
  139746. * How big is the buffer related to the main canvas.
  139747. */
  139748. get ratio(): number;
  139749. /** @hidden */
  139750. static _SceneComponentInitialization: (scene: Scene) => void;
  139751. /**
  139752. * Creates a new G Buffer for the scene
  139753. * @param scene The scene the buffer belongs to
  139754. * @param ratio How big is the buffer related to the main canvas.
  139755. */
  139756. constructor(scene: Scene, ratio?: number);
  139757. /**
  139758. * Checks wether everything is ready to render a submesh to the G buffer.
  139759. * @param subMesh the submesh to check readiness for
  139760. * @param useInstances is the mesh drawn using instance or not
  139761. * @returns true if ready otherwise false
  139762. */
  139763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139764. /**
  139765. * Gets the current underlying G Buffer.
  139766. * @returns the buffer
  139767. */
  139768. getGBuffer(): MultiRenderTarget;
  139769. /**
  139770. * Gets the number of samples used to render the buffer (anti aliasing).
  139771. */
  139772. get samples(): number;
  139773. /**
  139774. * Sets the number of samples used to render the buffer (anti aliasing).
  139775. */
  139776. set samples(value: number);
  139777. /**
  139778. * Disposes the renderer and frees up associated resources.
  139779. */
  139780. dispose(): void;
  139781. protected _createRenderTargets(): void;
  139782. private _copyBonesTransformationMatrices;
  139783. }
  139784. }
  139785. declare module BABYLON {
  139786. interface Scene {
  139787. /** @hidden (Backing field) */
  139788. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139789. /**
  139790. * Gets or Sets the current geometry buffer associated to the scene.
  139791. */
  139792. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  139793. /**
  139794. * Enables a GeometryBufferRender and associates it with the scene
  139795. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  139796. * @returns the GeometryBufferRenderer
  139797. */
  139798. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  139799. /**
  139800. * Disables the GeometryBufferRender associated with the scene
  139801. */
  139802. disableGeometryBufferRenderer(): void;
  139803. }
  139804. /**
  139805. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  139806. * in several rendering techniques.
  139807. */
  139808. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  139809. /**
  139810. * The component name helpful to identify the component in the list of scene components.
  139811. */
  139812. readonly name: string;
  139813. /**
  139814. * The scene the component belongs to.
  139815. */
  139816. scene: Scene;
  139817. /**
  139818. * Creates a new instance of the component for the given scene
  139819. * @param scene Defines the scene to register the component in
  139820. */
  139821. constructor(scene: Scene);
  139822. /**
  139823. * Registers the component in a given scene
  139824. */
  139825. register(): void;
  139826. /**
  139827. * Rebuilds the elements related to this component in case of
  139828. * context lost for instance.
  139829. */
  139830. rebuild(): void;
  139831. /**
  139832. * Disposes the component and the associated ressources
  139833. */
  139834. dispose(): void;
  139835. private _gatherRenderTargets;
  139836. }
  139837. }
  139838. declare module BABYLON {
  139839. /** @hidden */
  139840. export var motionBlurPixelShader: {
  139841. name: string;
  139842. shader: string;
  139843. };
  139844. }
  139845. declare module BABYLON {
  139846. /**
  139847. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  139848. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  139849. * As an example, all you have to do is to create the post-process:
  139850. * var mb = new BABYLON.MotionBlurPostProcess(
  139851. * 'mb', // The name of the effect.
  139852. * scene, // The scene containing the objects to blur according to their velocity.
  139853. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  139854. * camera // The camera to apply the render pass to.
  139855. * );
  139856. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  139857. */
  139858. export class MotionBlurPostProcess extends PostProcess {
  139859. /**
  139860. * Defines how much the image is blurred by the movement. Default value is equal to 1
  139861. */
  139862. motionStrength: number;
  139863. /**
  139864. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  139865. */
  139866. get motionBlurSamples(): number;
  139867. /**
  139868. * Sets the number of iterations to be used for motion blur quality
  139869. */
  139870. set motionBlurSamples(samples: number);
  139871. private _motionBlurSamples;
  139872. private _geometryBufferRenderer;
  139873. /**
  139874. * Creates a new instance MotionBlurPostProcess
  139875. * @param name The name of the effect.
  139876. * @param scene The scene containing the objects to blur according to their velocity.
  139877. * @param options The required width/height ratio to downsize to before computing the render pass.
  139878. * @param camera The camera to apply the render pass to.
  139879. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139880. * @param engine The engine which the post process will be applied. (default: current engine)
  139881. * @param reusable If the post process can be reused on the same frame. (default: false)
  139882. * @param textureType Type of textures used when performing the post process. (default: 0)
  139883. * @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)
  139884. */
  139885. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139886. /**
  139887. * Excludes the given skinned mesh from computing bones velocities.
  139888. * 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.
  139889. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  139890. */
  139891. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139892. /**
  139893. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  139894. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  139895. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  139896. */
  139897. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  139898. /**
  139899. * Disposes the post process.
  139900. * @param camera The camera to dispose the post process on.
  139901. */
  139902. dispose(camera?: Camera): void;
  139903. }
  139904. }
  139905. declare module BABYLON {
  139906. /** @hidden */
  139907. export var refractionPixelShader: {
  139908. name: string;
  139909. shader: string;
  139910. };
  139911. }
  139912. declare module BABYLON {
  139913. /**
  139914. * Post process which applies a refractin texture
  139915. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139916. */
  139917. export class RefractionPostProcess extends PostProcess {
  139918. /** the base color of the refraction (used to taint the rendering) */
  139919. color: Color3;
  139920. /** simulated refraction depth */
  139921. depth: number;
  139922. /** the coefficient of the base color (0 to remove base color tainting) */
  139923. colorLevel: number;
  139924. private _refTexture;
  139925. private _ownRefractionTexture;
  139926. /**
  139927. * Gets or sets the refraction texture
  139928. * Please note that you are responsible for disposing the texture if you set it manually
  139929. */
  139930. get refractionTexture(): Texture;
  139931. set refractionTexture(value: Texture);
  139932. /**
  139933. * Initializes the RefractionPostProcess
  139934. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  139935. * @param name The name of the effect.
  139936. * @param refractionTextureUrl Url of the refraction texture to use
  139937. * @param color the base color of the refraction (used to taint the rendering)
  139938. * @param depth simulated refraction depth
  139939. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  139940. * @param camera The camera to apply the render pass to.
  139941. * @param options The required width/height ratio to downsize to before computing the render pass.
  139942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139943. * @param engine The engine which the post process will be applied. (default: current engine)
  139944. * @param reusable If the post process can be reused on the same frame. (default: false)
  139945. */
  139946. constructor(name: string, refractionTextureUrl: string,
  139947. /** the base color of the refraction (used to taint the rendering) */
  139948. color: Color3,
  139949. /** simulated refraction depth */
  139950. depth: number,
  139951. /** the coefficient of the base color (0 to remove base color tainting) */
  139952. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  139953. /**
  139954. * Disposes of the post process
  139955. * @param camera Camera to dispose post process on
  139956. */
  139957. dispose(camera: Camera): void;
  139958. }
  139959. }
  139960. declare module BABYLON {
  139961. /** @hidden */
  139962. export var sharpenPixelShader: {
  139963. name: string;
  139964. shader: string;
  139965. };
  139966. }
  139967. declare module BABYLON {
  139968. /**
  139969. * The SharpenPostProcess applies a sharpen kernel to every pixel
  139970. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  139971. */
  139972. export class SharpenPostProcess extends PostProcess {
  139973. /**
  139974. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  139975. */
  139976. colorAmount: number;
  139977. /**
  139978. * How much sharpness should be applied (default: 0.3)
  139979. */
  139980. edgeAmount: number;
  139981. /**
  139982. * Creates a new instance ConvolutionPostProcess
  139983. * @param name The name of the effect.
  139984. * @param options The required width/height ratio to downsize to before computing the render pass.
  139985. * @param camera The camera to apply the render pass to.
  139986. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  139987. * @param engine The engine which the post process will be applied. (default: current engine)
  139988. * @param reusable If the post process can be reused on the same frame. (default: false)
  139989. * @param textureType Type of textures used when performing the post process. (default: 0)
  139990. * @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)
  139991. */
  139992. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  139993. }
  139994. }
  139995. declare module BABYLON {
  139996. /**
  139997. * PostProcessRenderPipeline
  139998. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  139999. */
  140000. export class PostProcessRenderPipeline {
  140001. private engine;
  140002. private _renderEffects;
  140003. private _renderEffectsForIsolatedPass;
  140004. /**
  140005. * List of inspectable custom properties (used by the Inspector)
  140006. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  140007. */
  140008. inspectableCustomProperties: IInspectable[];
  140009. /**
  140010. * @hidden
  140011. */
  140012. protected _cameras: Camera[];
  140013. /** @hidden */
  140014. _name: string;
  140015. /**
  140016. * Gets pipeline name
  140017. */
  140018. get name(): string;
  140019. /** Gets the list of attached cameras */
  140020. get cameras(): Camera[];
  140021. /**
  140022. * Initializes a PostProcessRenderPipeline
  140023. * @param engine engine to add the pipeline to
  140024. * @param name name of the pipeline
  140025. */
  140026. constructor(engine: Engine, name: string);
  140027. /**
  140028. * Gets the class name
  140029. * @returns "PostProcessRenderPipeline"
  140030. */
  140031. getClassName(): string;
  140032. /**
  140033. * If all the render effects in the pipeline are supported
  140034. */
  140035. get isSupported(): boolean;
  140036. /**
  140037. * Adds an effect to the pipeline
  140038. * @param renderEffect the effect to add
  140039. */
  140040. addEffect(renderEffect: PostProcessRenderEffect): void;
  140041. /** @hidden */
  140042. _rebuild(): void;
  140043. /** @hidden */
  140044. _enableEffect(renderEffectName: string, cameras: Camera): void;
  140045. /** @hidden */
  140046. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  140047. /** @hidden */
  140048. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140049. /** @hidden */
  140050. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  140051. /** @hidden */
  140052. _attachCameras(cameras: Camera, unique: boolean): void;
  140053. /** @hidden */
  140054. _attachCameras(cameras: Camera[], unique: boolean): void;
  140055. /** @hidden */
  140056. _detachCameras(cameras: Camera): void;
  140057. /** @hidden */
  140058. _detachCameras(cameras: Nullable<Camera[]>): void;
  140059. /** @hidden */
  140060. _update(): void;
  140061. /** @hidden */
  140062. _reset(): void;
  140063. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  140064. /**
  140065. * Disposes of the pipeline
  140066. */
  140067. dispose(): void;
  140068. }
  140069. }
  140070. declare module BABYLON {
  140071. /**
  140072. * PostProcessRenderPipelineManager class
  140073. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140074. */
  140075. export class PostProcessRenderPipelineManager {
  140076. private _renderPipelines;
  140077. /**
  140078. * Initializes a PostProcessRenderPipelineManager
  140079. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140080. */
  140081. constructor();
  140082. /**
  140083. * Gets the list of supported render pipelines
  140084. */
  140085. get supportedPipelines(): PostProcessRenderPipeline[];
  140086. /**
  140087. * Adds a pipeline to the manager
  140088. * @param renderPipeline The pipeline to add
  140089. */
  140090. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  140091. /**
  140092. * Attaches a camera to the pipeline
  140093. * @param renderPipelineName The name of the pipeline to attach to
  140094. * @param cameras the camera to attach
  140095. * @param unique if the camera can be attached multiple times to the pipeline
  140096. */
  140097. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  140098. /**
  140099. * Detaches a camera from the pipeline
  140100. * @param renderPipelineName The name of the pipeline to detach from
  140101. * @param cameras the camera to detach
  140102. */
  140103. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  140104. /**
  140105. * Enables an effect by name on a pipeline
  140106. * @param renderPipelineName the name of the pipeline to enable the effect in
  140107. * @param renderEffectName the name of the effect to enable
  140108. * @param cameras the cameras that the effect should be enabled on
  140109. */
  140110. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140111. /**
  140112. * Disables an effect by name on a pipeline
  140113. * @param renderPipelineName the name of the pipeline to disable the effect in
  140114. * @param renderEffectName the name of the effect to disable
  140115. * @param cameras the cameras that the effect should be disabled on
  140116. */
  140117. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  140118. /**
  140119. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  140120. */
  140121. update(): void;
  140122. /** @hidden */
  140123. _rebuild(): void;
  140124. /**
  140125. * Disposes of the manager and pipelines
  140126. */
  140127. dispose(): void;
  140128. }
  140129. }
  140130. declare module BABYLON {
  140131. interface Scene {
  140132. /** @hidden (Backing field) */
  140133. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140134. /**
  140135. * Gets the postprocess render pipeline manager
  140136. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  140137. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140138. */
  140139. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  140140. }
  140141. /**
  140142. * Defines the Render Pipeline scene component responsible to rendering pipelines
  140143. */
  140144. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  140145. /**
  140146. * The component name helpfull to identify the component in the list of scene components.
  140147. */
  140148. readonly name: string;
  140149. /**
  140150. * The scene the component belongs to.
  140151. */
  140152. scene: Scene;
  140153. /**
  140154. * Creates a new instance of the component for the given scene
  140155. * @param scene Defines the scene to register the component in
  140156. */
  140157. constructor(scene: Scene);
  140158. /**
  140159. * Registers the component in a given scene
  140160. */
  140161. register(): void;
  140162. /**
  140163. * Rebuilds the elements related to this component in case of
  140164. * context lost for instance.
  140165. */
  140166. rebuild(): void;
  140167. /**
  140168. * Disposes the component and the associated ressources
  140169. */
  140170. dispose(): void;
  140171. private _gatherRenderTargets;
  140172. }
  140173. }
  140174. declare module BABYLON {
  140175. /**
  140176. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  140177. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  140178. */
  140179. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140180. private _scene;
  140181. private _camerasToBeAttached;
  140182. /**
  140183. * ID of the sharpen post process,
  140184. */
  140185. private readonly SharpenPostProcessId;
  140186. /**
  140187. * @ignore
  140188. * ID of the image processing post process;
  140189. */
  140190. readonly ImageProcessingPostProcessId: string;
  140191. /**
  140192. * @ignore
  140193. * ID of the Fast Approximate Anti-Aliasing post process;
  140194. */
  140195. readonly FxaaPostProcessId: string;
  140196. /**
  140197. * ID of the chromatic aberration post process,
  140198. */
  140199. private readonly ChromaticAberrationPostProcessId;
  140200. /**
  140201. * ID of the grain post process
  140202. */
  140203. private readonly GrainPostProcessId;
  140204. /**
  140205. * Sharpen post process which will apply a sharpen convolution to enhance edges
  140206. */
  140207. sharpen: SharpenPostProcess;
  140208. private _sharpenEffect;
  140209. private bloom;
  140210. /**
  140211. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  140212. */
  140213. depthOfField: DepthOfFieldEffect;
  140214. /**
  140215. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  140216. */
  140217. fxaa: FxaaPostProcess;
  140218. /**
  140219. * Image post processing pass used to perform operations such as tone mapping or color grading.
  140220. */
  140221. imageProcessing: ImageProcessingPostProcess;
  140222. /**
  140223. * Chromatic aberration post process which will shift rgb colors in the image
  140224. */
  140225. chromaticAberration: ChromaticAberrationPostProcess;
  140226. private _chromaticAberrationEffect;
  140227. /**
  140228. * Grain post process which add noise to the image
  140229. */
  140230. grain: GrainPostProcess;
  140231. private _grainEffect;
  140232. /**
  140233. * Glow post process which adds a glow to emissive areas of the image
  140234. */
  140235. private _glowLayer;
  140236. /**
  140237. * Animations which can be used to tweak settings over a period of time
  140238. */
  140239. animations: Animation[];
  140240. private _imageProcessingConfigurationObserver;
  140241. private _sharpenEnabled;
  140242. private _bloomEnabled;
  140243. private _depthOfFieldEnabled;
  140244. private _depthOfFieldBlurLevel;
  140245. private _fxaaEnabled;
  140246. private _imageProcessingEnabled;
  140247. private _defaultPipelineTextureType;
  140248. private _bloomScale;
  140249. private _chromaticAberrationEnabled;
  140250. private _grainEnabled;
  140251. private _buildAllowed;
  140252. /**
  140253. * Gets active scene
  140254. */
  140255. get scene(): Scene;
  140256. /**
  140257. * Enable or disable the sharpen process from the pipeline
  140258. */
  140259. set sharpenEnabled(enabled: boolean);
  140260. get sharpenEnabled(): boolean;
  140261. private _resizeObserver;
  140262. private _hardwareScaleLevel;
  140263. private _bloomKernel;
  140264. /**
  140265. * Specifies the size of the bloom blur kernel, relative to the final output size
  140266. */
  140267. get bloomKernel(): number;
  140268. set bloomKernel(value: number);
  140269. /**
  140270. * Specifies the weight of the bloom in the final rendering
  140271. */
  140272. private _bloomWeight;
  140273. /**
  140274. * Specifies the luma threshold for the area that will be blurred by the bloom
  140275. */
  140276. private _bloomThreshold;
  140277. private _hdr;
  140278. /**
  140279. * The strength of the bloom.
  140280. */
  140281. set bloomWeight(value: number);
  140282. get bloomWeight(): number;
  140283. /**
  140284. * The strength of the bloom.
  140285. */
  140286. set bloomThreshold(value: number);
  140287. get bloomThreshold(): number;
  140288. /**
  140289. * The scale of the bloom, lower value will provide better performance.
  140290. */
  140291. set bloomScale(value: number);
  140292. get bloomScale(): number;
  140293. /**
  140294. * Enable or disable the bloom from the pipeline
  140295. */
  140296. set bloomEnabled(enabled: boolean);
  140297. get bloomEnabled(): boolean;
  140298. private _rebuildBloom;
  140299. /**
  140300. * If the depth of field is enabled.
  140301. */
  140302. get depthOfFieldEnabled(): boolean;
  140303. set depthOfFieldEnabled(enabled: boolean);
  140304. /**
  140305. * Blur level of the depth of field effect. (Higher blur will effect performance)
  140306. */
  140307. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  140308. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  140309. /**
  140310. * If the anti aliasing is enabled.
  140311. */
  140312. set fxaaEnabled(enabled: boolean);
  140313. get fxaaEnabled(): boolean;
  140314. private _samples;
  140315. /**
  140316. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  140317. */
  140318. set samples(sampleCount: number);
  140319. get samples(): number;
  140320. /**
  140321. * If image processing is enabled.
  140322. */
  140323. set imageProcessingEnabled(enabled: boolean);
  140324. get imageProcessingEnabled(): boolean;
  140325. /**
  140326. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  140327. */
  140328. set glowLayerEnabled(enabled: boolean);
  140329. get glowLayerEnabled(): boolean;
  140330. /**
  140331. * Gets the glow layer (or null if not defined)
  140332. */
  140333. get glowLayer(): Nullable<GlowLayer>;
  140334. /**
  140335. * Enable or disable the chromaticAberration process from the pipeline
  140336. */
  140337. set chromaticAberrationEnabled(enabled: boolean);
  140338. get chromaticAberrationEnabled(): boolean;
  140339. /**
  140340. * Enable or disable the grain process from the pipeline
  140341. */
  140342. set grainEnabled(enabled: boolean);
  140343. get grainEnabled(): boolean;
  140344. /**
  140345. * @constructor
  140346. * @param name - The rendering pipeline name (default: "")
  140347. * @param hdr - If high dynamic range textures should be used (default: true)
  140348. * @param scene - The scene linked to this pipeline (default: the last created scene)
  140349. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  140350. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  140351. */
  140352. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  140353. /**
  140354. * Get the class name
  140355. * @returns "DefaultRenderingPipeline"
  140356. */
  140357. getClassName(): string;
  140358. /**
  140359. * Force the compilation of the entire pipeline.
  140360. */
  140361. prepare(): void;
  140362. private _hasCleared;
  140363. private _prevPostProcess;
  140364. private _prevPrevPostProcess;
  140365. private _setAutoClearAndTextureSharing;
  140366. private _depthOfFieldSceneObserver;
  140367. private _buildPipeline;
  140368. private _disposePostProcesses;
  140369. /**
  140370. * Adds a camera to the pipeline
  140371. * @param camera the camera to be added
  140372. */
  140373. addCamera(camera: Camera): void;
  140374. /**
  140375. * Removes a camera from the pipeline
  140376. * @param camera the camera to remove
  140377. */
  140378. removeCamera(camera: Camera): void;
  140379. /**
  140380. * Dispose of the pipeline and stop all post processes
  140381. */
  140382. dispose(): void;
  140383. /**
  140384. * Serialize the rendering pipeline (Used when exporting)
  140385. * @returns the serialized object
  140386. */
  140387. serialize(): any;
  140388. /**
  140389. * Parse the serialized pipeline
  140390. * @param source Source pipeline.
  140391. * @param scene The scene to load the pipeline to.
  140392. * @param rootUrl The URL of the serialized pipeline.
  140393. * @returns An instantiated pipeline from the serialized object.
  140394. */
  140395. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  140396. }
  140397. }
  140398. declare module BABYLON {
  140399. /** @hidden */
  140400. export var lensHighlightsPixelShader: {
  140401. name: string;
  140402. shader: string;
  140403. };
  140404. }
  140405. declare module BABYLON {
  140406. /** @hidden */
  140407. export var depthOfFieldPixelShader: {
  140408. name: string;
  140409. shader: string;
  140410. };
  140411. }
  140412. declare module BABYLON {
  140413. /**
  140414. * BABYLON.JS Chromatic Aberration GLSL Shader
  140415. * Author: Olivier Guyot
  140416. * Separates very slightly R, G and B colors on the edges of the screen
  140417. * Inspired by Francois Tarlier & Martins Upitis
  140418. */
  140419. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  140420. /**
  140421. * @ignore
  140422. * The chromatic aberration PostProcess id in the pipeline
  140423. */
  140424. LensChromaticAberrationEffect: string;
  140425. /**
  140426. * @ignore
  140427. * The highlights enhancing PostProcess id in the pipeline
  140428. */
  140429. HighlightsEnhancingEffect: string;
  140430. /**
  140431. * @ignore
  140432. * The depth-of-field PostProcess id in the pipeline
  140433. */
  140434. LensDepthOfFieldEffect: string;
  140435. private _scene;
  140436. private _depthTexture;
  140437. private _grainTexture;
  140438. private _chromaticAberrationPostProcess;
  140439. private _highlightsPostProcess;
  140440. private _depthOfFieldPostProcess;
  140441. private _edgeBlur;
  140442. private _grainAmount;
  140443. private _chromaticAberration;
  140444. private _distortion;
  140445. private _highlightsGain;
  140446. private _highlightsThreshold;
  140447. private _dofDistance;
  140448. private _dofAperture;
  140449. private _dofDarken;
  140450. private _dofPentagon;
  140451. private _blurNoise;
  140452. /**
  140453. * @constructor
  140454. *
  140455. * Effect parameters are as follow:
  140456. * {
  140457. * chromatic_aberration: number; // from 0 to x (1 for realism)
  140458. * edge_blur: number; // from 0 to x (1 for realism)
  140459. * distortion: number; // from 0 to x (1 for realism)
  140460. * grain_amount: number; // from 0 to 1
  140461. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  140462. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  140463. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  140464. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  140465. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  140466. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  140467. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  140468. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  140469. * }
  140470. * Note: if an effect parameter is unset, effect is disabled
  140471. *
  140472. * @param name The rendering pipeline name
  140473. * @param parameters - An object containing all parameters (see above)
  140474. * @param scene The scene linked to this pipeline
  140475. * @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)
  140476. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140477. */
  140478. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  140479. /**
  140480. * Get the class name
  140481. * @returns "LensRenderingPipeline"
  140482. */
  140483. getClassName(): string;
  140484. /**
  140485. * Gets associated scene
  140486. */
  140487. get scene(): Scene;
  140488. /**
  140489. * Gets or sets the edge blur
  140490. */
  140491. get edgeBlur(): number;
  140492. set edgeBlur(value: number);
  140493. /**
  140494. * Gets or sets the grain amount
  140495. */
  140496. get grainAmount(): number;
  140497. set grainAmount(value: number);
  140498. /**
  140499. * Gets or sets the chromatic aberration amount
  140500. */
  140501. get chromaticAberration(): number;
  140502. set chromaticAberration(value: number);
  140503. /**
  140504. * Gets or sets the depth of field aperture
  140505. */
  140506. get dofAperture(): number;
  140507. set dofAperture(value: number);
  140508. /**
  140509. * Gets or sets the edge distortion
  140510. */
  140511. get edgeDistortion(): number;
  140512. set edgeDistortion(value: number);
  140513. /**
  140514. * Gets or sets the depth of field distortion
  140515. */
  140516. get dofDistortion(): number;
  140517. set dofDistortion(value: number);
  140518. /**
  140519. * Gets or sets the darken out of focus amount
  140520. */
  140521. get darkenOutOfFocus(): number;
  140522. set darkenOutOfFocus(value: number);
  140523. /**
  140524. * Gets or sets a boolean indicating if blur noise is enabled
  140525. */
  140526. get blurNoise(): boolean;
  140527. set blurNoise(value: boolean);
  140528. /**
  140529. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  140530. */
  140531. get pentagonBokeh(): boolean;
  140532. set pentagonBokeh(value: boolean);
  140533. /**
  140534. * Gets or sets the highlight grain amount
  140535. */
  140536. get highlightsGain(): number;
  140537. set highlightsGain(value: number);
  140538. /**
  140539. * Gets or sets the highlight threshold
  140540. */
  140541. get highlightsThreshold(): number;
  140542. set highlightsThreshold(value: number);
  140543. /**
  140544. * Sets the amount of blur at the edges
  140545. * @param amount blur amount
  140546. */
  140547. setEdgeBlur(amount: number): void;
  140548. /**
  140549. * Sets edge blur to 0
  140550. */
  140551. disableEdgeBlur(): void;
  140552. /**
  140553. * Sets the amout of grain
  140554. * @param amount Amount of grain
  140555. */
  140556. setGrainAmount(amount: number): void;
  140557. /**
  140558. * Set grain amount to 0
  140559. */
  140560. disableGrain(): void;
  140561. /**
  140562. * Sets the chromatic aberration amount
  140563. * @param amount amount of chromatic aberration
  140564. */
  140565. setChromaticAberration(amount: number): void;
  140566. /**
  140567. * Sets chromatic aberration amount to 0
  140568. */
  140569. disableChromaticAberration(): void;
  140570. /**
  140571. * Sets the EdgeDistortion amount
  140572. * @param amount amount of EdgeDistortion
  140573. */
  140574. setEdgeDistortion(amount: number): void;
  140575. /**
  140576. * Sets edge distortion to 0
  140577. */
  140578. disableEdgeDistortion(): void;
  140579. /**
  140580. * Sets the FocusDistance amount
  140581. * @param amount amount of FocusDistance
  140582. */
  140583. setFocusDistance(amount: number): void;
  140584. /**
  140585. * Disables depth of field
  140586. */
  140587. disableDepthOfField(): void;
  140588. /**
  140589. * Sets the Aperture amount
  140590. * @param amount amount of Aperture
  140591. */
  140592. setAperture(amount: number): void;
  140593. /**
  140594. * Sets the DarkenOutOfFocus amount
  140595. * @param amount amount of DarkenOutOfFocus
  140596. */
  140597. setDarkenOutOfFocus(amount: number): void;
  140598. private _pentagonBokehIsEnabled;
  140599. /**
  140600. * Creates a pentagon bokeh effect
  140601. */
  140602. enablePentagonBokeh(): void;
  140603. /**
  140604. * Disables the pentagon bokeh effect
  140605. */
  140606. disablePentagonBokeh(): void;
  140607. /**
  140608. * Enables noise blur
  140609. */
  140610. enableNoiseBlur(): void;
  140611. /**
  140612. * Disables noise blur
  140613. */
  140614. disableNoiseBlur(): void;
  140615. /**
  140616. * Sets the HighlightsGain amount
  140617. * @param amount amount of HighlightsGain
  140618. */
  140619. setHighlightsGain(amount: number): void;
  140620. /**
  140621. * Sets the HighlightsThreshold amount
  140622. * @param amount amount of HighlightsThreshold
  140623. */
  140624. setHighlightsThreshold(amount: number): void;
  140625. /**
  140626. * Disables highlights
  140627. */
  140628. disableHighlights(): void;
  140629. /**
  140630. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  140631. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  140632. */
  140633. dispose(disableDepthRender?: boolean): void;
  140634. private _createChromaticAberrationPostProcess;
  140635. private _createHighlightsPostProcess;
  140636. private _createDepthOfFieldPostProcess;
  140637. private _createGrainTexture;
  140638. }
  140639. }
  140640. declare module BABYLON {
  140641. /** @hidden */
  140642. export var ssao2PixelShader: {
  140643. name: string;
  140644. shader: string;
  140645. };
  140646. }
  140647. declare module BABYLON {
  140648. /** @hidden */
  140649. export var ssaoCombinePixelShader: {
  140650. name: string;
  140651. shader: string;
  140652. };
  140653. }
  140654. declare module BABYLON {
  140655. /**
  140656. * Render pipeline to produce ssao effect
  140657. */
  140658. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  140659. /**
  140660. * @ignore
  140661. * The PassPostProcess id in the pipeline that contains the original scene color
  140662. */
  140663. SSAOOriginalSceneColorEffect: string;
  140664. /**
  140665. * @ignore
  140666. * The SSAO PostProcess id in the pipeline
  140667. */
  140668. SSAORenderEffect: string;
  140669. /**
  140670. * @ignore
  140671. * The horizontal blur PostProcess id in the pipeline
  140672. */
  140673. SSAOBlurHRenderEffect: string;
  140674. /**
  140675. * @ignore
  140676. * The vertical blur PostProcess id in the pipeline
  140677. */
  140678. SSAOBlurVRenderEffect: string;
  140679. /**
  140680. * @ignore
  140681. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140682. */
  140683. SSAOCombineRenderEffect: string;
  140684. /**
  140685. * The output strength of the SSAO post-process. Default value is 1.0.
  140686. */
  140687. totalStrength: number;
  140688. /**
  140689. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  140690. */
  140691. maxZ: number;
  140692. /**
  140693. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  140694. */
  140695. minZAspect: number;
  140696. private _samples;
  140697. /**
  140698. * Number of samples used for the SSAO calculations. Default value is 8
  140699. */
  140700. set samples(n: number);
  140701. get samples(): number;
  140702. private _textureSamples;
  140703. /**
  140704. * Number of samples to use for antialiasing
  140705. */
  140706. set textureSamples(n: number);
  140707. get textureSamples(): number;
  140708. /**
  140709. * Ratio object used for SSAO ratio and blur ratio
  140710. */
  140711. private _ratio;
  140712. /**
  140713. * Dynamically generated sphere sampler.
  140714. */
  140715. private _sampleSphere;
  140716. /**
  140717. * Blur filter offsets
  140718. */
  140719. private _samplerOffsets;
  140720. private _expensiveBlur;
  140721. /**
  140722. * If bilateral blur should be used
  140723. */
  140724. set expensiveBlur(b: boolean);
  140725. get expensiveBlur(): boolean;
  140726. /**
  140727. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  140728. */
  140729. radius: number;
  140730. /**
  140731. * The base color of the SSAO post-process
  140732. * The final result is "base + ssao" between [0, 1]
  140733. */
  140734. base: number;
  140735. /**
  140736. * Support test.
  140737. */
  140738. static get IsSupported(): boolean;
  140739. private _scene;
  140740. private _depthTexture;
  140741. private _normalTexture;
  140742. private _randomTexture;
  140743. private _originalColorPostProcess;
  140744. private _ssaoPostProcess;
  140745. private _blurHPostProcess;
  140746. private _blurVPostProcess;
  140747. private _ssaoCombinePostProcess;
  140748. /**
  140749. * Gets active scene
  140750. */
  140751. get scene(): Scene;
  140752. /**
  140753. * @constructor
  140754. * @param name The rendering pipeline name
  140755. * @param scene The scene linked to this pipeline
  140756. * @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 }
  140757. * @param cameras The array of cameras that the rendering pipeline will be attached to
  140758. */
  140759. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140760. /**
  140761. * Get the class name
  140762. * @returns "SSAO2RenderingPipeline"
  140763. */
  140764. getClassName(): string;
  140765. /**
  140766. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140767. */
  140768. dispose(disableGeometryBufferRenderer?: boolean): void;
  140769. private _createBlurPostProcess;
  140770. /** @hidden */
  140771. _rebuild(): void;
  140772. private _bits;
  140773. private _radicalInverse_VdC;
  140774. private _hammersley;
  140775. private _hemisphereSample_uniform;
  140776. private _generateHemisphere;
  140777. private _createSSAOPostProcess;
  140778. private _createSSAOCombinePostProcess;
  140779. private _createRandomTexture;
  140780. /**
  140781. * Serialize the rendering pipeline (Used when exporting)
  140782. * @returns the serialized object
  140783. */
  140784. serialize(): any;
  140785. /**
  140786. * Parse the serialized pipeline
  140787. * @param source Source pipeline.
  140788. * @param scene The scene to load the pipeline to.
  140789. * @param rootUrl The URL of the serialized pipeline.
  140790. * @returns An instantiated pipeline from the serialized object.
  140791. */
  140792. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  140793. }
  140794. }
  140795. declare module BABYLON {
  140796. /** @hidden */
  140797. export var ssaoPixelShader: {
  140798. name: string;
  140799. shader: string;
  140800. };
  140801. }
  140802. declare module BABYLON {
  140803. /**
  140804. * Render pipeline to produce ssao effect
  140805. */
  140806. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  140807. /**
  140808. * @ignore
  140809. * The PassPostProcess id in the pipeline that contains the original scene color
  140810. */
  140811. SSAOOriginalSceneColorEffect: string;
  140812. /**
  140813. * @ignore
  140814. * The SSAO PostProcess id in the pipeline
  140815. */
  140816. SSAORenderEffect: string;
  140817. /**
  140818. * @ignore
  140819. * The horizontal blur PostProcess id in the pipeline
  140820. */
  140821. SSAOBlurHRenderEffect: string;
  140822. /**
  140823. * @ignore
  140824. * The vertical blur PostProcess id in the pipeline
  140825. */
  140826. SSAOBlurVRenderEffect: string;
  140827. /**
  140828. * @ignore
  140829. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  140830. */
  140831. SSAOCombineRenderEffect: string;
  140832. /**
  140833. * The output strength of the SSAO post-process. Default value is 1.0.
  140834. */
  140835. totalStrength: number;
  140836. /**
  140837. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  140838. */
  140839. radius: number;
  140840. /**
  140841. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  140842. * Must not be equal to fallOff and superior to fallOff.
  140843. * Default value is 0.0075
  140844. */
  140845. area: number;
  140846. /**
  140847. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  140848. * Must not be equal to area and inferior to area.
  140849. * Default value is 0.000001
  140850. */
  140851. fallOff: number;
  140852. /**
  140853. * The base color of the SSAO post-process
  140854. * The final result is "base + ssao" between [0, 1]
  140855. */
  140856. base: number;
  140857. private _scene;
  140858. private _depthTexture;
  140859. private _randomTexture;
  140860. private _originalColorPostProcess;
  140861. private _ssaoPostProcess;
  140862. private _blurHPostProcess;
  140863. private _blurVPostProcess;
  140864. private _ssaoCombinePostProcess;
  140865. private _firstUpdate;
  140866. /**
  140867. * Gets active scene
  140868. */
  140869. get scene(): Scene;
  140870. /**
  140871. * @constructor
  140872. * @param name - The rendering pipeline name
  140873. * @param scene - The scene linked to this pipeline
  140874. * @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 }
  140875. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  140876. */
  140877. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  140878. /**
  140879. * Get the class name
  140880. * @returns "SSAORenderingPipeline"
  140881. */
  140882. getClassName(): string;
  140883. /**
  140884. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  140885. */
  140886. dispose(disableDepthRender?: boolean): void;
  140887. private _createBlurPostProcess;
  140888. /** @hidden */
  140889. _rebuild(): void;
  140890. private _createSSAOPostProcess;
  140891. private _createSSAOCombinePostProcess;
  140892. private _createRandomTexture;
  140893. }
  140894. }
  140895. declare module BABYLON {
  140896. /** @hidden */
  140897. export var screenSpaceReflectionPixelShader: {
  140898. name: string;
  140899. shader: string;
  140900. };
  140901. }
  140902. declare module BABYLON {
  140903. /**
  140904. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  140905. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  140906. */
  140907. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  140908. /**
  140909. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  140910. */
  140911. threshold: number;
  140912. /**
  140913. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  140914. */
  140915. strength: number;
  140916. /**
  140917. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  140918. */
  140919. reflectionSpecularFalloffExponent: number;
  140920. /**
  140921. * 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]
  140922. */
  140923. step: number;
  140924. /**
  140925. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  140926. */
  140927. roughnessFactor: number;
  140928. private _geometryBufferRenderer;
  140929. private _enableSmoothReflections;
  140930. private _reflectionSamples;
  140931. private _smoothSteps;
  140932. /**
  140933. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  140934. * @param name The name of the effect.
  140935. * @param scene The scene containing the objects to calculate reflections.
  140936. * @param options The required width/height ratio to downsize to before computing the render pass.
  140937. * @param camera The camera to apply the render pass to.
  140938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  140939. * @param engine The engine which the post process will be applied. (default: current engine)
  140940. * @param reusable If the post process can be reused on the same frame. (default: false)
  140941. * @param textureType Type of textures used when performing the post process. (default: 0)
  140942. * @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)
  140943. */
  140944. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  140945. /**
  140946. * Gets wether or not smoothing reflections is enabled.
  140947. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140948. */
  140949. get enableSmoothReflections(): boolean;
  140950. /**
  140951. * Sets wether or not smoothing reflections is enabled.
  140952. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  140953. */
  140954. set enableSmoothReflections(enabled: boolean);
  140955. /**
  140956. * Gets the number of samples taken while computing reflections. More samples count is high,
  140957. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140958. */
  140959. get reflectionSamples(): number;
  140960. /**
  140961. * Sets the number of samples taken while computing reflections. More samples count is high,
  140962. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  140963. */
  140964. set reflectionSamples(samples: number);
  140965. /**
  140966. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  140967. * more the post-process will require GPU power and can generate a drop in FPS.
  140968. * Default value (5.0) work pretty well in all cases but can be adjusted.
  140969. */
  140970. get smoothSteps(): number;
  140971. set smoothSteps(steps: number);
  140972. private _updateEffectDefines;
  140973. }
  140974. }
  140975. declare module BABYLON {
  140976. /** @hidden */
  140977. export var standardPixelShader: {
  140978. name: string;
  140979. shader: string;
  140980. };
  140981. }
  140982. declare module BABYLON {
  140983. /**
  140984. * Standard rendering pipeline
  140985. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  140986. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  140987. */
  140988. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  140989. /**
  140990. * Public members
  140991. */
  140992. /**
  140993. * Post-process which contains the original scene color before the pipeline applies all the effects
  140994. */
  140995. originalPostProcess: Nullable<PostProcess>;
  140996. /**
  140997. * Post-process used to down scale an image x4
  140998. */
  140999. downSampleX4PostProcess: Nullable<PostProcess>;
  141000. /**
  141001. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  141002. */
  141003. brightPassPostProcess: Nullable<PostProcess>;
  141004. /**
  141005. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  141006. */
  141007. blurHPostProcesses: PostProcess[];
  141008. /**
  141009. * Post-process array storing all the vertical blur post-processes used by the pipeline
  141010. */
  141011. blurVPostProcesses: PostProcess[];
  141012. /**
  141013. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  141014. */
  141015. textureAdderPostProcess: Nullable<PostProcess>;
  141016. /**
  141017. * Post-process used to create volumetric lighting effect
  141018. */
  141019. volumetricLightPostProcess: Nullable<PostProcess>;
  141020. /**
  141021. * Post-process used to smooth the previous volumetric light post-process on the X axis
  141022. */
  141023. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  141024. /**
  141025. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  141026. */
  141027. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  141028. /**
  141029. * Post-process used to merge the volumetric light effect and the real scene color
  141030. */
  141031. volumetricLightMergePostProces: Nullable<PostProcess>;
  141032. /**
  141033. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  141034. */
  141035. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  141036. /**
  141037. * Base post-process used to calculate the average luminance of the final image for HDR
  141038. */
  141039. luminancePostProcess: Nullable<PostProcess>;
  141040. /**
  141041. * Post-processes used to create down sample post-processes in order to get
  141042. * the average luminance of the final image for HDR
  141043. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  141044. */
  141045. luminanceDownSamplePostProcesses: PostProcess[];
  141046. /**
  141047. * Post-process used to create a HDR effect (light adaptation)
  141048. */
  141049. hdrPostProcess: Nullable<PostProcess>;
  141050. /**
  141051. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  141052. */
  141053. textureAdderFinalPostProcess: Nullable<PostProcess>;
  141054. /**
  141055. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  141056. */
  141057. lensFlareFinalPostProcess: Nullable<PostProcess>;
  141058. /**
  141059. * Post-process used to merge the final HDR post-process and the real scene color
  141060. */
  141061. hdrFinalPostProcess: Nullable<PostProcess>;
  141062. /**
  141063. * Post-process used to create a lens flare effect
  141064. */
  141065. lensFlarePostProcess: Nullable<PostProcess>;
  141066. /**
  141067. * Post-process that merges the result of the lens flare post-process and the real scene color
  141068. */
  141069. lensFlareComposePostProcess: Nullable<PostProcess>;
  141070. /**
  141071. * Post-process used to create a motion blur effect
  141072. */
  141073. motionBlurPostProcess: Nullable<PostProcess>;
  141074. /**
  141075. * Post-process used to create a depth of field effect
  141076. */
  141077. depthOfFieldPostProcess: Nullable<PostProcess>;
  141078. /**
  141079. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  141080. */
  141081. fxaaPostProcess: Nullable<FxaaPostProcess>;
  141082. /**
  141083. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  141084. */
  141085. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  141086. /**
  141087. * Represents the brightness threshold in order to configure the illuminated surfaces
  141088. */
  141089. brightThreshold: number;
  141090. /**
  141091. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  141092. */
  141093. blurWidth: number;
  141094. /**
  141095. * Sets if the blur for highlighted surfaces must be only horizontal
  141096. */
  141097. horizontalBlur: boolean;
  141098. /**
  141099. * Gets the overall exposure used by the pipeline
  141100. */
  141101. get exposure(): number;
  141102. /**
  141103. * Sets the overall exposure used by the pipeline
  141104. */
  141105. set exposure(value: number);
  141106. /**
  141107. * Texture used typically to simulate "dirty" on camera lens
  141108. */
  141109. lensTexture: Nullable<Texture>;
  141110. /**
  141111. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  141112. */
  141113. volumetricLightCoefficient: number;
  141114. /**
  141115. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  141116. */
  141117. volumetricLightPower: number;
  141118. /**
  141119. * Used the set the blur intensity to smooth the volumetric lights
  141120. */
  141121. volumetricLightBlurScale: number;
  141122. /**
  141123. * Light (spot or directional) used to generate the volumetric lights rays
  141124. * The source light must have a shadow generate so the pipeline can get its
  141125. * depth map
  141126. */
  141127. sourceLight: Nullable<SpotLight | DirectionalLight>;
  141128. /**
  141129. * For eye adaptation, represents the minimum luminance the eye can see
  141130. */
  141131. hdrMinimumLuminance: number;
  141132. /**
  141133. * For eye adaptation, represents the decrease luminance speed
  141134. */
  141135. hdrDecreaseRate: number;
  141136. /**
  141137. * For eye adaptation, represents the increase luminance speed
  141138. */
  141139. hdrIncreaseRate: number;
  141140. /**
  141141. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141142. */
  141143. get hdrAutoExposure(): boolean;
  141144. /**
  141145. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  141146. */
  141147. set hdrAutoExposure(value: boolean);
  141148. /**
  141149. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  141150. */
  141151. lensColorTexture: Nullable<Texture>;
  141152. /**
  141153. * The overall strengh for the lens flare effect
  141154. */
  141155. lensFlareStrength: number;
  141156. /**
  141157. * Dispersion coefficient for lens flare ghosts
  141158. */
  141159. lensFlareGhostDispersal: number;
  141160. /**
  141161. * Main lens flare halo width
  141162. */
  141163. lensFlareHaloWidth: number;
  141164. /**
  141165. * Based on the lens distortion effect, defines how much the lens flare result
  141166. * is distorted
  141167. */
  141168. lensFlareDistortionStrength: number;
  141169. /**
  141170. * Configures the blur intensity used for for lens flare (halo)
  141171. */
  141172. lensFlareBlurWidth: number;
  141173. /**
  141174. * Lens star texture must be used to simulate rays on the flares and is available
  141175. * in the documentation
  141176. */
  141177. lensStarTexture: Nullable<Texture>;
  141178. /**
  141179. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  141180. * flare effect by taking account of the dirt texture
  141181. */
  141182. lensFlareDirtTexture: Nullable<Texture>;
  141183. /**
  141184. * Represents the focal length for the depth of field effect
  141185. */
  141186. depthOfFieldDistance: number;
  141187. /**
  141188. * Represents the blur intensity for the blurred part of the depth of field effect
  141189. */
  141190. depthOfFieldBlurWidth: number;
  141191. /**
  141192. * Gets how much the image is blurred by the movement while using the motion blur post-process
  141193. */
  141194. get motionStrength(): number;
  141195. /**
  141196. * Sets how much the image is blurred by the movement while using the motion blur post-process
  141197. */
  141198. set motionStrength(strength: number);
  141199. /**
  141200. * Gets wether or not the motion blur post-process is object based or screen based.
  141201. */
  141202. get objectBasedMotionBlur(): boolean;
  141203. /**
  141204. * Sets wether or not the motion blur post-process should be object based or screen based
  141205. */
  141206. set objectBasedMotionBlur(value: boolean);
  141207. /**
  141208. * List of animations for the pipeline (IAnimatable implementation)
  141209. */
  141210. animations: Animation[];
  141211. /**
  141212. * Private members
  141213. */
  141214. private _scene;
  141215. private _currentDepthOfFieldSource;
  141216. private _basePostProcess;
  141217. private _fixedExposure;
  141218. private _currentExposure;
  141219. private _hdrAutoExposure;
  141220. private _hdrCurrentLuminance;
  141221. private _motionStrength;
  141222. private _isObjectBasedMotionBlur;
  141223. private _floatTextureType;
  141224. private _camerasToBeAttached;
  141225. private _ratio;
  141226. private _bloomEnabled;
  141227. private _depthOfFieldEnabled;
  141228. private _vlsEnabled;
  141229. private _lensFlareEnabled;
  141230. private _hdrEnabled;
  141231. private _motionBlurEnabled;
  141232. private _fxaaEnabled;
  141233. private _screenSpaceReflectionsEnabled;
  141234. private _motionBlurSamples;
  141235. private _volumetricLightStepsCount;
  141236. private _samples;
  141237. /**
  141238. * @ignore
  141239. * Specifies if the bloom pipeline is enabled
  141240. */
  141241. get BloomEnabled(): boolean;
  141242. set BloomEnabled(enabled: boolean);
  141243. /**
  141244. * @ignore
  141245. * Specifies if the depth of field pipeline is enabed
  141246. */
  141247. get DepthOfFieldEnabled(): boolean;
  141248. set DepthOfFieldEnabled(enabled: boolean);
  141249. /**
  141250. * @ignore
  141251. * Specifies if the lens flare pipeline is enabed
  141252. */
  141253. get LensFlareEnabled(): boolean;
  141254. set LensFlareEnabled(enabled: boolean);
  141255. /**
  141256. * @ignore
  141257. * Specifies if the HDR pipeline is enabled
  141258. */
  141259. get HDREnabled(): boolean;
  141260. set HDREnabled(enabled: boolean);
  141261. /**
  141262. * @ignore
  141263. * Specifies if the volumetric lights scattering effect is enabled
  141264. */
  141265. get VLSEnabled(): boolean;
  141266. set VLSEnabled(enabled: boolean);
  141267. /**
  141268. * @ignore
  141269. * Specifies if the motion blur effect is enabled
  141270. */
  141271. get MotionBlurEnabled(): boolean;
  141272. set MotionBlurEnabled(enabled: boolean);
  141273. /**
  141274. * Specifies if anti-aliasing is enabled
  141275. */
  141276. get fxaaEnabled(): boolean;
  141277. set fxaaEnabled(enabled: boolean);
  141278. /**
  141279. * Specifies if screen space reflections are enabled.
  141280. */
  141281. get screenSpaceReflectionsEnabled(): boolean;
  141282. set screenSpaceReflectionsEnabled(enabled: boolean);
  141283. /**
  141284. * Specifies the number of steps used to calculate the volumetric lights
  141285. * Typically in interval [50, 200]
  141286. */
  141287. get volumetricLightStepsCount(): number;
  141288. set volumetricLightStepsCount(count: number);
  141289. /**
  141290. * Specifies the number of samples used for the motion blur effect
  141291. * Typically in interval [16, 64]
  141292. */
  141293. get motionBlurSamples(): number;
  141294. set motionBlurSamples(samples: number);
  141295. /**
  141296. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  141297. */
  141298. get samples(): number;
  141299. set samples(sampleCount: number);
  141300. /**
  141301. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  141302. * @constructor
  141303. * @param name The rendering pipeline name
  141304. * @param scene The scene linked to this pipeline
  141305. * @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)
  141306. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  141307. * @param cameras The array of cameras that the rendering pipeline will be attached to
  141308. */
  141309. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  141310. private _buildPipeline;
  141311. private _createDownSampleX4PostProcess;
  141312. private _createBrightPassPostProcess;
  141313. private _createBlurPostProcesses;
  141314. private _createTextureAdderPostProcess;
  141315. private _createVolumetricLightPostProcess;
  141316. private _createLuminancePostProcesses;
  141317. private _createHdrPostProcess;
  141318. private _createLensFlarePostProcess;
  141319. private _createDepthOfFieldPostProcess;
  141320. private _createMotionBlurPostProcess;
  141321. private _getDepthTexture;
  141322. private _disposePostProcesses;
  141323. /**
  141324. * Dispose of the pipeline and stop all post processes
  141325. */
  141326. dispose(): void;
  141327. /**
  141328. * Serialize the rendering pipeline (Used when exporting)
  141329. * @returns the serialized object
  141330. */
  141331. serialize(): any;
  141332. /**
  141333. * Parse the serialized pipeline
  141334. * @param source Source pipeline.
  141335. * @param scene The scene to load the pipeline to.
  141336. * @param rootUrl The URL of the serialized pipeline.
  141337. * @returns An instantiated pipeline from the serialized object.
  141338. */
  141339. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  141340. /**
  141341. * Luminance steps
  141342. */
  141343. static LuminanceSteps: number;
  141344. }
  141345. }
  141346. declare module BABYLON {
  141347. /** @hidden */
  141348. export var tonemapPixelShader: {
  141349. name: string;
  141350. shader: string;
  141351. };
  141352. }
  141353. declare module BABYLON {
  141354. /** Defines operator used for tonemapping */
  141355. export enum TonemappingOperator {
  141356. /** Hable */
  141357. Hable = 0,
  141358. /** Reinhard */
  141359. Reinhard = 1,
  141360. /** HejiDawson */
  141361. HejiDawson = 2,
  141362. /** Photographic */
  141363. Photographic = 3
  141364. }
  141365. /**
  141366. * Defines a post process to apply tone mapping
  141367. */
  141368. export class TonemapPostProcess extends PostProcess {
  141369. private _operator;
  141370. /** Defines the required exposure adjustement */
  141371. exposureAdjustment: number;
  141372. /**
  141373. * Creates a new TonemapPostProcess
  141374. * @param name defines the name of the postprocess
  141375. * @param _operator defines the operator to use
  141376. * @param exposureAdjustment defines the required exposure adjustement
  141377. * @param camera defines the camera to use (can be null)
  141378. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  141379. * @param engine defines the hosting engine (can be ignore if camera is set)
  141380. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  141381. */
  141382. constructor(name: string, _operator: TonemappingOperator,
  141383. /** Defines the required exposure adjustement */
  141384. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  141385. }
  141386. }
  141387. declare module BABYLON {
  141388. /** @hidden */
  141389. export var volumetricLightScatteringPixelShader: {
  141390. name: string;
  141391. shader: string;
  141392. };
  141393. }
  141394. declare module BABYLON {
  141395. /** @hidden */
  141396. export var volumetricLightScatteringPassVertexShader: {
  141397. name: string;
  141398. shader: string;
  141399. };
  141400. }
  141401. declare module BABYLON {
  141402. /** @hidden */
  141403. export var volumetricLightScatteringPassPixelShader: {
  141404. name: string;
  141405. shader: string;
  141406. };
  141407. }
  141408. declare module BABYLON {
  141409. /**
  141410. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  141411. */
  141412. export class VolumetricLightScatteringPostProcess extends PostProcess {
  141413. private _volumetricLightScatteringPass;
  141414. private _volumetricLightScatteringRTT;
  141415. private _viewPort;
  141416. private _screenCoordinates;
  141417. private _cachedDefines;
  141418. /**
  141419. * If not undefined, the mesh position is computed from the attached node position
  141420. */
  141421. attachedNode: {
  141422. position: Vector3;
  141423. };
  141424. /**
  141425. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  141426. */
  141427. customMeshPosition: Vector3;
  141428. /**
  141429. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  141430. */
  141431. useCustomMeshPosition: boolean;
  141432. /**
  141433. * If the post-process should inverse the light scattering direction
  141434. */
  141435. invert: boolean;
  141436. /**
  141437. * The internal mesh used by the post-process
  141438. */
  141439. mesh: Mesh;
  141440. /**
  141441. * @hidden
  141442. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  141443. */
  141444. get useDiffuseColor(): boolean;
  141445. set useDiffuseColor(useDiffuseColor: boolean);
  141446. /**
  141447. * Array containing the excluded meshes not rendered in the internal pass
  141448. */
  141449. excludedMeshes: AbstractMesh[];
  141450. /**
  141451. * Controls the overall intensity of the post-process
  141452. */
  141453. exposure: number;
  141454. /**
  141455. * Dissipates each sample's contribution in range [0, 1]
  141456. */
  141457. decay: number;
  141458. /**
  141459. * Controls the overall intensity of each sample
  141460. */
  141461. weight: number;
  141462. /**
  141463. * Controls the density of each sample
  141464. */
  141465. density: number;
  141466. /**
  141467. * @constructor
  141468. * @param name The post-process name
  141469. * @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)
  141470. * @param camera The camera that the post-process will be attached to
  141471. * @param mesh The mesh used to create the light scattering
  141472. * @param samples The post-process quality, default 100
  141473. * @param samplingModeThe post-process filtering mode
  141474. * @param engine The babylon engine
  141475. * @param reusable If the post-process is reusable
  141476. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  141477. */
  141478. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  141479. /**
  141480. * Returns the string "VolumetricLightScatteringPostProcess"
  141481. * @returns "VolumetricLightScatteringPostProcess"
  141482. */
  141483. getClassName(): string;
  141484. private _isReady;
  141485. /**
  141486. * Sets the new light position for light scattering effect
  141487. * @param position The new custom light position
  141488. */
  141489. setCustomMeshPosition(position: Vector3): void;
  141490. /**
  141491. * Returns the light position for light scattering effect
  141492. * @return Vector3 The custom light position
  141493. */
  141494. getCustomMeshPosition(): Vector3;
  141495. /**
  141496. * Disposes the internal assets and detaches the post-process from the camera
  141497. */
  141498. dispose(camera: Camera): void;
  141499. /**
  141500. * Returns the render target texture used by the post-process
  141501. * @return the render target texture used by the post-process
  141502. */
  141503. getPass(): RenderTargetTexture;
  141504. private _meshExcluded;
  141505. private _createPass;
  141506. private _updateMeshScreenCoordinates;
  141507. /**
  141508. * Creates a default mesh for the Volumeric Light Scattering post-process
  141509. * @param name The mesh name
  141510. * @param scene The scene where to create the mesh
  141511. * @return the default mesh
  141512. */
  141513. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  141514. }
  141515. }
  141516. declare module BABYLON {
  141517. interface Scene {
  141518. /** @hidden (Backing field) */
  141519. _boundingBoxRenderer: BoundingBoxRenderer;
  141520. /** @hidden (Backing field) */
  141521. _forceShowBoundingBoxes: boolean;
  141522. /**
  141523. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  141524. */
  141525. forceShowBoundingBoxes: boolean;
  141526. /**
  141527. * Gets the bounding box renderer associated with the scene
  141528. * @returns a BoundingBoxRenderer
  141529. */
  141530. getBoundingBoxRenderer(): BoundingBoxRenderer;
  141531. }
  141532. interface AbstractMesh {
  141533. /** @hidden (Backing field) */
  141534. _showBoundingBox: boolean;
  141535. /**
  141536. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  141537. */
  141538. showBoundingBox: boolean;
  141539. }
  141540. /**
  141541. * Component responsible of rendering the bounding box of the meshes in a scene.
  141542. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  141543. */
  141544. export class BoundingBoxRenderer implements ISceneComponent {
  141545. /**
  141546. * The component name helpfull to identify the component in the list of scene components.
  141547. */
  141548. readonly name: string;
  141549. /**
  141550. * The scene the component belongs to.
  141551. */
  141552. scene: Scene;
  141553. /**
  141554. * Color of the bounding box lines placed in front of an object
  141555. */
  141556. frontColor: Color3;
  141557. /**
  141558. * Color of the bounding box lines placed behind an object
  141559. */
  141560. backColor: Color3;
  141561. /**
  141562. * Defines if the renderer should show the back lines or not
  141563. */
  141564. showBackLines: boolean;
  141565. /**
  141566. * @hidden
  141567. */
  141568. renderList: SmartArray<BoundingBox>;
  141569. private _colorShader;
  141570. private _vertexBuffers;
  141571. private _indexBuffer;
  141572. private _fillIndexBuffer;
  141573. private _fillIndexData;
  141574. /**
  141575. * Instantiates a new bounding box renderer in a scene.
  141576. * @param scene the scene the renderer renders in
  141577. */
  141578. constructor(scene: Scene);
  141579. /**
  141580. * Registers the component in a given scene
  141581. */
  141582. register(): void;
  141583. private _evaluateSubMesh;
  141584. private _activeMesh;
  141585. private _prepareRessources;
  141586. private _createIndexBuffer;
  141587. /**
  141588. * Rebuilds the elements related to this component in case of
  141589. * context lost for instance.
  141590. */
  141591. rebuild(): void;
  141592. /**
  141593. * @hidden
  141594. */
  141595. reset(): void;
  141596. /**
  141597. * Render the bounding boxes of a specific rendering group
  141598. * @param renderingGroupId defines the rendering group to render
  141599. */
  141600. render(renderingGroupId: number): void;
  141601. /**
  141602. * In case of occlusion queries, we can render the occlusion bounding box through this method
  141603. * @param mesh Define the mesh to render the occlusion bounding box for
  141604. */
  141605. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  141606. /**
  141607. * Dispose and release the resources attached to this renderer.
  141608. */
  141609. dispose(): void;
  141610. }
  141611. }
  141612. declare module BABYLON {
  141613. interface Scene {
  141614. /** @hidden (Backing field) */
  141615. _depthRenderer: {
  141616. [id: string]: DepthRenderer;
  141617. };
  141618. /**
  141619. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  141620. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  141621. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  141622. * @returns the created depth renderer
  141623. */
  141624. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean): DepthRenderer;
  141625. /**
  141626. * Disables a depth renderer for a given camera
  141627. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  141628. */
  141629. disableDepthRenderer(camera?: Nullable<Camera>): void;
  141630. }
  141631. /**
  141632. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  141633. * in several rendering techniques.
  141634. */
  141635. export class DepthRendererSceneComponent implements ISceneComponent {
  141636. /**
  141637. * The component name helpfull to identify the component in the list of scene components.
  141638. */
  141639. readonly name: string;
  141640. /**
  141641. * The scene the component belongs to.
  141642. */
  141643. scene: Scene;
  141644. /**
  141645. * Creates a new instance of the component for the given scene
  141646. * @param scene Defines the scene to register the component in
  141647. */
  141648. constructor(scene: Scene);
  141649. /**
  141650. * Registers the component in a given scene
  141651. */
  141652. register(): void;
  141653. /**
  141654. * Rebuilds the elements related to this component in case of
  141655. * context lost for instance.
  141656. */
  141657. rebuild(): void;
  141658. /**
  141659. * Disposes the component and the associated ressources
  141660. */
  141661. dispose(): void;
  141662. private _gatherRenderTargets;
  141663. private _gatherActiveCameraRenderTargets;
  141664. }
  141665. }
  141666. declare module BABYLON {
  141667. /** @hidden */
  141668. export var outlinePixelShader: {
  141669. name: string;
  141670. shader: string;
  141671. };
  141672. }
  141673. declare module BABYLON {
  141674. /** @hidden */
  141675. export var outlineVertexShader: {
  141676. name: string;
  141677. shader: string;
  141678. };
  141679. }
  141680. declare module BABYLON {
  141681. interface Scene {
  141682. /** @hidden */
  141683. _outlineRenderer: OutlineRenderer;
  141684. /**
  141685. * Gets the outline renderer associated with the scene
  141686. * @returns a OutlineRenderer
  141687. */
  141688. getOutlineRenderer(): OutlineRenderer;
  141689. }
  141690. interface AbstractMesh {
  141691. /** @hidden (Backing field) */
  141692. _renderOutline: boolean;
  141693. /**
  141694. * Gets or sets a boolean indicating if the outline must be rendered as well
  141695. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  141696. */
  141697. renderOutline: boolean;
  141698. /** @hidden (Backing field) */
  141699. _renderOverlay: boolean;
  141700. /**
  141701. * Gets or sets a boolean indicating if the overlay must be rendered as well
  141702. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  141703. */
  141704. renderOverlay: boolean;
  141705. }
  141706. /**
  141707. * This class is responsible to draw bothe outline/overlay of meshes.
  141708. * It should not be used directly but through the available method on mesh.
  141709. */
  141710. export class OutlineRenderer implements ISceneComponent {
  141711. /**
  141712. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  141713. */
  141714. private static _StencilReference;
  141715. /**
  141716. * The name of the component. Each component must have a unique name.
  141717. */
  141718. name: string;
  141719. /**
  141720. * The scene the component belongs to.
  141721. */
  141722. scene: Scene;
  141723. /**
  141724. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  141725. */
  141726. zOffset: number;
  141727. private _engine;
  141728. private _effect;
  141729. private _cachedDefines;
  141730. private _savedDepthWrite;
  141731. /**
  141732. * Instantiates a new outline renderer. (There could be only one per scene).
  141733. * @param scene Defines the scene it belongs to
  141734. */
  141735. constructor(scene: Scene);
  141736. /**
  141737. * Register the component to one instance of a scene.
  141738. */
  141739. register(): void;
  141740. /**
  141741. * Rebuilds the elements related to this component in case of
  141742. * context lost for instance.
  141743. */
  141744. rebuild(): void;
  141745. /**
  141746. * Disposes the component and the associated ressources.
  141747. */
  141748. dispose(): void;
  141749. /**
  141750. * Renders the outline in the canvas.
  141751. * @param subMesh Defines the sumesh to render
  141752. * @param batch Defines the batch of meshes in case of instances
  141753. * @param useOverlay Defines if the rendering is for the overlay or the outline
  141754. */
  141755. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  141756. /**
  141757. * Returns whether or not the outline renderer is ready for a given submesh.
  141758. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  141759. * @param subMesh Defines the submesh to check readyness for
  141760. * @param useInstances Defines wheter wee are trying to render instances or not
  141761. * @returns true if ready otherwise false
  141762. */
  141763. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  141764. private _beforeRenderingMesh;
  141765. private _afterRenderingMesh;
  141766. }
  141767. }
  141768. declare module BABYLON {
  141769. /**
  141770. * Defines the basic options interface of a Sprite Frame Source Size.
  141771. */
  141772. export interface ISpriteJSONSpriteSourceSize {
  141773. /**
  141774. * number of the original width of the Frame
  141775. */
  141776. w: number;
  141777. /**
  141778. * number of the original height of the Frame
  141779. */
  141780. h: number;
  141781. }
  141782. /**
  141783. * Defines the basic options interface of a Sprite Frame Data.
  141784. */
  141785. export interface ISpriteJSONSpriteFrameData {
  141786. /**
  141787. * number of the x offset of the Frame
  141788. */
  141789. x: number;
  141790. /**
  141791. * number of the y offset of the Frame
  141792. */
  141793. y: number;
  141794. /**
  141795. * number of the width of the Frame
  141796. */
  141797. w: number;
  141798. /**
  141799. * number of the height of the Frame
  141800. */
  141801. h: number;
  141802. }
  141803. /**
  141804. * Defines the basic options interface of a JSON Sprite.
  141805. */
  141806. export interface ISpriteJSONSprite {
  141807. /**
  141808. * string name of the Frame
  141809. */
  141810. filename: string;
  141811. /**
  141812. * ISpriteJSONSpriteFrame basic object of the frame data
  141813. */
  141814. frame: ISpriteJSONSpriteFrameData;
  141815. /**
  141816. * boolean to flag is the frame was rotated.
  141817. */
  141818. rotated: boolean;
  141819. /**
  141820. * boolean to flag is the frame was trimmed.
  141821. */
  141822. trimmed: boolean;
  141823. /**
  141824. * ISpriteJSONSpriteFrame basic object of the source data
  141825. */
  141826. spriteSourceSize: ISpriteJSONSpriteFrameData;
  141827. /**
  141828. * ISpriteJSONSpriteFrame basic object of the source data
  141829. */
  141830. sourceSize: ISpriteJSONSpriteSourceSize;
  141831. }
  141832. /**
  141833. * Defines the basic options interface of a JSON atlas.
  141834. */
  141835. export interface ISpriteJSONAtlas {
  141836. /**
  141837. * Array of objects that contain the frame data.
  141838. */
  141839. frames: Array<ISpriteJSONSprite>;
  141840. /**
  141841. * object basic object containing the sprite meta data.
  141842. */
  141843. meta?: object;
  141844. }
  141845. }
  141846. declare module BABYLON {
  141847. /** @hidden */
  141848. export var spriteMapPixelShader: {
  141849. name: string;
  141850. shader: string;
  141851. };
  141852. }
  141853. declare module BABYLON {
  141854. /** @hidden */
  141855. export var spriteMapVertexShader: {
  141856. name: string;
  141857. shader: string;
  141858. };
  141859. }
  141860. declare module BABYLON {
  141861. /**
  141862. * Defines the basic options interface of a SpriteMap
  141863. */
  141864. export interface ISpriteMapOptions {
  141865. /**
  141866. * Vector2 of the number of cells in the grid.
  141867. */
  141868. stageSize?: Vector2;
  141869. /**
  141870. * Vector2 of the size of the output plane in World Units.
  141871. */
  141872. outputSize?: Vector2;
  141873. /**
  141874. * Vector3 of the position of the output plane in World Units.
  141875. */
  141876. outputPosition?: Vector3;
  141877. /**
  141878. * Vector3 of the rotation of the output plane.
  141879. */
  141880. outputRotation?: Vector3;
  141881. /**
  141882. * number of layers that the system will reserve in resources.
  141883. */
  141884. layerCount?: number;
  141885. /**
  141886. * number of max animation frames a single cell will reserve in resources.
  141887. */
  141888. maxAnimationFrames?: number;
  141889. /**
  141890. * number cell index of the base tile when the system compiles.
  141891. */
  141892. baseTile?: number;
  141893. /**
  141894. * boolean flip the sprite after its been repositioned by the framing data.
  141895. */
  141896. flipU?: boolean;
  141897. /**
  141898. * Vector3 scalar of the global RGB values of the SpriteMap.
  141899. */
  141900. colorMultiply?: Vector3;
  141901. }
  141902. /**
  141903. * Defines the IDisposable interface in order to be cleanable from resources.
  141904. */
  141905. export interface ISpriteMap extends IDisposable {
  141906. /**
  141907. * String name of the SpriteMap.
  141908. */
  141909. name: string;
  141910. /**
  141911. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  141912. */
  141913. atlasJSON: ISpriteJSONAtlas;
  141914. /**
  141915. * Texture of the SpriteMap.
  141916. */
  141917. spriteSheet: Texture;
  141918. /**
  141919. * The parameters to initialize the SpriteMap with.
  141920. */
  141921. options: ISpriteMapOptions;
  141922. }
  141923. /**
  141924. * Class used to manage a grid restricted sprite deployment on an Output plane.
  141925. */
  141926. export class SpriteMap implements ISpriteMap {
  141927. /** The Name of the spriteMap */
  141928. name: string;
  141929. /** The JSON file with the frame and meta data */
  141930. atlasJSON: ISpriteJSONAtlas;
  141931. /** The systems Sprite Sheet Texture */
  141932. spriteSheet: Texture;
  141933. /** Arguments passed with the Constructor */
  141934. options: ISpriteMapOptions;
  141935. /** Public Sprite Storage array, parsed from atlasJSON */
  141936. sprites: Array<ISpriteJSONSprite>;
  141937. /** Returns the Number of Sprites in the System */
  141938. get spriteCount(): number;
  141939. /** Returns the Position of Output Plane*/
  141940. get position(): Vector3;
  141941. /** Returns the Position of Output Plane*/
  141942. set position(v: Vector3);
  141943. /** Returns the Rotation of Output Plane*/
  141944. get rotation(): Vector3;
  141945. /** Returns the Rotation of Output Plane*/
  141946. set rotation(v: Vector3);
  141947. /** Sets the AnimationMap*/
  141948. get animationMap(): RawTexture;
  141949. /** Sets the AnimationMap*/
  141950. set animationMap(v: RawTexture);
  141951. /** Scene that the SpriteMap was created in */
  141952. private _scene;
  141953. /** Texture Buffer of Float32 that holds tile frame data*/
  141954. private _frameMap;
  141955. /** Texture Buffers of Float32 that holds tileMap data*/
  141956. private _tileMaps;
  141957. /** Texture Buffer of Float32 that holds Animation Data*/
  141958. private _animationMap;
  141959. /** Custom ShaderMaterial Central to the System*/
  141960. private _material;
  141961. /** Custom ShaderMaterial Central to the System*/
  141962. private _output;
  141963. /** Systems Time Ticker*/
  141964. private _time;
  141965. /**
  141966. * Creates a new SpriteMap
  141967. * @param name defines the SpriteMaps Name
  141968. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  141969. * @param spriteSheet is the Texture that the Sprites are on.
  141970. * @param options a basic deployment configuration
  141971. * @param scene The Scene that the map is deployed on
  141972. */
  141973. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  141974. /**
  141975. * Returns tileID location
  141976. * @returns Vector2 the cell position ID
  141977. */
  141978. getTileID(): Vector2;
  141979. /**
  141980. * Gets the UV location of the mouse over the SpriteMap.
  141981. * @returns Vector2 the UV position of the mouse interaction
  141982. */
  141983. getMousePosition(): Vector2;
  141984. /**
  141985. * Creates the "frame" texture Buffer
  141986. * -------------------------------------
  141987. * Structure of frames
  141988. * "filename": "Falling-Water-2.png",
  141989. * "frame": {"x":69,"y":103,"w":24,"h":32},
  141990. * "rotated": true,
  141991. * "trimmed": true,
  141992. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  141993. * "sourceSize": {"w":32,"h":32}
  141994. * @returns RawTexture of the frameMap
  141995. */
  141996. private _createFrameBuffer;
  141997. /**
  141998. * Creates the tileMap texture Buffer
  141999. * @param buffer normally and array of numbers, or a false to generate from scratch
  142000. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  142001. * @returns RawTexture of the tileMap
  142002. */
  142003. private _createTileBuffer;
  142004. /**
  142005. * Modifies the data of the tileMaps
  142006. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  142007. * @param pos is the iVector2 Coordinates of the Tile
  142008. * @param tile The SpriteIndex of the new Tile
  142009. */
  142010. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  142011. /**
  142012. * Creates the animationMap texture Buffer
  142013. * @param buffer normally and array of numbers, or a false to generate from scratch
  142014. * @returns RawTexture of the animationMap
  142015. */
  142016. private _createTileAnimationBuffer;
  142017. /**
  142018. * Modifies the data of the animationMap
  142019. * @param cellID is the Index of the Sprite
  142020. * @param _frame is the target Animation frame
  142021. * @param toCell is the Target Index of the next frame of the animation
  142022. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  142023. * @param speed is a global scalar of the time variable on the map.
  142024. */
  142025. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  142026. /**
  142027. * Exports the .tilemaps file
  142028. */
  142029. saveTileMaps(): void;
  142030. /**
  142031. * Imports the .tilemaps file
  142032. * @param url of the .tilemaps file
  142033. */
  142034. loadTileMaps(url: string): void;
  142035. /**
  142036. * Release associated resources
  142037. */
  142038. dispose(): void;
  142039. }
  142040. }
  142041. declare module BABYLON {
  142042. /**
  142043. * Class used to manage multiple sprites of different sizes on the same spritesheet
  142044. * @see http://doc.babylonjs.com/babylon101/sprites
  142045. */
  142046. export class SpritePackedManager extends SpriteManager {
  142047. /** defines the packed manager's name */
  142048. name: string;
  142049. /**
  142050. * Creates a new sprite manager from a packed sprite sheet
  142051. * @param name defines the manager's name
  142052. * @param imgUrl defines the sprite sheet url
  142053. * @param capacity defines the maximum allowed number of sprites
  142054. * @param scene defines the hosting scene
  142055. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  142056. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  142057. * @param samplingMode defines the smapling mode to use with spritesheet
  142058. * @param fromPacked set to true; do not alter
  142059. */
  142060. constructor(
  142061. /** defines the packed manager's name */
  142062. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  142063. }
  142064. }
  142065. declare module BABYLON {
  142066. /**
  142067. * Defines the list of states available for a task inside a AssetsManager
  142068. */
  142069. export enum AssetTaskState {
  142070. /**
  142071. * Initialization
  142072. */
  142073. INIT = 0,
  142074. /**
  142075. * Running
  142076. */
  142077. RUNNING = 1,
  142078. /**
  142079. * Done
  142080. */
  142081. DONE = 2,
  142082. /**
  142083. * Error
  142084. */
  142085. ERROR = 3
  142086. }
  142087. /**
  142088. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  142089. */
  142090. export abstract class AbstractAssetTask {
  142091. /**
  142092. * Task name
  142093. */ name: string;
  142094. /**
  142095. * Callback called when the task is successful
  142096. */
  142097. onSuccess: (task: any) => void;
  142098. /**
  142099. * Callback called when the task is not successful
  142100. */
  142101. onError: (task: any, message?: string, exception?: any) => void;
  142102. /**
  142103. * Creates a new AssetsManager
  142104. * @param name defines the name of the task
  142105. */
  142106. constructor(
  142107. /**
  142108. * Task name
  142109. */ name: string);
  142110. private _isCompleted;
  142111. private _taskState;
  142112. private _errorObject;
  142113. /**
  142114. * Get if the task is completed
  142115. */
  142116. get isCompleted(): boolean;
  142117. /**
  142118. * Gets the current state of the task
  142119. */
  142120. get taskState(): AssetTaskState;
  142121. /**
  142122. * Gets the current error object (if task is in error)
  142123. */
  142124. get errorObject(): {
  142125. message?: string;
  142126. exception?: any;
  142127. };
  142128. /**
  142129. * Internal only
  142130. * @hidden
  142131. */
  142132. _setErrorObject(message?: string, exception?: any): void;
  142133. /**
  142134. * Execute the current task
  142135. * @param scene defines the scene where you want your assets to be loaded
  142136. * @param onSuccess is a callback called when the task is successfully executed
  142137. * @param onError is a callback called if an error occurs
  142138. */
  142139. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142140. /**
  142141. * Execute the current task
  142142. * @param scene defines the scene where you want your assets to be loaded
  142143. * @param onSuccess is a callback called when the task is successfully executed
  142144. * @param onError is a callback called if an error occurs
  142145. */
  142146. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142147. /**
  142148. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  142149. * This can be used with failed tasks that have the reason for failure fixed.
  142150. */
  142151. reset(): void;
  142152. private onErrorCallback;
  142153. private onDoneCallback;
  142154. }
  142155. /**
  142156. * Define the interface used by progress events raised during assets loading
  142157. */
  142158. export interface IAssetsProgressEvent {
  142159. /**
  142160. * Defines the number of remaining tasks to process
  142161. */
  142162. remainingCount: number;
  142163. /**
  142164. * Defines the total number of tasks
  142165. */
  142166. totalCount: number;
  142167. /**
  142168. * Defines the task that was just processed
  142169. */
  142170. task: AbstractAssetTask;
  142171. }
  142172. /**
  142173. * Class used to share progress information about assets loading
  142174. */
  142175. export class AssetsProgressEvent implements IAssetsProgressEvent {
  142176. /**
  142177. * Defines the number of remaining tasks to process
  142178. */
  142179. remainingCount: number;
  142180. /**
  142181. * Defines the total number of tasks
  142182. */
  142183. totalCount: number;
  142184. /**
  142185. * Defines the task that was just processed
  142186. */
  142187. task: AbstractAssetTask;
  142188. /**
  142189. * Creates a AssetsProgressEvent
  142190. * @param remainingCount defines the number of remaining tasks to process
  142191. * @param totalCount defines the total number of tasks
  142192. * @param task defines the task that was just processed
  142193. */
  142194. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  142195. }
  142196. /**
  142197. * Define a task used by AssetsManager to load meshes
  142198. */
  142199. export class MeshAssetTask extends AbstractAssetTask {
  142200. /**
  142201. * Defines the name of the task
  142202. */
  142203. name: string;
  142204. /**
  142205. * Defines the list of mesh's names you want to load
  142206. */
  142207. meshesNames: any;
  142208. /**
  142209. * Defines the root url to use as a base to load your meshes and associated resources
  142210. */
  142211. rootUrl: string;
  142212. /**
  142213. * Defines the filename of the scene to load from
  142214. */
  142215. sceneFilename: string;
  142216. /**
  142217. * Gets the list of loaded meshes
  142218. */
  142219. loadedMeshes: Array<AbstractMesh>;
  142220. /**
  142221. * Gets the list of loaded particle systems
  142222. */
  142223. loadedParticleSystems: Array<IParticleSystem>;
  142224. /**
  142225. * Gets the list of loaded skeletons
  142226. */
  142227. loadedSkeletons: Array<Skeleton>;
  142228. /**
  142229. * Gets the list of loaded animation groups
  142230. */
  142231. loadedAnimationGroups: Array<AnimationGroup>;
  142232. /**
  142233. * Callback called when the task is successful
  142234. */
  142235. onSuccess: (task: MeshAssetTask) => void;
  142236. /**
  142237. * Callback called when the task is successful
  142238. */
  142239. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  142240. /**
  142241. * Creates a new MeshAssetTask
  142242. * @param name defines the name of the task
  142243. * @param meshesNames defines the list of mesh's names you want to load
  142244. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  142245. * @param sceneFilename defines the filename of the scene to load from
  142246. */
  142247. constructor(
  142248. /**
  142249. * Defines the name of the task
  142250. */
  142251. name: string,
  142252. /**
  142253. * Defines the list of mesh's names you want to load
  142254. */
  142255. meshesNames: any,
  142256. /**
  142257. * Defines the root url to use as a base to load your meshes and associated resources
  142258. */
  142259. rootUrl: string,
  142260. /**
  142261. * Defines the filename of the scene to load from
  142262. */
  142263. sceneFilename: string);
  142264. /**
  142265. * Execute the current task
  142266. * @param scene defines the scene where you want your assets to be loaded
  142267. * @param onSuccess is a callback called when the task is successfully executed
  142268. * @param onError is a callback called if an error occurs
  142269. */
  142270. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142271. }
  142272. /**
  142273. * Define a task used by AssetsManager to load text content
  142274. */
  142275. export class TextFileAssetTask extends AbstractAssetTask {
  142276. /**
  142277. * Defines the name of the task
  142278. */
  142279. name: string;
  142280. /**
  142281. * Defines the location of the file to load
  142282. */
  142283. url: string;
  142284. /**
  142285. * Gets the loaded text string
  142286. */
  142287. text: string;
  142288. /**
  142289. * Callback called when the task is successful
  142290. */
  142291. onSuccess: (task: TextFileAssetTask) => void;
  142292. /**
  142293. * Callback called when the task is successful
  142294. */
  142295. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  142296. /**
  142297. * Creates a new TextFileAssetTask object
  142298. * @param name defines the name of the task
  142299. * @param url defines the location of the file to load
  142300. */
  142301. constructor(
  142302. /**
  142303. * Defines the name of the task
  142304. */
  142305. name: string,
  142306. /**
  142307. * Defines the location of the file to load
  142308. */
  142309. url: string);
  142310. /**
  142311. * Execute the current task
  142312. * @param scene defines the scene where you want your assets to be loaded
  142313. * @param onSuccess is a callback called when the task is successfully executed
  142314. * @param onError is a callback called if an error occurs
  142315. */
  142316. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142317. }
  142318. /**
  142319. * Define a task used by AssetsManager to load binary data
  142320. */
  142321. export class BinaryFileAssetTask extends AbstractAssetTask {
  142322. /**
  142323. * Defines the name of the task
  142324. */
  142325. name: string;
  142326. /**
  142327. * Defines the location of the file to load
  142328. */
  142329. url: string;
  142330. /**
  142331. * Gets the lodaded data (as an array buffer)
  142332. */
  142333. data: ArrayBuffer;
  142334. /**
  142335. * Callback called when the task is successful
  142336. */
  142337. onSuccess: (task: BinaryFileAssetTask) => void;
  142338. /**
  142339. * Callback called when the task is successful
  142340. */
  142341. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  142342. /**
  142343. * Creates a new BinaryFileAssetTask object
  142344. * @param name defines the name of the new task
  142345. * @param url defines the location of the file to load
  142346. */
  142347. constructor(
  142348. /**
  142349. * Defines the name of the task
  142350. */
  142351. name: string,
  142352. /**
  142353. * Defines the location of the file to load
  142354. */
  142355. url: string);
  142356. /**
  142357. * Execute the current task
  142358. * @param scene defines the scene where you want your assets to be loaded
  142359. * @param onSuccess is a callback called when the task is successfully executed
  142360. * @param onError is a callback called if an error occurs
  142361. */
  142362. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142363. }
  142364. /**
  142365. * Define a task used by AssetsManager to load images
  142366. */
  142367. export class ImageAssetTask extends AbstractAssetTask {
  142368. /**
  142369. * Defines the name of the task
  142370. */
  142371. name: string;
  142372. /**
  142373. * Defines the location of the image to load
  142374. */
  142375. url: string;
  142376. /**
  142377. * Gets the loaded images
  142378. */
  142379. image: HTMLImageElement;
  142380. /**
  142381. * Callback called when the task is successful
  142382. */
  142383. onSuccess: (task: ImageAssetTask) => void;
  142384. /**
  142385. * Callback called when the task is successful
  142386. */
  142387. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  142388. /**
  142389. * Creates a new ImageAssetTask
  142390. * @param name defines the name of the task
  142391. * @param url defines the location of the image to load
  142392. */
  142393. constructor(
  142394. /**
  142395. * Defines the name of the task
  142396. */
  142397. name: string,
  142398. /**
  142399. * Defines the location of the image to load
  142400. */
  142401. url: string);
  142402. /**
  142403. * Execute the current task
  142404. * @param scene defines the scene where you want your assets to be loaded
  142405. * @param onSuccess is a callback called when the task is successfully executed
  142406. * @param onError is a callback called if an error occurs
  142407. */
  142408. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142409. }
  142410. /**
  142411. * Defines the interface used by texture loading tasks
  142412. */
  142413. export interface ITextureAssetTask<TEX extends BaseTexture> {
  142414. /**
  142415. * Gets the loaded texture
  142416. */
  142417. texture: TEX;
  142418. }
  142419. /**
  142420. * Define a task used by AssetsManager to load 2D textures
  142421. */
  142422. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  142423. /**
  142424. * Defines the name of the task
  142425. */
  142426. name: string;
  142427. /**
  142428. * Defines the location of the file to load
  142429. */
  142430. url: string;
  142431. /**
  142432. * Defines if mipmap should not be generated (default is false)
  142433. */
  142434. noMipmap?: boolean | undefined;
  142435. /**
  142436. * Defines if texture must be inverted on Y axis (default is true)
  142437. */
  142438. invertY: boolean;
  142439. /**
  142440. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142441. */
  142442. samplingMode: number;
  142443. /**
  142444. * Gets the loaded texture
  142445. */
  142446. texture: Texture;
  142447. /**
  142448. * Callback called when the task is successful
  142449. */
  142450. onSuccess: (task: TextureAssetTask) => void;
  142451. /**
  142452. * Callback called when the task is successful
  142453. */
  142454. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  142455. /**
  142456. * Creates a new TextureAssetTask object
  142457. * @param name defines the name of the task
  142458. * @param url defines the location of the file to load
  142459. * @param noMipmap defines if mipmap should not be generated (default is false)
  142460. * @param invertY defines if texture must be inverted on Y axis (default is true)
  142461. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142462. */
  142463. constructor(
  142464. /**
  142465. * Defines the name of the task
  142466. */
  142467. name: string,
  142468. /**
  142469. * Defines the location of the file to load
  142470. */
  142471. url: string,
  142472. /**
  142473. * Defines if mipmap should not be generated (default is false)
  142474. */
  142475. noMipmap?: boolean | undefined,
  142476. /**
  142477. * Defines if texture must be inverted on Y axis (default is true)
  142478. */
  142479. invertY?: boolean,
  142480. /**
  142481. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  142482. */
  142483. samplingMode?: number);
  142484. /**
  142485. * Execute the current task
  142486. * @param scene defines the scene where you want your assets to be loaded
  142487. * @param onSuccess is a callback called when the task is successfully executed
  142488. * @param onError is a callback called if an error occurs
  142489. */
  142490. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142491. }
  142492. /**
  142493. * Define a task used by AssetsManager to load cube textures
  142494. */
  142495. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  142496. /**
  142497. * Defines the name of the task
  142498. */
  142499. name: string;
  142500. /**
  142501. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142502. */
  142503. url: string;
  142504. /**
  142505. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142506. */
  142507. extensions?: string[] | undefined;
  142508. /**
  142509. * Defines if mipmaps should not be generated (default is false)
  142510. */
  142511. noMipmap?: boolean | undefined;
  142512. /**
  142513. * Defines the explicit list of files (undefined by default)
  142514. */
  142515. files?: string[] | undefined;
  142516. /**
  142517. * Gets the loaded texture
  142518. */
  142519. texture: CubeTexture;
  142520. /**
  142521. * Callback called when the task is successful
  142522. */
  142523. onSuccess: (task: CubeTextureAssetTask) => void;
  142524. /**
  142525. * Callback called when the task is successful
  142526. */
  142527. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  142528. /**
  142529. * Creates a new CubeTextureAssetTask
  142530. * @param name defines the name of the task
  142531. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142532. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142533. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142534. * @param files defines the explicit list of files (undefined by default)
  142535. */
  142536. constructor(
  142537. /**
  142538. * Defines the name of the task
  142539. */
  142540. name: string,
  142541. /**
  142542. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  142543. */
  142544. url: string,
  142545. /**
  142546. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  142547. */
  142548. extensions?: string[] | undefined,
  142549. /**
  142550. * Defines if mipmaps should not be generated (default is false)
  142551. */
  142552. noMipmap?: boolean | undefined,
  142553. /**
  142554. * Defines the explicit list of files (undefined by default)
  142555. */
  142556. files?: string[] | undefined);
  142557. /**
  142558. * Execute the current task
  142559. * @param scene defines the scene where you want your assets to be loaded
  142560. * @param onSuccess is a callback called when the task is successfully executed
  142561. * @param onError is a callback called if an error occurs
  142562. */
  142563. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142564. }
  142565. /**
  142566. * Define a task used by AssetsManager to load HDR cube textures
  142567. */
  142568. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  142569. /**
  142570. * Defines the name of the task
  142571. */
  142572. name: string;
  142573. /**
  142574. * Defines the location of the file to load
  142575. */
  142576. url: string;
  142577. /**
  142578. * Defines the desired size (the more it increases the longer the generation will be)
  142579. */
  142580. size: number;
  142581. /**
  142582. * Defines if mipmaps should not be generated (default is false)
  142583. */
  142584. noMipmap: boolean;
  142585. /**
  142586. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142587. */
  142588. generateHarmonics: boolean;
  142589. /**
  142590. * 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)
  142591. */
  142592. gammaSpace: boolean;
  142593. /**
  142594. * Internal Use Only
  142595. */
  142596. reserved: boolean;
  142597. /**
  142598. * Gets the loaded texture
  142599. */
  142600. texture: HDRCubeTexture;
  142601. /**
  142602. * Callback called when the task is successful
  142603. */
  142604. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  142605. /**
  142606. * Callback called when the task is successful
  142607. */
  142608. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  142609. /**
  142610. * Creates a new HDRCubeTextureAssetTask object
  142611. * @param name defines the name of the task
  142612. * @param url defines the location of the file to load
  142613. * @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.
  142614. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142615. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142616. * @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)
  142617. * @param reserved Internal use only
  142618. */
  142619. constructor(
  142620. /**
  142621. * Defines the name of the task
  142622. */
  142623. name: string,
  142624. /**
  142625. * Defines the location of the file to load
  142626. */
  142627. url: string,
  142628. /**
  142629. * Defines the desired size (the more it increases the longer the generation will be)
  142630. */
  142631. size: number,
  142632. /**
  142633. * Defines if mipmaps should not be generated (default is false)
  142634. */
  142635. noMipmap?: boolean,
  142636. /**
  142637. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  142638. */
  142639. generateHarmonics?: boolean,
  142640. /**
  142641. * 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)
  142642. */
  142643. gammaSpace?: boolean,
  142644. /**
  142645. * Internal Use Only
  142646. */
  142647. reserved?: boolean);
  142648. /**
  142649. * Execute the current task
  142650. * @param scene defines the scene where you want your assets to be loaded
  142651. * @param onSuccess is a callback called when the task is successfully executed
  142652. * @param onError is a callback called if an error occurs
  142653. */
  142654. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142655. }
  142656. /**
  142657. * Define a task used by AssetsManager to load Equirectangular cube textures
  142658. */
  142659. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  142660. /**
  142661. * Defines the name of the task
  142662. */
  142663. name: string;
  142664. /**
  142665. * Defines the location of the file to load
  142666. */
  142667. url: string;
  142668. /**
  142669. * Defines the desired size (the more it increases the longer the generation will be)
  142670. */
  142671. size: number;
  142672. /**
  142673. * Defines if mipmaps should not be generated (default is false)
  142674. */
  142675. noMipmap: boolean;
  142676. /**
  142677. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142678. * but the standard material would require them in Gamma space) (default is true)
  142679. */
  142680. gammaSpace: boolean;
  142681. /**
  142682. * Gets the loaded texture
  142683. */
  142684. texture: EquiRectangularCubeTexture;
  142685. /**
  142686. * Callback called when the task is successful
  142687. */
  142688. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  142689. /**
  142690. * Callback called when the task is successful
  142691. */
  142692. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  142693. /**
  142694. * Creates a new EquiRectangularCubeTextureAssetTask object
  142695. * @param name defines the name of the task
  142696. * @param url defines the location of the file to load
  142697. * @param size defines the desired size (the more it increases the longer the generation will be)
  142698. * If the size is omitted this implies you are using a preprocessed cubemap.
  142699. * @param noMipmap defines if mipmaps should not be generated (default is false)
  142700. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  142701. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  142702. * (default is true)
  142703. */
  142704. constructor(
  142705. /**
  142706. * Defines the name of the task
  142707. */
  142708. name: string,
  142709. /**
  142710. * Defines the location of the file to load
  142711. */
  142712. url: string,
  142713. /**
  142714. * Defines the desired size (the more it increases the longer the generation will be)
  142715. */
  142716. size: number,
  142717. /**
  142718. * Defines if mipmaps should not be generated (default is false)
  142719. */
  142720. noMipmap?: boolean,
  142721. /**
  142722. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  142723. * but the standard material would require them in Gamma space) (default is true)
  142724. */
  142725. gammaSpace?: boolean);
  142726. /**
  142727. * Execute the current task
  142728. * @param scene defines the scene where you want your assets to be loaded
  142729. * @param onSuccess is a callback called when the task is successfully executed
  142730. * @param onError is a callback called if an error occurs
  142731. */
  142732. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  142733. }
  142734. /**
  142735. * This class can be used to easily import assets into a scene
  142736. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  142737. */
  142738. export class AssetsManager {
  142739. private _scene;
  142740. private _isLoading;
  142741. protected _tasks: AbstractAssetTask[];
  142742. protected _waitingTasksCount: number;
  142743. protected _totalTasksCount: number;
  142744. /**
  142745. * Callback called when all tasks are processed
  142746. */
  142747. onFinish: (tasks: AbstractAssetTask[]) => void;
  142748. /**
  142749. * Callback called when a task is successful
  142750. */
  142751. onTaskSuccess: (task: AbstractAssetTask) => void;
  142752. /**
  142753. * Callback called when a task had an error
  142754. */
  142755. onTaskError: (task: AbstractAssetTask) => void;
  142756. /**
  142757. * Callback called when a task is done (whatever the result is)
  142758. */
  142759. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  142760. /**
  142761. * Observable called when all tasks are processed
  142762. */
  142763. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  142764. /**
  142765. * Observable called when a task had an error
  142766. */
  142767. onTaskErrorObservable: Observable<AbstractAssetTask>;
  142768. /**
  142769. * Observable called when all tasks were executed
  142770. */
  142771. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  142772. /**
  142773. * Observable called when a task is done (whatever the result is)
  142774. */
  142775. onProgressObservable: Observable<IAssetsProgressEvent>;
  142776. /**
  142777. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  142778. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  142779. */
  142780. useDefaultLoadingScreen: boolean;
  142781. /**
  142782. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  142783. * when all assets have been downloaded.
  142784. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  142785. */
  142786. autoHideLoadingUI: boolean;
  142787. /**
  142788. * Creates a new AssetsManager
  142789. * @param scene defines the scene to work on
  142790. */
  142791. constructor(scene: Scene);
  142792. /**
  142793. * Add a MeshAssetTask to the list of active tasks
  142794. * @param taskName defines the name of the new task
  142795. * @param meshesNames defines the name of meshes to load
  142796. * @param rootUrl defines the root url to use to locate files
  142797. * @param sceneFilename defines the filename of the scene file
  142798. * @returns a new MeshAssetTask object
  142799. */
  142800. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  142801. /**
  142802. * Add a TextFileAssetTask to the list of active tasks
  142803. * @param taskName defines the name of the new task
  142804. * @param url defines the url of the file to load
  142805. * @returns a new TextFileAssetTask object
  142806. */
  142807. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  142808. /**
  142809. * Add a BinaryFileAssetTask to the list of active tasks
  142810. * @param taskName defines the name of the new task
  142811. * @param url defines the url of the file to load
  142812. * @returns a new BinaryFileAssetTask object
  142813. */
  142814. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  142815. /**
  142816. * Add a ImageAssetTask to the list of active tasks
  142817. * @param taskName defines the name of the new task
  142818. * @param url defines the url of the file to load
  142819. * @returns a new ImageAssetTask object
  142820. */
  142821. addImageTask(taskName: string, url: string): ImageAssetTask;
  142822. /**
  142823. * Add a TextureAssetTask to the list of active tasks
  142824. * @param taskName defines the name of the new task
  142825. * @param url defines the url of the file to load
  142826. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142827. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  142828. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  142829. * @returns a new TextureAssetTask object
  142830. */
  142831. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  142832. /**
  142833. * Add a CubeTextureAssetTask to the list of active tasks
  142834. * @param taskName defines the name of the new task
  142835. * @param url defines the url of the file to load
  142836. * @param extensions defines the extension to use to load the cube map (can be null)
  142837. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142838. * @param files defines the list of files to load (can be null)
  142839. * @returns a new CubeTextureAssetTask object
  142840. */
  142841. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  142842. /**
  142843. *
  142844. * Add a HDRCubeTextureAssetTask to the list of active tasks
  142845. * @param taskName defines the name of the new task
  142846. * @param url defines the url of the file to load
  142847. * @param size defines the size you want for the cubemap (can be null)
  142848. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142849. * @param generateHarmonics defines if you want to automatically generate (true by default)
  142850. * @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)
  142851. * @param reserved Internal use only
  142852. * @returns a new HDRCubeTextureAssetTask object
  142853. */
  142854. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  142855. /**
  142856. *
  142857. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  142858. * @param taskName defines the name of the new task
  142859. * @param url defines the url of the file to load
  142860. * @param size defines the size you want for the cubemap (can be null)
  142861. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  142862. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142863. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142864. * @returns a new EquiRectangularCubeTextureAssetTask object
  142865. */
  142866. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  142867. /**
  142868. * Remove a task from the assets manager.
  142869. * @param task the task to remove
  142870. */
  142871. removeTask(task: AbstractAssetTask): void;
  142872. private _decreaseWaitingTasksCount;
  142873. private _runTask;
  142874. /**
  142875. * Reset the AssetsManager and remove all tasks
  142876. * @return the current instance of the AssetsManager
  142877. */
  142878. reset(): AssetsManager;
  142879. /**
  142880. * Start the loading process
  142881. * @return the current instance of the AssetsManager
  142882. */
  142883. load(): AssetsManager;
  142884. /**
  142885. * Start the loading process as an async operation
  142886. * @return a promise returning the list of failed tasks
  142887. */
  142888. loadAsync(): Promise<void>;
  142889. }
  142890. }
  142891. declare module BABYLON {
  142892. /**
  142893. * Wrapper class for promise with external resolve and reject.
  142894. */
  142895. export class Deferred<T> {
  142896. /**
  142897. * The promise associated with this deferred object.
  142898. */
  142899. readonly promise: Promise<T>;
  142900. private _resolve;
  142901. private _reject;
  142902. /**
  142903. * The resolve method of the promise associated with this deferred object.
  142904. */
  142905. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  142906. /**
  142907. * The reject method of the promise associated with this deferred object.
  142908. */
  142909. get reject(): (reason?: any) => void;
  142910. /**
  142911. * Constructor for this deferred object.
  142912. */
  142913. constructor();
  142914. }
  142915. }
  142916. declare module BABYLON {
  142917. /**
  142918. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  142919. */
  142920. export class MeshExploder {
  142921. private _centerMesh;
  142922. private _meshes;
  142923. private _meshesOrigins;
  142924. private _toCenterVectors;
  142925. private _scaledDirection;
  142926. private _newPosition;
  142927. private _centerPosition;
  142928. /**
  142929. * Explodes meshes from a center mesh.
  142930. * @param meshes The meshes to explode.
  142931. * @param centerMesh The mesh to be center of explosion.
  142932. */
  142933. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  142934. private _setCenterMesh;
  142935. /**
  142936. * Get class name
  142937. * @returns "MeshExploder"
  142938. */
  142939. getClassName(): string;
  142940. /**
  142941. * "Exploded meshes"
  142942. * @returns Array of meshes with the centerMesh at index 0.
  142943. */
  142944. getMeshes(): Array<Mesh>;
  142945. /**
  142946. * Explodes meshes giving a specific direction
  142947. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  142948. */
  142949. explode(direction?: number): void;
  142950. }
  142951. }
  142952. declare module BABYLON {
  142953. /**
  142954. * Class used to help managing file picking and drag'n'drop
  142955. */
  142956. export class FilesInput {
  142957. /**
  142958. * List of files ready to be loaded
  142959. */
  142960. static get FilesToLoad(): {
  142961. [key: string]: File;
  142962. };
  142963. /**
  142964. * Callback called when a file is processed
  142965. */
  142966. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  142967. private _engine;
  142968. private _currentScene;
  142969. private _sceneLoadedCallback;
  142970. private _progressCallback;
  142971. private _additionalRenderLoopLogicCallback;
  142972. private _textureLoadingCallback;
  142973. private _startingProcessingFilesCallback;
  142974. private _onReloadCallback;
  142975. private _errorCallback;
  142976. private _elementToMonitor;
  142977. private _sceneFileToLoad;
  142978. private _filesToLoad;
  142979. /**
  142980. * Creates a new FilesInput
  142981. * @param engine defines the rendering engine
  142982. * @param scene defines the hosting scene
  142983. * @param sceneLoadedCallback callback called when scene is loaded
  142984. * @param progressCallback callback called to track progress
  142985. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  142986. * @param textureLoadingCallback callback called when a texture is loading
  142987. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  142988. * @param onReloadCallback callback called when a reload is requested
  142989. * @param errorCallback callback call if an error occurs
  142990. */
  142991. 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);
  142992. private _dragEnterHandler;
  142993. private _dragOverHandler;
  142994. private _dropHandler;
  142995. /**
  142996. * Calls this function to listen to drag'n'drop events on a specific DOM element
  142997. * @param elementToMonitor defines the DOM element to track
  142998. */
  142999. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  143000. /**
  143001. * Release all associated resources
  143002. */
  143003. dispose(): void;
  143004. private renderFunction;
  143005. private drag;
  143006. private drop;
  143007. private _traverseFolder;
  143008. private _processFiles;
  143009. /**
  143010. * Load files from a drop event
  143011. * @param event defines the drop event to use as source
  143012. */
  143013. loadFiles(event: any): void;
  143014. private _processReload;
  143015. /**
  143016. * Reload the current scene from the loaded files
  143017. */
  143018. reload(): void;
  143019. }
  143020. }
  143021. declare module BABYLON {
  143022. /**
  143023. * Defines the root class used to create scene optimization to use with SceneOptimizer
  143024. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143025. */
  143026. export class SceneOptimization {
  143027. /**
  143028. * Defines the priority of this optimization (0 by default which means first in the list)
  143029. */
  143030. priority: number;
  143031. /**
  143032. * Gets a string describing the action executed by the current optimization
  143033. * @returns description string
  143034. */
  143035. getDescription(): string;
  143036. /**
  143037. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143038. * @param scene defines the current scene where to apply this optimization
  143039. * @param optimizer defines the current optimizer
  143040. * @returns true if everything that can be done was applied
  143041. */
  143042. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143043. /**
  143044. * Creates the SceneOptimization object
  143045. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143046. * @param desc defines the description associated with the optimization
  143047. */
  143048. constructor(
  143049. /**
  143050. * Defines the priority of this optimization (0 by default which means first in the list)
  143051. */
  143052. priority?: number);
  143053. }
  143054. /**
  143055. * Defines an optimization used to reduce the size of render target textures
  143056. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143057. */
  143058. export class TextureOptimization extends SceneOptimization {
  143059. /**
  143060. * Defines the priority of this optimization (0 by default which means first in the list)
  143061. */
  143062. priority: number;
  143063. /**
  143064. * 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
  143065. */
  143066. maximumSize: number;
  143067. /**
  143068. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143069. */
  143070. step: number;
  143071. /**
  143072. * Gets a string describing the action executed by the current optimization
  143073. * @returns description string
  143074. */
  143075. getDescription(): string;
  143076. /**
  143077. * Creates the TextureOptimization object
  143078. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143079. * @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
  143080. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143081. */
  143082. constructor(
  143083. /**
  143084. * Defines the priority of this optimization (0 by default which means first in the list)
  143085. */
  143086. priority?: number,
  143087. /**
  143088. * 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
  143089. */
  143090. maximumSize?: number,
  143091. /**
  143092. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  143093. */
  143094. step?: number);
  143095. /**
  143096. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143097. * @param scene defines the current scene where to apply this optimization
  143098. * @param optimizer defines the current optimizer
  143099. * @returns true if everything that can be done was applied
  143100. */
  143101. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143102. }
  143103. /**
  143104. * Defines an optimization used to increase or decrease the rendering resolution
  143105. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143106. */
  143107. export class HardwareScalingOptimization extends SceneOptimization {
  143108. /**
  143109. * Defines the priority of this optimization (0 by default which means first in the list)
  143110. */
  143111. priority: number;
  143112. /**
  143113. * Defines the maximum scale to use (2 by default)
  143114. */
  143115. maximumScale: number;
  143116. /**
  143117. * Defines the step to use between two passes (0.5 by default)
  143118. */
  143119. step: number;
  143120. private _currentScale;
  143121. private _directionOffset;
  143122. /**
  143123. * Gets a string describing the action executed by the current optimization
  143124. * @return description string
  143125. */
  143126. getDescription(): string;
  143127. /**
  143128. * Creates the HardwareScalingOptimization object
  143129. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143130. * @param maximumScale defines the maximum scale to use (2 by default)
  143131. * @param step defines the step to use between two passes (0.5 by default)
  143132. */
  143133. constructor(
  143134. /**
  143135. * Defines the priority of this optimization (0 by default which means first in the list)
  143136. */
  143137. priority?: number,
  143138. /**
  143139. * Defines the maximum scale to use (2 by default)
  143140. */
  143141. maximumScale?: number,
  143142. /**
  143143. * Defines the step to use between two passes (0.5 by default)
  143144. */
  143145. step?: number);
  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 remove shadows
  143156. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143157. */
  143158. export class ShadowsOptimization 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 post-processes off
  143174. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143175. */
  143176. export class PostProcessesOptimization 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 used to turn lens flares off
  143192. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143193. */
  143194. export class LensFlaresOptimization extends SceneOptimization {
  143195. /**
  143196. * Gets a string describing the action executed by the current optimization
  143197. * @return description string
  143198. */
  143199. getDescription(): string;
  143200. /**
  143201. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143202. * @param scene defines the current scene where to apply this optimization
  143203. * @param optimizer defines the current optimizer
  143204. * @returns true if everything that can be done was applied
  143205. */
  143206. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143207. }
  143208. /**
  143209. * Defines an optimization based on user defined callback.
  143210. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143211. */
  143212. export class CustomOptimization extends SceneOptimization {
  143213. /**
  143214. * Callback called to apply the custom optimization.
  143215. */
  143216. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  143217. /**
  143218. * Callback called to get custom description
  143219. */
  143220. onGetDescription: () => string;
  143221. /**
  143222. * Gets a string describing the action executed by the current optimization
  143223. * @returns 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 particles off
  143236. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143237. */
  143238. export class ParticlesOptimization 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 turn render targets off
  143254. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143255. */
  143256. export class RenderTargetsOptimization extends SceneOptimization {
  143257. /**
  143258. * Gets a string describing the action executed by the current optimization
  143259. * @return description string
  143260. */
  143261. getDescription(): string;
  143262. /**
  143263. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143264. * @param scene defines the current scene where to apply this optimization
  143265. * @param optimizer defines the current optimizer
  143266. * @returns true if everything that can be done was applied
  143267. */
  143268. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  143269. }
  143270. /**
  143271. * Defines an optimization used to merge meshes with compatible materials
  143272. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143273. */
  143274. export class MergeMeshesOptimization extends SceneOptimization {
  143275. private static _UpdateSelectionTree;
  143276. /**
  143277. * Gets or sets a boolean which defines if optimization octree has to be updated
  143278. */
  143279. static get UpdateSelectionTree(): boolean;
  143280. /**
  143281. * Gets or sets a boolean which defines if optimization octree has to be updated
  143282. */
  143283. static set UpdateSelectionTree(value: boolean);
  143284. /**
  143285. * Gets a string describing the action executed by the current optimization
  143286. * @return description string
  143287. */
  143288. getDescription(): string;
  143289. private _canBeMerged;
  143290. /**
  143291. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  143292. * @param scene defines the current scene where to apply this optimization
  143293. * @param optimizer defines the current optimizer
  143294. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  143295. * @returns true if everything that can be done was applied
  143296. */
  143297. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  143298. }
  143299. /**
  143300. * Defines a list of options used by SceneOptimizer
  143301. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143302. */
  143303. export class SceneOptimizerOptions {
  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. * Gets the list of optimizations to apply
  143314. */
  143315. optimizations: SceneOptimization[];
  143316. /**
  143317. * Creates a new list of options used by SceneOptimizer
  143318. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  143319. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  143320. */
  143321. constructor(
  143322. /**
  143323. * Defines the target frame rate to reach (60 by default)
  143324. */
  143325. targetFrameRate?: number,
  143326. /**
  143327. * Defines the interval between two checkes (2000ms by default)
  143328. */
  143329. trackerDuration?: number);
  143330. /**
  143331. * Add a new optimization
  143332. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  143333. * @returns the current SceneOptimizerOptions
  143334. */
  143335. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  143336. /**
  143337. * Add a new custom optimization
  143338. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  143339. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  143340. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  143341. * @returns the current SceneOptimizerOptions
  143342. */
  143343. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  143344. /**
  143345. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  143346. * @param targetFrameRate defines the target frame rate (60 by default)
  143347. * @returns a SceneOptimizerOptions object
  143348. */
  143349. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143350. /**
  143351. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  143352. * @param targetFrameRate defines the target frame rate (60 by default)
  143353. * @returns a SceneOptimizerOptions object
  143354. */
  143355. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143356. /**
  143357. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  143358. * @param targetFrameRate defines the target frame rate (60 by default)
  143359. * @returns a SceneOptimizerOptions object
  143360. */
  143361. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  143362. }
  143363. /**
  143364. * Class used to run optimizations in order to reach a target frame rate
  143365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  143366. */
  143367. export class SceneOptimizer implements IDisposable {
  143368. private _isRunning;
  143369. private _options;
  143370. private _scene;
  143371. private _currentPriorityLevel;
  143372. private _targetFrameRate;
  143373. private _trackerDuration;
  143374. private _currentFrameRate;
  143375. private _sceneDisposeObserver;
  143376. private _improvementMode;
  143377. /**
  143378. * Defines an observable called when the optimizer reaches the target frame rate
  143379. */
  143380. onSuccessObservable: Observable<SceneOptimizer>;
  143381. /**
  143382. * Defines an observable called when the optimizer enables an optimization
  143383. */
  143384. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  143385. /**
  143386. * Defines an observable called when the optimizer is not able to reach the target frame rate
  143387. */
  143388. onFailureObservable: Observable<SceneOptimizer>;
  143389. /**
  143390. * Gets a boolean indicating if the optimizer is in improvement mode
  143391. */
  143392. get isInImprovementMode(): boolean;
  143393. /**
  143394. * Gets the current priority level (0 at start)
  143395. */
  143396. get currentPriorityLevel(): number;
  143397. /**
  143398. * Gets the current frame rate checked by the SceneOptimizer
  143399. */
  143400. get currentFrameRate(): number;
  143401. /**
  143402. * Gets or sets the current target frame rate (60 by default)
  143403. */
  143404. get targetFrameRate(): number;
  143405. /**
  143406. * Gets or sets the current target frame rate (60 by default)
  143407. */
  143408. set targetFrameRate(value: number);
  143409. /**
  143410. * Gets or sets the current interval between two checks (every 2000ms by default)
  143411. */
  143412. get trackerDuration(): number;
  143413. /**
  143414. * Gets or sets the current interval between two checks (every 2000ms by default)
  143415. */
  143416. set trackerDuration(value: number);
  143417. /**
  143418. * Gets the list of active optimizations
  143419. */
  143420. get optimizations(): SceneOptimization[];
  143421. /**
  143422. * Creates a new SceneOptimizer
  143423. * @param scene defines the scene to work on
  143424. * @param options defines the options to use with the SceneOptimizer
  143425. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  143426. * @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)
  143427. */
  143428. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  143429. /**
  143430. * Stops the current optimizer
  143431. */
  143432. stop(): void;
  143433. /**
  143434. * Reset the optimizer to initial step (current priority level = 0)
  143435. */
  143436. reset(): void;
  143437. /**
  143438. * Start the optimizer. By default it will try to reach a specific framerate
  143439. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  143440. */
  143441. start(): void;
  143442. private _checkCurrentState;
  143443. /**
  143444. * Release all resources
  143445. */
  143446. dispose(): void;
  143447. /**
  143448. * Helper function to create a SceneOptimizer with one single line of code
  143449. * @param scene defines the scene to work on
  143450. * @param options defines the options to use with the SceneOptimizer
  143451. * @param onSuccess defines a callback to call on success
  143452. * @param onFailure defines a callback to call on failure
  143453. * @returns the new SceneOptimizer object
  143454. */
  143455. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  143456. }
  143457. }
  143458. declare module BABYLON {
  143459. /**
  143460. * Class used to serialize a scene into a string
  143461. */
  143462. export class SceneSerializer {
  143463. /**
  143464. * Clear cache used by a previous serialization
  143465. */
  143466. static ClearCache(): void;
  143467. /**
  143468. * Serialize a scene into a JSON compatible object
  143469. * @param scene defines the scene to serialize
  143470. * @returns a JSON compatible object
  143471. */
  143472. static Serialize(scene: Scene): any;
  143473. /**
  143474. * Serialize a mesh into a JSON compatible object
  143475. * @param toSerialize defines the mesh to serialize
  143476. * @param withParents defines if parents must be serialized as well
  143477. * @param withChildren defines if children must be serialized as well
  143478. * @returns a JSON compatible object
  143479. */
  143480. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  143481. }
  143482. }
  143483. declare module BABYLON {
  143484. /**
  143485. * Class used to host texture specific utilities
  143486. */
  143487. export class TextureTools {
  143488. /**
  143489. * Uses the GPU to create a copy texture rescaled at a given size
  143490. * @param texture Texture to copy from
  143491. * @param width defines the desired width
  143492. * @param height defines the desired height
  143493. * @param useBilinearMode defines if bilinear mode has to be used
  143494. * @return the generated texture
  143495. */
  143496. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  143497. }
  143498. }
  143499. declare module BABYLON {
  143500. /**
  143501. * This represents the different options available for the video capture.
  143502. */
  143503. export interface VideoRecorderOptions {
  143504. /** Defines the mime type of the video. */
  143505. mimeType: string;
  143506. /** Defines the FPS the video should be recorded at. */
  143507. fps: number;
  143508. /** Defines the chunk size for the recording data. */
  143509. recordChunckSize: number;
  143510. /** The audio tracks to attach to the recording. */
  143511. audioTracks?: MediaStreamTrack[];
  143512. }
  143513. /**
  143514. * This can help with recording videos from BabylonJS.
  143515. * This is based on the available WebRTC functionalities of the browser.
  143516. *
  143517. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  143518. */
  143519. export class VideoRecorder {
  143520. private static readonly _defaultOptions;
  143521. /**
  143522. * Returns whether or not the VideoRecorder is available in your browser.
  143523. * @param engine Defines the Babylon Engine.
  143524. * @returns true if supported otherwise false.
  143525. */
  143526. static IsSupported(engine: Engine): boolean;
  143527. private readonly _options;
  143528. private _canvas;
  143529. private _mediaRecorder;
  143530. private _recordedChunks;
  143531. private _fileName;
  143532. private _resolve;
  143533. private _reject;
  143534. /**
  143535. * True when a recording is already in progress.
  143536. */
  143537. get isRecording(): boolean;
  143538. /**
  143539. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  143540. * @param engine Defines the BabylonJS Engine you wish to record.
  143541. * @param options Defines options that can be used to customize the capture.
  143542. */
  143543. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  143544. /**
  143545. * Stops the current recording before the default capture timeout passed in the startRecording function.
  143546. */
  143547. stopRecording(): void;
  143548. /**
  143549. * Starts recording the canvas for a max duration specified in parameters.
  143550. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  143551. * If null no automatic download will start and you can rely on the promise to get the data back.
  143552. * @param maxDuration Defines the maximum recording time in seconds.
  143553. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  143554. * @return A promise callback at the end of the recording with the video data in Blob.
  143555. */
  143556. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  143557. /**
  143558. * Releases internal resources used during the recording.
  143559. */
  143560. dispose(): void;
  143561. private _handleDataAvailable;
  143562. private _handleError;
  143563. private _handleStop;
  143564. }
  143565. }
  143566. declare module BABYLON {
  143567. /**
  143568. * Class containing a set of static utilities functions for screenshots
  143569. */
  143570. export class ScreenshotTools {
  143571. /**
  143572. * Captures a screenshot of the current rendering
  143573. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143574. * @param engine defines the rendering engine
  143575. * @param camera defines the source camera
  143576. * @param size This parameter can be set to a single number or to an object with the
  143577. * following (optional) properties: precision, width, height. If a single number is passed,
  143578. * it will be used for both width and height. If an object is passed, the screenshot size
  143579. * will be derived from the parameters. The precision property is a multiplier allowing
  143580. * rendering at a higher or lower resolution
  143581. * @param successCallback defines the callback receives a single parameter which contains the
  143582. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143583. * src parameter of an <img> to display it
  143584. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143585. * Check your browser for supported MIME types
  143586. */
  143587. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  143588. /**
  143589. * Captures a screenshot of the current rendering
  143590. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143591. * @param engine defines the rendering engine
  143592. * @param camera defines the source camera
  143593. * @param size This parameter can be set to a single number or to an object with the
  143594. * following (optional) properties: precision, width, height. If a single number is passed,
  143595. * it will be used for both width and height. If an object is passed, the screenshot size
  143596. * will be derived from the parameters. The precision property is a multiplier allowing
  143597. * rendering at a higher or lower resolution
  143598. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  143599. * Check your browser for supported MIME types
  143600. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143601. * to the src parameter of an <img> to display it
  143602. */
  143603. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  143604. /**
  143605. * Generates an image screenshot from the specified camera.
  143606. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143607. * @param engine The engine to use for rendering
  143608. * @param camera The camera to use for rendering
  143609. * @param size This parameter can be set to a single number or to an object with the
  143610. * following (optional) properties: precision, width, height. If a single number is passed,
  143611. * it will be used for both width and height. If an object is passed, the screenshot size
  143612. * will be derived from the parameters. The precision property is a multiplier allowing
  143613. * rendering at a higher or lower resolution
  143614. * @param successCallback The callback receives a single parameter which contains the
  143615. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  143616. * src parameter of an <img> to display it
  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. */
  143624. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): void;
  143625. /**
  143626. * Generates an image screenshot from the specified camera.
  143627. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  143628. * @param engine The engine to use for rendering
  143629. * @param camera The camera to use for rendering
  143630. * @param size This parameter can be set to a single number or to an object with the
  143631. * following (optional) properties: precision, width, height. If a single number is passed,
  143632. * it will be used for both width and height. If an object is passed, the screenshot size
  143633. * will be derived from the parameters. The precision property is a multiplier allowing
  143634. * rendering at a higher or lower resolution
  143635. * @param mimeType The MIME type of the screenshot image (default: image/png).
  143636. * Check your browser for supported MIME types
  143637. * @param samples Texture samples (default: 1)
  143638. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  143639. * @param fileName A name for for the downloaded file.
  143640. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  143641. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  143642. * to the src parameter of an <img> to display it
  143643. */
  143644. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  143645. /**
  143646. * Gets height and width for screenshot size
  143647. * @private
  143648. */
  143649. private static _getScreenshotSize;
  143650. }
  143651. }
  143652. declare module BABYLON {
  143653. /**
  143654. * Interface for a data buffer
  143655. */
  143656. export interface IDataBuffer {
  143657. /**
  143658. * Reads bytes from the data buffer.
  143659. * @param byteOffset The byte offset to read
  143660. * @param byteLength The byte length to read
  143661. * @returns A promise that resolves when the bytes are read
  143662. */
  143663. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  143664. /**
  143665. * The byte length of the buffer.
  143666. */
  143667. readonly byteLength: number;
  143668. }
  143669. /**
  143670. * Utility class for reading from a data buffer
  143671. */
  143672. export class DataReader {
  143673. /**
  143674. * The data buffer associated with this data reader.
  143675. */
  143676. readonly buffer: IDataBuffer;
  143677. /**
  143678. * The current byte offset from the beginning of the data buffer.
  143679. */
  143680. byteOffset: number;
  143681. private _dataView;
  143682. private _dataByteOffset;
  143683. /**
  143684. * Constructor
  143685. * @param buffer The buffer to read
  143686. */
  143687. constructor(buffer: IDataBuffer);
  143688. /**
  143689. * Loads the given byte length.
  143690. * @param byteLength The byte length to load
  143691. * @returns A promise that resolves when the load is complete
  143692. */
  143693. loadAsync(byteLength: number): Promise<void>;
  143694. /**
  143695. * Read a unsigned 32-bit integer from the currently loaded data range.
  143696. * @returns The 32-bit integer read
  143697. */
  143698. readUint32(): number;
  143699. /**
  143700. * Read a byte array from the currently loaded data range.
  143701. * @param byteLength The byte length to read
  143702. * @returns The byte array read
  143703. */
  143704. readUint8Array(byteLength: number): Uint8Array;
  143705. /**
  143706. * Read a string from the currently loaded data range.
  143707. * @param byteLength The byte length to read
  143708. * @returns The string read
  143709. */
  143710. readString(byteLength: number): string;
  143711. /**
  143712. * Skips the given byte length the currently loaded data range.
  143713. * @param byteLength The byte length to skip
  143714. */
  143715. skipBytes(byteLength: number): void;
  143716. }
  143717. }
  143718. declare module BABYLON {
  143719. /**
  143720. * Class for storing data to local storage if available or in-memory storage otherwise
  143721. */
  143722. export class DataStorage {
  143723. private static _Storage;
  143724. private static _GetStorage;
  143725. /**
  143726. * Reads a string from the data storage
  143727. * @param key The key to read
  143728. * @param defaultValue The value if the key doesn't exist
  143729. * @returns The string value
  143730. */
  143731. static ReadString(key: string, defaultValue: string): string;
  143732. /**
  143733. * Writes a string to the data storage
  143734. * @param key The key to write
  143735. * @param value The value to write
  143736. */
  143737. static WriteString(key: string, value: string): void;
  143738. /**
  143739. * Reads a boolean from the data storage
  143740. * @param key The key to read
  143741. * @param defaultValue The value if the key doesn't exist
  143742. * @returns The boolean value
  143743. */
  143744. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  143745. /**
  143746. * Writes a boolean to the data storage
  143747. * @param key The key to write
  143748. * @param value The value to write
  143749. */
  143750. static WriteBoolean(key: string, value: boolean): void;
  143751. /**
  143752. * Reads a number from the data storage
  143753. * @param key The key to read
  143754. * @param defaultValue The value if the key doesn't exist
  143755. * @returns The number value
  143756. */
  143757. static ReadNumber(key: string, defaultValue: number): number;
  143758. /**
  143759. * Writes a number to the data storage
  143760. * @param key The key to write
  143761. * @param value The value to write
  143762. */
  143763. static WriteNumber(key: string, value: number): void;
  143764. }
  143765. }
  143766. declare module BABYLON {
  143767. /**
  143768. * Options used for hit testing
  143769. */
  143770. export interface IWebXRLegacyHitTestOptions {
  143771. /**
  143772. * Only test when user interacted with the scene. Default - hit test every frame
  143773. */
  143774. testOnPointerDownOnly?: boolean;
  143775. /**
  143776. * The node to use to transform the local results to world coordinates
  143777. */
  143778. worldParentNode?: TransformNode;
  143779. }
  143780. /**
  143781. * Interface defining the babylon result of raycasting/hit-test
  143782. */
  143783. export interface IWebXRLegacyHitResult {
  143784. /**
  143785. * Transformation matrix that can be applied to a node that will put it in the hit point location
  143786. */
  143787. transformationMatrix: Matrix;
  143788. /**
  143789. * The native hit test result
  143790. */
  143791. xrHitResult: XRHitResult | XRHitTestResult;
  143792. }
  143793. /**
  143794. * The currently-working hit-test module.
  143795. * Hit test (or Ray-casting) is used to interact with the real world.
  143796. * For further information read here - https://github.com/immersive-web/hit-test
  143797. */
  143798. export class WebXRHitTestLegacy extends WebXRAbstractFeature {
  143799. /**
  143800. * options to use when constructing this feature
  143801. */
  143802. readonly options: IWebXRLegacyHitTestOptions;
  143803. private _direction;
  143804. private _mat;
  143805. private _onSelectEnabled;
  143806. private _origin;
  143807. /**
  143808. * The module's name
  143809. */
  143810. static readonly Name: string;
  143811. /**
  143812. * The (Babylon) version of this module.
  143813. * This is an integer representing the implementation version.
  143814. * This number does not correspond to the WebXR specs version
  143815. */
  143816. static readonly Version: number;
  143817. /**
  143818. * Populated with the last native XR Hit Results
  143819. */
  143820. lastNativeXRHitResults: XRHitResult[];
  143821. /**
  143822. * Triggered when new babylon (transformed) hit test results are available
  143823. */
  143824. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  143825. /**
  143826. * Creates a new instance of the (legacy version) hit test feature
  143827. * @param _xrSessionManager an instance of WebXRSessionManager
  143828. * @param options options to use when constructing this feature
  143829. */
  143830. constructor(_xrSessionManager: WebXRSessionManager,
  143831. /**
  143832. * options to use when constructing this feature
  143833. */
  143834. options?: IWebXRLegacyHitTestOptions);
  143835. /**
  143836. * execute a hit test with an XR Ray
  143837. *
  143838. * @param xrSession a native xrSession that will execute this hit test
  143839. * @param xrRay the ray (position and direction) to use for ray-casting
  143840. * @param referenceSpace native XR reference space to use for the hit-test
  143841. * @param filter filter function that will filter the results
  143842. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143843. */
  143844. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  143845. /**
  143846. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  143847. * @param event the (select) event to use to select with
  143848. * @param referenceSpace the reference space to use for this hit test
  143849. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  143850. */
  143851. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  143852. /**
  143853. * attach this feature
  143854. * Will usually be called by the features manager
  143855. *
  143856. * @returns true if successful.
  143857. */
  143858. attach(): boolean;
  143859. /**
  143860. * detach this feature.
  143861. * Will usually be called by the features manager
  143862. *
  143863. * @returns true if successful.
  143864. */
  143865. detach(): boolean;
  143866. /**
  143867. * Dispose this feature and all of the resources attached
  143868. */
  143869. dispose(): void;
  143870. protected _onXRFrame(frame: XRFrame): void;
  143871. private _onHitTestResults;
  143872. private _onSelect;
  143873. }
  143874. }
  143875. declare module BABYLON {
  143876. /**
  143877. * Options used in the plane detector module
  143878. */
  143879. export interface IWebXRPlaneDetectorOptions {
  143880. /**
  143881. * The node to use to transform the local results to world coordinates
  143882. */
  143883. worldParentNode?: TransformNode;
  143884. }
  143885. /**
  143886. * A babylon interface for a WebXR plane.
  143887. * A Plane is actually a polygon, built from N points in space
  143888. *
  143889. * Supported in chrome 79, not supported in canary 81 ATM
  143890. */
  143891. export interface IWebXRPlane {
  143892. /**
  143893. * a babylon-assigned ID for this polygon
  143894. */
  143895. id: number;
  143896. /**
  143897. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  143898. */
  143899. polygonDefinition: Array<Vector3>;
  143900. /**
  143901. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  143902. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  143903. */
  143904. transformationMatrix: Matrix;
  143905. /**
  143906. * the native xr-plane object
  143907. */
  143908. xrPlane: XRPlane;
  143909. }
  143910. /**
  143911. * The plane detector is used to detect planes in the real world when in AR
  143912. * For more information see https://github.com/immersive-web/real-world-geometry/
  143913. */
  143914. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  143915. private _options;
  143916. private _detectedPlanes;
  143917. private _enabled;
  143918. private _lastFrameDetected;
  143919. /**
  143920. * The module's name
  143921. */
  143922. static readonly Name: string;
  143923. /**
  143924. * The (Babylon) version of this module.
  143925. * This is an integer representing the implementation version.
  143926. * This number does not correspond to the WebXR specs version
  143927. */
  143928. static readonly Version: number;
  143929. /**
  143930. * Observers registered here will be executed when a new plane was added to the session
  143931. */
  143932. onPlaneAddedObservable: Observable<IWebXRPlane>;
  143933. /**
  143934. * Observers registered here will be executed when a plane is no longer detected in the session
  143935. */
  143936. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  143937. /**
  143938. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  143939. * This can execute N times every frame
  143940. */
  143941. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  143942. /**
  143943. * construct a new Plane Detector
  143944. * @param _xrSessionManager an instance of xr Session manager
  143945. * @param _options configuration to use when constructing this feature
  143946. */
  143947. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  143948. /**
  143949. * Dispose this feature and all of the resources attached
  143950. */
  143951. dispose(): void;
  143952. protected _onXRFrame(frame: XRFrame): void;
  143953. private _init;
  143954. private _updatePlaneWithXRPlane;
  143955. /**
  143956. * avoiding using Array.find for global support.
  143957. * @param xrPlane the plane to find in the array
  143958. */
  143959. private findIndexInPlaneArray;
  143960. }
  143961. }
  143962. declare module BABYLON {
  143963. /**
  143964. * Configuration options of the anchor system
  143965. */
  143966. export interface IWebXRAnchorSystemOptions {
  143967. /**
  143968. * Should a new anchor be added every time a select event is triggered
  143969. */
  143970. addAnchorOnSelect?: boolean;
  143971. /**
  143972. * should the anchor system use plane detection.
  143973. * If set to true, the plane-detection feature should be set using setPlaneDetector
  143974. */
  143975. usePlaneDetection?: boolean;
  143976. /**
  143977. * a node that will be used to convert local to world coordinates
  143978. */
  143979. worldParentNode?: TransformNode;
  143980. }
  143981. /**
  143982. * A babylon container for an XR Anchor
  143983. */
  143984. export interface IWebXRAnchor {
  143985. /**
  143986. * A babylon-assigned ID for this anchor
  143987. */
  143988. id: number;
  143989. /**
  143990. * Transformation matrix to apply to an object attached to this anchor
  143991. */
  143992. transformationMatrix: Matrix;
  143993. /**
  143994. * The native anchor object
  143995. */
  143996. xrAnchor: XRAnchor;
  143997. }
  143998. /**
  143999. * An implementation of the anchor system of WebXR.
  144000. * Note that the current documented implementation is not available in any browser. Future implementations
  144001. * will use the frame to create an anchor and not the session or a detected plane
  144002. * For further information see https://github.com/immersive-web/anchors/
  144003. */
  144004. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  144005. private _options;
  144006. private _enabled;
  144007. private _hitTestModule;
  144008. private _lastFrameDetected;
  144009. private _onSelect;
  144010. private _planeDetector;
  144011. private _trackedAnchors;
  144012. /**
  144013. * The module's name
  144014. */
  144015. static readonly Name: string;
  144016. /**
  144017. * The (Babylon) version of this module.
  144018. * This is an integer representing the implementation version.
  144019. * This number does not correspond to the WebXR specs version
  144020. */
  144021. static readonly Version: number;
  144022. /**
  144023. * Observers registered here will be executed when a new anchor was added to the session
  144024. */
  144025. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  144026. /**
  144027. * Observers registered here will be executed when an anchor was removed from the session
  144028. */
  144029. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  144030. /**
  144031. * Observers registered here will be executed when an existing anchor updates
  144032. * This can execute N times every frame
  144033. */
  144034. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  144035. /**
  144036. * constructs a new anchor system
  144037. * @param _xrSessionManager an instance of WebXRSessionManager
  144038. * @param _options configuration object for this feature
  144039. */
  144040. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  144041. /**
  144042. * Add anchor at a specific XR point.
  144043. *
  144044. * @param xrRigidTransformation xr-coordinates where a new anchor should be added
  144045. * @param anchorCreator the object o use to create an anchor with. either a session or a plane
  144046. * @returns a promise the fulfills when the anchor was created
  144047. */
  144048. addAnchorAtRigidTransformation(xrRigidTransformation: XRRigidTransform, anchorCreator?: XRAnchorCreator): Promise<XRAnchor>;
  144049. /**
  144050. * attach this feature
  144051. * Will usually be called by the features manager
  144052. *
  144053. * @returns true if successful.
  144054. */
  144055. attach(): boolean;
  144056. /**
  144057. * detach this feature.
  144058. * Will usually be called by the features manager
  144059. *
  144060. * @returns true if successful.
  144061. */
  144062. detach(): boolean;
  144063. /**
  144064. * Dispose this feature and all of the resources attached
  144065. */
  144066. dispose(): void;
  144067. /**
  144068. * If set, it will improve performance by using the current hit-test results instead of executing a new hit-test
  144069. * @param hitTestModule the hit-test module to use.
  144070. */
  144071. setHitTestModule(hitTestModule: WebXRHitTestLegacy): void;
  144072. /**
  144073. * set the plane detector to use in order to create anchors from frames
  144074. * @param planeDetector the plane-detector module to use
  144075. * @param enable enable plane-anchors. default is true
  144076. */
  144077. setPlaneDetector(planeDetector: WebXRPlaneDetector, enable?: boolean): void;
  144078. protected _onXRFrame(frame: XRFrame): void;
  144079. /**
  144080. * avoiding using Array.find for global support.
  144081. * @param xrAnchor the plane to find in the array
  144082. */
  144083. private _findIndexInAnchorArray;
  144084. private _updateAnchorWithXRFrame;
  144085. }
  144086. }
  144087. declare module BABYLON {
  144088. /**
  144089. * Options interface for the background remover plugin
  144090. */
  144091. export interface IWebXRBackgroundRemoverOptions {
  144092. /**
  144093. * Further background meshes to disable when entering AR
  144094. */
  144095. backgroundMeshes?: AbstractMesh[];
  144096. /**
  144097. * flags to configure the removal of the environment helper.
  144098. * If not set, the entire background will be removed. If set, flags should be set as well.
  144099. */
  144100. environmentHelperRemovalFlags?: {
  144101. /**
  144102. * Should the skybox be removed (default false)
  144103. */
  144104. skyBox?: boolean;
  144105. /**
  144106. * Should the ground be removed (default false)
  144107. */
  144108. ground?: boolean;
  144109. };
  144110. /**
  144111. * don't disable the environment helper
  144112. */
  144113. ignoreEnvironmentHelper?: boolean;
  144114. }
  144115. /**
  144116. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  144117. */
  144118. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  144119. /**
  144120. * read-only options to be used in this module
  144121. */
  144122. readonly options: IWebXRBackgroundRemoverOptions;
  144123. /**
  144124. * The module's name
  144125. */
  144126. static readonly Name: string;
  144127. /**
  144128. * The (Babylon) version of this module.
  144129. * This is an integer representing the implementation version.
  144130. * This number does not correspond to the WebXR specs version
  144131. */
  144132. static readonly Version: number;
  144133. /**
  144134. * registered observers will be triggered when the background state changes
  144135. */
  144136. onBackgroundStateChangedObservable: Observable<boolean>;
  144137. /**
  144138. * constructs a new background remover module
  144139. * @param _xrSessionManager the session manager for this module
  144140. * @param options read-only options to be used in this module
  144141. */
  144142. constructor(_xrSessionManager: WebXRSessionManager,
  144143. /**
  144144. * read-only options to be used in this module
  144145. */
  144146. options?: IWebXRBackgroundRemoverOptions);
  144147. /**
  144148. * attach this feature
  144149. * Will usually be called by the features manager
  144150. *
  144151. * @returns true if successful.
  144152. */
  144153. attach(): boolean;
  144154. /**
  144155. * detach this feature.
  144156. * Will usually be called by the features manager
  144157. *
  144158. * @returns true if successful.
  144159. */
  144160. detach(): boolean;
  144161. /**
  144162. * Dispose this feature and all of the resources attached
  144163. */
  144164. dispose(): void;
  144165. protected _onXRFrame(_xrFrame: XRFrame): void;
  144166. private _setBackgroundState;
  144167. }
  144168. }
  144169. declare module BABYLON {
  144170. /**
  144171. * Options for the controller physics feature
  144172. */
  144173. export class IWebXRControllerPhysicsOptions {
  144174. /**
  144175. * Should the headset get its own impostor
  144176. */
  144177. enableHeadsetImpostor?: boolean;
  144178. /**
  144179. * Optional parameters for the headset impostor
  144180. */
  144181. headsetImpostorParams?: {
  144182. /**
  144183. * The type of impostor to create. Default is sphere
  144184. */
  144185. impostorType: number;
  144186. /**
  144187. * the size of the impostor. Defaults to 10cm
  144188. */
  144189. impostorSize?: number | {
  144190. width: number;
  144191. height: number;
  144192. depth: number;
  144193. };
  144194. /**
  144195. * Friction definitions
  144196. */
  144197. friction?: number;
  144198. /**
  144199. * Restitution
  144200. */
  144201. restitution?: number;
  144202. };
  144203. /**
  144204. * The physics properties of the future impostors
  144205. */
  144206. physicsProperties?: {
  144207. /**
  144208. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  144209. * Note that this requires a physics engine that supports mesh impostors!
  144210. */
  144211. useControllerMesh?: boolean;
  144212. /**
  144213. * The type of impostor to create. Default is sphere
  144214. */
  144215. impostorType?: number;
  144216. /**
  144217. * the size of the impostor. Defaults to 10cm
  144218. */
  144219. impostorSize?: number | {
  144220. width: number;
  144221. height: number;
  144222. depth: number;
  144223. };
  144224. /**
  144225. * Friction definitions
  144226. */
  144227. friction?: number;
  144228. /**
  144229. * Restitution
  144230. */
  144231. restitution?: number;
  144232. };
  144233. /**
  144234. * the xr input to use with this pointer selection
  144235. */
  144236. xrInput: WebXRInput;
  144237. }
  144238. /**
  144239. * Add physics impostor to your webxr controllers,
  144240. * including naive calculation of their linear and angular velocity
  144241. */
  144242. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  144243. private readonly _options;
  144244. private _attachController;
  144245. private _controllers;
  144246. private _debugMode;
  144247. private _delta;
  144248. private _headsetImpostor?;
  144249. private _headsetMesh?;
  144250. private _lastTimestamp;
  144251. private _tmpQuaternion;
  144252. private _tmpVector;
  144253. /**
  144254. * The module's name
  144255. */
  144256. static readonly Name: string;
  144257. /**
  144258. * The (Babylon) version of this module.
  144259. * This is an integer representing the implementation version.
  144260. * This number does not correspond to the webxr specs version
  144261. */
  144262. static readonly Version: number;
  144263. /**
  144264. * Construct a new Controller Physics Feature
  144265. * @param _xrSessionManager the corresponding xr session manager
  144266. * @param _options options to create this feature with
  144267. */
  144268. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  144269. /**
  144270. * @hidden
  144271. * enable debugging - will show console outputs and the impostor mesh
  144272. */
  144273. _enablePhysicsDebug(): void;
  144274. /**
  144275. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  144276. * @param xrController the controller to add
  144277. */
  144278. addController(xrController: WebXRInputSource): void;
  144279. /**
  144280. * attach this feature
  144281. * Will usually be called by the features manager
  144282. *
  144283. * @returns true if successful.
  144284. */
  144285. attach(): boolean;
  144286. /**
  144287. * detach this feature.
  144288. * Will usually be called by the features manager
  144289. *
  144290. * @returns true if successful.
  144291. */
  144292. detach(): boolean;
  144293. /**
  144294. * Get the headset impostor, if enabled
  144295. * @returns the impostor
  144296. */
  144297. getHeadsetImpostor(): PhysicsImpostor | undefined;
  144298. /**
  144299. * Get the physics impostor of a specific controller.
  144300. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  144301. * @param controller the controller or the controller id of which to get the impostor
  144302. * @returns the impostor or null
  144303. */
  144304. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  144305. /**
  144306. * Update the physics properties provided in the constructor
  144307. * @param newProperties the new properties object
  144308. */
  144309. setPhysicsProperties(newProperties: {
  144310. impostorType?: number;
  144311. impostorSize?: number | {
  144312. width: number;
  144313. height: number;
  144314. depth: number;
  144315. };
  144316. friction?: number;
  144317. restitution?: number;
  144318. }): void;
  144319. protected _onXRFrame(_xrFrame: any): void;
  144320. private _detachController;
  144321. }
  144322. }
  144323. declare module BABYLON {
  144324. /**
  144325. * Options used for hit testing (version 2)
  144326. */
  144327. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  144328. /**
  144329. * Do not create a permanent hit test. Will usually be used when only
  144330. * transient inputs are needed.
  144331. */
  144332. disablePermanentHitTest?: boolean;
  144333. /**
  144334. * Enable transient (for example touch-based) hit test inspections
  144335. */
  144336. enableTransientHitTest?: boolean;
  144337. /**
  144338. * Offset ray for the permanent hit test
  144339. */
  144340. offsetRay?: Vector3;
  144341. /**
  144342. * Offset ray for the transient hit test
  144343. */
  144344. transientOffsetRay?: Vector3;
  144345. /**
  144346. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  144347. */
  144348. useReferenceSpace?: boolean;
  144349. }
  144350. /**
  144351. * Interface defining the babylon result of hit-test
  144352. */
  144353. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  144354. /**
  144355. * The input source that generated this hit test (if transient)
  144356. */
  144357. inputSource?: XRInputSource;
  144358. /**
  144359. * Is this a transient hit test
  144360. */
  144361. isTransient?: boolean;
  144362. /**
  144363. * Position of the hit test result
  144364. */
  144365. position: Vector3;
  144366. /**
  144367. * Rotation of the hit test result
  144368. */
  144369. rotationQuaternion: Quaternion;
  144370. }
  144371. /**
  144372. * The currently-working hit-test module.
  144373. * Hit test (or Ray-casting) is used to interact with the real world.
  144374. * For further information read here - https://github.com/immersive-web/hit-test
  144375. *
  144376. * Tested on chrome (mobile) 80.
  144377. */
  144378. export class WebXRHitTest extends WebXRAbstractFeature {
  144379. /**
  144380. * options to use when constructing this feature
  144381. */
  144382. readonly options: IWebXRHitTestOptions;
  144383. private _tmpMat;
  144384. private _tmpPos;
  144385. private _tmpQuat;
  144386. private _transientXrHitTestSource;
  144387. private _xrHitTestSource;
  144388. private initHitTestSource;
  144389. /**
  144390. * The module's name
  144391. */
  144392. static readonly Name: string;
  144393. /**
  144394. * The (Babylon) version of this module.
  144395. * This is an integer representing the implementation version.
  144396. * This number does not correspond to the WebXR specs version
  144397. */
  144398. static readonly Version: number;
  144399. /**
  144400. * When set to true, each hit test will have its own position/rotation objects
  144401. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  144402. * the developers will clone them or copy them as they see fit.
  144403. */
  144404. autoCloneTransformation: boolean;
  144405. /**
  144406. * Populated with the last native XR Hit Results
  144407. */
  144408. lastNativeXRHitResults: XRHitResult[];
  144409. /**
  144410. * Triggered when new babylon (transformed) hit test results are available
  144411. */
  144412. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  144413. /**
  144414. * Use this to temporarily pause hit test checks.
  144415. */
  144416. paused: boolean;
  144417. /**
  144418. * Creates a new instance of the hit test feature
  144419. * @param _xrSessionManager an instance of WebXRSessionManager
  144420. * @param options options to use when constructing this feature
  144421. */
  144422. constructor(_xrSessionManager: WebXRSessionManager,
  144423. /**
  144424. * options to use when constructing this feature
  144425. */
  144426. options?: IWebXRHitTestOptions);
  144427. /**
  144428. * attach this feature
  144429. * Will usually be called by the features manager
  144430. *
  144431. * @returns true if successful.
  144432. */
  144433. attach(): boolean;
  144434. /**
  144435. * detach this feature.
  144436. * Will usually be called by the features manager
  144437. *
  144438. * @returns true if successful.
  144439. */
  144440. detach(): boolean;
  144441. /**
  144442. * Dispose this feature and all of the resources attached
  144443. */
  144444. dispose(): void;
  144445. protected _onXRFrame(frame: XRFrame): void;
  144446. private _processWebXRHitTestResult;
  144447. }
  144448. }
  144449. declare module BABYLON {
  144450. /**
  144451. * The motion controller class for all microsoft mixed reality controllers
  144452. */
  144453. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  144454. protected readonly _mapping: {
  144455. defaultButton: {
  144456. valueNodeName: string;
  144457. unpressedNodeName: string;
  144458. pressedNodeName: string;
  144459. };
  144460. defaultAxis: {
  144461. valueNodeName: string;
  144462. minNodeName: string;
  144463. maxNodeName: string;
  144464. };
  144465. buttons: {
  144466. "xr-standard-trigger": {
  144467. rootNodeName: string;
  144468. componentProperty: string;
  144469. states: string[];
  144470. };
  144471. "xr-standard-squeeze": {
  144472. rootNodeName: string;
  144473. componentProperty: string;
  144474. states: string[];
  144475. };
  144476. "xr-standard-touchpad": {
  144477. rootNodeName: string;
  144478. labelAnchorNodeName: string;
  144479. touchPointNodeName: string;
  144480. };
  144481. "xr-standard-thumbstick": {
  144482. rootNodeName: string;
  144483. componentProperty: string;
  144484. states: string[];
  144485. };
  144486. };
  144487. axes: {
  144488. "xr-standard-touchpad": {
  144489. "x-axis": {
  144490. rootNodeName: string;
  144491. };
  144492. "y-axis": {
  144493. rootNodeName: string;
  144494. };
  144495. };
  144496. "xr-standard-thumbstick": {
  144497. "x-axis": {
  144498. rootNodeName: string;
  144499. };
  144500. "y-axis": {
  144501. rootNodeName: string;
  144502. };
  144503. };
  144504. };
  144505. };
  144506. /**
  144507. * The base url used to load the left and right controller models
  144508. */
  144509. static MODEL_BASE_URL: string;
  144510. /**
  144511. * The name of the left controller model file
  144512. */
  144513. static MODEL_LEFT_FILENAME: string;
  144514. /**
  144515. * The name of the right controller model file
  144516. */
  144517. static MODEL_RIGHT_FILENAME: string;
  144518. profileId: string;
  144519. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144520. protected _getFilenameAndPath(): {
  144521. filename: string;
  144522. path: string;
  144523. };
  144524. protected _getModelLoadingConstraints(): boolean;
  144525. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144526. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144527. protected _updateModel(): void;
  144528. }
  144529. }
  144530. declare module BABYLON {
  144531. /**
  144532. * The motion controller class for oculus touch (quest, rift).
  144533. * This class supports legacy mapping as well the standard xr mapping
  144534. */
  144535. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  144536. private _forceLegacyControllers;
  144537. private _modelRootNode;
  144538. /**
  144539. * The base url used to load the left and right controller models
  144540. */
  144541. static MODEL_BASE_URL: string;
  144542. /**
  144543. * The name of the left controller model file
  144544. */
  144545. static MODEL_LEFT_FILENAME: string;
  144546. /**
  144547. * The name of the right controller model file
  144548. */
  144549. static MODEL_RIGHT_FILENAME: string;
  144550. /**
  144551. * Base Url for the Quest controller model.
  144552. */
  144553. static QUEST_MODEL_BASE_URL: string;
  144554. profileId: string;
  144555. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  144556. protected _getFilenameAndPath(): {
  144557. filename: string;
  144558. path: string;
  144559. };
  144560. protected _getModelLoadingConstraints(): boolean;
  144561. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144562. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144563. protected _updateModel(): void;
  144564. /**
  144565. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  144566. * between the touch and touch 2.
  144567. */
  144568. private _isQuest;
  144569. }
  144570. }
  144571. declare module BABYLON {
  144572. /**
  144573. * The motion controller class for the standard HTC-Vive controllers
  144574. */
  144575. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  144576. private _modelRootNode;
  144577. /**
  144578. * The base url used to load the left and right controller models
  144579. */
  144580. static MODEL_BASE_URL: string;
  144581. /**
  144582. * File name for the controller model.
  144583. */
  144584. static MODEL_FILENAME: string;
  144585. profileId: string;
  144586. /**
  144587. * Create a new Vive motion controller object
  144588. * @param scene the scene to use to create this controller
  144589. * @param gamepadObject the corresponding gamepad object
  144590. * @param handness the handness of the controller
  144591. */
  144592. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handness: MotionControllerHandness);
  144593. protected _getFilenameAndPath(): {
  144594. filename: string;
  144595. path: string;
  144596. };
  144597. protected _getModelLoadingConstraints(): boolean;
  144598. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  144599. protected _setRootMesh(meshes: AbstractMesh[]): void;
  144600. protected _updateModel(): void;
  144601. }
  144602. }
  144603. declare module BABYLON {
  144604. /**
  144605. * A cursor which tracks a point on a path
  144606. */
  144607. export class PathCursor {
  144608. private path;
  144609. /**
  144610. * Stores path cursor callbacks for when an onchange event is triggered
  144611. */
  144612. private _onchange;
  144613. /**
  144614. * The value of the path cursor
  144615. */
  144616. value: number;
  144617. /**
  144618. * The animation array of the path cursor
  144619. */
  144620. animations: Animation[];
  144621. /**
  144622. * Initializes the path cursor
  144623. * @param path The path to track
  144624. */
  144625. constructor(path: Path2);
  144626. /**
  144627. * Gets the cursor point on the path
  144628. * @returns A point on the path cursor at the cursor location
  144629. */
  144630. getPoint(): Vector3;
  144631. /**
  144632. * Moves the cursor ahead by the step amount
  144633. * @param step The amount to move the cursor forward
  144634. * @returns This path cursor
  144635. */
  144636. moveAhead(step?: number): PathCursor;
  144637. /**
  144638. * Moves the cursor behind by the step amount
  144639. * @param step The amount to move the cursor back
  144640. * @returns This path cursor
  144641. */
  144642. moveBack(step?: number): PathCursor;
  144643. /**
  144644. * Moves the cursor by the step amount
  144645. * If the step amount is greater than one, an exception is thrown
  144646. * @param step The amount to move the cursor
  144647. * @returns This path cursor
  144648. */
  144649. move(step: number): PathCursor;
  144650. /**
  144651. * Ensures that the value is limited between zero and one
  144652. * @returns This path cursor
  144653. */
  144654. private ensureLimits;
  144655. /**
  144656. * Runs onchange callbacks on change (used by the animation engine)
  144657. * @returns This path cursor
  144658. */
  144659. private raiseOnChange;
  144660. /**
  144661. * Executes a function on change
  144662. * @param f A path cursor onchange callback
  144663. * @returns This path cursor
  144664. */
  144665. onchange(f: (cursor: PathCursor) => void): PathCursor;
  144666. }
  144667. }
  144668. declare module BABYLON {
  144669. /** @hidden */
  144670. export var blurPixelShader: {
  144671. name: string;
  144672. shader: string;
  144673. };
  144674. }
  144675. declare module BABYLON {
  144676. /** @hidden */
  144677. export var pointCloudVertexDeclaration: {
  144678. name: string;
  144679. shader: string;
  144680. };
  144681. }
  144682. // Mixins
  144683. interface Window {
  144684. mozIndexedDB: IDBFactory;
  144685. webkitIndexedDB: IDBFactory;
  144686. msIndexedDB: IDBFactory;
  144687. webkitURL: typeof URL;
  144688. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  144689. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  144690. WebGLRenderingContext: WebGLRenderingContext;
  144691. MSGesture: MSGesture;
  144692. CANNON: any;
  144693. AudioContext: AudioContext;
  144694. webkitAudioContext: AudioContext;
  144695. PointerEvent: any;
  144696. Math: Math;
  144697. Uint8Array: Uint8ArrayConstructor;
  144698. Float32Array: Float32ArrayConstructor;
  144699. mozURL: typeof URL;
  144700. msURL: typeof URL;
  144701. VRFrameData: any; // WebVR, from specs 1.1
  144702. DracoDecoderModule: any;
  144703. setImmediate(handler: (...args: any[]) => void): number;
  144704. }
  144705. interface HTMLCanvasElement {
  144706. requestPointerLock(): void;
  144707. msRequestPointerLock?(): void;
  144708. mozRequestPointerLock?(): void;
  144709. webkitRequestPointerLock?(): void;
  144710. /** Track wether a record is in progress */
  144711. isRecording: boolean;
  144712. /** Capture Stream method defined by some browsers */
  144713. captureStream(fps?: number): MediaStream;
  144714. }
  144715. interface CanvasRenderingContext2D {
  144716. msImageSmoothingEnabled: boolean;
  144717. }
  144718. interface MouseEvent {
  144719. mozMovementX: number;
  144720. mozMovementY: number;
  144721. webkitMovementX: number;
  144722. webkitMovementY: number;
  144723. msMovementX: number;
  144724. msMovementY: number;
  144725. }
  144726. interface Navigator {
  144727. mozGetVRDevices: (any: any) => any;
  144728. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144729. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144730. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  144731. webkitGetGamepads(): Gamepad[];
  144732. msGetGamepads(): Gamepad[];
  144733. webkitGamepads(): Gamepad[];
  144734. }
  144735. interface HTMLVideoElement {
  144736. mozSrcObject: any;
  144737. }
  144738. interface Math {
  144739. fround(x: number): number;
  144740. imul(a: number, b: number): number;
  144741. }
  144742. interface WebGLRenderingContext {
  144743. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  144744. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  144745. vertexAttribDivisor(index: number, divisor: number): void;
  144746. createVertexArray(): any;
  144747. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  144748. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  144749. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  144750. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  144751. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  144752. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  144753. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  144754. // Queries
  144755. createQuery(): WebGLQuery;
  144756. deleteQuery(query: WebGLQuery): void;
  144757. beginQuery(target: number, query: WebGLQuery): void;
  144758. endQuery(target: number): void;
  144759. getQueryParameter(query: WebGLQuery, pname: number): any;
  144760. getQuery(target: number, pname: number): any;
  144761. MAX_SAMPLES: number;
  144762. RGBA8: number;
  144763. READ_FRAMEBUFFER: number;
  144764. DRAW_FRAMEBUFFER: number;
  144765. UNIFORM_BUFFER: number;
  144766. HALF_FLOAT_OES: number;
  144767. RGBA16F: number;
  144768. RGBA32F: number;
  144769. R32F: number;
  144770. RG32F: number;
  144771. RGB32F: number;
  144772. R16F: number;
  144773. RG16F: number;
  144774. RGB16F: number;
  144775. RED: number;
  144776. RG: number;
  144777. R8: number;
  144778. RG8: number;
  144779. UNSIGNED_INT_24_8: number;
  144780. DEPTH24_STENCIL8: number;
  144781. MIN: number;
  144782. MAX: number;
  144783. /* Multiple Render Targets */
  144784. drawBuffers(buffers: number[]): void;
  144785. readBuffer(src: number): void;
  144786. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  144787. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  144788. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  144789. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  144790. // Occlusion Query
  144791. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  144792. ANY_SAMPLES_PASSED: number;
  144793. QUERY_RESULT_AVAILABLE: number;
  144794. QUERY_RESULT: number;
  144795. }
  144796. interface WebGLProgram {
  144797. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  144798. }
  144799. interface EXT_disjoint_timer_query {
  144800. QUERY_COUNTER_BITS_EXT: number;
  144801. TIME_ELAPSED_EXT: number;
  144802. TIMESTAMP_EXT: number;
  144803. GPU_DISJOINT_EXT: number;
  144804. QUERY_RESULT_EXT: number;
  144805. QUERY_RESULT_AVAILABLE_EXT: number;
  144806. queryCounterEXT(query: WebGLQuery, target: number): void;
  144807. createQueryEXT(): WebGLQuery;
  144808. beginQueryEXT(target: number, query: WebGLQuery): void;
  144809. endQueryEXT(target: number): void;
  144810. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  144811. deleteQueryEXT(query: WebGLQuery): void;
  144812. }
  144813. interface WebGLUniformLocation {
  144814. _currentState: any;
  144815. }
  144816. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  144817. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  144818. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  144819. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144820. interface WebGLRenderingContext {
  144821. readonly RASTERIZER_DISCARD: number;
  144822. readonly DEPTH_COMPONENT24: number;
  144823. readonly TEXTURE_3D: number;
  144824. readonly TEXTURE_2D_ARRAY: number;
  144825. readonly TEXTURE_COMPARE_FUNC: number;
  144826. readonly TEXTURE_COMPARE_MODE: number;
  144827. readonly COMPARE_REF_TO_TEXTURE: number;
  144828. readonly TEXTURE_WRAP_R: number;
  144829. readonly HALF_FLOAT: number;
  144830. readonly RGB8: number;
  144831. readonly RED_INTEGER: number;
  144832. readonly RG_INTEGER: number;
  144833. readonly RGB_INTEGER: number;
  144834. readonly RGBA_INTEGER: number;
  144835. readonly R8_SNORM: number;
  144836. readonly RG8_SNORM: number;
  144837. readonly RGB8_SNORM: number;
  144838. readonly RGBA8_SNORM: number;
  144839. readonly R8I: number;
  144840. readonly RG8I: number;
  144841. readonly RGB8I: number;
  144842. readonly RGBA8I: number;
  144843. readonly R8UI: number;
  144844. readonly RG8UI: number;
  144845. readonly RGB8UI: number;
  144846. readonly RGBA8UI: number;
  144847. readonly R16I: number;
  144848. readonly RG16I: number;
  144849. readonly RGB16I: number;
  144850. readonly RGBA16I: number;
  144851. readonly R16UI: number;
  144852. readonly RG16UI: number;
  144853. readonly RGB16UI: number;
  144854. readonly RGBA16UI: number;
  144855. readonly R32I: number;
  144856. readonly RG32I: number;
  144857. readonly RGB32I: number;
  144858. readonly RGBA32I: number;
  144859. readonly R32UI: number;
  144860. readonly RG32UI: number;
  144861. readonly RGB32UI: number;
  144862. readonly RGBA32UI: number;
  144863. readonly RGB10_A2UI: number;
  144864. readonly R11F_G11F_B10F: number;
  144865. readonly RGB9_E5: number;
  144866. readonly RGB10_A2: number;
  144867. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  144868. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  144869. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  144870. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  144871. readonly DEPTH_COMPONENT32F: number;
  144872. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  144873. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  144874. 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;
  144875. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  144876. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  144877. readonly TRANSFORM_FEEDBACK: number;
  144878. readonly INTERLEAVED_ATTRIBS: number;
  144879. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  144880. createTransformFeedback(): WebGLTransformFeedback;
  144881. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  144882. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  144883. beginTransformFeedback(primitiveMode: number): void;
  144884. endTransformFeedback(): void;
  144885. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  144886. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144887. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144888. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  144889. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  144890. }
  144891. interface ImageBitmap {
  144892. readonly width: number;
  144893. readonly height: number;
  144894. close(): void;
  144895. }
  144896. interface WebGLQuery extends WebGLObject {
  144897. }
  144898. declare var WebGLQuery: {
  144899. prototype: WebGLQuery;
  144900. new(): WebGLQuery;
  144901. };
  144902. interface WebGLSampler extends WebGLObject {
  144903. }
  144904. declare var WebGLSampler: {
  144905. prototype: WebGLSampler;
  144906. new(): WebGLSampler;
  144907. };
  144908. interface WebGLSync extends WebGLObject {
  144909. }
  144910. declare var WebGLSync: {
  144911. prototype: WebGLSync;
  144912. new(): WebGLSync;
  144913. };
  144914. interface WebGLTransformFeedback extends WebGLObject {
  144915. }
  144916. declare var WebGLTransformFeedback: {
  144917. prototype: WebGLTransformFeedback;
  144918. new(): WebGLTransformFeedback;
  144919. };
  144920. interface WebGLVertexArrayObject extends WebGLObject {
  144921. }
  144922. declare var WebGLVertexArrayObject: {
  144923. prototype: WebGLVertexArrayObject;
  144924. new(): WebGLVertexArrayObject;
  144925. };
  144926. // Type definitions for WebVR API
  144927. // Project: https://w3c.github.io/webvr/
  144928. // Definitions by: six a <https://github.com/lostfictions>
  144929. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  144930. interface VRDisplay extends EventTarget {
  144931. /**
  144932. * Dictionary of capabilities describing the VRDisplay.
  144933. */
  144934. readonly capabilities: VRDisplayCapabilities;
  144935. /**
  144936. * z-depth defining the far plane of the eye view frustum
  144937. * enables mapping of values in the render target depth
  144938. * attachment to scene coordinates. Initially set to 10000.0.
  144939. */
  144940. depthFar: number;
  144941. /**
  144942. * z-depth defining the near plane of the eye view frustum
  144943. * enables mapping of values in the render target depth
  144944. * attachment to scene coordinates. Initially set to 0.01.
  144945. */
  144946. depthNear: number;
  144947. /**
  144948. * An identifier for this distinct VRDisplay. Used as an
  144949. * association point in the Gamepad API.
  144950. */
  144951. readonly displayId: number;
  144952. /**
  144953. * A display name, a user-readable name identifying it.
  144954. */
  144955. readonly displayName: string;
  144956. readonly isConnected: boolean;
  144957. readonly isPresenting: boolean;
  144958. /**
  144959. * If this VRDisplay supports room-scale experiences, the optional
  144960. * stage attribute contains details on the room-scale parameters.
  144961. */
  144962. readonly stageParameters: VRStageParameters | null;
  144963. /**
  144964. * Passing the value returned by `requestAnimationFrame` to
  144965. * `cancelAnimationFrame` will unregister the callback.
  144966. * @param handle Define the hanle of the request to cancel
  144967. */
  144968. cancelAnimationFrame(handle: number): void;
  144969. /**
  144970. * Stops presenting to the VRDisplay.
  144971. * @returns a promise to know when it stopped
  144972. */
  144973. exitPresent(): Promise<void>;
  144974. /**
  144975. * Return the current VREyeParameters for the given eye.
  144976. * @param whichEye Define the eye we want the parameter for
  144977. * @returns the eye parameters
  144978. */
  144979. getEyeParameters(whichEye: string): VREyeParameters;
  144980. /**
  144981. * Populates the passed VRFrameData with the information required to render
  144982. * the current frame.
  144983. * @param frameData Define the data structure to populate
  144984. * @returns true if ok otherwise false
  144985. */
  144986. getFrameData(frameData: VRFrameData): boolean;
  144987. /**
  144988. * Get the layers currently being presented.
  144989. * @returns the list of VR layers
  144990. */
  144991. getLayers(): VRLayer[];
  144992. /**
  144993. * Return a VRPose containing the future predicted pose of the VRDisplay
  144994. * when the current frame will be presented. The value returned will not
  144995. * change until JavaScript has returned control to the browser.
  144996. *
  144997. * The VRPose will contain the position, orientation, velocity,
  144998. * and acceleration of each of these properties.
  144999. * @returns the pose object
  145000. */
  145001. getPose(): VRPose;
  145002. /**
  145003. * Return the current instantaneous pose of the VRDisplay, with no
  145004. * prediction applied.
  145005. * @returns the current instantaneous pose
  145006. */
  145007. getImmediatePose(): VRPose;
  145008. /**
  145009. * The callback passed to `requestAnimationFrame` will be called
  145010. * any time a new frame should be rendered. When the VRDisplay is
  145011. * presenting the callback will be called at the native refresh
  145012. * rate of the HMD. When not presenting this function acts
  145013. * identically to how window.requestAnimationFrame acts. Content should
  145014. * make no assumptions of frame rate or vsync behavior as the HMD runs
  145015. * asynchronously from other displays and at differing refresh rates.
  145016. * @param callback Define the eaction to run next frame
  145017. * @returns the request handle it
  145018. */
  145019. requestAnimationFrame(callback: FrameRequestCallback): number;
  145020. /**
  145021. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  145022. * Repeat calls while already presenting will update the VRLayers being displayed.
  145023. * @param layers Define the list of layer to present
  145024. * @returns a promise to know when the request has been fulfilled
  145025. */
  145026. requestPresent(layers: VRLayer[]): Promise<void>;
  145027. /**
  145028. * Reset the pose for this display, treating its current position and
  145029. * orientation as the "origin/zero" values. VRPose.position,
  145030. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  145031. * updated when calling resetPose(). This should be called in only
  145032. * sitting-space experiences.
  145033. */
  145034. resetPose(): void;
  145035. /**
  145036. * The VRLayer provided to the VRDisplay will be captured and presented
  145037. * in the HMD. Calling this function has the same effect on the source
  145038. * canvas as any other operation that uses its source image, and canvases
  145039. * created without preserveDrawingBuffer set to true will be cleared.
  145040. * @param pose Define the pose to submit
  145041. */
  145042. submitFrame(pose?: VRPose): void;
  145043. }
  145044. declare var VRDisplay: {
  145045. prototype: VRDisplay;
  145046. new(): VRDisplay;
  145047. };
  145048. interface VRLayer {
  145049. leftBounds?: number[] | Float32Array | null;
  145050. rightBounds?: number[] | Float32Array | null;
  145051. source?: HTMLCanvasElement | null;
  145052. }
  145053. interface VRDisplayCapabilities {
  145054. readonly canPresent: boolean;
  145055. readonly hasExternalDisplay: boolean;
  145056. readonly hasOrientation: boolean;
  145057. readonly hasPosition: boolean;
  145058. readonly maxLayers: number;
  145059. }
  145060. interface VREyeParameters {
  145061. /** @deprecated */
  145062. readonly fieldOfView: VRFieldOfView;
  145063. readonly offset: Float32Array;
  145064. readonly renderHeight: number;
  145065. readonly renderWidth: number;
  145066. }
  145067. interface VRFieldOfView {
  145068. readonly downDegrees: number;
  145069. readonly leftDegrees: number;
  145070. readonly rightDegrees: number;
  145071. readonly upDegrees: number;
  145072. }
  145073. interface VRFrameData {
  145074. readonly leftProjectionMatrix: Float32Array;
  145075. readonly leftViewMatrix: Float32Array;
  145076. readonly pose: VRPose;
  145077. readonly rightProjectionMatrix: Float32Array;
  145078. readonly rightViewMatrix: Float32Array;
  145079. readonly timestamp: number;
  145080. }
  145081. interface VRPose {
  145082. readonly angularAcceleration: Float32Array | null;
  145083. readonly angularVelocity: Float32Array | null;
  145084. readonly linearAcceleration: Float32Array | null;
  145085. readonly linearVelocity: Float32Array | null;
  145086. readonly orientation: Float32Array | null;
  145087. readonly position: Float32Array | null;
  145088. readonly timestamp: number;
  145089. }
  145090. interface VRStageParameters {
  145091. sittingToStandingTransform?: Float32Array;
  145092. sizeX?: number;
  145093. sizeY?: number;
  145094. }
  145095. interface Navigator {
  145096. getVRDisplays(): Promise<VRDisplay[]>;
  145097. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  145098. }
  145099. interface Window {
  145100. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  145101. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  145102. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  145103. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145104. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  145105. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  145106. }
  145107. interface Gamepad {
  145108. readonly displayId: number;
  145109. }
  145110. type XRSessionMode =
  145111. | "inline"
  145112. | "immersive-vr"
  145113. | "immersive-ar";
  145114. type XRReferenceSpaceType =
  145115. | "viewer"
  145116. | "local"
  145117. | "local-floor"
  145118. | "bounded-floor"
  145119. | "unbounded";
  145120. type XREnvironmentBlendMode =
  145121. | "opaque"
  145122. | "additive"
  145123. | "alpha-blend";
  145124. type XRVisibilityState =
  145125. | "visible"
  145126. | "visible-blurred"
  145127. | "hidden";
  145128. type XRHandedness =
  145129. | "none"
  145130. | "left"
  145131. | "right";
  145132. type XRTargetRayMode =
  145133. | "gaze"
  145134. | "tracked-pointer"
  145135. | "screen";
  145136. type XREye =
  145137. | "none"
  145138. | "left"
  145139. | "right";
  145140. interface XRSpace extends EventTarget {
  145141. }
  145142. interface XRRenderState {
  145143. depthNear?: number;
  145144. depthFar?: number;
  145145. inlineVerticalFieldOfView?: number;
  145146. baseLayer?: XRWebGLLayer;
  145147. }
  145148. interface XRInputSource {
  145149. handedness: XRHandedness;
  145150. targetRayMode: XRTargetRayMode;
  145151. targetRaySpace: XRSpace;
  145152. gripSpace: XRSpace | undefined;
  145153. gamepad: Gamepad | undefined;
  145154. profiles: Array<string>;
  145155. }
  145156. interface XRSessionInit {
  145157. optionalFeatures?: XRReferenceSpaceType[];
  145158. requiredFeatures?: XRReferenceSpaceType[];
  145159. }
  145160. interface XRSession extends XRAnchorCreator {
  145161. addEventListener: Function;
  145162. removeEventListener: Function;
  145163. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  145164. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  145165. requestAnimationFrame: Function;
  145166. end(): Promise<void>;
  145167. renderState: XRRenderState;
  145168. inputSources: Array<XRInputSource>;
  145169. // hit test
  145170. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  145171. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  145172. // legacy AR hit test
  145173. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  145174. // legacy plane detection
  145175. updateWorldTrackingState(options: {
  145176. planeDetectionState?: { enabled: boolean; }
  145177. }): void;
  145178. }
  145179. interface XRReferenceSpace extends XRSpace {
  145180. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  145181. onreset: any;
  145182. }
  145183. type XRPlaneSet = Set<XRPlane>;
  145184. type XRAnchorSet = Set<XRAnchor>;
  145185. interface XRFrame {
  145186. session: XRSession;
  145187. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  145188. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  145189. // AR
  145190. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult> ;
  145191. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  145192. // Anchors
  145193. trackedAnchors?: XRAnchorSet;
  145194. // Planes
  145195. worldInformation: {
  145196. detectedPlanes?: XRPlaneSet;
  145197. };
  145198. }
  145199. interface XRViewerPose extends XRPose {
  145200. views: Array<XRView>;
  145201. }
  145202. interface XRPose {
  145203. transform: XRRigidTransform;
  145204. emulatedPosition: boolean;
  145205. }
  145206. interface XRWebGLLayerOptions {
  145207. antialias?: boolean;
  145208. depth?: boolean;
  145209. stencil?: boolean;
  145210. alpha?: boolean;
  145211. multiview?: boolean;
  145212. framebufferScaleFactor?: number;
  145213. }
  145214. declare var XRWebGLLayer: {
  145215. prototype: XRWebGLLayer;
  145216. new(session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  145217. };
  145218. interface XRWebGLLayer {
  145219. framebuffer: WebGLFramebuffer;
  145220. framebufferWidth: number;
  145221. framebufferHeight: number;
  145222. getViewport: Function;
  145223. }
  145224. declare class XRRigidTransform {
  145225. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  145226. position: DOMPointReadOnly;
  145227. orientation: DOMPointReadOnly;
  145228. matrix: Float32Array;
  145229. inverse: XRRigidTransform;
  145230. }
  145231. interface XRView {
  145232. eye: XREye;
  145233. projectionMatrix: Float32Array;
  145234. transform: XRRigidTransform;
  145235. }
  145236. interface XRInputSourceChangeEvent {
  145237. session: XRSession;
  145238. removed: Array<XRInputSource>;
  145239. added: Array<XRInputSource>;
  145240. }
  145241. interface XRInputSourceEvent extends Event {
  145242. readonly frame: XRFrame;
  145243. readonly inputSource: XRInputSource;
  145244. }
  145245. // Experimental(er) features
  145246. declare class XRRay {
  145247. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  145248. origin: DOMPointReadOnly;
  145249. direction: DOMPointReadOnly;
  145250. matrix: Float32Array;
  145251. }
  145252. declare enum XRHitTestTrackableType {
  145253. "point",
  145254. "plane"
  145255. }
  145256. interface XRHitResult {
  145257. hitMatrix: Float32Array;
  145258. }
  145259. interface XRTransientInputHitTestResult {
  145260. readonly inputSource: XRInputSource;
  145261. readonly results: Array<XRHitTestResult>;
  145262. }
  145263. interface XRHitTestResult {
  145264. getPose(baseSpace: XRSpace): XRPose | undefined;
  145265. }
  145266. interface XRHitTestSource {
  145267. cancel(): void;
  145268. }
  145269. interface XRTransientInputHitTestSource {
  145270. cancel(): void;
  145271. }
  145272. interface XRHitTestOptionsInit {
  145273. space: XRSpace;
  145274. entityTypes?: Array<XRHitTestTrackableType>;
  145275. offsetRay?: XRRay;
  145276. }
  145277. interface XRTransientInputHitTestOptionsInit {
  145278. profile: string;
  145279. entityTypes?: Array<XRHitTestTrackableType>;
  145280. offsetRay?: XRRay;
  145281. }
  145282. interface XRAnchor {
  145283. // remove?
  145284. id?: string;
  145285. anchorSpace: XRSpace;
  145286. lastChangedTime: number;
  145287. detach(): void;
  145288. }
  145289. interface XRPlane extends XRAnchorCreator {
  145290. orientation: "Horizontal" | "Vertical";
  145291. planeSpace: XRSpace;
  145292. polygon: Array<DOMPointReadOnly>;
  145293. lastChangedTime: number;
  145294. }
  145295. interface XRAnchorCreator {
  145296. // AR Anchors
  145297. createAnchor(pose: XRPose | XRRigidTransform, referenceSpace: XRReferenceSpace): Promise<XRAnchor>;
  145298. }